Skip to content

Commit 282f666

Browse files
author
Shaoliu Wu
committed
update readme
1 parent 3b56053 commit 282f666

File tree

4 files changed

+91
-9
lines changed

4 files changed

+91
-9
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,10 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# temp files
132+
*.json
133+
*.txt
134+
135+
# idea
136+
.idea/

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,28 @@
44

55
原作者已经写的非常好了,在这里做了部分的 bug 修改,部分脚本 poc 未生效,配置错误。之前在做一次内网渗透,扫了一圈,发现 CVE-2017-10271 与 CVE-2019-2890,当时就郁闷了,怎么跨度这么大,中间的漏洞一个都没有,难道还有修一半,漏一半的,查了一下发现部分 poc 无法使用。在这个项目里面对脚本做了一些修改,提高准确率。
66

7-
后续进行说明更新,目前修改 ws.py 里面的目标就行,批量的方法就不多说了
7+
# 快速开始
88

9+
### 依赖
10+
11+
+ python >= 3.6
12+
13+
进入项目目录,使用以下命令安装依赖库
14+
15+
```
16+
$ pip3 install requests
17+
```
18+
19+
### 使用说明
20+
21+
```
22+
usage: ws.py [-h] -t TARGETS [TARGETS ...] [-o OUTPUT]
23+
24+
optional arguments:
25+
-h, --help 帮助信息
26+
-t TARGETS [TARGETS ...], --targets TARGETS [TARGETS ...]
27+
直接填入目标或文件列表(默认使用端口7001). 例子:
28+
127.0.0.1:7001
29+
-o OUTPUT, --output OUTPUT
30+
输出 json 结果的路径。默认不输出结果
31+
```

stars/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ class ResultCode(BaseState):
2323
EXISTS = 20
2424
# not exists anything
2525
NOTEXISTS = 40
26-
# not exists anything
26+
# timeout
2727
TIMEOUT = 50
28+
# error
29+
ERROR = 60
2830
# detect finish
2931
FINISH = 100
3032

@@ -48,6 +50,7 @@ def __init__(self):
4850
self.ext_msg: Dict[str, List[str]] = {}
4951
for key in rc:
5052
code = rc[key]
53+
print(1000, code)
5154
self.ext_msg[code] = []
5255
if code == result_code.START:
5356
self.ext_msg[code].append('[*] Start to detect {call} for {target}.')
@@ -64,12 +67,20 @@ def __init__(self):
6467
self.ext_msg[code].append('[*] Please verify {call} vulnerability manually!')
6568
if code == result_code.TIMEOUT:
6669
self.ext_msg[code].append('[!] Target {target} detect timeout!')
70+
if code == result_code.ERROR:
71+
self.ext_msg[code].append('[!] Target {target} connection error!')
6772
if code == result_code.FINISH:
6873
self.ext_msg[code].append('---------------- Heartless Split Line ----------------')
74+
print(1000, self.ext_msg)
6975

7076
def light_and_msg(self, dip, dport, *arg, **kwargs):
7177
self.msg(f'{dip}:{dport}', result_code.START)
72-
res, data = self.light_up(dip, dport, *arg, **kwargs)
78+
res = False
79+
data = {}
80+
try:
81+
res, data = self.light_up(dip, dport, *arg, **kwargs)
82+
except ConnectionAbortedError:
83+
self.msg(f'{dip}:{dport}', result_code.ERROR)
7384
if res:
7485
self.msg(f'{dip}:{dport}', result_code.EXISTS)
7586
else:

ws.py

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,53 @@
11
#!/usr/bin/env python3
22
# _*_ coding:utf-8 _*_
3+
import json
4+
import os
5+
import re
6+
import time
7+
38
import stars
49
import stars._import
510

611
if __name__ == '__main__':
7-
dip = '10.0.179.247'
8-
dport = '8001'
9-
for group_name in stars.universe.actived:
10-
for star in stars.universe.actived[group_name]:
11-
instance = star()
12-
instance.light_and_msg(dip, dport)
12+
import argparse
13+
14+
parser = argparse.ArgumentParser()
15+
parser.add_argument('-t', '--targets', required=True, nargs='+',
16+
help='target, or targets file(default port 7001). eg. 127.0.0.1:7001')
17+
parser.add_argument('-o', '--output', type=str, help='Path to json output(default without output).')
18+
args = parser.parse_args()
19+
20+
21+
if args.output and not os.path.isdir(args.output):
22+
print('error! output expected folder.')
23+
exit(1)
24+
25+
m_target = {}
26+
for target in args.targets:
27+
t_list = []
28+
if os.path.isfile(target):
29+
with open(target) as _f:
30+
for it in _f.read().split('\n'):
31+
res = re.search(r'^(\d{,3}\.\d{,3}\.\d{,3}\.\d{,3})([ :](\d{,5}))?$', it)
32+
if res:
33+
port = res.group(3) if res.group(3) else '7001'
34+
id = res.group(1) + ':' + port
35+
m_target[id] = {'ip': res.group(1), 'port': port}
36+
else:
37+
res = re.search(r'^(\d{,3}\.\d{,3}\.\d{,3}\.\d{,3})([ :](\d{,5}))?$', target)
38+
if res:
39+
port = res.group(3) if res.group(3) else '7001'
40+
id = res.group(1) + ':' + port
41+
m_target[id] = {'ip': res.group(1), 'port': port}
42+
43+
for key in m_target:
44+
for group_name in stars.universe.actived:
45+
for star in stars.universe.actived[group_name]:
46+
instance = star()
47+
res, msg = instance.light_and_msg(m_target[key]['ip'], m_target[key]['port'])
48+
ikey = instance.info['CVE'] if instance.info['CVE'] else instance.info['NAME']
49+
m_target[key][ikey] = res
50+
51+
if args.output:
52+
with open(os.path.join(args.output, f'{int(time.time())}.json'), 'w') as _f:
53+
_f.write(json.dumps(m_target))

0 commit comments

Comments
 (0)