• MD5在线查询的实现


      1. #!/usr/bin/env python
      2. -*- coding: UTF--*-
      3. '''
      4. 快速查询md5值工具,通过模拟浏览器发包请求http://cmd5.com和
      5. http://xmd5.org两个网站进行在线查询。
      6. By Terry
      7. '''
      8. import urllib
      9. import urllib2
      10. import re
      11. import sys
      12. def xmd5(hash_str): 
      13.     #
      14.     #http://xmd5.org以GET方式提交请求,模拟浏览器发送GET请求包。
      15.     #
      16.     xmd_url = 'http://www.xmd5.org/md5/search.asp?hash='+hash_str
      17.     xmd_request = urllib2.Request(xmd_url)
      18.     xmd_request.add_header("Connection", "keep-alive")
      19.     xmd_request.add_header("Accept","text/xmd_html,application/xxmd_html+xml,application/xml;q=0.9,*/*;q=0.8")
      20.     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")
      21.     xmd_request.add_header("Referer", "http://www.xmd5.org/index_cn.htm")
      22.     xmd_request.add_header("Accept-Encoding", "gzip,deflate,sdch")
      23.     xmd_request.add_header("Accept-Language", "en-US,en;q=0.8")
      24.     xmd_request.add_header("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3")
      25.     
      26.     response = urllib2.urlopen(xmd_request)
      27.     xmd_html = response.read()
      28.     pattern = re.compile(r'<font color="red" size="4">&nbsp;Result:</font><font color="#ffffff" size="3">([wW]*)</font>')
      29.     match_html = pattern.findall(xmd_html)
      30.     pattern = re.compile(r'[S]*')
      31.     match_key = pattern.findall(match_html[0])
      32.     #for i in match_key:
      33.     # print '#'+i
      34.     #print match2[2]
      35.     #print len(match_key[2])
      36.     if len(match_key[2])==52:
      37.         print u'xmd5:请确认是否是标准的MD5数据!xmd5支持16位和32位MD5数据'
      38.     elif len(match_key[2])>0:
      39.         print u'xmd5:恭喜,明文是>>>'+match_key[2]
      40.     else:
      41.         print u'xmd5:暂时还没查询到 - -|||'
      42. def cmd5(hash_str):
      43.     #
      44.     #http://cmd5.com网站是以POST请求发送的,模拟浏览器进行发送POST请求。
      45.     #
      46.     cmd5_url = 'http://cmd5.com'
      47.     cmd5_data = {
      48.     "__EVENTTARGET":"Button1",
      49.     "__EVENTARGUMENT":"",
      50.     "__VIEWSTATE":"8L1jRFsVmr/4ZHakSdlLVXaEMDhLz+4eoqPVVK0+Jbp8z3QE2vIkUVP02wy4oW+23Rk61GvhSZIi1n3m4B+hpJVmt6luda2LgVNU7SUAOYOPsy2UcCjKRS7STM00pUPadDrWvQEmQLH1UvDzkmf/oc48uiJ8sWjmmGWh0JbuUVYOdcHjVburdEvRTVT6nAVsyrBEMPbI3a3vNi3lzG/eTDrR6QBwzBw1RSXW0Szdn3tNV8SKj9qJfrzTlGuksLoDNba7qQ5txF8e2G1F9ZVS9RmeTYtbYRpCUeyDhorfMCq2klfSSfz2p8MOtb+f/RtvQV9/jknystxD4ZkqtKn7NcrEYeF1lcM4m9rOnq+tf2kdu+CcbSuXSR5ffnUGEt67fW/aijbvWiRECuYpEUPI6sPxvzRgI+LJhMaM7d3RLmAZGuCZkxs1lh+scdJ0jfM/v1Y9+g1kMf0Z7p5OOlRkG90X9uJVB7Q6SwrT85usgUduAza/NW0SCSS1uvGYeCENywnlgUihEupK7Fl1jso7WAOILLtpBdAMeo0dsl1OrwQ2WBjJq9dDRxpF7XQnNcjI0yJKgNsJkI/fB4qfgUx0lb/G1oPg/wk24rpA3XpxFpwYKO5E/7dHFqnchw9tvuchS2oA4Rni6vCs2bbViJS5sq7Mh0lh05rKIJbBhlCVhnZTG4QktDJmiUn12bVe/Uf0yC5HcX6LTH+3TPzuqgcNeKWy0FQc4R26UFEvJA7UHld9U3xDq+MjfG2WmUF/hgm6FoEhIUjm8z9rAnXPtSLJ7Cbq1EXneb+wdgW2cfTLz2h+CaVMdFpbcdvoRr+TdJZ5voX15/b57X8mInevtukDskJAD/7hS47B2kWtXjzo/H9bL2x629FkssG2xc1P/PAKMk9e0bjROdw9Mu45UYtWGO5eOSRPEGaZ0Dx0y/gMsWtqcGy8aOHcQp9YF46VuWcTIJFJrAF1a0ZSqyNBnQo4z3yhGed5BTc4Zl+hHRLbcw5IKxS4Jpah01VtNbJilewUP62XlsmpX9CLoB/D1RjHmRSm027+aVrfQ2oOpMUYKU/XrDgk4Nj+4CcXulIVFBXVFc6VdIDsi+oZPFfuhxVduMQbZSl/GgJe2dz+6q7CKJuOqhMUurZg3Rb0mkwKNG8tcSpv8MZGLKmtnuof2zeUJw7nSBLqzTTALZk9sPZe8iFuLQb+NHKHKCHz4laa9aLzovEoRtmE0j3BgBehmzb0F3eyIZ/I/+RviEBaYJcJ6q2FQAYrC7CSrmk8hVMtixCjUqUYA4vhVBX0uhv0pNaiUuHYtGlZhdtlTMfNucRkwXgqw7KU1Bl4C4ICIL07cOfjsUdNhkBTvOdzm1tTvrKpe70Sy0Da1IQRtbUxXdgLUtN4144mW9GOO33MkwOo6ZRqmMkLoZucuZcOL0UnB7pVitUQUr7eXD0B7VuLOZcUTVyUkJ6fCpKFHc/mbVXJQrGyWIyRb7lgjDBsxvfm",
      51.     "ctl00$ContentPlaceHolder1$TextBoxInput":hash_str,
      52.     "ctl00$ContentPlaceHolder1$InputHashType":"md5",
      53.     "ctl00$ContentPlaceHolder1$Button1":"解密",
      54.     "ctl00$ContentPlaceHolder1$HiddenField1":"",
      55.     "ctl00$ContentPlaceHolder1$HiddenField2":"0k7/kHiRphkDzojwmW8II+N7F04M5Fv6oWRFL2JpdZR4H/dnc1JlkGaMpuAeawdZ"
      56.     }
      57.     cmd5_url_data = urllib.urlencode(cmd5_data)
      58.     cmd5_header = {
      59.     "Connection": "keep-alive",
      60.     "Content-Length": str(len(cmd5_url_data)),
      61.     "Cache-Control": "max-age=0",
      62.     "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
      63.     "Origin": "http://cmd5.com",
      64.     "User-Agent": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)",
      65.     "Content-Type": "application/x-www-form-urlencoded",
      66.     "Referer": "http://cmd5.com/",
      67.     "Accept-Encoding": "gzip,deflate,sdch",
      68.     "Accept-Language": "en-US,en;q=0.8",
      69.     "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
      70.     }
      71.     cmd5_request = urllib2.Request(cmd5_url,cmd5_url_data,cmd5_header)
      72.     cmd5_response = urllib2.urlopen(cmd5_request)
      73.     cmd5_html = cmd5_response.read()
      74.     #print cmd5_html
      75.     pattern = re.compile(r'<span id="ctl00_ContentPlaceHolder1_LabelAnswer">([wW]*?)')
      76.     match = pattern.findall(cmd5_html)
      77.     #print match
      78.     #print len(match[0])
      79.     if len(match[0])==204:
      80.         print u"cmd5:已查到,这是一条付费记录."
      81.     elif len(match[0])==157:
      82.         print u"cmd5:密文无法识别或无法处理,请确认密文类型是否选择正确."
      83.     elif len(match[0])==184:
      84.         print u"cmd5:未查到."
      85.     elif len(match[0])==45:
      86.         print u"cmd5:请打开网页"http://cmd5.com"输入验证码后继续."
      87.     else:
      88.         print u"cmd5:恭喜,明文是>>>" + match[0]
      89.     
      90. if __name__ == '__main__':
      91.     
      92.     if len(sys.argv)>1:
      93.         xmd5(sys.argv[1])
      94.         cmd5(sys.argv[1])
      95.     else:
      96.         print(u"请传递参数,用法: md5.py 21232f297a57a5a743894a0e4a801fc3")
  • 相关阅读:
    数组名作为左值和右值的区别
    指针与数组区别
    linux服务器开启免密登录
    mssql清空数据和添加主键约束语法
    链接服务器方式查视图导致索引失效的解决方法
    sqlserver2008r2 版本数据库迁移到2019版本导致查询效率慢的解决方法
    lnmp一键安装访问default目录可行,访问其它站点报404错误
    lPeer reports incompatible or unsupported protocol version.
    yum安装时出现:Cannot retrieve metalink for repository: epel. Please verify its path and try again
    Linux Centos7.4 下安装 LAMP环境及配置(php5.6,mysql5.7)
  • 原文地址:https://www.cnblogs.com/milantgh/p/3616749.html
Copyright © 2020-2023  润新知