网络安全 DVWA通关指南 DVWA SQL Injection (Blind SQL盲注)

DVWASQLInjection (Blind) 参考文献 WEB 安全靶场通关指南 Low 0、分析网页源代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 <?php if( isset( $_GET[ 'Submit' ] ) ) { // Get input $id = $_GET[ 'id' ]; // Check database $getid = "SELECT first_name, last_name FROM users WHERE user_id = '$id';"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $getid ); // Removed 'or die' to suppress mysql errors // Get results $num = @mysqli_num_rows( $result ); // The '@' character suppresses errors if( $num > 0 ) { // Feedback for end user $html .= '<pre>User ID exists in the database.</pre>'; } else { // User wasn't found, so the page wasn't! header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' ); // Feedback for end user $html .= '<pre>User ID is MISSING from the database.</pre>'; } ((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); } ?> <?php // 检查是否点击了提交按钮(例如,表单提交) if( isset( $_GET[ 'Submit' ] ) ) { // 获取用户通过GET方式传递的ID值 $id = $_GET[ 'id' ]; // 创建SQL查询语句:根据$user_id查询users表中的first_name和last_name字段 $getid = "SELECT first_name, last_name FROM users WHERE user_id = '$id';"; // 执行SQL查询(假设$___mysqli_ston是全局的数据库连接对象) // 使用@字符抑制可能出现的MySQL错误信息 $result = mysqli_query($GLOBALS["___mysqli_ston"], $getid ); // 获取查询结果中记录的数量 $num = @mysqli_num_rows( $result ); // 判断查询结果中是否存在记录 if( $num > 0 ) { // 如果查询到至少一条记录,则输出反馈信息表示用户ID存在于数据库中 $html .= '<pre>User ID exists in the database.</pre>'; } else { // 若未查询到任何记录,则发送HTTP 404状态码(页面未找到) header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' ); // 同时输出反馈信息表示用户ID在数据库中不存在 $html .= '<pre>User ID is MISSING from the database.</pre>'; } // 关闭数据库连接 ((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); } ?> // 从URL参数中获取一个id,然后查询数据库中是否存在对应这个id的用户。如果存在,它会在页面上显示"User ID exists in the database.";如果不存在,则发送HTTP 404状态码并显示"User ID is MISSING from the database."。 网页不会直接返回数据,而是返回特定信息。比如输入1,页面返回“User ID exists in the database.”,查询内容没有回显。 ...

九月 23, 2024 · 8 分钟 · 3901 字