哈希(md5)绕过

发布时间 2023-07-09 11:28:26作者: ntrack

MD5

形式

MD5一共128位,内容由0-9之间的数字和a-f之间的小写字母组成

右边是一个MD5:d41d8cd98f00b204e9800998ecf8427e,共32个字符(一个字符4位)

绕过

0e绕过

原理:0e开头的字符串在参与比较时,会被当做科学计数法,结果转换为0

#生成0e开头+后面全是数字的md5编码的字符串的python脚本:
import hashlib
import itertools

def find_md5_with_0e_prefix():
    chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    length = 1
    num = 0

    while True:
        for combination in itertools.product(chars, repeat=length):
            test_string = "".join(combination)
            hash_value = hashlib.md5(test_string.encode()).hexdigest()
            if hash_value[:2] == "0e" and hash_value[2:].isdigit():
                print("输入字符串:", test_string)
                print("MD5加密结果:", hashlib.md5(test_string.encode()).hexdigest())
                num += 1
                if(num == 2):
                    return
        length += 1

find_md5_with_0e_prefix()
aaroZmOk
aaK1STfY
aaO8zKZF
QNKCDZO
240610708
byGcY
sonZ7y
aabg7XSs
aabC9RqS
s878926199a
s155964671a
s214587387a
s1091221200a

数组绕过

原理:md5不能加密数组,传入数组会报错,但会继续执行并且返回结果为null

例子:md5(a[]=1) === md5(b[]=2)

<?php
$a = array(0=>"hello");
$b = array(1=>"word");
print_r($a);
print_r($b);
var_dump(md5($a) === var_dump(md5($b))) //bool(true)
?>