1.前言
在渗透测试时,有时我们会遇到后台登陆页面,burp抓包发现密码做了前端加密,加密方式可通过查看源码获得。这里遇到的是md5加密。发现输入的密码都会经过md5加密后到后端进行验证。那我们是不是可以构造一个md5弱密码字典进行爆破呢?当然可以。


当然,Burp也是可以实现的,并且也有人写了详细的使用步骤 。现在主要通过python脚本实现。
Burpsuite MD5hash爆破可参考:https://www.secpulse.com/archives/132644.html
2.md5单次加密脚本
once_Md5_encode.py:
#!/usr/bin/python
# Env: python3
# Author: afei_0and1
# -*- coding: utf8 -*-
import sys, hashlib
def once_Md5_encode():
if (len(sys.argv) < 2):
print("-----------------------------------------------")
print(" ")
print("Useg: python %s" % sys.argv[0])
print("eg: python once_Md5_encode.py 'hloolelwrd'")
print(" ")
print("-----------------------------------------------")
return
flag = sys.argv[1]
#MD5加密
data = hashlib.md5()
data.update(flag.encode('utf-8'))
print(flag+'加密结果:'+data.hexdigest())
if(__name__ == '__main__'):
once_Md5_encode()


3.python实现MD5碰撞字典
该脚本可以实现单个字符串加密,也可以批量生成md5值字典,在实际环境中可以拿着生成好的md5字典去碰撞。
#!/usr/bin/python
# Env: python3
# Author: afei_0and1
# -*- coding: utf8 -*-
import hashlib, time, argparse
def title():
print("")
print('*'.center(60, '*'))
print("github:https://github.com/ltfafei".center(50))
print("CSDN: afei00123.blog.csdn.net".center(50))
print("公众号:网络运维渗透".center(40))
print("")
print('*'.center(60, '*'))
print("")
class batch_Md5():
def one_md5_encode(self, string):
md5_data = hashlib.md5()
md5_data.update(string.encode("utf-8"))
print(string +" ===> "+md5_data.hexdigest())
def batch_md5_encode(self, file, outfile):
for strtmp in file:
strtmp = strtmp.replace("\n", "")
time.sleep(1)
try:
md5_data = hashlib.md5()
md5_data.update(str(strtmp).encode("utf-8"))
res = md5_data.hexdigest()
with open(outfile, "a") as fw:
fw.writelines(str(res) + "\n")
print(strtmp +" ===> "+res)
except Exception as e:
print("md5加密超时!")
return res
if(__name__ == "__main__"):
title()
parser = argparse.ArgumentParser(description="Made md5 Dicts Script")
parser.add_argument(
'-s', '--string', type=str, metavar="",
help='Please input strings to md5 encode. eg: afei'
)
parser.add_argument(
'-f', '--file', type=argparse.FileType('r'), metavar="",
help='Please input file path for batch encode. eg: c:/str.txt'
)
parser.add_argument(
'-o', '--outfile', metavar="",
help="Please input path for output file. eg:c:/output.txt"
)
args = parser.parse_args()
run = batch_Md5()
if args.string:
run.one_md5_encode(args.string)
exit()
if args.file:
run.batch_md5_encode(args.file, args.outfile)
else:
print("请输入-h选项查看用法!")

本文作者:阿飞
本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/158748.html
必填 您当前尚未登录。 登录? 注册
必填(保密)