-
MD5在线查询的实现
- #!/usr/bin/env python
- # -*- coding: UTF-8 -*-
- '''
- 快速查询md5值工具,通过模拟浏览器发包请求http://cmd5.com和
- http://xmd5.org两个网站进行在线查询。
- By Terry
- '''
- import urllib
- import urllib2
- import re
- import sys
- def xmd5(hash_str):
- #
- #http://xmd5.org以GET方式提交请求,模拟浏览器发送GET请求包。
- #
- xmd_url = 'http://www.xmd5.org/md5/search.asp?hash='+hash_str
- xmd_request = urllib2.Request(xmd_url)
- xmd_request.add_header("Connection", "keep-alive")
- xmd_request.add_header("Accept","text/xmd_html,application/xxmd_html+xml,application/xml;q=0.9,*/*;q=0.8")
- xmd_request.add_header("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (Kxmd_html, like Gecko) Chrome/24.0.1312.57 Safari/537.17")
- xmd_request.add_header("Referer", "http://www.xmd5.org/index_cn.htm")
- xmd_request.add_header("Accept-Encoding", "gzip,deflate,sdch")
- xmd_request.add_header("Accept-Language", "en-US,en;q=0.8")
- xmd_request.add_header("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3")
-
- response = urllib2.urlopen(xmd_request)
- xmd_html = response.read()
- pattern = re.compile(r'<font color="red" size="4"> Result:</font><font color="#ffffff" size="3">([wW]*)</font>')
- match_html = pattern.findall(xmd_html)
- pattern = re.compile(r'[S]*')
- match_key = pattern.findall(match_html[0])
- #for i in match_key:
- # print '#'+i
- #print match2[2]
- #print len(match_key[2])
- if len(match_key[2])==52:
- print u'xmd5:请确认是否是标准的MD5数据!xmd5支持16位和32位MD5数据'
- elif len(match_key[2])>0:
- print u'xmd5:恭喜,明文是>>>'+match_key[2]
- else:
- print u'xmd5:暂时还没查询到 - -|||'
- def cmd5(hash_str):
- #
- #http://cmd5.com网站是以POST请求发送的,模拟浏览器进行发送POST请求。
- #
- cmd5_url = 'http://cmd5.com'
- cmd5_data = {
- "__EVENTTARGET":"Button1",
- "__EVENTARGUMENT":"",
- "__VIEWSTATE":"8L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rDgk4Nj+4CcXulIVFBXVFc6VdIDsi+oZPFfuhxVduMQbZSl/GgJe2dz+6q7CKJuOqhMUurZg3Rb0mkwKNG8tcSpv8MZGLKmtnuof2zeUJw7nSBLqzTTALZk9sPZe8iFuLQb+NHKHKCHz4laa9aLzovEoRtmE0j3BgBehmzb0F3eyIZ/I/+RviEBaYJcJ6q2FQAYrC7CSrmk8hVMtixCjUqUYA4vhVBX0uhv0pNaiUuHYtGlZhdtlTMfNucRkwXgqw7KU1Bl4C4ICIL07cOfjsUdNhkBTvOdzm1tTvrKpe70Sy0Da1IQRtbUxXdgLUtN4144mW9GOO33MkwOo6ZRqmMkLoZucuZcOL0UnB7pVitUQUr7eXD0B7VuLOZcUTVyUkJ6fCpKFHc/mbVXJQrGyWIyRb7lgjDBsxvfm",
- "ctl00$ContentPlaceHolder1$TextBoxInput":hash_str,
- "ctl00$ContentPlaceHolder1$InputHashType":"md5",
- "ctl00$ContentPlaceHolder1$Button1":"解密",
- "ctl00$ContentPlaceHolder1$HiddenField1":"",
- "ctl00$ContentPlaceHolder1$HiddenField2":"0k7/kHiRphkDzojwmW8II+N7F04M5Fv6oWRFL2JpdZR4H/dnc1JlkGaMpuAeawdZ"
- }
- cmd5_url_data = urllib.urlencode(cmd5_data)
- cmd5_header = {
- "Connection": "keep-alive",
- "Content-Length": str(len(cmd5_url_data)),
- "Cache-Control": "max-age=0",
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
- "Origin": "http://cmd5.com",
- "User-Agent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)",
- "Content-Type": "application/x-www-form-urlencoded",
- "Referer": "http://cmd5.com/",
- "Accept-Encoding": "gzip,deflate,sdch",
- "Accept-Language": "en-US,en;q=0.8",
- "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
- }
- cmd5_request = urllib2.Request(cmd5_url,cmd5_url_data,cmd5_header)
- cmd5_response = urllib2.urlopen(cmd5_request)
- cmd5_html = cmd5_response.read()
- #print cmd5_html
- pattern = re.compile(r'<span id="ctl00_ContentPlaceHolder1_LabelAnswer">([wW]*?)')
- match = pattern.findall(cmd5_html)
- #print match
- #print len(match[0])
- if len(match[0])==204:
- print u"cmd5:已查到,这是一条付费记录."
- elif len(match[0])==157:
- print u"cmd5:密文无法识别或无法处理,请确认密文类型是否选择正确."
- elif len(match[0])==184:
- print u"cmd5:未查到."
- elif len(match[0])==45:
- print u"cmd5:请打开网页"http://cmd5.com"输入验证码后继续."
- else:
- print u"cmd5:恭喜,明文是>>>" + match[0]
-
- if __name__ == '__main__':
-
- if len(sys.argv)>1:
- xmd5(sys.argv[1])
- cmd5(sys.argv[1])
- else:
- print(u"请传递参数,用法:
md5.py 21232f297a57a5a743894a0e4a801fc3")
-
相关阅读:
双指针
二维数组 查找常用字符
将数组分为相等的三部分
交换 排序
买股票
双指针 回文数
双指针
测试SM图床
cnpm,vue等命令不识别的问题废人解决方案
typeof面试题解答
-
原文地址:https://www.cnblogs.com/milantgh/p/3616749.html
Copyright © 2020-2023
润新知