diff --git a/README.md b/README.md index 803f413..8e1ca6a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ KnockKnock is a Python script to find admin panel of a website. (Illegal use is - Multiplatform - Multithreaded - Random User-Agents +- Proxy - Big path list More features are coming soon @@ -12,7 +13,7 @@ More features are coming soon ## Requirements ```bash # Install requirements -$ pip install -r requirements.txt +$ pip3 install -r requirements.txt ``` ## Usage @@ -26,6 +27,11 @@ $ python3 knockknock.py http://example.com -f # Check all paths with random user-agent $ python3 knockknock.py http://example.com -r +# Use HTTP(S) or SOCKS(4/5) proxy +$ python3 knockknock.py http://example.com --proxy http://127.0.0.1:8080 +# OR +$ python3 knockknock.py http://example.com --proxy socks5h://127.0.0.1:8080 + # Help $ python3 knockknock.py -h ``` \ No newline at end of file diff --git a/knockknock.py b/knockknock.py index 67440e4..b1a1f3c 100644 --- a/knockknock.py +++ b/knockknock.py @@ -24,12 +24,15 @@ class KnockKnock: agents = None total_found = 0 total_scanned = 0 + scan_errors = 0 - def __init__(self, url:str, multithread:bool, random_agent:bool) -> None: + def __init__(self, url:str, multithread:bool, random_agent:bool, proxy:str) -> None: self.get_paths() if random_agent: self.get_agents() - self.url = self.validate_url(url) + self.url = self.check_url(url) + if proxy: + self.proxies = self.check_proxy(proxy) self.multithread = multithread self.random_agent = random_agent @@ -41,22 +44,45 @@ def get_agents(self): print(f'{self.cred}user-agents.txt file is missing!{self.cend}') sys.exit(1) - def validate_url(self, url): + def check_url(self, url): valid_url = url.removesuffix('/') if url[:4] != 'http': valid_url = 'http://' + url - print(f'\n{self.cyellow}Verifying url, please wait...{self.cend}', end='') + print(f'\n{self.cyellowbg} Checking URL... {self.cend}', end='') try: requests.get(valid_url) except requests.exceptions.RequestException: - print(f'\x1b[1K\r{self.cred}Failed to validate:{self.cend} {valid_url}') + print(f'\x1b[1K\r{self.cred}URL/Network error{self.cend}') print(f'\t╟═══ Check the url format') - print(f'\t╟═══ Check whether url is valid') + print(f'\t╟═══ Check whether the url is valid') print(f'\t╚═══ Check your network connection') sys.exit(1) + except KeyboardInterrupt: + print(f'\x1b[1K\r\n{self.cred}Session canceled{self.cend}\n\x1b[1K\r') + sys.exit(1) print(f'\x1b[1K\r{self.cgreen}Valid:{self.cend} {valid_url}\n') return valid_url + def check_proxy(self, proxy): + proxies = { + 'http': proxy, + 'https': proxy + } + print(f'\n{self.cyellowbg} Checking proxy... {self.cend}', end='') + try: + requests.get('https://httpbin.org/get', timeout=5, proxies=proxies) + except requests.exceptions.RequestException: + print(f'\x1b[1K\r{self.cred}Proxy/Network error{self.cend}') + print(f'\t╟═══ Check the proxy format') + print(f'\t╟═══ Check the proxy quality') + print(f'\t╚═══ Check your network connection') + sys.exit(1) + except KeyboardInterrupt: + print(f'\x1b[1K\r\n{self.cred}Session canceled{self.cend}\n\x1b[1K\r') + sys.exit(1) + print(f'\x1b[1K\r{self.cgreen}Valid:{self.cend} {proxy}\n') + return proxies + def get_paths(self): try: with open('paths.txt', 'r') as file: @@ -69,24 +95,24 @@ def scan(self, path): full_url = self.url + path if self.random_agent: self.headers = {'user-agent': random.choice(self.agents)} - sys.stdout.write(f'\x1b[1K\r{self.cyellow}Scanning:{self.cend} {path}') try: r = requests.get(full_url, timeout=self.timeout, headers=self.headers, proxies=self.proxies) except requests.exceptions.RequestException: + self.scan_errors += 1 with self.print_lock_: - sys.stdout.write(f'\x1b[1K\r{self.cred}Unable to scan:{self.cend} {path}') + sys.stdout.write(f'\x1b[1K\r{self.cyellow}[!]{self.cend} {full_url}') else: self.total_scanned += 1 if r.status_code == 200: self.total_found += 1 with self.print_lock_: - sys.stdout.write(f'\x1b[1K\r{self.cgreen}[+] {self.cend}{full_url}\n') + sys.stdout.write(f'\x1b[1K\r{self.cgreen}[+]{self.cend} {full_url}\n') else: with self.print_lock_: - sys.stdout.write(f'\x1b[1K\r{self.cred}[-] {self.cend}{full_url}') + sys.stdout.write(f'\x1b[1K\r{self.cred}[-]{self.cend} {full_url}') def run_scan(self): - print(f'{self.cgreen}Session started...{self.cend}\n') + print(f'{self.cgreenbg} Session started... {self.cend}\n') try: if self.multithread: threads = [] @@ -100,21 +126,22 @@ def run_scan(self): else: for path in self.paths: self.scan(path) - print(f'\n\n{self.cgreen}Session completed!{self.cend}') - print(f'\t╟═══[📄] Total pages found: {self.total_found}') - print(f'\t╚═══[📚] Total pages scanned: {self.total_scanned}') + print(f'\n\n{self.cgreenbg} Session completed! {self.cend}') + print(f'\t╟═══ {self.cyellow}Total found:{self.cend} {self.total_found}') + print(f'\t╟═══ {self.cyellow}Total scanned:{self.cend} {self.total_scanned}') + print(f'\t╚═══ {self.cyellow}Unable to scan (due to some errors):{self.cend} {self.scan_errors}') except KeyboardInterrupt: - sys.stdout.write(f'\x1b[1K\r\n{self.cred}Session terminated!{self.cend}\n\x1b[1K\r') + sys.stdout.write(f'\x1b[1K\r\n{self.cred}Session canceled{self.cend}\n\x1b[1K\r') sys.exit(1) if __name__ == '__main__': - print('\33[91m' + ''' + print('\33[93m' + ''' █▄▀ █▄░█ █▀█ █▀▀ █▄▀ █▄▀ █▄░█ █▀█ █▀▀ █▄▀ █░█ █░▀█ █▄█ █▄▄ █░█ █░█ █░▀█ █▄█ █▄▄ █░█ - 🔥 v0.2.1 made by Kaustubh Prabhu 🔥 + 🔥 v0.3 made by Kaustubh Prabhu 🔥 [https://github.com/kaustubhrprabhu/KnockKnock.git] ''' + '\33[0m') @@ -123,7 +150,8 @@ def run_scan(self): parser.add_argument('url', type=str, help='target url (eg. http://example.com)') parser.add_argument('-f', '--fast', help='use multithreads', dest='fast', action='store_true') parser.add_argument('-r', '--random-agent', help='use random user-agents', dest='ragent', action='store_true') + parser.add_argument('-p', '--proxy', default=False, help='use HTTP(s) proxy (eg. http://127.0.0.1:8080) or SOCKS(4/5) proxy (eg. socks5://127.0.0.1:8080)') args = parser.parse_args() - knockknock = KnockKnock(args.url, args.fast, args.ragent) + knockknock = KnockKnock(args.url, args.fast, args.ragent, args.proxy) knockknock.run_scan() diff --git a/requirements.txt b/requirements.txt index 2c24336..69423fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -requests==2.31.0 +PySocks==1.7.1 +requests==2.31.0 \ No newline at end of file