From bfbb76c0cbd15090e105f73b47a75ba6f7385e15 Mon Sep 17 00:00:00 2001 From: Kaihatsu <168131226+ka1hatsu@users.noreply.github.com> Date: Thu, 31 Oct 2024 23:10:26 +0530 Subject: [PATCH] Update webdork.py Fixed syntax issues --- webdork.py | 119 ++++++++++++++++++++--------------------------------- 1 file changed, 44 insertions(+), 75 deletions(-) diff --git a/webdork.py b/webdork.py index de5a909..44496b9 100644 --- a/webdork.py +++ b/webdork.py @@ -3,9 +3,8 @@ # Author : HACKE-RC commonly known as RC; # Description : WebDork by RC - A python tool to automate some google dorking stuff to find information disclosures. # Developer contact: @coder_rc on twitter. You can request new feature by tagging me on any of your tweet. -# Proxy integration is by me (ka1hatsu) -#Importing modules +# Importing modules from os import access import webbrowser from sys import exit @@ -34,16 +33,15 @@ def banner() -> None: print("----- github.com/HACKE-RC/webdork -----") @staticmethod - def createdork(prefix : str, site : str, args : argparse.Namespace) -> None: + def createdork(prefix: str, site: str, args: argparse.Namespace) -> None: fulldork = prefix + site + f'%20\"{args.company_name}\"' dorkscontainer.append(fulldork) if args.verbose: print(f"[v] Added the dork {unquote(fulldork)} to dorks list. [v]") - del fulldork return @staticmethod - def browseropen(args : argparse.Namespace, dork : str) -> None: + def browseropen(args: argparse.Namespace, dork: str) -> None: dork = f"https://www.google.com/search?q={dork}" if args.verbose: print(f"[v] Opening the dork {dork} results in browser. [v]") @@ -52,27 +50,29 @@ def browseropen(args : argparse.Namespace, dork : str) -> None: return @staticmethod - def getuseragent() -> int: + def getuseragent() -> str: """ Returns a random useragent """ - all_agents = ("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36", - "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36", - "https://developers.whatismybrowser.com/useragents/parse/16254-googlebot") - return all_agents[randint(0, len(all_agents)-1)] - + all_agents = [ + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36", + "https://developers.whatismybrowser.com/useragents/parse/16254-googlebot" + ] + return all_agents[randint(0, len(all_agents) - 1)] + @staticmethod - def writeresults(list_name, filename : str): + def writeresults(list_name, filename: str): """ Writes a file from a list, list or tuple """ - file = open(filename, "a") - for item in list_name: - if not item==":": - file.write(item+"\n") + with open(filename, "a") as file: + for item in list_name: + if item != ":": + file.write(item + "\n") return None - + @staticmethod def filtergoogle(url_list) -> list: """ @@ -81,71 +81,56 @@ def filtergoogle(url_list) -> list: actual_results = [] for url in url_list: if ".google." in url: - pass + continue elif "://webcache." in url: - if ":" == url: - pass - else: - actual_results.append(url[url.index(":http")+1:] ) + if ":" in url: + actual_results.append(url[url.index(":http") + 1:]) else: - if ":" == url: - pass - else: + if ":" not in url: actual_results.append(url) - return list(actual_results) + return actual_results @staticmethod def showresults(iterable_name) -> None: """ - Takes a iterable and prints all the items from it. + Takes an iterable and prints all the items from it. """ for item in iterable_name: - if not item==":": + if item != ":": print(item) - return parser = argparse.ArgumentParser(description='A python tool to automatically dork on a given company\'s name.') -parser.add_argument('-cn', "--company-name", type=str, - metavar="Company name", help='Name of the company', - required=True) +parser.add_argument('-cn', "--company-name", type=str, metavar="Company name", help='Name of the company', required=True) parser.add_argument("-bw", '--browser', help="Search the dorks in browser.", action="store_true") parser.add_argument("--show", help="Print results from the dorks.", action="store_true") -parser.add_argument("-o", metavar="Output", type=str, help="Output filename(default is dorkresults.txt).", - default="dorkresults.txt") +parser.add_argument("-o", metavar="Output", type=str, help="Output filename(default is dorkresults.txt).", default="dorkresults.txt") parser.add_argument("-v", "--verbose", help="Turn verbose mode on.", action="store_true") parser.add_argument("-s", "--silent", help="Just save the results without printing anything.", action="store_true") parser.add_argument("--no-save-output", help="Don\'t save the output in file.", action="store_true") -args = parser.parse_args() parser.add_argument("--proxy", type=str, help="Specify proxy address and port as
: