Brute Force_medium

 1  <?php
 2 
 3 if( isset( $_GET[ 'Login' ] ) ) {
 4     // Sanitise username input
 5     $user = $_GET[ 'username' ];
 6     $user = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $user ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
 7     //mysqli_real_escape_string(connection,escapestring) 函数转义在 SQL 语句中使用的字符串中的特殊字符。返回已转义的字符串。
 8     //connection,必需。规定要使用的 MySQL 连接。
 9     //escapestring,必需。要转义的字符串。编码的字符是 NUL(ASCII 0)、\n、\r、\、'、" 和 Control-Z。
10     
11     /***************************************************************************
12     trigger_error(error_message,error_types)
13     trigger_error() 函数创建用户自定义的错误消息。
14     trigger_error() 函数用于在用户指定的条件下触发一个错误消息。它可以与内建的错误处理程序一起使用,
15     或者与由 set_error_handler() 函数设置的用户自定义函数一起使用。
16     当您需要在运行脚本时的某个指定条件下自定义错误消息时,该函数很有用。
17     如果指定了一个不合法的错误类型,该函数返回 FALSE,否则返回 TRUE。
18     error_message    必需。规定错误消息。长度限制为 1024 个字符。
19     error_types    可选。规定错误消息的错误类型。
20         可能的错误类型:
21             E_USER_ERROR - 用户生成的运行时的致命错误。不能恢复的错误。停止执行脚本。
22             E_USER_WARNING - 用户生成的运行时的非致命警告。脚本没有停止执行。
23             E_USER_NOTICE - 默认。用户生成的运行时的通知。脚本发现可能是一个错误,但也可能在脚本正常运行时发生    
24     ******************************************************************************/
25     
26     // Sanitise password input
27     $pass = $_GET[ 'password' ];
28     $pass = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $pass ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
29     $pass = md5( $pass );
30 
31     // Check the database
32     $query  = "SELECT * FROM `users` WHERE user = '$user' AND password = '$pass';";
33     $result = mysqli_query($GLOBALS["___mysqli_ston"],  $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
34 
35     if( $result && mysqli_num_rows( $result ) == 1 ) {
36         // Get users details
37         $row    = mysqli_fetch_assoc( $result );
38         $avatar = $row["avatar"];
39 
40         // Login successful
41         echo "<p>Welcome to the password protected area {$user}</p>";
42         echo "<img src=\"{$avatar}\" />";
43     }
44     else {
45         // Login failed
46         sleep( 2 );
47         echo "<pre><br />Username and/or password incorrect.</pre>";
48     }
49 
50     ((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
51 }
52 
53 ?>

Meidum级别代码加入了mysql_real_escape_string() 函数,相比low的代码,这个代码可以防止sql注入,但对爆破还是没有影响。

转载于:https://www.cnblogs.com/guiguxiaosheng/p/9189182.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值