Jboss反序列化漏洞批量验证

什么是反序列化漏洞?

2015年11月6日,FoxGlove Security安全团队的@breenmachine 发布的一篇博客中介绍了如何利用Java反序列化漏洞,来攻击最新版的WebLogic、WebSphere、JBoss、Jenkins、OpenNMS这些大名鼎鼎的Java应用,实现远程代码执行。

Shodan批量下载ip

在上篇文章 Shodan批量自动化 讲到如何批量下载ip,是为现在打下基础。执行下面代码下载第一页ip

1
python Shodan_So.py -search "JBossWeb-2.1 port:8080" --list_ip >> ips1.txt  --list_ip_port



执行下面代码下载第2页ip

1
python Shodan_So.py -search "JBossWeb-2.1 port:8080" --list_ip >> ips10.txt  --list_ip_port --page 2

以此类推,一共有搜索到1237个ip。

批量验证Jboss反序列化漏洞

脚本代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding=utf-8
import requests
import re
import sys
def get_status(url):
try:
r = requests.get(url, allow_redirects=False)
status_code = r.status_code
except requests.exceptions.ConnectionError as e:
if (e):
status_code = 404
return status_code
def get_target_ip(file_name):
with open(file_name) as fo:
contents = fo.read()
return re.findall(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b:8080", contents)
def request_main(result):
for line in result:
print line
if line:
status = get_status('http://' + line + '/' + '/invoker/readonly')
if status == 500:
print "Success"
#success_file = open("success.txt")
with open("success.txt","a") as fo:
fo.write(line+"\n")
else:
print "Failed"
if __name__ == "__main__":
file_name = sys.argv[1]
result = get_target_ip(file_name)
request_main(result)

将代码保存为12.py,代码简单验证http://URL/invoker/readonly 网页状态码是500,就可能存在漏洞,省下很多时间。。。
使用方法

1
python 12.py ip1.txt


网页状态码是500的写入success.txt文本。

Jboss反序列化工具


直接获取的shell。
如果遇到是乱码还可以使用另一个工具反弹shell。
nc监听端口

反弹shell

收到反弹的shell

-------------本文结束感谢您的阅读-------------