From b8fa138b942e05de332da4af00f124adb83bf825 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Fri, 9 Jun 2023 22:06:50 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- src/Dork-Harvest/dork-harvest.py | 7 +- src/HarvestBin/harvestbin.py | 56 +++++++------ src/adv-search.py | 36 ++++----- src/discrow.py | 13 ++- src/fugitive.py | 16 ++-- src/geo-recon/geo-recon.py | 26 +++--- src/geo-recon/modules/checkIp.py | 19 +++-- src/geo-recon/modules/commands.py | 14 ++-- src/geo-recon/modules/getData.py | 6 +- src/geo-recon/modules/myip.py | 3 +- .../build/lib/holehe/modules/cms/gravatar.py | 3 +- .../build/lib/holehe/modules/cms/voxmedia.py | 12 +-- .../build/lib/holehe/modules/cms/wordpress.py | 7 +- .../build/lib/holehe/modules/crm/axonaut.py | 6 +- .../build/lib/holehe/modules/crm/nimble.py | 5 +- .../build/lib/holehe/modules/crm/nocrm.py | 5 +- .../build/lib/holehe/modules/crm/zoho.py | 6 +- .../lib/holehe/modules/jobs/seoclerks.py | 10 +-- .../build/lib/holehe/modules/mails/google.py | 5 +- .../lib/holehe/modules/mails/protonmail.py | 4 +- .../build/lib/holehe/modules/medias/flickr.py | 2 +- .../build/lib/holehe/modules/music/lastfm.py | 2 +- .../lib/holehe/modules/music/soundcloud.py | 27 +++---- .../lib/holehe/modules/osint/rocketreach.py | 5 +- .../build/lib/holehe/modules/payment/venmo.py | 32 ++++---- .../build/lib/holehe/modules/porn/xnxx.py | 12 +-- .../lib/holehe/modules/programing/github.py | 14 ++-- .../lib/holehe/modules/shopping/amazon.py | 2 +- .../lib/holehe/modules/shopping/vivino.py | 27 +++---- .../holehe/modules/social_media/bitmoji.py | 2 +- .../holehe/modules/social_media/instagram.py | 38 ++++----- .../modules/social_media/odnoklassniki.py | 14 ++-- .../lib/holehe/modules/social_media/parler.py | 3 +- .../holehe/modules/social_media/snapchat.py | 2 +- .../holehe/modules/social_media/wattpad.py | 2 +- .../lib/holehe/modules/software/issuu.py | 7 +- .../lib/holehe/modules/software/lastpass.py | 2 +- .../lib/holehe/modules/software/office365.py | 7 +- .../lib/holehe/modules/sport/bodybuilding.py | 4 +- .../lib/holehe/modules/transport/blablacar.py | 10 +-- src/holehe/holehe/core.py | 20 +++-- src/holehe/holehe/modules/cms/gravatar.py | 3 +- src/holehe/holehe/modules/cms/voxmedia.py | 12 +-- src/holehe/holehe/modules/cms/wordpress.py | 7 +- src/holehe/holehe/modules/crm/axonaut.py | 6 +- src/holehe/holehe/modules/crm/nimble.py | 5 +- src/holehe/holehe/modules/crm/nocrm.py | 5 +- src/holehe/holehe/modules/crm/zoho.py | 6 +- src/holehe/holehe/modules/jobs/seoclerks.py | 10 +-- src/holehe/holehe/modules/mails/google.py | 5 +- src/holehe/holehe/modules/mails/protonmail.py | 4 +- src/holehe/holehe/modules/medias/flickr.py | 2 +- src/holehe/holehe/modules/music/lastfm.py | 2 +- src/holehe/holehe/modules/music/soundcloud.py | 27 +++---- .../holehe/modules/osint/rocketreach.py | 5 +- src/holehe/holehe/modules/payment/venmo.py | 32 ++++---- src/holehe/holehe/modules/porn/xnxx.py | 12 +-- .../holehe/modules/programing/github.py | 14 ++-- src/holehe/holehe/modules/shopping/amazon.py | 2 +- src/holehe/holehe/modules/shopping/vivino.py | 27 +++---- .../holehe/modules/social_media/bitmoji.py | 2 +- .../holehe/modules/social_media/instagram.py | 38 ++++----- .../modules/social_media/odnoklassniki.py | 14 ++-- .../holehe/modules/social_media/parler.py | 3 +- .../holehe/modules/social_media/snapchat.py | 2 +- .../holehe/modules/social_media/wattpad.py | 2 +- src/holehe/holehe/modules/software/issuu.py | 7 +- .../holehe/modules/software/lastpass.py | 2 +- .../holehe/modules/software/office365.py | 7 +- .../holehe/modules/sport/bodybuilding.py | 4 +- .../holehe/modules/transport/blablacar.py | 10 +-- src/infoga/infoga.py | 23 +++--- src/infoga/lib/check.py | 12 +-- src/infoga/lib/output.py | 15 ++-- src/infoga/recon/ask.py | 2 +- src/infoga/recon/baidu.py | 2 +- src/infoga/recon/bing.py | 2 +- src/infoga/recon/dogpile.py | 2 +- src/infoga/recon/exalead.py | 2 +- src/infoga/recon/google.py | 4 +- src/infoga/recon/mailtester.py | 3 +- src/infoga/recon/pgp.py | 2 +- src/infoga/recon/pwned.py | 4 +- src/infoga/recon/shodan.py | 3 +- src/infoga/recon/yahoo.py | 2 +- src/maigret/launcher.py | 2 +- src/maigret/maigret/activation.py | 2 +- src/maigret/maigret/checking.py | 81 +++++++------------ src/maigret/maigret/errors.py | 32 +++----- src/maigret/maigret/executors.py | 8 +- src/maigret/maigret/maigret.py | 25 +++--- src/maigret/maigret/notify.py | 2 +- src/maigret/maigret/report.py | 46 +++++------ src/maigret/maigret/sites.py | 27 +++---- src/maigret/maigret/submit.py | 47 +++++------ src/maigret/maigret/utils.py | 26 +++--- src/maigret/tests/test_cli.py | 30 +++---- src/maigret/tests/test_data.py | 2 +- src/maigret/tests/test_maigret.py | 12 +-- src/maigret/tests/test_report.py | 2 +- src/maigret/tests/test_sites.py | 4 +- src/maigret/tests/test_utils.py | 2 +- src/maigret/utils/add_tags.py | 7 +- src/maigret/utils/import_sites.py | 5 +- src/maigret/utils/sites_diff.py | 11 ++- src/maigret/utils/update_site_data.py | 13 +-- 106 files changed, 604 insertions(+), 630 deletions(-) diff --git a/src/Dork-Harvest/dork-harvest.py b/src/Dork-Harvest/dork-harvest.py index 2f84f4f..30e1760 100644 --- a/src/Dork-Harvest/dork-harvest.py +++ b/src/Dork-Harvest/dork-harvest.py @@ -92,10 +92,9 @@ class colors: def logger(data): - file = open((l0g) + ".txt", "a") - file.write(str(data)) - file.write("\n") - file.close() + with open(f"{l0g}.txt", "a") as file: + file.write(str(data)) + file.write("\n") if data.startswith("y" or "Y"): diff --git a/src/HarvestBin/harvestbin.py b/src/HarvestBin/harvestbin.py index 433be10..c5c58a4 100644 --- a/src/HarvestBin/harvestbin.py +++ b/src/HarvestBin/harvestbin.py @@ -11,8 +11,8 @@ from googlesearch import search import requests except ImportError: - print(red +"[ERR] Modules 'requests' and 'google' aren't installed.") - if input(cyan +"Do you want to install them? (y/n)") == "y": + print(f"{red}[ERR] Modules 'requests' and 'google' aren't installed.") + if input(f"{cyan}Do you want to install them? (y/n)") == "y": import pip pip.main(["install", "google"]) @@ -20,23 +20,24 @@ from googlesearch import search import requests else: - print(red +"Exiting...") + print(f"{red}Exiting...") exit() def search_links(): site = "pastebin.com" - query = input(Y +"Enter the search query: ") + query = input(f"{Y}Enter the search query: ") - query = query + " site:" + site + query = f"{query} site:{site}" results_max = int( - input(Y +"Enter the maximum number of search results (default 10): ") or "10" + input(f"{Y}Enter the maximum number of search results (default 10): ") + or "10" ) results = search(query, stop=results_max, pause=2) - results = [result for result in results if not "/u/" in result] + results = [result for result in results if "/u/" not in result] for i in range(len(results)): results[i] = results[i].replace(".com/", ".com/raw/") @@ -44,40 +45,45 @@ def search_links(): output_way = input(cyan +"""Enter the output way (file/console): """) if output_way == "file": - print(red +"Warning! File will be overwritten.") - output_file = input(Y +"Enter the output file name: ") + print(f"{red}Warning! File will be overwritten.") + output_file = input(f"{Y}Enter the output file name: ") output_file = open(output_file, "w") - separator = input(Y +"Enter what to separate links by (default newline): ") or "\n" + separator = ( + input(f"{Y}Enter what to separate links by (default newline): ") + or "\n" + ) output_file.write(separator.join(results)) elif output_way == "console": print("\n".join(results)) else: - print(red +"Invalid way!") + print(f"{red}Invalid way!") exit() def scrape_from_links(links: list): contents = [requests.get(link).text for link in links] - output_way = input(Y +"Enter the output way (file/console): ") + output_way = input(f"{Y}Enter the output way (file/console): ") if output_way == "file": - print(red + "Warning! File will be overwritten.") - output_file = input(Y +"Enter the output file name: ") + print(f"{red}Warning! File will be overwritten.") + output_file = input(f"{Y}Enter the output file name: ") output_file = open(output_file, "w") separator = ( - input(Y +"What to separate links by when writing by (default newline): ") + input( + f"{Y}What to separate links by when writing by (default newline): " + ) or "\n" ) separator = "\n" + separator + "\n" try: output_file.write(separator.join(contents)) - print(green +"Successfully wrote to file") + print(f"{green}Successfully wrote to file") except: - print(red +"[ERR] Couldn't write to file.") + print(f"{red}[ERR] Couldn't write to file.") exit() elif output_way == "console": print("\n".join(contents)) else: - print(red +"Invalid way!") + print(f"{red}Invalid way!") exit() @@ -116,27 +122,29 @@ def main(): █─█─██▀▄─██▄─▄▄▀█▄─█─▄█▄─▄▄─█─▄▄▄▄█─▄─▄─███▄─▄─▀█▄─▄█▄─▀█▄─▄█ █─▄─██─▀─███─▄─▄██▄▀▄███─▄█▀█▄▄▄▄─███─██████─▄─▀██─███─█▄▀─██ ▀▄▀▄▀▄▄▀▄▄▀▄▄▀▄▄▀▀▀▄▀▀▀▄▄▄▄▄▀▄▄▄▄▄▀▀▄▄▄▀▀▀▀▄▄▄▄▀▀▄▄▄▀▄▄▄▀▀▄▄▀""") - print(red +"Welcome to HarvestBin!") - print(red + "[INF] We scrape from pastebin.com") + print(f"{red}Welcome to HarvestBin!") + print(f"{red}[INF] We scrape from pastebin.com") print(red + "We aren't responsible for your actions. Tool made for educational purposes only." ) while True: print(cyan +"\nMenu:\n\n1 -> Scrape links\n2 -> Scrape links contents") - choice = input(Y +"Enter your choice: ") + choice = input(f"{Y}Enter your choice: ") if choice == "1": search_links() elif choice == "2": - links_file = input(Y +"File to import links from: ") + links_file = input(f"{Y}File to import links from: ") sep = ( - input(Y +"What to separate links by when reading (default newline): ") + input( + f"{Y}What to separate links by when reading (default newline): " + ) or "\n" ) with open(links_file, "r") as f: links = f.read().split(sep) scrape_from_links(links) else: - print(red +"Invalid choice!") + print(f"{red}Invalid choice!") if __name__ == "__main__": diff --git a/src/adv-search.py b/src/adv-search.py index 7aea808..825fb72 100644 --- a/src/adv-search.py +++ b/src/adv-search.py @@ -34,7 +34,7 @@ def banner(): def parser_error(self): banner() - print("Usage: python " + sys.argv[0] + " [Options] use -h for help") + print(f"Usage: python {sys.argv[0]} [Options] use -h for help") sys.exit() @@ -45,8 +45,7 @@ def parse_args(): parser.add_argument('-f', '--dorkfile', required=False) parser.add_argument('-d', '--dork', required=False) parser.add_argument('-o', '--output', required=False) - args = parser.parse_args() - return args + return parser.parse_args() def input_(dork): @@ -67,7 +66,7 @@ def urlExtract(): global final urls = helium.find_all(S('.yuRUbf')) url = [i.web_element.find_element_by_tag_name('a').get_attribute('href') for i in urls] - if (url == []): + if not url: kill_browser() re_enter() url = clean(url) @@ -102,24 +101,22 @@ def flow(): def exechaha(args,dorks): global driver - if(args.dorkfile): + if args.dorkfile: with open(dorks) as f: while True: - line = f.readline() - if not line: + if not (line := f.readline()): break - else: - driver = helium.start_firefox(headless=False) - go_to('https://www.google.com/search?q=site:doxbin.com | site:instagram.com | site:facebook.com | site:youtube.com | site:zerobin.net | site:pastebin.com | site:skidbin.net | site:hastebin.com | site:twitter.com | site:linkedin.com | site:pinterest.com | site:tumblr.com | site:snapchat.com | site:reddit.com | site:github.com | site:gitlab.com | site:pornhub.com | site:whatsapp.com \ site:tiktok.com "' + test +'"') - input_(line) - time.sleep(5) - flow() + driver = helium.start_firefox(headless=False) + go_to('https://www.google.com/search?q=site:doxbin.com | site:instagram.com | site:facebook.com | site:youtube.com | site:zerobin.net | site:pastebin.com | site:skidbin.net | site:hastebin.com | site:twitter.com | site:linkedin.com | site:pinterest.com | site:tumblr.com | site:snapchat.com | site:reddit.com | site:github.com | site:gitlab.com | site:pornhub.com | site:whatsapp.com \ site:tiktok.com "' + test +'"') + input_(line) + time.sleep(5) + flow() else: line = args.dork driver = helium.start_firefox(headless=False) time.sleep(5) - go_to('https://www.google.com/search?q="' + test + '"') + go_to(f'https://www.google.com/search?q="{test}"') input_(line) time.sleep(5) flow() @@ -130,14 +127,13 @@ def main(): args = parse_args() dorks = args.dorkfile exechaha(args,dorks) - if(args.output): - file1 = open(args.output+'.txt', 'w') - for i in clean(final): - file1.write(i.strip()+'\n') - file1.close() + if args.output: + with open(f'{args.output}.txt', 'w') as file1: + for i in clean(final): + file1.write(i.strip()+'\n') else: for i in clean(final): - print(f"{Fore.YELLOW}[{Fore.GREEN}ϟ{Fore.YELLOW}] {Fore.BLUE}" + i) + print(f"{Fore.YELLOW}[{Fore.GREEN}ϟ{Fore.YELLOW}] {Fore.BLUE}{i}") if __name__ == '__main__': try: diff --git a/src/discrow.py b/src/discrow.py index 6f074bd..414fb93 100644 --- a/src/discrow.py +++ b/src/discrow.py @@ -18,18 +18,23 @@ my_token = input("Enter your token: ").strip() user_id = input("Enter the user ID: ").strip() -r = get("https://discord.com/api/v8/users/" + user_id, headers={"authorization": my_token}) +r = get( + f"https://discord.com/api/v8/users/{user_id}", + headers={"authorization": my_token}, +) if r.status_code != 200: print("[-] *Invalid user ID or token*") exit() j = r.json() -j["username_full"] = "%s#%s" % (j['username'], j['discriminator'],) +j["username_full"] = f"{j['username']}#{j['discriminator']}" if (j['avatar'] is not None): - j["avatar_full"] = "https://cdn.discordapp.com/avatars/%s/%s.png" % (j['id'], j['avatar'],) + j[ + "avatar_full" + ] = f"https://cdn.discordapp.com/avatars/{j['id']}/{j['avatar']}.png" else: j['avatar_full'] = "" - + for key, value in j.items(): print(f"[+] {key}: {value}") diff --git a/src/fugitive.py b/src/fugitive.py index f0787b0..972163b 100644 --- a/src/fugitive.py +++ b/src/fugitive.py @@ -114,13 +114,15 @@ def option8(): os.system("cd Xurma-Dox && pip install -r requirements.txt && python3 xurma-dox.py") def option9(): - os.system("clear") - print(f'{Fore.WHITE}Loading {Fore.YELLOW}[{Fore.CYAN}GEO-Recon{Fore.YELLOW}]{Fore.WHITE}...') - time.sleep(5) - os.system("pip3 install colorama requests") - os.system("clear") - entry = input(f"{Fore.WHITE}Enter IP Address{Fore.YELLOW}:{Fore.CYAN} ") - os.system("cd geo-recon && chmod +x geo-recon.py && pip install -r requirements.txt && python3 geo-recon.py " + entry) + os.system("clear") + print(f'{Fore.WHITE}Loading {Fore.YELLOW}[{Fore.CYAN}GEO-Recon{Fore.YELLOW}]{Fore.WHITE}...') + time.sleep(5) + os.system("pip3 install colorama requests") + os.system("clear") + entry = input(f"{Fore.WHITE}Enter IP Address{Fore.YELLOW}:{Fore.CYAN} ") + os.system( + f"cd geo-recon && chmod +x geo-recon.py && pip install -r requirements.txt && python3 geo-recon.py {entry}" + ) def option10(): diff --git a/src/geo-recon/geo-recon.py b/src/geo-recon/geo-recon.py index d672628..0d601e2 100644 --- a/src/geo-recon/geo-recon.py +++ b/src/geo-recon/geo-recon.py @@ -39,18 +39,18 @@ def zero(syA): if (len(sys.argv) > 1): syA1 = sys.argv[1] if sys.argv[1].startswith('-'): - if syA1 == "--help" or syA1 == '-h': - os.system('clear') - welcome() - help(syA1) - - elif syA1 == '-b' or syA1 == '--banner': - os.system('clear') - welcome() - elif syA1 == '-c' or syA1 == '--commands': - os.system('clear') - welcome() - listCommand() + if syA1 in ["--help", '-h']: + os.system('clear') + welcome() + help(syA1) + + elif syA1 in ['-b', '--banner']: + os.system('clear') + welcome() + elif syA1 in ['-c', '--commands']: + os.system('clear') + welcome() + listCommand() elif syA1 == 'localhost': ip = myIp() @@ -67,7 +67,7 @@ def zero(syA): getGeo(syA1) check(syA1) - + if (len(sys.argv) > 2): syA1 = sys.argv[1] diff --git a/src/geo-recon/modules/checkIp.py b/src/geo-recon/modules/checkIp.py index 2988677..bc25c96 100644 --- a/src/geo-recon/modules/checkIp.py +++ b/src/geo-recon/modules/checkIp.py @@ -20,10 +20,10 @@ def check(syA1): } response = requests.request(method='GET', url=url, headers=headers, params=querystring) - + # Formatted output decodedResponse = json.loads(response.text) - print ( Fore.WHITE + "Domain: " + json.dumps(decodedResponse ["data"]["domain"])) + print(f"{Fore.WHITE}Domain: " + json.dumps(decodedResponse ["data"]["domain"])) print ( "Hostname: " + json.dumps(decodedResponse ["data"]["hostnames"])) print ( "Usage Type: " + json.dumps(decodedResponse ["data"]["usageType"])) print ( "Confidence of Abuse: " + json.dumps(decodedResponse ["data"]["abuseConfidenceScore"])) @@ -33,13 +33,20 @@ def check(syA1): #This conditional statement outputs the status of the ip address based on abuse of confidence if json.dumps(decodedResponse ["data"]["abuseConfidenceScore"]) == "100": - print ( Fore.YELLOW + "The IP Address " + sys.argv[1] + " Is Malicious and well known for SSH Bruteforce Attacks" + "\n") + print( + f"{Fore.YELLOW}The IP Address {sys.argv[1]} Is Malicious and well known for SSH Bruteforce Attacks" + + "\n" + ) elif json.dumps(decodedResponse ["data"]["abuseConfidenceScore"]) == "0": - print ( Fore.GREEN + "The IP Address " + sys.argv[1] + " Is Not Malicious" + "\n") + print(f"{Fore.GREEN}The IP Address {sys.argv[1]} Is Not Malicious" + "\n") elif json.dumps(decodedResponse ["data"]["abuseConfidenceScore"]) < "20": - print ( "The IP Address " + sys.argv[1] + " Is Probably Not Malicious But Should Be Investigated Further") + print( + f"The IP Address {sys.argv[1]} Is Probably Not Malicious But Should Be Investigated Further" + ) elif json.dumps(decodedResponse ["data"]["abuseConfidenceScore"]) <= "20": - print ( "The IP Address " + sys.argv[1] + " Is Probably Malicious And Should Be Investigated Further") + print( + f"The IP Address {sys.argv[1]} Is Probably Malicious And Should Be Investigated Further" + ) else: print ( "" ) diff --git a/src/geo-recon/modules/commands.py b/src/geo-recon/modules/commands.py index f211420..e8e9171 100644 --- a/src/geo-recon/modules/commands.py +++ b/src/geo-recon/modules/commands.py @@ -6,12 +6,12 @@ def command(syA2, syA1): print("##################################### \n") - if syA2 == '--nmap' or syA2 == '-n': + if syA2 in ['--nmap', '-n']: print('-------------------------- -------------------------------------------') print("If Nmap is slow to respond don't worry, sometimes it takes a while.") print('--------------------------------------------------------------------- \n \n') ip = syA1 - nmapcc = os.system('nmap ' + ip) + nmapcc = os.system(f'nmap {ip}') print(nmapcc) sys.exit(0) @@ -21,8 +21,8 @@ def command(syA2, syA1): def listCommand(): - print(Fore.WHITE+'# Commands') - print('python geo-recon.py --help or -h (Display help)') - print('python geo-recon.py 138.121.128.19 --nmap or -n (Nmap standard use)') - print('python geo-recon.py 138.121.128.19 (Standard use, infos about IP)') - print('python geo-recon.py --commands or -c (Display commands availables )') + print(f'{Fore.WHITE}# Commands') + print('python geo-recon.py --help or -h (Display help)') + print('python geo-recon.py 138.121.128.19 --nmap or -n (Nmap standard use)') + print('python geo-recon.py 138.121.128.19 (Standard use, infos about IP)') + print('python geo-recon.py --commands or -c (Display commands availables )') diff --git a/src/geo-recon/modules/getData.py b/src/geo-recon/modules/getData.py index e3296ca..07ded86 100644 --- a/src/geo-recon/modules/getData.py +++ b/src/geo-recon/modules/getData.py @@ -5,12 +5,12 @@ import os def getGeo(syA1): - r = requests.get('http://ip-api.com/json/'+syA1) + r = requests.get(f'http://ip-api.com/json/{syA1}') response = json.loads(r.text) #Iterate the data, filter & print ( data for specific fields - #print ( sys.argv[1] ) - print ( Fore.WHITE + "Country: "+ response["country"]) + #print ( sys.argv[1] ) + print(f"{Fore.WHITE}Country: " + response["country"]) print ( "Region: " + response["regionName"]) print ( "City: " + response["city"]) print ( "Organization: "+response["org"]) diff --git a/src/geo-recon/modules/myip.py b/src/geo-recon/modules/myip.py index 5865987..7bd4dc0 100644 --- a/src/geo-recon/modules/myip.py +++ b/src/geo-recon/modules/myip.py @@ -8,6 +8,5 @@ def myIp(): r = requests.get('https://api.myip.com') response = json.loads(r.text) - ip = (response["ip"]) - return ip + return response["ip"] diff --git a/src/holehe/build/lib/holehe/modules/cms/gravatar.py b/src/holehe/build/lib/holehe/modules/cms/gravatar.py index 7f1471a..bc9d70f 100644 --- a/src/holehe/build/lib/holehe/modules/cms/gravatar.py +++ b/src/holehe/build/lib/holehe/modules/cms/gravatar.py @@ -24,7 +24,8 @@ async def gravatar(email, client, out): FullName = data['entry'][0]['displayName'] others = { - 'FullName': str(FullName)+" / "+str(data['entry'][0]["profileUrl"]), + 'FullName': f"{str(FullName)} / " + + str(data['entry'][0]["profileUrl"]) } out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/build/lib/holehe/modules/cms/voxmedia.py b/src/holehe/build/lib/holehe/modules/cms/voxmedia.py index 1cc2aea..8f87cad 100644 --- a/src/holehe/build/lib/holehe/modules/cms/voxmedia.py +++ b/src/holehe/build/lib/holehe/modules/cms/voxmedia.py @@ -28,14 +28,10 @@ async def voxmedia(email, client, out): response = await client.post('https://auth.voxmedia.com/chorus_auth/email_valid.json', headers=headers, data=data) try: rep = response.json() - if rep["available"]: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - elif rep["message"]=="You cannot use this email address.": + if ( + rep["available"] + or rep["message"] == "You cannot use this email address." + ): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, "exists": False, diff --git a/src/holehe/build/lib/holehe/modules/cms/wordpress.py b/src/holehe/build/lib/holehe/modules/cms/wordpress.py index 55fe561..0685a40 100644 --- a/src/holehe/build/lib/holehe/modules/cms/wordpress.py +++ b/src/holehe/build/lib/holehe/modules/cms/wordpress.py @@ -30,7 +30,12 @@ async def wordpress(email, client, out): 'locale': 'fr', } try: - response = await client.get('https://public-api.wordpress.com/rest/v1.1/users/' + email + '/auth-options', headers=headers, params=params, cookies=cookies) + response = await client.get( + f'https://public-api.wordpress.com/rest/v1.1/users/{email}/auth-options', + headers=headers, + params=params, + cookies=cookies, + ) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, diff --git a/src/holehe/build/lib/holehe/modules/crm/axonaut.py b/src/holehe/build/lib/holehe/modules/crm/axonaut.py index aaf463d..f78fc94 100644 --- a/src/holehe/build/lib/holehe/modules/crm/axonaut.py +++ b/src/holehe/build/lib/holehe/modules/crm/axonaut.py @@ -22,7 +22,11 @@ async def axonaut(email, client, out): } - response = await client.get('https://axonaut.com/onboarding/?email='+email, headers=headers,follow_redirects=False) + response = await client.get( + f'https://axonaut.com/onboarding/?email={email}', + headers=headers, + follow_redirects=False, + ) if response.status_code == 302 and "/login?email" in str(response.headers['Location']): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/build/lib/holehe/modules/crm/nimble.py b/src/holehe/build/lib/holehe/modules/crm/nimble.py index 86f9599..87426bc 100644 --- a/src/holehe/build/lib/holehe/modules/crm/nimble.py +++ b/src/holehe/build/lib/holehe/modules/crm/nimble.py @@ -20,7 +20,10 @@ async def nimble(email, client, out): 'Accept-Language': 'en-US;q=0.8,en;q=0.7', } - response = await client.get('https://www.nimble.com/lib/register.php?email='+email, headers=headers) + response = await client.get( + f'https://www.nimble.com/lib/register.php?email={email}', + headers=headers, + ) if response.text=='"I thought you looked familiar! This email is already registered."': out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/build/lib/holehe/modules/crm/nocrm.py b/src/holehe/build/lib/holehe/modules/crm/nocrm.py index 7317f04..bc986eb 100644 --- a/src/holehe/build/lib/holehe/modules/crm/nocrm.py +++ b/src/holehe/build/lib/holehe/modules/crm/nocrm.py @@ -21,7 +21,10 @@ async def nocrm(email, client, out): } - response = await client.get('https://register.nocrm.io/register/check_trial_duplicate?email='+email, headers=headers) + response = await client.get( + f'https://register.nocrm.io/register/check_trial_duplicate?email={email}', + headers=headers, + ) if '{"account":1,"url":"' in response.text: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/build/lib/holehe/modules/crm/zoho.py b/src/holehe/build/lib/holehe/modules/crm/zoho.py index 3d0c4c2..e184ca8 100644 --- a/src/holehe/build/lib/holehe/modules/crm/zoho.py +++ b/src/holehe/build/lib/holehe/modules/crm/zoho.py @@ -29,7 +29,11 @@ async def zoho(email, client, out): 'service_language': 'fr' } - response = await client.post('https://accounts.zoho.com/signin/v2/lookup/'+email, headers=headers, data=data) + response = await client.post( + f'https://accounts.zoho.com/signin/v2/lookup/{email}', + headers=headers, + data=data, + ) if response.status_code==200 and "message" in response.json().keys() and response.json()["message"]=="User exists" and response.json()["status_code"]==201: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/build/lib/holehe/modules/jobs/seoclerks.py b/src/holehe/build/lib/holehe/modules/jobs/seoclerks.py index 330f0cf..fa4e8f6 100644 --- a/src/holehe/build/lib/holehe/modules/jobs/seoclerks.py +++ b/src/holehe/build/lib/holehe/modules/jobs/seoclerks.py @@ -34,18 +34,18 @@ async def seoclerks(email, client, out): return None letters = string.ascii_lowercase - username = ''.join(random.choice(letters) for i in range(6)) - password = ''.join(random.choice(letters) for i in range(6)) + username = ''.join(random.choice(letters) for _ in range(6)) + password = ''.join(random.choice(letters) for _ in range(6)) data = { 'token': str(token), '__cr': str(cr), 'fsub': '1', 'droplet': '', - 'user_username': str(username), + 'user_username': username, 'user_email': str(email), - 'user_password': str(password), - 'confirm_password': str(password) + 'user_password': password, + 'confirm_password': password, } response = await client.post('https://www.seoclerks.com/signup/check', headers=headers, data=data) diff --git a/src/holehe/build/lib/holehe/modules/mails/google.py b/src/holehe/build/lib/holehe/modules/mails/google.py index ba2beaf..63a8c39 100644 --- a/src/holehe/build/lib/holehe/modules/mails/google.py +++ b/src/holehe/build/lib/holehe/modules/mails/google.py @@ -46,13 +46,12 @@ async def google(email, client, out): 'continue': 'https://accounts.google.com/', 'dsh': '', 'hl': 'fr', - 'f.req': '["' + freq + '","","","' + email + '",false]', + 'f.req': f'["{freq}","","","{email}",false]', 'azt': '', 'cookiesDisabled': 'false', 'deviceinfo': '[null,null,null,[],null,"FR",null,null,[],"GlifWebSignIn",null,[null,null,[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[],null,null,null,[],[]],null,null,null,null,0,null,false]', 'gmscoreversion': 'unined', - '': '' - + '': '', } response = await client.post('https://accounts.google.com/_/signup/webusernameavailability', headers=headers, params=params, data=data) if '"gf.wuar",2' in response.text: diff --git a/src/holehe/build/lib/holehe/modules/mails/protonmail.py b/src/holehe/build/lib/holehe/modules/mails/protonmail.py index 18d37f6..64da46b 100644 --- a/src/holehe/build/lib/holehe/modules/mails/protonmail.py +++ b/src/holehe/build/lib/holehe/modules/mails/protonmail.py @@ -10,7 +10,9 @@ async def protonmail(email, client, out): frequent_rate_limit=False try: - response = await client.get('https://api.protonmail.ch/pks/lookup?op=index&search='+email) + response = await client.get( + f'https://api.protonmail.ch/pks/lookup?op=index&search={email}' + ) if "info:1:0" in response.text : out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/build/lib/holehe/modules/medias/flickr.py b/src/holehe/build/lib/holehe/modules/medias/flickr.py index ac61820..24334b5 100644 --- a/src/holehe/build/lib/holehe/modules/medias/flickr.py +++ b/src/holehe/build/lib/holehe/modules/medias/flickr.py @@ -19,7 +19,7 @@ async def flickr(email, client, out): 'TE': 'Trailers', } try: - response = await client.get(url + "?email=" + str(email), headers=headers) + response = await client.get(f"{url}?email={str(email)}", headers=headers) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, diff --git a/src/holehe/build/lib/holehe/modules/music/lastfm.py b/src/holehe/build/lib/holehe/modules/music/lastfm.py index 8ac342b..781456b 100644 --- a/src/holehe/build/lib/holehe/modules/music/lastfm.py +++ b/src/holehe/build/lib/holehe/modules/music/lastfm.py @@ -25,7 +25,7 @@ async def lastfm(email, client, out): "Accept": "*/*", "Referer": "https://www.last.fm/join", "X-Requested-With": "XMLHttpRequest", - "Cookie": "csrftoken=" + str(token), + "Cookie": f"csrftoken={str(token)}", } try: diff --git a/src/holehe/build/lib/holehe/modules/music/soundcloud.py b/src/holehe/build/lib/holehe/modules/music/soundcloud.py index ce74b14..e94964a 100644 --- a/src/holehe/build/lib/holehe/modules/music/soundcloud.py +++ b/src/holehe/build/lib/holehe/modules/music/soundcloud.py @@ -20,17 +20,16 @@ async def soundcloud(email, client, out): linkMail = email.replace('@','%40') API = await client.get(f'https://api-auth.soundcloud.com/web-auth/identifier?q={linkMail}&client_id={clientId}', headers=headers) Json = json.loads(API.text) - if Json['status'] == 'available' or 'in_use': - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True if Json['status'] == 'in_use' else False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": True, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) + out.append( + { + "name": name, + "domain": domain, + "method": method, + "frequent_rate_limit": frequent_rate_limit, + "rateLimit": False, + "exists": Json['status'] == 'in_use', + "emailrecovery": None, + "phoneNumber": None, + "others": None, + } + ) diff --git a/src/holehe/build/lib/holehe/modules/osint/rocketreach.py b/src/holehe/build/lib/holehe/modules/osint/rocketreach.py index 11f3be6..c2bcbf0 100644 --- a/src/holehe/build/lib/holehe/modules/osint/rocketreach.py +++ b/src/holehe/build/lib/holehe/modules/osint/rocketreach.py @@ -18,7 +18,10 @@ async def rocketreach(email, client, out): 'TE': 'Trailers', } try: - r = await client.get('https://rocketreach.co/v1/validateEmail?email_address='+email, headers=headers) + r = await client.get( + f'https://rocketreach.co/v1/validateEmail?email_address={email}', + headers=headers, + ) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, diff --git a/src/holehe/build/lib/holehe/modules/payment/venmo.py b/src/holehe/build/lib/holehe/modules/payment/venmo.py index 29ca8f5..bf8c2e0 100644 --- a/src/holehe/build/lib/holehe/modules/payment/venmo.py +++ b/src/holehe/build/lib/holehe/modules/payment/venmo.py @@ -35,25 +35,25 @@ async def venmo(email, client, out): email + '","password":"","phone":"1","client_id":10}' response = await client.post('https://venmo.com/api/v5/users', headers=headers, data=data) - if "Not acceptable" not in response.text: - if "That email is already registered in our system." in response.text: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: + if "Not acceptable" in response.text: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, "exists": False, "emailrecovery": None, "phoneNumber": None, "others": None}) + + elif "That email is already registered in our system." in response.text: + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": True, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) + else: + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": False, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) diff --git a/src/holehe/build/lib/holehe/modules/porn/xnxx.py b/src/holehe/build/lib/holehe/modules/porn/xnxx.py index bc1ef22..ac52816 100644 --- a/src/holehe/build/lib/holehe/modules/porn/xnxx.py +++ b/src/holehe/build/lib/holehe/modules/porn/xnxx.py @@ -2,11 +2,6 @@ from holehe.localuseragent import * async def xnxx(email, client, out): - name = "xnxx" - domain = "xnxx.com" - method= "register" - frequent_rate_limit=True - headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, br', @@ -20,12 +15,17 @@ async def xnxx(email, client, out): if XNXX.status_code == 200: headers['Referer'] = 'https://www.xnxx.com/video-holehe/palenath_fucks_xnxx_with_holehe' headers['X-Requested-With'] = 'XMLHttpRequest' - + email = email.replace('@', '%40') APIRQST = await client.get(f'https://www.xnxx.com/account/checkemail?email={email}', headers=headers, cookies=XNXX.cookies) if APIRQST.status_code == 200: API = json.loads(APIRQST.text) + name = "xnxx" + domain = "xnxx.com" + method= "register" + frequent_rate_limit=True + if API['result'] == False and API['code'] == 1 and API['message'] == 'Cet email est déjà utilisé ou son propriétaire l'a exclu de notre site.': out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/build/lib/holehe/modules/programing/github.py b/src/holehe/build/lib/holehe/modules/programing/github.py index 291be07..db1112d 100644 --- a/src/holehe/build/lib/holehe/modules/programing/github.py +++ b/src/holehe/build/lib/holehe/modules/programing/github.py @@ -14,7 +14,10 @@ async def github(email, client, out): token = re.findall(token_regex, freq.text) data = {"value": email, "authenticity_token": token[0]} req = await client.post("https://github.com/signup_check/email", data=data) - if "Your browser did something unexpected." in req.text: + if ( + "Your browser did something unexpected." in req.text + or req.status_code not in [422, 200] + ): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, "exists": None, @@ -28,17 +31,10 @@ async def github(email, client, out): "emailrecovery": None, "phoneNumber": None, "others": None}) - elif req.status_code == 200: + else: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, "exists": False, "emailrecovery": None, "phoneNumber": None, "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": True, - "exists": None, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) diff --git a/src/holehe/build/lib/holehe/modules/shopping/amazon.py b/src/holehe/build/lib/holehe/modules/shopping/amazon.py index d1fccb9..c6aecd7 100644 --- a/src/holehe/build/lib/holehe/modules/shopping/amazon.py +++ b/src/holehe/build/lib/holehe/modules/shopping/amazon.py @@ -16,7 +16,7 @@ async def amazon(email, client, out): data = dict([(x["name"], x["value"]) for x in body.select( 'form input') if ('name' in x.attrs and 'value' in x.attrs)]) data["email"] = email - req = await client.post(f'https://www.amazon.com/ap/signin/', data=data) + req = await client.post('https://www.amazon.com/ap/signin/', data=data) body = BeautifulSoup(req.text, 'html.parser') if body.find("div", {"id": "auth-password-missing-alert"}): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/build/lib/holehe/modules/shopping/vivino.py b/src/holehe/build/lib/holehe/modules/shopping/vivino.py index 1f81fee..3dfcdc0 100644 --- a/src/holehe/build/lib/holehe/modules/shopping/vivino.py +++ b/src/holehe/build/lib/holehe/modules/shopping/vivino.py @@ -33,21 +33,20 @@ async def vivino(email, client, out): "emailrecovery": None, "phoneNumber": None, "others": None}) + elif response.json()['error'] == "The supplied email does not exist": + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": False, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) else: - if response.json()['error'] == "The supplied email does not exist": - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": True, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/build/lib/holehe/modules/social_media/bitmoji.py b/src/holehe/build/lib/holehe/modules/social_media/bitmoji.py index 9282f2d..9613a7e 100644 --- a/src/holehe/build/lib/holehe/modules/social_media/bitmoji.py +++ b/src/holehe/build/lib/holehe/modules/social_media/bitmoji.py @@ -21,7 +21,7 @@ async def bitmoji(email, client, out): "Accept-Encoding": "gzip, late", "Content-Type": "application/json", "Connection": "close", - "Cookie": "xsrf_token=" + xsrf + "; web_client_id=" + webClientId + "Cookie": f"xsrf_token={xsrf}; web_client_id={webClientId}", } data = '{"email":' + email + ',"app":"BITMOJI_APP"}' diff --git a/src/holehe/build/lib/holehe/modules/social_media/instagram.py b/src/holehe/build/lib/holehe/modules/social_media/instagram.py index 31d55a2..1ee6f0d 100644 --- a/src/holehe/build/lib/holehe/modules/social_media/instagram.py +++ b/src/holehe/build/lib/holehe/modules/social_media/instagram.py @@ -41,32 +41,32 @@ async def instagram(email, client, out): data=data, headers=headers) check = check.json() - if check["status"] != "fail": - if 'email' in check["errors"].keys(): - if check["errors"]["email"][0]["code"] == "email_is_taken": - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - elif "email_sharing_limit" in str(check["errors"]): - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: + if check["status"] == "fail": + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": True, + "exists": False, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) + + elif 'email' in check["errors"].keys(): + if check["errors"]["email"][0]["code"] == "email_is_taken": out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, - "exists": False, + "exists": True, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) + elif "email_sharing_limit" in str(check["errors"]): + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": True, "emailrecovery": None, "phoneNumber": None, "others": None}) else: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": True, + "rateLimit": False, "exists": False, "emailrecovery": None, "phoneNumber": None, diff --git a/src/holehe/build/lib/holehe/modules/social_media/odnoklassniki.py b/src/holehe/build/lib/holehe/modules/social_media/odnoklassniki.py index cbecce3..1cb6c2c 100644 --- a/src/holehe/build/lib/holehe/modules/social_media/odnoklassniki.py +++ b/src/holehe/build/lib/holehe/modules/social_media/odnoklassniki.py @@ -21,13 +21,12 @@ async def odnoklassniki(email, client, out): OK_LOGIN_URL = 'https://www.ok.ru/dk?st.cmd=anonymMain&st.accRecovery=on&st.error=errors.password.wrong' OK_RECOVER_URL = 'https://www.ok.ru/dk?st.cmd=anonymRecoveryAfterFailedLogin&st._aid=LeftColumn_Login_ForgotPassword' try: - await client.get(OK_LOGIN_URL + '&st.email=' + email, headers=headers) + await client.get(f'{OK_LOGIN_URL}&st.email={email}', headers=headers) request = await client.get(OK_RECOVER_URL, headers=headers) root_soup = BeautifulSoup(request.content, 'html.parser') - soup = root_soup.find( - 'div', { - 'data-l': 'registrationContainer,offer_contact_rest'}) - if soup: + if soup := root_soup.find( + 'div', {'data-l': 'registrationContainer,offer_contact_rest'} + ): account_info = soup.find( 'div', {'class': 'ext-registration_tx taCenter'}) masked_email = soup.find('button', {'data-l': 't,email'}) @@ -43,8 +42,9 @@ async def odnoklassniki(email, client, out): 'div', {'class': 'ext-registration_username_header'}) if masked_name: masked_name = masked_name.get_text() - account_info = account_info.findAll('div', {'class': 'lstp-t'}) - if account_info: + if account_info := account_info.findAll( + 'div', {'class': 'lstp-t'} + ): profile_info = account_info[0].get_text() profile_registred = account_info[1].get_text() else: diff --git a/src/holehe/build/lib/holehe/modules/social_media/parler.py b/src/holehe/build/lib/holehe/modules/social_media/parler.py index 4f57ece..b323abf 100644 --- a/src/holehe/build/lib/holehe/modules/social_media/parler.py +++ b/src/holehe/build/lib/holehe/modules/social_media/parler.py @@ -7,6 +7,7 @@ def get_random_string(length): letters = string.ascii_lowercase result_str = ''.join(random.choice(letters) for i in range(length)) return(result_str) + name = "parler" domain = "parler.com" method = "login" @@ -27,7 +28,7 @@ def get_random_string(length): 'accept-language': 'es,en-US;q=0.9,en;q=0.8', 'sec-gpc': '1', } - email = '"' + email + '"' + email = f'"{email}"' data = '{"identifier":' + email + \ ',"password":"invalidpasswordfortest","deviceId":"' + get_random_string(16) + '"}' try: diff --git a/src/holehe/build/lib/holehe/modules/social_media/snapchat.py b/src/holehe/build/lib/holehe/modules/social_media/snapchat.py index ce04e00..f211eb0 100644 --- a/src/holehe/build/lib/holehe/modules/social_media/snapchat.py +++ b/src/holehe/build/lib/holehe/modules/social_media/snapchat.py @@ -20,7 +20,7 @@ async def snapchat(email, client, out): "Accept-Encoding": "gzip, late", "Content-Type": "application/json", "Connection": "close", - "Cookie": "xsrf_token=" + xsrf + "; web_client_id=" + webClientId + "Cookie": f"xsrf_token={xsrf}; web_client_id={webClientId}", } data = '{"email":' + email + ',"app":"BITMOJI_APP"}' diff --git a/src/holehe/build/lib/holehe/modules/social_media/wattpad.py b/src/holehe/build/lib/holehe/modules/social_media/wattpad.py index 1fd26dd..2ab6e66 100644 --- a/src/holehe/build/lib/holehe/modules/social_media/wattpad.py +++ b/src/holehe/build/lib/holehe/modules/social_media/wattpad.py @@ -32,7 +32,7 @@ async def wattpad(email, client, out): 'email': email, } response = await client.get('https://www.wattpad.com/api/v3/users/validate', headers=headers, params=params) - if (response.status_code == 200 or response.status_code == 400): + if response.status_code in [200, 400]: if "Cette adresse" not in response.text or response.text == '{"message":"OK","code":200}': out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/build/lib/holehe/modules/software/issuu.py b/src/holehe/build/lib/holehe/modules/software/issuu.py index cc1d3c6..0ed2154 100644 --- a/src/holehe/build/lib/holehe/modules/software/issuu.py +++ b/src/holehe/build/lib/holehe/modules/software/issuu.py @@ -3,7 +3,6 @@ async def issuu(email, client, out): - name = "issuu" domain = "issuu.com" method = "register" frequent_rate_limit=False @@ -21,9 +20,9 @@ async def issuu(email, client, out): } response = await client.get( - 'https://issuu.com/call/signup/check-email/' + - email, - headers=headers) + f'https://issuu.com/call/signup/check-email/{email}', headers=headers + ) + name = "issuu" try: if response.json()["status"] == "unavailable": out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/build/lib/holehe/modules/software/lastpass.py b/src/holehe/build/lib/holehe/modules/software/lastpass.py index ba5050d..75d2c6b 100644 --- a/src/holehe/build/lib/holehe/modules/software/lastpass.py +++ b/src/holehe/build/lib/holehe/modules/software/lastpass.py @@ -36,7 +36,7 @@ async def lastpass(email, client, out): "emailrecovery": None, "phoneNumber": None, "others": None}) - elif response.text == "ok" or response.text == "emailinvalid": + elif response.text in ["ok", "emailinvalid"]: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, "exists": False, diff --git a/src/holehe/build/lib/holehe/modules/software/office365.py b/src/holehe/build/lib/holehe/modules/software/office365.py index 39cdd1d..0b2b18d 100644 --- a/src/holehe/build/lib/holehe/modules/software/office365.py +++ b/src/holehe/build/lib/holehe/modules/software/office365.py @@ -14,11 +14,14 @@ def get_random_string(length): letters = string.digits result_str = ''.join(random.choice(letters) for i in range(length)) return(result_str) + r = await client.get( 'https://outlook.office365.com/autodiscover/autodiscover.json/v1.0/{}?Protocol=Autodiscoverv1'.format( - get_random_string(30)+"@"+email.split('@')[1]), + f"{get_random_string(30)}@" + email.split('@')[1] + ), headers=headers, - follow_redirects=False) + follow_redirects=False, + ) if r.status_code != 200: r = await client.get( 'https://outlook.office365.com/autodiscover/autodiscover.json/v1.0/{}?Protocol=Autodiscoverv1'.format( diff --git a/src/holehe/build/lib/holehe/modules/sport/bodybuilding.py b/src/holehe/build/lib/holehe/modules/sport/bodybuilding.py index dcaa38a..8855588 100644 --- a/src/holehe/build/lib/holehe/modules/sport/bodybuilding.py +++ b/src/holehe/build/lib/holehe/modules/sport/bodybuilding.py @@ -18,7 +18,9 @@ async def bodybuilding(email, client, out): 'Referer': 'https://www.bodybuilding.com/', } - response = await client.head('https://api.bodybuilding.com/profile/email/' + email, headers=headers) + response = await client.head( + f'https://api.bodybuilding.com/profile/email/{email}', headers=headers + ) if response.status_code == 200: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/build/lib/holehe/modules/transport/blablacar.py b/src/holehe/build/lib/holehe/modules/transport/blablacar.py index f9d72b6..4d0d033 100644 --- a/src/holehe/build/lib/holehe/modules/transport/blablacar.py +++ b/src/holehe/build/lib/holehe/modules/transport/blablacar.py @@ -3,7 +3,6 @@ async def blablacar(email, client, out): - name = "blablacar" domain = "blablacar.com" method = "register" frequent_rate_limit=True @@ -23,6 +22,7 @@ async def blablacar(email, client, out): 'Connection': 'keep-alive', 'TE': 'Trailers', } + name = "blablacar" try: appToken = await client.get( "https://www.blablacar.fr/register", @@ -42,7 +42,7 @@ async def blablacar(email, client, out): 'datadome': '', } try: - headers["Authorization"] = 'Bearer ' + appToken + headers["Authorization"] = f'Bearer {appToken}' except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, @@ -53,10 +53,10 @@ async def blablacar(email, client, out): return None response = await client.get( - 'https://edge.blablacar.fr/auth/validation/email/' + - email, + f'https://edge.blablacar.fr/auth/validation/email/{email}', headers=headers, - cookies=cookies) + cookies=cookies, + ) data = response.json() if "url" in data.keys(): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/core.py b/src/holehe/holehe/core.py index 8b6cf39..82dc18e 100644 --- a/src/holehe/holehe/core.py +++ b/src/holehe/holehe/core.py @@ -40,10 +40,10 @@ def import_submodules(package, recursive=True): package = importlib.import_module(package) results = {} for loader, name, is_pkg in pkgutil.walk_packages(package.__path__): - full_name = package.__name__ + '.' + name + full_name = f'{package.__name__}.{name}' results[full_name] = importlib.import_module(full_name) if recursive and is_pkg: - results.update(import_submodules(full_name)) + results |= import_submodules(full_name) return results @@ -105,10 +105,7 @@ def is_email(email: str) -> bool: def print_result(data,args,email,start_time,websites): def print_color(text,color,args): - if args.nocolor == False: - return(colored(text,color)) - else: - return(text) + return (colored(text,color)) if args.nocolor == False else text description = print_color("[+] Email used","green",args) + "," + print_color(" [-] Email not used", "magenta",args) + "," + print_color(" [x] Rate limit","red",args) if args.noclear==False: @@ -116,7 +113,7 @@ def print_color(text,color,args): else: print("\n") print("*" * (len(email) + 6)) - print(" " + email) + print(f" {email}") print("*" * (len(email) + 6)) for results in data: @@ -141,8 +138,9 @@ def print_color(text,color,args): print(websiteprint) print("\n" + description) - print(str(len(websites)) + " websites checked in " + - str(round(time.time() - start_time, 2)) + " seconds") + print( + f"{len(websites)} websites checked in {str(round(time.time() - start_time, 2))} seconds" + ) def export_csv(data,args,email): @@ -150,12 +148,12 @@ def export_csv(data,args,email): if args.csvoutput == True: now = datetime.now() timestamp = datetime.timestamp(now) - name_file="holehe_"+str(round(timestamp))+"_"+email+"_results.csv" + name_file = f"holehe_{str(round(timestamp))}_{email}_results.csv" with open(name_file, 'w', encoding='utf8', newline='') as output_file: fc = csv.DictWriter(output_file,fieldnames=data[0].keys()) fc.writeheader() fc.writerows(data) - exit("All results have been exported to "+name_file) + exit(f"All results have been exported to {name_file}") async def launch_module(module,email, client, out): data={'aboutme': 'about.me', 'adobe': 'adobe.com', 'amazon': 'amazon.com', 'anydo': 'any.do', 'archive': 'archive.org', 'armurerieauxerre': 'armurerie-auxerre.com', 'atlassian': 'atlassian.com', 'babeshows': 'babeshows.co.uk', 'badeggsonline': 'badeggsonline.com', 'biosmods': 'bios-mods.com', 'biotechnologyforums': 'biotechnologyforums.com', 'bitmoji': 'bitmoji.com', 'blablacar': 'blablacar.com', 'blackworldforum': 'blackworldforum.com', 'blip': 'blip.fm', 'blitzortung': 'forum.blitzortung.org', 'bluegrassrivals': 'bluegrassrivals.com', 'bodybuilding': 'bodybuilding.com', 'buymeacoffee': 'buymeacoffee.com', 'cambridgemt': 'discussion.cambridge-mt.com', 'caringbridge': 'caringbridge.org', 'chinaphonearena': 'chinaphonearena.com', 'clashfarmer': 'clashfarmer.com', 'codecademy': 'codecademy.com', 'codeigniter': 'forum.codeigniter.com', 'codepen': 'codepen.io', 'coroflot': 'coroflot.com', 'cpaelites': 'cpaelites.com', 'cpahero': 'cpahero.com', 'cracked_to': 'cracked.to', 'crevado': 'crevado.com', 'deliveroo': 'deliveroo.com', 'demonforums': 'demonforums.net', 'devrant': 'devrant.com', 'diigo': 'diigo.com', 'discord': 'discord.com', 'docker': 'docker.com', 'dominosfr': 'dominos.fr', 'ebay': 'ebay.com', 'ello': 'ello.co', 'envato': 'envato.com', 'eventbrite': 'eventbrite.com', 'evernote': 'evernote.com', 'fanpop': 'fanpop.com', 'firefox': 'firefox.com', 'flickr': 'flickr.com', 'freelancer': 'freelancer.com', 'freiberg': 'drachenhort.user.stunet.tu-freiberg.de', 'garmin': 'garmin.com', 'github': 'github.com', 'google': 'google.com', 'gravatar': 'gravatar.com', 'imgur': 'imgur.com', 'instagram': 'instagram.com', 'issuu': 'issuu.com', 'koditv': 'forum.kodi.tv', 'komoot': 'komoot.com', 'laposte': 'laposte.fr', 'lastfm': 'last.fm', 'lastpass': 'lastpass.com', 'mail_ru': 'mail.ru', 'mybb': 'community.mybb.com', 'myspace': 'myspace.com', 'nattyornot': 'nattyornotforum.nattyornot.com', 'naturabuy': 'naturabuy.fr', 'ndemiccreations': 'forum.ndemiccreations.com', 'nextpvr': 'forums.nextpvr.com', 'nike': 'nike.com', 'odampublishing': 'forum.odampublishing.com', 'odnoklassniki': 'ok.ru', 'office365': 'office365.com', 'onlinesequencer': 'onlinesequencer.net', 'parler': 'parler.com', 'patreon': 'patreon.com', 'pinterest': 'pinterest.com', 'plurk': 'plurk.com', 'pornhub': 'pornhub.com', 'protonmail': 'protonmail.ch', 'quora': 'quora.com', 'raidforums': 'raidforums.com', 'rambler': 'rambler.ru', 'redtube': 'redtube.com', 'replit': 'replit.com', 'rocketreach': 'rocketreach.co', 'samsung': 'samsung.com', 'seoclerks': 'seoclerks.com', 'sevencups': '7cups.com', 'smule': 'smule.com', 'snapchat': 'snapchat.com', 'soundcloud': 'soundcloud.com', 'sporcle': 'sporcle.com', 'spotify': 'spotify.com', 'strava': 'strava.com', 'taringa': 'taringa.net', 'teamtreehouse': 'teamtreehouse.com', 'tellonym': 'tellonym.me', 'thecardboard': 'thecardboard.org', 'therianguide': 'forums.therian-guide.com', 'thevapingforum': 'thevapingforum.com', 'treasureclassifieds': 'forum.treasureclassifieds.com', 'tumblr': 'tumblr.com', 'tunefind': 'tunefind.com', 'twitter': 'twitter.com', 'venmo': 'venmo.com', 'vivino': 'vivino.com', 'voxmedia': 'voxmedia.com', 'vrbo': 'vrbo.com', 'vsco': 'vsco.co', 'wattpad': 'wattpad.com', 'wordpress': 'wordpress.com', 'xing': 'xing.com', 'xnxx': 'xnxx.com', 'xvideos': 'xvideos.com', 'yahoo': 'yahoo.com','hubspot': 'hubspot.com', 'pipedrive': 'pipedrive.com', 'insightly': 'insightly.com', 'nutshell': 'nutshell.com', 'zoho': 'zoho.com', 'axonaut': 'axonaut.com', 'amocrm': 'amocrm.com', 'nimble': 'nimble.com', 'nocrm': 'nocrm.io', 'teamleader': 'teamleader.eu'} diff --git a/src/holehe/holehe/modules/cms/gravatar.py b/src/holehe/holehe/modules/cms/gravatar.py index 7f1471a..bc9d70f 100644 --- a/src/holehe/holehe/modules/cms/gravatar.py +++ b/src/holehe/holehe/modules/cms/gravatar.py @@ -24,7 +24,8 @@ async def gravatar(email, client, out): FullName = data['entry'][0]['displayName'] others = { - 'FullName': str(FullName)+" / "+str(data['entry'][0]["profileUrl"]), + 'FullName': f"{str(FullName)} / " + + str(data['entry'][0]["profileUrl"]) } out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/modules/cms/voxmedia.py b/src/holehe/holehe/modules/cms/voxmedia.py index 1cc2aea..8f87cad 100644 --- a/src/holehe/holehe/modules/cms/voxmedia.py +++ b/src/holehe/holehe/modules/cms/voxmedia.py @@ -28,14 +28,10 @@ async def voxmedia(email, client, out): response = await client.post('https://auth.voxmedia.com/chorus_auth/email_valid.json', headers=headers, data=data) try: rep = response.json() - if rep["available"]: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - elif rep["message"]=="You cannot use this email address.": + if ( + rep["available"] + or rep["message"] == "You cannot use this email address." + ): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, "exists": False, diff --git a/src/holehe/holehe/modules/cms/wordpress.py b/src/holehe/holehe/modules/cms/wordpress.py index 55fe561..0685a40 100644 --- a/src/holehe/holehe/modules/cms/wordpress.py +++ b/src/holehe/holehe/modules/cms/wordpress.py @@ -30,7 +30,12 @@ async def wordpress(email, client, out): 'locale': 'fr', } try: - response = await client.get('https://public-api.wordpress.com/rest/v1.1/users/' + email + '/auth-options', headers=headers, params=params, cookies=cookies) + response = await client.get( + f'https://public-api.wordpress.com/rest/v1.1/users/{email}/auth-options', + headers=headers, + params=params, + cookies=cookies, + ) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, diff --git a/src/holehe/holehe/modules/crm/axonaut.py b/src/holehe/holehe/modules/crm/axonaut.py index aaf463d..f78fc94 100644 --- a/src/holehe/holehe/modules/crm/axonaut.py +++ b/src/holehe/holehe/modules/crm/axonaut.py @@ -22,7 +22,11 @@ async def axonaut(email, client, out): } - response = await client.get('https://axonaut.com/onboarding/?email='+email, headers=headers,follow_redirects=False) + response = await client.get( + f'https://axonaut.com/onboarding/?email={email}', + headers=headers, + follow_redirects=False, + ) if response.status_code == 302 and "/login?email" in str(response.headers['Location']): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/modules/crm/nimble.py b/src/holehe/holehe/modules/crm/nimble.py index 86f9599..87426bc 100644 --- a/src/holehe/holehe/modules/crm/nimble.py +++ b/src/holehe/holehe/modules/crm/nimble.py @@ -20,7 +20,10 @@ async def nimble(email, client, out): 'Accept-Language': 'en-US;q=0.8,en;q=0.7', } - response = await client.get('https://www.nimble.com/lib/register.php?email='+email, headers=headers) + response = await client.get( + f'https://www.nimble.com/lib/register.php?email={email}', + headers=headers, + ) if response.text=='"I thought you looked familiar! This email is already registered."': out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/modules/crm/nocrm.py b/src/holehe/holehe/modules/crm/nocrm.py index 7317f04..bc986eb 100644 --- a/src/holehe/holehe/modules/crm/nocrm.py +++ b/src/holehe/holehe/modules/crm/nocrm.py @@ -21,7 +21,10 @@ async def nocrm(email, client, out): } - response = await client.get('https://register.nocrm.io/register/check_trial_duplicate?email='+email, headers=headers) + response = await client.get( + f'https://register.nocrm.io/register/check_trial_duplicate?email={email}', + headers=headers, + ) if '{"account":1,"url":"' in response.text: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/holehe/modules/crm/zoho.py b/src/holehe/holehe/modules/crm/zoho.py index 3d0c4c2..e184ca8 100644 --- a/src/holehe/holehe/modules/crm/zoho.py +++ b/src/holehe/holehe/modules/crm/zoho.py @@ -29,7 +29,11 @@ async def zoho(email, client, out): 'service_language': 'fr' } - response = await client.post('https://accounts.zoho.com/signin/v2/lookup/'+email, headers=headers, data=data) + response = await client.post( + f'https://accounts.zoho.com/signin/v2/lookup/{email}', + headers=headers, + data=data, + ) if response.status_code==200 and "message" in response.json().keys() and response.json()["message"]=="User exists" and response.json()["status_code"]==201: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/holehe/modules/jobs/seoclerks.py b/src/holehe/holehe/modules/jobs/seoclerks.py index 330f0cf..fa4e8f6 100644 --- a/src/holehe/holehe/modules/jobs/seoclerks.py +++ b/src/holehe/holehe/modules/jobs/seoclerks.py @@ -34,18 +34,18 @@ async def seoclerks(email, client, out): return None letters = string.ascii_lowercase - username = ''.join(random.choice(letters) for i in range(6)) - password = ''.join(random.choice(letters) for i in range(6)) + username = ''.join(random.choice(letters) for _ in range(6)) + password = ''.join(random.choice(letters) for _ in range(6)) data = { 'token': str(token), '__cr': str(cr), 'fsub': '1', 'droplet': '', - 'user_username': str(username), + 'user_username': username, 'user_email': str(email), - 'user_password': str(password), - 'confirm_password': str(password) + 'user_password': password, + 'confirm_password': password, } response = await client.post('https://www.seoclerks.com/signup/check', headers=headers, data=data) diff --git a/src/holehe/holehe/modules/mails/google.py b/src/holehe/holehe/modules/mails/google.py index ba2beaf..63a8c39 100644 --- a/src/holehe/holehe/modules/mails/google.py +++ b/src/holehe/holehe/modules/mails/google.py @@ -46,13 +46,12 @@ async def google(email, client, out): 'continue': 'https://accounts.google.com/', 'dsh': '', 'hl': 'fr', - 'f.req': '["' + freq + '","","","' + email + '",false]', + 'f.req': f'["{freq}","","","{email}",false]', 'azt': '', 'cookiesDisabled': 'false', 'deviceinfo': '[null,null,null,[],null,"FR",null,null,[],"GlifWebSignIn",null,[null,null,[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[],null,null,null,[],[]],null,null,null,null,0,null,false]', 'gmscoreversion': 'unined', - '': '' - + '': '', } response = await client.post('https://accounts.google.com/_/signup/webusernameavailability', headers=headers, params=params, data=data) if '"gf.wuar",2' in response.text: diff --git a/src/holehe/holehe/modules/mails/protonmail.py b/src/holehe/holehe/modules/mails/protonmail.py index 18d37f6..64da46b 100644 --- a/src/holehe/holehe/modules/mails/protonmail.py +++ b/src/holehe/holehe/modules/mails/protonmail.py @@ -10,7 +10,9 @@ async def protonmail(email, client, out): frequent_rate_limit=False try: - response = await client.get('https://api.protonmail.ch/pks/lookup?op=index&search='+email) + response = await client.get( + f'https://api.protonmail.ch/pks/lookup?op=index&search={email}' + ) if "info:1:0" in response.text : out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/holehe/modules/medias/flickr.py b/src/holehe/holehe/modules/medias/flickr.py index ac61820..24334b5 100644 --- a/src/holehe/holehe/modules/medias/flickr.py +++ b/src/holehe/holehe/modules/medias/flickr.py @@ -19,7 +19,7 @@ async def flickr(email, client, out): 'TE': 'Trailers', } try: - response = await client.get(url + "?email=" + str(email), headers=headers) + response = await client.get(f"{url}?email={str(email)}", headers=headers) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, diff --git a/src/holehe/holehe/modules/music/lastfm.py b/src/holehe/holehe/modules/music/lastfm.py index 8ac342b..781456b 100644 --- a/src/holehe/holehe/modules/music/lastfm.py +++ b/src/holehe/holehe/modules/music/lastfm.py @@ -25,7 +25,7 @@ async def lastfm(email, client, out): "Accept": "*/*", "Referer": "https://www.last.fm/join", "X-Requested-With": "XMLHttpRequest", - "Cookie": "csrftoken=" + str(token), + "Cookie": f"csrftoken={str(token)}", } try: diff --git a/src/holehe/holehe/modules/music/soundcloud.py b/src/holehe/holehe/modules/music/soundcloud.py index ce74b14..e94964a 100644 --- a/src/holehe/holehe/modules/music/soundcloud.py +++ b/src/holehe/holehe/modules/music/soundcloud.py @@ -20,17 +20,16 @@ async def soundcloud(email, client, out): linkMail = email.replace('@','%40') API = await client.get(f'https://api-auth.soundcloud.com/web-auth/identifier?q={linkMail}&client_id={clientId}', headers=headers) Json = json.loads(API.text) - if Json['status'] == 'available' or 'in_use': - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True if Json['status'] == 'in_use' else False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": True, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) + out.append( + { + "name": name, + "domain": domain, + "method": method, + "frequent_rate_limit": frequent_rate_limit, + "rateLimit": False, + "exists": Json['status'] == 'in_use', + "emailrecovery": None, + "phoneNumber": None, + "others": None, + } + ) diff --git a/src/holehe/holehe/modules/osint/rocketreach.py b/src/holehe/holehe/modules/osint/rocketreach.py index 11f3be6..c2bcbf0 100644 --- a/src/holehe/holehe/modules/osint/rocketreach.py +++ b/src/holehe/holehe/modules/osint/rocketreach.py @@ -18,7 +18,10 @@ async def rocketreach(email, client, out): 'TE': 'Trailers', } try: - r = await client.get('https://rocketreach.co/v1/validateEmail?email_address='+email, headers=headers) + r = await client.get( + f'https://rocketreach.co/v1/validateEmail?email_address={email}', + headers=headers, + ) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, diff --git a/src/holehe/holehe/modules/payment/venmo.py b/src/holehe/holehe/modules/payment/venmo.py index 29ca8f5..bf8c2e0 100644 --- a/src/holehe/holehe/modules/payment/venmo.py +++ b/src/holehe/holehe/modules/payment/venmo.py @@ -35,25 +35,25 @@ async def venmo(email, client, out): email + '","password":"","phone":"1","client_id":10}' response = await client.post('https://venmo.com/api/v5/users', headers=headers, data=data) - if "Not acceptable" not in response.text: - if "That email is already registered in our system." in response.text: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: + if "Not acceptable" in response.text: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, "exists": False, "emailrecovery": None, "phoneNumber": None, "others": None}) + + elif "That email is already registered in our system." in response.text: + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": True, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) + else: + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": False, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) diff --git a/src/holehe/holehe/modules/porn/xnxx.py b/src/holehe/holehe/modules/porn/xnxx.py index bc1ef22..ac52816 100644 --- a/src/holehe/holehe/modules/porn/xnxx.py +++ b/src/holehe/holehe/modules/porn/xnxx.py @@ -2,11 +2,6 @@ from holehe.localuseragent import * async def xnxx(email, client, out): - name = "xnxx" - domain = "xnxx.com" - method= "register" - frequent_rate_limit=True - headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, br', @@ -20,12 +15,17 @@ async def xnxx(email, client, out): if XNXX.status_code == 200: headers['Referer'] = 'https://www.xnxx.com/video-holehe/palenath_fucks_xnxx_with_holehe' headers['X-Requested-With'] = 'XMLHttpRequest' - + email = email.replace('@', '%40') APIRQST = await client.get(f'https://www.xnxx.com/account/checkemail?email={email}', headers=headers, cookies=XNXX.cookies) if APIRQST.status_code == 200: API = json.loads(APIRQST.text) + name = "xnxx" + domain = "xnxx.com" + method= "register" + frequent_rate_limit=True + if API['result'] == False and API['code'] == 1 and API['message'] == 'Cet email est déjà utilisé ou son propriétaire l'a exclu de notre site.': out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/holehe/modules/programing/github.py b/src/holehe/holehe/modules/programing/github.py index 291be07..db1112d 100644 --- a/src/holehe/holehe/modules/programing/github.py +++ b/src/holehe/holehe/modules/programing/github.py @@ -14,7 +14,10 @@ async def github(email, client, out): token = re.findall(token_regex, freq.text) data = {"value": email, "authenticity_token": token[0]} req = await client.post("https://github.com/signup_check/email", data=data) - if "Your browser did something unexpected." in req.text: + if ( + "Your browser did something unexpected." in req.text + or req.status_code not in [422, 200] + ): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, "exists": None, @@ -28,17 +31,10 @@ async def github(email, client, out): "emailrecovery": None, "phoneNumber": None, "others": None}) - elif req.status_code == 200: + else: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, "exists": False, "emailrecovery": None, "phoneNumber": None, "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": True, - "exists": None, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) diff --git a/src/holehe/holehe/modules/shopping/amazon.py b/src/holehe/holehe/modules/shopping/amazon.py index d1fccb9..c6aecd7 100644 --- a/src/holehe/holehe/modules/shopping/amazon.py +++ b/src/holehe/holehe/modules/shopping/amazon.py @@ -16,7 +16,7 @@ async def amazon(email, client, out): data = dict([(x["name"], x["value"]) for x in body.select( 'form input') if ('name' in x.attrs and 'value' in x.attrs)]) data["email"] = email - req = await client.post(f'https://www.amazon.com/ap/signin/', data=data) + req = await client.post('https://www.amazon.com/ap/signin/', data=data) body = BeautifulSoup(req.text, 'html.parser') if body.find("div", {"id": "auth-password-missing-alert"}): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/modules/shopping/vivino.py b/src/holehe/holehe/modules/shopping/vivino.py index 1f81fee..3dfcdc0 100644 --- a/src/holehe/holehe/modules/shopping/vivino.py +++ b/src/holehe/holehe/modules/shopping/vivino.py @@ -33,21 +33,20 @@ async def vivino(email, client, out): "emailrecovery": None, "phoneNumber": None, "others": None}) + elif response.json()['error'] == "The supplied email does not exist": + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": False, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) else: - if response.json()['error'] == "The supplied email does not exist": - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": False, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": True, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/modules/social_media/bitmoji.py b/src/holehe/holehe/modules/social_media/bitmoji.py index 9282f2d..9613a7e 100644 --- a/src/holehe/holehe/modules/social_media/bitmoji.py +++ b/src/holehe/holehe/modules/social_media/bitmoji.py @@ -21,7 +21,7 @@ async def bitmoji(email, client, out): "Accept-Encoding": "gzip, late", "Content-Type": "application/json", "Connection": "close", - "Cookie": "xsrf_token=" + xsrf + "; web_client_id=" + webClientId + "Cookie": f"xsrf_token={xsrf}; web_client_id={webClientId}", } data = '{"email":' + email + ',"app":"BITMOJI_APP"}' diff --git a/src/holehe/holehe/modules/social_media/instagram.py b/src/holehe/holehe/modules/social_media/instagram.py index 31d55a2..1ee6f0d 100644 --- a/src/holehe/holehe/modules/social_media/instagram.py +++ b/src/holehe/holehe/modules/social_media/instagram.py @@ -41,32 +41,32 @@ async def instagram(email, client, out): data=data, headers=headers) check = check.json() - if check["status"] != "fail": - if 'email' in check["errors"].keys(): - if check["errors"]["email"][0]["code"] == "email_is_taken": - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - elif "email_sharing_limit" in str(check["errors"]): - out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": False, - "exists": True, - "emailrecovery": None, - "phoneNumber": None, - "others": None}) - else: + if check["status"] == "fail": + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": True, + "exists": False, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) + + elif 'email' in check["errors"].keys(): + if check["errors"]["email"][0]["code"] == "email_is_taken": out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, - "exists": False, + "exists": True, + "emailrecovery": None, + "phoneNumber": None, + "others": None}) + elif "email_sharing_limit" in str(check["errors"]): + out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, + "rateLimit": False, + "exists": True, "emailrecovery": None, "phoneNumber": None, "others": None}) else: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, - "rateLimit": True, + "rateLimit": False, "exists": False, "emailrecovery": None, "phoneNumber": None, diff --git a/src/holehe/holehe/modules/social_media/odnoklassniki.py b/src/holehe/holehe/modules/social_media/odnoklassniki.py index cbecce3..1cb6c2c 100644 --- a/src/holehe/holehe/modules/social_media/odnoklassniki.py +++ b/src/holehe/holehe/modules/social_media/odnoklassniki.py @@ -21,13 +21,12 @@ async def odnoklassniki(email, client, out): OK_LOGIN_URL = 'https://www.ok.ru/dk?st.cmd=anonymMain&st.accRecovery=on&st.error=errors.password.wrong' OK_RECOVER_URL = 'https://www.ok.ru/dk?st.cmd=anonymRecoveryAfterFailedLogin&st._aid=LeftColumn_Login_ForgotPassword' try: - await client.get(OK_LOGIN_URL + '&st.email=' + email, headers=headers) + await client.get(f'{OK_LOGIN_URL}&st.email={email}', headers=headers) request = await client.get(OK_RECOVER_URL, headers=headers) root_soup = BeautifulSoup(request.content, 'html.parser') - soup = root_soup.find( - 'div', { - 'data-l': 'registrationContainer,offer_contact_rest'}) - if soup: + if soup := root_soup.find( + 'div', {'data-l': 'registrationContainer,offer_contact_rest'} + ): account_info = soup.find( 'div', {'class': 'ext-registration_tx taCenter'}) masked_email = soup.find('button', {'data-l': 't,email'}) @@ -43,8 +42,9 @@ async def odnoklassniki(email, client, out): 'div', {'class': 'ext-registration_username_header'}) if masked_name: masked_name = masked_name.get_text() - account_info = account_info.findAll('div', {'class': 'lstp-t'}) - if account_info: + if account_info := account_info.findAll( + 'div', {'class': 'lstp-t'} + ): profile_info = account_info[0].get_text() profile_registred = account_info[1].get_text() else: diff --git a/src/holehe/holehe/modules/social_media/parler.py b/src/holehe/holehe/modules/social_media/parler.py index 4f57ece..b323abf 100644 --- a/src/holehe/holehe/modules/social_media/parler.py +++ b/src/holehe/holehe/modules/social_media/parler.py @@ -7,6 +7,7 @@ def get_random_string(length): letters = string.ascii_lowercase result_str = ''.join(random.choice(letters) for i in range(length)) return(result_str) + name = "parler" domain = "parler.com" method = "login" @@ -27,7 +28,7 @@ def get_random_string(length): 'accept-language': 'es,en-US;q=0.9,en;q=0.8', 'sec-gpc': '1', } - email = '"' + email + '"' + email = f'"{email}"' data = '{"identifier":' + email + \ ',"password":"invalidpasswordfortest","deviceId":"' + get_random_string(16) + '"}' try: diff --git a/src/holehe/holehe/modules/social_media/snapchat.py b/src/holehe/holehe/modules/social_media/snapchat.py index ce04e00..f211eb0 100644 --- a/src/holehe/holehe/modules/social_media/snapchat.py +++ b/src/holehe/holehe/modules/social_media/snapchat.py @@ -20,7 +20,7 @@ async def snapchat(email, client, out): "Accept-Encoding": "gzip, late", "Content-Type": "application/json", "Connection": "close", - "Cookie": "xsrf_token=" + xsrf + "; web_client_id=" + webClientId + "Cookie": f"xsrf_token={xsrf}; web_client_id={webClientId}", } data = '{"email":' + email + ',"app":"BITMOJI_APP"}' diff --git a/src/holehe/holehe/modules/social_media/wattpad.py b/src/holehe/holehe/modules/social_media/wattpad.py index 1fd26dd..2ab6e66 100644 --- a/src/holehe/holehe/modules/social_media/wattpad.py +++ b/src/holehe/holehe/modules/social_media/wattpad.py @@ -32,7 +32,7 @@ async def wattpad(email, client, out): 'email': email, } response = await client.get('https://www.wattpad.com/api/v3/users/validate', headers=headers, params=params) - if (response.status_code == 200 or response.status_code == 400): + if response.status_code in [200, 400]: if "Cette adresse" not in response.text or response.text == '{"message":"OK","code":200}': out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/holehe/modules/software/issuu.py b/src/holehe/holehe/modules/software/issuu.py index cc1d3c6..0ed2154 100644 --- a/src/holehe/holehe/modules/software/issuu.py +++ b/src/holehe/holehe/modules/software/issuu.py @@ -3,7 +3,6 @@ async def issuu(email, client, out): - name = "issuu" domain = "issuu.com" method = "register" frequent_rate_limit=False @@ -21,9 +20,9 @@ async def issuu(email, client, out): } response = await client.get( - 'https://issuu.com/call/signup/check-email/' + - email, - headers=headers) + f'https://issuu.com/call/signup/check-email/{email}', headers=headers + ) + name = "issuu" try: if response.json()["status"] == "unavailable": out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/holehe/holehe/modules/software/lastpass.py b/src/holehe/holehe/modules/software/lastpass.py index ba5050d..75d2c6b 100644 --- a/src/holehe/holehe/modules/software/lastpass.py +++ b/src/holehe/holehe/modules/software/lastpass.py @@ -36,7 +36,7 @@ async def lastpass(email, client, out): "emailrecovery": None, "phoneNumber": None, "others": None}) - elif response.text == "ok" or response.text == "emailinvalid": + elif response.text in ["ok", "emailinvalid"]: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, "exists": False, diff --git a/src/holehe/holehe/modules/software/office365.py b/src/holehe/holehe/modules/software/office365.py index 39cdd1d..0b2b18d 100644 --- a/src/holehe/holehe/modules/software/office365.py +++ b/src/holehe/holehe/modules/software/office365.py @@ -14,11 +14,14 @@ def get_random_string(length): letters = string.digits result_str = ''.join(random.choice(letters) for i in range(length)) return(result_str) + r = await client.get( 'https://outlook.office365.com/autodiscover/autodiscover.json/v1.0/{}?Protocol=Autodiscoverv1'.format( - get_random_string(30)+"@"+email.split('@')[1]), + f"{get_random_string(30)}@" + email.split('@')[1] + ), headers=headers, - follow_redirects=False) + follow_redirects=False, + ) if r.status_code != 200: r = await client.get( 'https://outlook.office365.com/autodiscover/autodiscover.json/v1.0/{}?Protocol=Autodiscoverv1'.format( diff --git a/src/holehe/holehe/modules/sport/bodybuilding.py b/src/holehe/holehe/modules/sport/bodybuilding.py index dcaa38a..8855588 100644 --- a/src/holehe/holehe/modules/sport/bodybuilding.py +++ b/src/holehe/holehe/modules/sport/bodybuilding.py @@ -18,7 +18,9 @@ async def bodybuilding(email, client, out): 'Referer': 'https://www.bodybuilding.com/', } - response = await client.head('https://api.bodybuilding.com/profile/email/' + email, headers=headers) + response = await client.head( + f'https://api.bodybuilding.com/profile/email/{email}', headers=headers + ) if response.status_code == 200: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": False, diff --git a/src/holehe/holehe/modules/transport/blablacar.py b/src/holehe/holehe/modules/transport/blablacar.py index f9d72b6..4d0d033 100644 --- a/src/holehe/holehe/modules/transport/blablacar.py +++ b/src/holehe/holehe/modules/transport/blablacar.py @@ -3,7 +3,6 @@ async def blablacar(email, client, out): - name = "blablacar" domain = "blablacar.com" method = "register" frequent_rate_limit=True @@ -23,6 +22,7 @@ async def blablacar(email, client, out): 'Connection': 'keep-alive', 'TE': 'Trailers', } + name = "blablacar" try: appToken = await client.get( "https://www.blablacar.fr/register", @@ -42,7 +42,7 @@ async def blablacar(email, client, out): 'datadome': '', } try: - headers["Authorization"] = 'Bearer ' + appToken + headers["Authorization"] = f'Bearer {appToken}' except Exception: out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, "rateLimit": True, @@ -53,10 +53,10 @@ async def blablacar(email, client, out): return None response = await client.get( - 'https://edge.blablacar.fr/auth/validation/email/' + - email, + f'https://edge.blablacar.fr/auth/validation/email/{email}', headers=headers, - cookies=cookies) + cookies=cookies, + ) data = response.json() if "url" in data.keys(): out.append({"name": name,"domain":domain,"method":method,"frequent_rate_limit":frequent_rate_limit, diff --git a/src/infoga/infoga.py b/src/infoga/infoga.py index bcc680b..cb07178 100644 --- a/src/infoga/infoga.py +++ b/src/infoga/infoga.py @@ -41,18 +41,16 @@ def search(self,module): if email not in self.listEmail: self.listEmail.append(email) if self.verbose in (1,2,3): - info('Found %s emails in %s'%(len(emails), - module.__class__.__name__)) + info(f'Found {len(emails)} emails in {module.__class__.__name__}') def engine(self,target,engine): engine_list = [ Ask(target),Baidu(target),Bing(target),Dogpile(target), Exalead(target),Google(target),PGP(target),Yahoo(target) ] - if engine == 'all': - for e in engine_list: self.search(e) - else: - for e in engine_list: - if e.__class__.__name__.lower() in engine:self.search(e) + for e in engine_list: + if engine == 'all': + self.search(e) + elif e.__class__.__name__.lower() in engine:self.search(e) def tester(self,email): return MailTester(email).search() @@ -73,7 +71,7 @@ def main(self): if o in ('-r','--report'):self.report= open(a,'w') if a != '' else None if o in ('-i','--info'): self.listEmail.append(checkEmail(a)) - plus('Searching for: %s'%a) + plus(f'Searching for: {a}') if o in ('-h','--help'):Banner().usage(True) ### start #### if self.domain != ('' or None): @@ -87,9 +85,9 @@ def main(self): if self.source == 'pgp':self.engine(self.domain,'pgp') if self.source == 'yahoo':self.engine(self.domain,'yahoo') - if self.listEmail == [] or self.listEmail == None: + if self.listEmail == [] or self.listEmail is None: sys.exit(warn('Not found emails... :(')) - + for email in self.listEmail: ip = self.tester(email) if ip != ([] or None): @@ -99,9 +97,10 @@ def main(self): if len(ips) >=2: info("Found multiple ip for this email...") PPrint(ips,email,self.verbose,self.breach,self.report).output() - else:more('Not found any informations for %s'%(email)) + else:else + more(f'Not found any informations for {email}') if self.report != None: - info('File saved in: '+self.report.name) + info(f'File saved in: {self.report.name}') self.report.close() # end if __name__ == "__main__": diff --git a/src/infoga/lib/check.py b/src/infoga/lib/check.py index 99f07c3..89cc146 100644 --- a/src/infoga/lib/check.py +++ b/src/infoga/lib/check.py @@ -14,16 +14,12 @@ def checkTarget(target): o = urlparse(target) if o.netloc == "": - if "www." in o.path: return o.path.split('www.')[1] - return o.path - elif o.netloc != "": - if "www." in o.netloc: return o.netloc.split("www.")[1] - return o.netloc - else: return target + return o.path.split('www.')[1] if "www." in o.path else o.path + return o.netloc.split("www.")[1] if "www." in o.netloc else o.netloc def checkEmail(email): if '@' not in email: - exit(warn('Invalid email %s'%email)) + exit(warn(f'Invalid email {email}')) return email def checkSource(source): @@ -31,7 +27,7 @@ def checkSource(source): 'dogpile','exalead','jigsaw','pgp','yahoo' ] if source not in list_source: - exit(warn('Invalid search engine: %s'%source)) + exit(warn(f'Invalid search engine: {source}')) return source def checkVerbose(ver): diff --git a/src/infoga/lib/output.py b/src/infoga/lib/output.py index a08aeec..d013299 100644 --- a/src/infoga/lib/output.py +++ b/src/infoga/lib/output.py @@ -11,11 +11,16 @@ from recon.pwned import * from recon.shodan import * -def plus(string):print("%s[+]%s %s"%(G%0,E,string)) -def warn(string):print("%s[!]%s %s"%(R%0,E,string)) -def test(string):print("%s[*]%s %s"%(B%0,E,string)) -def info(string):print("%s[i]%s %s"%(Y%0,E,string)) -def more(string):print(" %s|%s %s"%(W%0,E,string)) +def plus(string): + print(f"{G % 0}[+]{E} {string}") +def warn(string): + print(f"{R % 0}[!]{E} {string}") +def test(string): + print(f"{B % 0}[*]{E} {string}") +def info(string): + print(f"{Y % 0}[i]{E} {string}") +def more(string): + print(f" {W % 0}|{E} {string}") class PPrint(object): '''PPrint class''' diff --git a/src/infoga/recon/ask.py b/src/infoga/recon/ask.py index 439c953..cd3b27b 100644 --- a/src/infoga/recon/ask.py +++ b/src/infoga/recon/ask.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in Ask...'%(self.target)) + test(f'Searching "{self.target}" in Ask...') url = "http://www.ask.com/web?q=%40{target}&pu=100&page=0".format( target=self.target) try: diff --git a/src/infoga/recon/baidu.py b/src/infoga/recon/baidu.py index 35fe6d5..5c9ee9b 100644 --- a/src/infoga/recon/baidu.py +++ b/src/infoga/recon/baidu.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in Baidu...'%(self.target)) + test(f'Searching "{self.target}" in Baidu...') url = "http://www.baidu.com/s?wd=%40{target}&pn=0".format( target=self.target) try: diff --git a/src/infoga/recon/bing.py b/src/infoga/recon/bing.py index 8efd64f..b1369ba 100644 --- a/src/infoga/recon/bing.py +++ b/src/infoga/recon/bing.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in Bing...'%(self.target)) + test(f'Searching "{self.target}" in Bing...') url = "http://bing.com/search?q=%40{target}".format( target=self.target) try: diff --git a/src/infoga/recon/dogpile.py b/src/infoga/recon/dogpile.py index 047e129..945a36a 100644 --- a/src/infoga/recon/dogpile.py +++ b/src/infoga/recon/dogpile.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in DogPile...'%(self.target)) + test(f'Searching "{self.target}" in DogPile...') url = "http://www.dogpile.com/search/web?qsi=0&q=%40{target}".format( target=self.target) try: diff --git a/src/infoga/recon/exalead.py b/src/infoga/recon/exalead.py index 3ae6bf7..927ffd5 100644 --- a/src/infoga/recon/exalead.py +++ b/src/infoga/recon/exalead.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in Exalead...'%(self.target)) + test(f'Searching "{self.target}" in Exalead...') url = "http://www.exalead.com/search/web/results/?q=%40{target}&elements_per_page=50&start_index=0".format( target=self.target) try: diff --git a/src/infoga/recon/google.py b/src/infoga/recon/google.py index 7966f6f..d912895 100644 --- a/src/infoga/recon/google.py +++ b/src/infoga/recon/google.py @@ -15,13 +15,13 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in Google...'%(self.target)) + test(f'Searching "{self.target}" in Google...') base_url = 'https://www.google.com/search?q=intext:%22%40{target}%22&num=50'.format( target=self.target) mails = [] # First 350 results (page 0 to 6) for page in range(0, 7): - url = base_url + "&start=" + str(page) + url = f"{base_url}&start={str(page)}" try: resp = self.send( method = 'GET', diff --git a/src/infoga/recon/mailtester.py b/src/infoga/recon/mailtester.py index 884ea32..d1ac26e 100644 --- a/src/infoga/recon/mailtester.py +++ b/src/infoga/recon/mailtester.py @@ -15,8 +15,7 @@ def __init__(self,email): self.email = email def search(self): - post_data = {'lang':'en'} - post_data['email'] = self.email + post_data = {'lang': 'en', 'email': self.email} url = "http://mailtester.com/testmail.php" try: resp = self.send( diff --git a/src/infoga/recon/pgp.py b/src/infoga/recon/pgp.py index b0a5dfe..ed86606 100644 --- a/src/infoga/recon/pgp.py +++ b/src/infoga/recon/pgp.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in PGP...'%(self.target)) + test(f'Searching "{self.target}" in PGP...') url = "http://pgp.mit.edu/pks/lookup?search={target}&op=index".format( target=self.target) try: diff --git a/src/infoga/recon/pwned.py b/src/infoga/recon/pwned.py index 0f85a81..93949af 100644 --- a/src/infoga/recon/pwned.py +++ b/src/infoga/recon/pwned.py @@ -23,8 +23,6 @@ def search(self): method = 'GET', url = url ) - if resp.status_code == 200: - return loads(resp.content) - return None + return loads(resp.content) if resp.status_code == 200 else None except Exception as e: pass \ No newline at end of file diff --git a/src/infoga/recon/shodan.py b/src/infoga/recon/shodan.py index f986739..35ecffd 100644 --- a/src/infoga/recon/shodan.py +++ b/src/infoga/recon/shodan.py @@ -22,7 +22,6 @@ def search(self): method = 'GET', url = url ) - if resp.status_code != 200: return b'{}' - return resp.content + return b'{}' if resp.status_code != 200 else resp.content except Exception as e: pass diff --git a/src/infoga/recon/yahoo.py b/src/infoga/recon/yahoo.py index 8eb9b4b..3af5976 100644 --- a/src/infoga/recon/yahoo.py +++ b/src/infoga/recon/yahoo.py @@ -15,7 +15,7 @@ def __init__(self,target): self.target = target def search(self): - test('Searching "%s" in Yahoo...'%(self.target)) + test(f'Searching "{self.target}" in Yahoo...') url = "http://search.yahoo.com/search?p=%40{target}&b=0&pz=10".format( target=self.target) try: diff --git a/src/maigret/launcher.py b/src/maigret/launcher.py index dde476f..05e6e89 100644 --- a/src/maigret/launcher.py +++ b/src/maigret/launcher.py @@ -13,7 +13,7 @@ """) usr = input(f"{Fore.WHITE}🅴🅽🆃🅴🆁 🆄🆂🅴🆁🅽🅰🅼🅴 {Fore.YELLOW}⑆ {Fore.BLUE}") -os.system("python3 maigret.py " + usr) +os.system(f"python3 maigret.py {usr}") print(f""" diff --git a/src/maigret/maigret/activation.py b/src/maigret/maigret/activation.py index 9ad9d4c..3967ee4 100644 --- a/src/maigret/maigret/activation.py +++ b/src/maigret/maigret/activation.py @@ -26,7 +26,7 @@ def vimeo(site, logger, cookies={}): r = requests.get(site.activation["url"], headers=headers) jwt_token = r.json()["jwt"] - site.headers["Authorization"] = "jwt " + jwt_token + site.headers["Authorization"] = f"jwt {jwt_token}" @staticmethod def spotify(site, logger, cookies={}): diff --git a/src/maigret/maigret/checking.py b/src/maigret/maigret/checking.py index b281287..de8d21d 100644 --- a/src/maigret/maigret/checking.py +++ b/src/maigret/maigret/checking.py @@ -71,20 +71,14 @@ def __init__(self, *args, **kwargs): ) def prepare(self, url, headers=None, allow_redirects=True, timeout=0, method='get'): - if method == 'get': - request_method = self.session.get - else: - request_method = self.session.head - - future = request_method( + request_method = self.session.get if method == 'get' else self.session.head + return request_method( url=url, headers=headers, allow_redirects=allow_redirects, timeout=timeout, ) - return future - async def close(self): await self.session.close() @@ -123,8 +117,7 @@ async def check(self, future) -> Tuple[str, int, Optional[CheckError]]: except Exception as e: # python-specific exceptions if sys.version_info.minor > 6 and ( - isinstance(e, ssl.SSLCertVerificationError) - or isinstance(e, ssl.SSLError) + isinstance(e, (ssl.SSLCertVerificationError, ssl.SSLError)) ): error = CheckError("SSL", str(e)) else: @@ -204,9 +197,7 @@ def detect_error_page( if flag in html_text: return CheckError("Site-specific", msg) - # Detect common restrictions such as provider censorship and bot protection - err = errors.detect(html_text) - if err: + if err := errors.detect(html_text): return err # Detect common site errors @@ -270,7 +261,7 @@ def process_site_result( # parsing activation is_need_activation = any( - [s for s in site.activation.get("marks", []) if s in html_text] + s for s in site.activation.get("marks", []) if s in html_text ) if site.activation and html_text and is_need_activation: @@ -334,7 +325,7 @@ def build_result(status, **kwargs): elif check_type == "message": # Checks if the error message is in the HTML is_absence_detected = any( - [(absence_flag in html_text) for absence_flag in site.absence_strs] + absence_flag in html_text for absence_flag in site.absence_strs ) if not is_absence_detected and is_presense_detected: result = build_result(QueryStatus.CLAIMED) @@ -399,24 +390,21 @@ def build_result(status, **kwargs): def make_site_result( site: MaigretSite, username: str, options: QueryOptions, logger ) -> QueryResultWrapper: - results_site: QueryResultWrapper = {} - - # Record URL of main site and username - results_site["site"] = site - results_site["username"] = username - results_site["parsing_enabled"] = options["parsing"] - results_site["url_main"] = site.url_main - results_site["cookies"] = ( - options.get("cookie_jar") + results_site: QueryResultWrapper = { + "site": site, + "username": username, + "parsing_enabled": options["parsing"], + "url_main": site.url_main, + "cookies": options.get("cookie_jar") and options["cookie_jar"].filter_cookies(site.url_main) - or None - ) + or None, + } headers = { "User-Agent": get_random_user_agent(), } - headers.update(site.headers) + headers |= site.headers if "url" not in site.__dict__: logger.error("No URL for site %s", site.name) @@ -442,7 +430,6 @@ def make_site_result( QueryStatus.ILLEGAL, error=CheckError("Check is disabled"), ) - # current username type could not be applied elif site.type != options["id_type"]: results_site["status"] = QueryResult( username, @@ -451,7 +438,6 @@ def make_site_result( QueryStatus.ILLEGAL, error=CheckError('Unsupported identifier type', f'Want "{site.type}"'), ) - # username is not allowed. elif site.regex_check and re.search(site.regex_check, username) is None: results_site["status"] = QueryResult( username, @@ -496,16 +482,7 @@ def make_site_result( # not respond properly unless we request the whole page. request_method = 'get' - if site.check_type == "response_url": - # Site forwards request to a different URL if username not - # found. Disallow the redirect so we can capture the - # http status from the original URL request. - allow_redirects = False - else: - # Allow whatever redirect that the site wants to do. - # The final result of the request will be what is available. - allow_redirects = True - + allow_redirects = site.check_type != "response_url" future = checker.prepare( method=request_method, url=url_probe, @@ -664,19 +641,19 @@ async def maigret( ) # make options objects for all the requests - options: QueryOptions = {} - options["cookies"] = cookie_jar - options["checkers"] = { - '': clearweb_checker, - 'tor': tor_checker, - 'dns': dns_checker, - 'i2p': i2p_checker, + options: QueryOptions = { + "cookies": cookie_jar, + "checkers": { + '': clearweb_checker, + 'tor': tor_checker, + 'dns': dns_checker, + 'i2p': i2p_checker, + }, + "parsing": is_parsing_enabled, + "timeout": timeout, + "id_type": id_type, + "forced": forced, } - options["parsing"] = is_parsing_enabled - options["timeout"] = timeout - options["id_type"] = id_type - options["forced"] = forced - # results from analysis of all sites all_results: Dict[str, QueryResultWrapper] = {} @@ -710,7 +687,7 @@ async def maigret( # wait for executor timeout errors await asyncio.sleep(1) - all_results.update(cur_results) + all_results |= cur_results sites = get_failed_sites(dict(cur_results)) attempts -= 1 diff --git a/src/maigret/maigret/errors.py b/src/maigret/maigret/errors.py index 9ba2183..afb6e5a 100644 --- a/src/maigret/maigret/errors.py +++ b/src/maigret/maigret/errors.py @@ -95,10 +95,7 @@ def is_permanent(err_type): def detect(text): - for flag, err in COMMON_ERRORS.items(): - if flag in text: - return err - return None + return next((err for flag, err in COMMON_ERRORS.items() if flag in text), None) def solution_of(err_type) -> str: @@ -112,19 +109,16 @@ def extract_and_group(search_res: QueryResultWrapper) -> List[Dict[str, Any]]: if not isinstance(r['status'], QueryResult): continue - err = r['status'].error - if not err: - continue - errors_counts[err.type] = errors_counts.get(err.type, 0) + 1 - - counts = [] - for err, count in sorted(errors_counts.items(), key=lambda x: x[1], reverse=True): - counts.append( - { - 'err': err, - 'count': count, - 'perc': round(count / len(search_res), 2) * 100, - } + if err := r['status'].error: + errors_counts[err.type] = errors_counts.get(err.type, 0) + 1 + + return [ + { + 'err': err, + 'count': count, + 'perc': round(count / len(search_res), 2) * 100, + } + for err, count in sorted( + errors_counts.items(), key=lambda x: x[1], reverse=True ) - - return counts + ] diff --git a/src/maigret/maigret/executors.py b/src/maigret/maigret/executors.py index aed3019..0b74072 100644 --- a/src/maigret/maigret/executors.py +++ b/src/maigret/maigret/executors.py @@ -9,11 +9,9 @@ def create_task_func(): if sys.version_info.minor > 6: - create_asyncio_task = asyncio.create_task - else: - loop = asyncio.get_event_loop() - create_asyncio_task = loop.create_task - return create_asyncio_task + return asyncio.create_task + loop = asyncio.get_event_loop() + return loop.create_task class AsyncExecutor: diff --git a/src/maigret/maigret/maigret.py b/src/maigret/maigret/maigret.py index 17700d4..a0c9188 100644 --- a/src/maigret/maigret/maigret.py +++ b/src/maigret/maigret/maigret.py @@ -49,8 +49,7 @@ def notify_about_errors(search_results: QueryResultWrapper, query_notify): if not errors.is_important(e): continue text = f'Too many errors of type "{e["err"]}" ({round(e["perc"],2)}%)' - solution = errors.solution_of(e['err']) - if solution: + if solution := errors.solution_of(e['err']): text = '. '.join([text, solution.capitalize()]) query_notify.warning(text, '!') @@ -101,13 +100,12 @@ def extract_ids_from_results(results: QueryResultWrapper, db: MaigretDatabase) - if not dictionary: continue - new_usernames = dictionary.get('ids_usernames') - if new_usernames: + if new_usernames := dictionary.get('ids_usernames'): for u, utype in new_usernames.items(): ids_results[u] = utype for url in dictionary.get('ids_links', []): - ids_results.update(db.extract_ids_from_url(url)) + ids_results |= db.extract_ids_from_url(url) return ids_results @@ -498,13 +496,13 @@ async def main(): # Make prompts if args.proxy is not None: - print("Using the proxy: " + args.proxy) + print(f"Using the proxy: {args.proxy}") if args.parse_url: extracted_ids = extract_ids_from_page( args.parse_url, logger, timeout=args.timeout ) - usernames.update(extracted_ids) + usernames |= extracted_ids if args.tags: args.tags = list(set(str(args.tags).split(','))) @@ -562,7 +560,7 @@ async def main(): print('Database was successfully updated.') else: print('Updates will be applied only for current search session.') - print('Scan sessions flags stats: ' + str(db.get_scan_stats(site_data))) + print(f'Scan sessions flags stats: {str(db.get_scan_stats(site_data))}') # Database statistics if args.stats: @@ -576,7 +574,7 @@ async def main(): # Define one report filename template report_filepath_tpl = path.join(report_dir, 'report_{username}{postfix}') - if usernames == {}: + if not usernames: # magic params to exit after init query_notify.warning('No usernames to check, exiting.') sys.exit(0) @@ -611,9 +609,9 @@ async def main(): ) continue - # check for characters do not supported by sites generally - found_unsupported_chars = set(BAD_CHARS).intersection(set(username)) - if found_unsupported_chars: + if found_unsupported_chars := set(BAD_CHARS).intersection( + set(username) + ): pretty_chars_str = ','.join( map(lambda s: f'"{s}"', found_unsupported_chars) ) @@ -708,8 +706,7 @@ async def main(): save_graph_report(filename, general_results, db) query_notify.warning(f'Graph report on all usernames saved in {filename}') - text_report = get_plaintext_report(report_context) - if text_report: + if text_report := get_plaintext_report(report_context): query_notify.info('Short text report:') print(text_report) diff --git a/src/maigret/maigret/notify.py b/src/maigret/maigret/notify.py index be86946..98d48c0 100644 --- a/src/maigret/maigret/notify.py +++ b/src/maigret/maigret/notify.py @@ -257,7 +257,7 @@ def update(self, result, is_similar=False): result.site_name, Fore.RED, Fore.YELLOW, - "Not found!" + ids_data_text, + f"Not found!{ids_data_text}", ) elif result.status == QueryStatus.UNKNOWN: if not self.skip_check_errors: diff --git a/src/maigret/maigret/report.py b/src/maigret/maigret/report.py index b747839..23cc833 100644 --- a/src/maigret/maigret/report.py +++ b/src/maigret/maigret/report.py @@ -29,12 +29,11 @@ def filter_supposed_data(data): # interesting fields allowed_fields = ["fullname", "gender", "location", "age"] - filtered_supposed_data = { + return { CaseConverter.snake_to_title(k): v[0] for k, v in data.items() if k in allowed_fields } - return filtered_supposed_data def sort_report_by_data_points(results): @@ -215,8 +214,9 @@ def process_ids(parent_node, ids): def get_plaintext_report(context: dict) -> str: output = (context['brief'] + " ").replace('. ', '.\n') interests = list(map(lambda x: x[0], context.get('interests_tuple_list', []))) - countries = list(map(lambda x: x[0], context.get('countries_tuple_list', []))) - if countries: + if countries := list( + map(lambda x: x[0], context.get('countries_tuple_list', [])) + ): output += f'Countries: {", ".join(countries)}\n' if interests: output += f'Interests (tags): {", ".join(interests)}\n' @@ -285,9 +285,7 @@ def generate_report_context(username_results: list): dictionary["ids_data"] = status.ids_data extended_info_count += 1 - # detect first seen - created_at = status.ids_data.get("created_at") - if created_at: + if created_at := status.ids_data.get("created_at"): if first_seen is None: first_seen = created_at else: @@ -326,19 +324,17 @@ def generate_report_context(username_results: list): "Pycountry exception: %s", str(e), exc_info=True ) - new_usernames = dictionary.get("ids_usernames") - if new_usernames: + if new_usernames := dictionary.get("ids_usernames"): for u, utype in new_usernames.items(): if u not in usernames: new_ids.append((u, utype)) usernames[u] = {"type": utype} - if status.status == QueryStatus.CLAIMED: - found_accounts += 1 - dictionary["found"] = True - else: + if status.status != QueryStatus.CLAIMED: continue + found_accounts += 1 + dictionary["found"] = True # ignore non-exact search results if status.tags: for t in status.tags: @@ -349,9 +345,7 @@ def generate_report_context(username_results: list): ) if new_ids: - ids_list = [] - for u, t in new_ids: - ids_list.append(f"{u} ({t})" if t != "username" else u) + ids_list = [f"{u} ({t})" if t != "username" else u for u, t in new_ids] brief_text.append("Found target's other IDs: " + ", ".join(ids_list) + ".") brief_text.append(f"Extended info extracted from {extended_info_count} accounts.") @@ -406,8 +400,7 @@ def generate_csv_report(username: str, results: dict, csvfile): def generate_txt_report(username: str, results: dict, file): exists_counter = 0 - for website_name in results: - dictionary = results[website_name] + for website_name, dictionary in results.items(): # TODO: fix no site data issue if not dictionary: continue @@ -424,8 +417,7 @@ def generate_json_report(username: str, results: dict, file, report_type): is_report_per_line = report_type.startswith("ndjson") all_json = {} - for sitename in results: - site_result = results[sitename] + for sitename, site_result in results.items(): # TODO: fix no site data issue if not site_result or not site_result.get("status"): continue @@ -470,21 +462,19 @@ def add_xmind_subtopic(userlink, k, v, supposed_data): if field not in supposed_data: supposed_data[field] = [] supposed_data[field].append(v) - currentsublabel.setTitle("%s: %s" % (k, v)) + currentsublabel.setTitle(f"{k}: {v}") def design_xmind_sheet(sheet, username, results): - alltags = {} supposed_data = {} - sheet.setTitle("%s Analysis" % (username)) + sheet.setTitle(f"{username} Analysis") root_topic1 = sheet.getRootTopic() - root_topic1.setTitle("%s" % (username)) + root_topic1.setTitle(f"{username}") undefinedsection = root_topic1.addSubTopic() undefinedsection.setTitle("Undefined") - alltags["undefined"] = undefinedsection - + alltags = {"undefined": undefinedsection} for website_name in results: dictionary = results[website_name] if not dictionary: @@ -501,7 +491,7 @@ def design_xmind_sheet(sheet, username, results): category = None for tag in normalized_tags: - if tag in alltags.keys(): + if tag in alltags: continue tagsection = root_topic1.addSubTopic() tagsection.setTitle(tag) @@ -528,4 +518,4 @@ def design_xmind_sheet(sheet, username, results): undefinedsection.setTitle("SUPPOSED DATA") for k, v in filtered_supposed_data.items(): currentsublabel = undefinedsection.addSubTopic() - currentsublabel.setTitle("%s: %s" % (k, v)) + currentsublabel.setTitle(f"{k}: {v}") diff --git a/src/maigret/maigret/sites.py b/src/maigret/maigret/sites.py index c073fe7..dbc8095 100644 --- a/src/maigret/maigret/sites.py +++ b/src/maigret/maigret/sites.py @@ -94,8 +94,7 @@ def update_detectors(self): def detect_username(self, url: str) -> Optional[str]: if self.url_regexp: - match_groups = self.url_regexp.match(url) - if match_groups: + if match_groups := self.url_regexp.match(url): return match_groups.groups()[-1].rstrip("/") return None @@ -115,9 +114,7 @@ def extract_id_from_url(self, url: str) -> Optional[Tuple[str, str]]: @property def pretty_name(self): - if self.source: - return f"{self.name} [{self.source}]" - return self.name + return f"{self.name} [{self.source}]" if self.source else self.name @property def json(self): @@ -138,7 +135,7 @@ def json(self): def errors_dict(self) -> dict: errors: Dict[str, str] = {} if self.engine_obj: - errors.update(self.engine_obj.site.get('errors', {})) + errors |= self.engine_obj.site.get('errors', {}) errors.update(self.errors) return errors @@ -321,8 +318,7 @@ def load_from_json(self, json_data: dict) -> "MaigretDatabase": try: maigret_site = MaigretSite(site_name, site_data[site_name]) - engine = site_data[site_name].get("engine") - if engine: + if engine := site_data[site_name].get("engine"): maigret_site.update_from_engine(self.engines_dict[engine]) self._sites.append(maigret_site) @@ -368,18 +364,17 @@ def load_from_http(self, url: str) -> "MaigretDatabase": f"{str(error)}" ) - if response.status_code == 200: - try: - data = response.json() - except Exception as error: - raise ValueError( - f"Problem parsing json contents at " f"'{url}': {str(error)}." - ) - else: + if response.status_code != 200: raise FileNotFoundError( f"Bad response while accessing " f"data file URL '{url}'." ) + try: + data = response.json() + except Exception as error: + raise ValueError( + f"Problem parsing json contents at " f"'{url}': {str(error)}." + ) return self.load_from_json(data) def load_from_file(self, filename: "str") -> "MaigretDatabase": diff --git a/src/maigret/maigret/submit.py b/src/maigret/maigret/submit.py index 511591f..cd6476c 100644 --- a/src/maigret/maigret/submit.py +++ b/src/maigret/maigret/submit.py @@ -136,8 +136,7 @@ def generate_additional_fields_dialog(self, engine: MaigretEngine, dialog): 'Detected engine suppose additional URL subpath using (/forum/, /blog/, etc). ' 'Enter in manually if it exists: ' ) - subpath = input(msg).strip('/') - if subpath: + if subpath := input(msg).strip('/'): fields['urlSubpath'] = f'/{subpath}' return fields @@ -155,25 +154,23 @@ async def detect_known_engine(self, url_exists, url_mainpage) -> List[MaigretSit for engine in self.db.engines: strs_to_check = engine.__dict__.get("presenseStrs") if strs_to_check and resp_text: - all_strs_in_response = True - for s in strs_to_check: - if s not in resp_text: - all_strs_in_response = False - sites = [] + all_strs_in_response = all(s in resp_text for s in strs_to_check) if all_strs_in_response: engine_name = engine.__dict__.get("name") print(f"Detected engine {engine_name} for site {url_mainpage}") usernames_to_check = self.settings.supposed_usernames - supposed_username = self.extract_username_dialog(url_exists) - if supposed_username: + if supposed_username := self.extract_username_dialog( + url_exists + ): usernames_to_check = [supposed_username] + usernames_to_check add_fields = self.generate_additional_fields_dialog( engine, url_exists ) + sites = [] for u in usernames_to_check: site_data = { "urlMain": url_mainpage, @@ -224,9 +221,7 @@ async def check_features_manually( url_user = url_exists.replace(supposed_username, "{username}") url_not_exists = url_exists.replace(supposed_username, non_exist_username) - headers = dict(self.HEADERS) - headers.update(custom_headers) - + headers = dict(self.HEADERS) | custom_headers exists_resp = await self.session.get( url_exists, headers=headers, @@ -273,9 +268,9 @@ async def check_features_manually( ] print("Detected text features of existing account: " + ", ".join(presence_list)) - features = input("If features was not detected correctly, write it manually: ") - - if features: + if features := input( + "If features was not detected correctly, write it manually: " + ): presence_list = list(map(str.strip, features.split(","))) absence_list = sorted(b_minus_a, key=match_fun, reverse=True)[ @@ -284,9 +279,9 @@ async def check_features_manually( print( "Detected text features of non-existing account: " + ", ".join(absence_list) ) - features = input("If features was not detected correctly, write it manually: ") - - if features: + if features := input( + "If features was not detected correctly, write it manually: " + ): absence_list = list(map(str.strip, features.split(","))) site_data = { @@ -302,20 +297,16 @@ async def check_features_manually( if headers != self.HEADERS: site_data['headers'] = headers - site = MaigretSite(url_mainpage.split("/")[-1], site_data) - return site + return MaigretSite(url_mainpage.split("/")[-1], site_data) async def dialog(self, url_exists, cookie_file): domain_raw = self.URL_RE.sub("", url_exists).strip().strip("/") domain_raw = domain_raw.split("/")[0] self.logger.info('Domain is %s', domain_raw) - # check for existence - matched_sites = list( + if matched_sites := list( filter(lambda x: domain_raw in x.url_main + x.url, self.db.sites) - ) - - if matched_sites: + ): print( f'Sites with domain "{domain_raw}" already exists in the Maigret database!' ) @@ -389,14 +380,12 @@ async def dialog(self, url_exists, cookie_file): return False if self.args.verbose: - source = input("Name the source site if it is mirror: ") - if source: + if source := input("Name the source site if it is mirror: "): chosen_site.source = source chosen_site.name = input("Change site name if you want: ") or chosen_site.name chosen_site.tags = list(map(str.strip, input("Site tags: ").split(','))) - rank = Submitter.get_alexa_rank(chosen_site.url_main) - if rank: + if rank := Submitter.get_alexa_rank(chosen_site.url_main): print(f'New alexa rank: {rank}') chosen_site.alexa_rank = rank diff --git a/src/maigret/maigret/utils.py b/src/maigret/maigret/utils.py index 8367c55..02a61bd 100644 --- a/src/maigret/maigret/utils.py +++ b/src/maigret/maigret/utils.py @@ -19,8 +19,7 @@ def camel_to_snake(camelcased_string: str) -> str: @staticmethod def snake_to_camel(snakecased_string: str) -> str: formatted = "".join(word.title() for word in snakecased_string.split("_")) - result = formatted[0].lower() + formatted[1:] - return result + return formatted[0].lower() + formatted[1:] @staticmethod def snake_to_title(snakecased_string: str) -> str: @@ -47,24 +46,21 @@ class URLMatcher: UNSAFE_SYMBOLS = ".?" @classmethod - def extract_main_part(self, url: str) -> str: - match = self.HTTP_URL_RE.search(url) - if match and match.group(2): - return match.group(2).rstrip("/") - - return "" + def extract_main_part(cls, url: str) -> str: + match = cls.HTTP_URL_RE.search(url) + return match.group(2).rstrip("/") if match and match.group(2) else "" @classmethod - def make_profile_url_regexp(self, url: str, username_regexp: str = ""): - url_main_part = self.extract_main_part(url) - for c in self.UNSAFE_SYMBOLS: + def make_profile_url_regexp(cls, url: str, username_regexp: str = ""): + url_main_part = cls.extract_main_part(url) + for c in cls.UNSAFE_SYMBOLS: url_main_part = url_main_part.replace(c, f"\\{c}") prepared_username_regexp = (username_regexp or ".+?").lstrip('^').rstrip('$') url_regexp = url_main_part.replace( "{username}", f"({prepared_username_regexp})" ) - regexp_str = self._HTTP_URL_RE_STR.replace("(.+)", url_regexp) + regexp_str = cls._HTTP_URL_RE_STR.replace("(.+)", url_regexp) return re.compile(regexp_str, re.IGNORECASE) @@ -110,10 +106,8 @@ def get_match_ratio(base_strs: list): def get_match_inner(s: str): return round( max( - [ - difflib.SequenceMatcher(a=s.lower(), b=s2.lower()).ratio() - for s2 in base_strs - ] + difflib.SequenceMatcher(a=s.lower(), b=s2.lower()).ratio() + for s2 in base_strs ), 2, ) diff --git a/src/maigret/tests/test_cli.py b/src/maigret/tests/test_cli.py index 8d677f1..13ba59f 100644 --- a/src/maigret/tests/test_cli.py +++ b/src/maigret/tests/test_cli.py @@ -51,7 +51,7 @@ def test_args_search_mode(argparser): assert args.username == ['username'] want_args = dict(DEFAULT_ARGS) - want_args.update({'username': ['username']}) + want_args['username'] = ['username'] assert args == Namespace(**want_args) @@ -62,7 +62,7 @@ def test_args_search_mode_several_usernames(argparser): assert args.username == ['username1', 'username2'] want_args = dict(DEFAULT_ARGS) - want_args.update({'username': ['username1', 'username2']}) + want_args['username'] = ['username1', 'username2'] assert args == Namespace(**want_args) @@ -70,15 +70,11 @@ def test_args_search_mode_several_usernames(argparser): def test_args_self_check_mode(argparser): args = argparser.parse_args('--self-check --site GitHub'.split()) - want_args = dict(DEFAULT_ARGS) - want_args.update( - { - 'self_check': True, - 'site_list': ['GitHub'], - 'username': [], - } - ) - + want_args = dict(DEFAULT_ARGS) | { + 'self_check': True, + 'site_list': ['GitHub'], + 'username': [], + } assert args == Namespace(**want_args) @@ -87,12 +83,8 @@ def test_args_multiple_sites(argparser): '--site GitHub VK --site PornHub --site Taringa,Steam'.split() ) - want_args = dict(DEFAULT_ARGS) - want_args.update( - { - 'site_list': ['GitHub', 'PornHub', 'Taringa,Steam'], - 'username': ['VK'], - } - ) - + want_args = dict(DEFAULT_ARGS) | { + 'site_list': ['GitHub', 'PornHub', 'Taringa,Steam'], + 'username': ['VK'], + } assert args == Namespace(**want_args) diff --git a/src/maigret/tests/test_data.py b/src/maigret/tests/test_data.py index 538aacf..48c01c9 100644 --- a/src/maigret/tests/test_data.py +++ b/src/maigret/tests/test_data.py @@ -13,4 +13,4 @@ def test_tags_validity(default_db): if tag not in tags: unknown_tags.add(tag) - assert unknown_tags == set() + assert not unknown_tags diff --git a/src/maigret/tests/test_maigret.py b/src/maigret/tests/test_maigret.py index 06ab4bc..33e745b 100644 --- a/src/maigret/tests/test_maigret.py +++ b/src/maigret/tests/test_maigret.py @@ -54,14 +54,14 @@ def test_self_check_db_positive_enable(test_db): test_db.sites[0].disabled = True test_db.sites[0].username_claimed = 'Skyeng' - assert test_db.sites[0].disabled is True + assert test_db.sites[0].disabled loop = asyncio.get_event_loop() loop.run_until_complete( self_check(test_db, test_db.sites_dict, logger, silent=True) ) - assert test_db.sites[0].disabled is False + assert not test_db.sites[0].disabled @pytest.mark.slow @@ -69,14 +69,14 @@ def test_self_check_db_negative_disabled(test_db): logger = Mock() test_db.sites[0].disabled = True - assert test_db.sites[0].disabled is True + assert test_db.sites[0].disabled loop = asyncio.get_event_loop() loop.run_until_complete( self_check(test_db, test_db.sites_dict, logger, silent=True) ) - assert test_db.sites[0].disabled is True + assert test_db.sites[0].disabled @pytest.mark.skip(reason='broken, fixme') @@ -86,14 +86,14 @@ def test_self_check_db_negative_enabled(test_db): test_db.sites[0].disabled = False test_db.sites[0].username_claimed = 'Skyeng' - assert test_db.sites[0].disabled is False + assert not test_db.sites[0].disabled loop = asyncio.get_event_loop() loop.run_until_complete( self_check(test_db, test_db.sites_dict, logger, silent=True) ) - assert test_db.sites[0].disabled is False + assert not test_db.sites[0].disabled @pytest.mark.slow diff --git a/src/maigret/tests/test_report.py b/src/maigret/tests/test_report.py index c7a9eb2..b5f0072 100644 --- a/src/maigret/tests/test_report.py +++ b/src/maigret/tests/test_report.py @@ -348,7 +348,7 @@ def test_generate_json_simple_report_broken(): data = jsonfile.readlines() assert len(data) == 1 - assert list(json.loads(data[0]).keys()) == [] + assert not list(json.loads(data[0]).keys()) def test_generate_json_ndjson_report(): diff --git a/src/maigret/tests/test_sites.py b/src/maigret/tests/test_sites.py index f0a4092..f50d803 100644 --- a/src/maigret/tests/test_sites.py +++ b/src/maigret/tests/test_sites.py @@ -143,8 +143,8 @@ def test_ranked_sites_dict(): # disjunction assert list(db.ranked_sites_dict(names=['2'], tags=['forum']).keys()) == ['2'] - assert list(db.ranked_sites_dict(names=['2'], tags=['ucoz']).keys()) == [] - assert list(db.ranked_sites_dict(names=['4'], tags=['ru']).keys()) == [] + assert not list(db.ranked_sites_dict(names=['2'], tags=['ucoz']).keys()) + assert not list(db.ranked_sites_dict(names=['4'], tags=['ru']).keys()) # reverse assert list(db.ranked_sites_dict(reverse=True).keys()) == ['3', '2', '1'] diff --git a/src/maigret/tests/test_utils.py b/src/maigret/tests/test_utils.py index 171cce7..fa43d93 100644 --- a/src/maigret/tests/test_utils.py +++ b/src/maigret/tests/test_utils.py @@ -79,7 +79,7 @@ def test_url_extract_main_part(): url = ''.join(url_parts) # ensure all combinations give valid main part assert URLMatcher.extract_main_part(url) == url_main_part - assert not url_regexp.match(url) is None + assert url_regexp.match(url) is not None def test_url_make_profile_url_regexp(): diff --git a/src/maigret/utils/add_tags.py b/src/maigret/utils/add_tags.py index b92d7c5..ea939a8 100644 --- a/src/maigret/utils/add_tags.py +++ b/src/maigret/utils/add_tags.py @@ -22,8 +22,7 @@ def update_tags(site): site.disabled = True print(f'Old alexa rank: {site.alexa_rank}') - rank = get_alexa_rank(site.url_main) - if rank: + if rank := get_alexa_rank(site.url_main): print(f'New alexa rank: {rank}') site.alexa_rank = rank @@ -37,7 +36,7 @@ def update_tags(site): dest="base_file", default="maigret/resources/data.json", help="JSON file with sites data to update.") - pool = list() + pool = [] args = parser.parse_args() @@ -49,7 +48,7 @@ def update_tags(site): if site.engine == 'uCoz': continue - if not 'in' in site.tags: + if 'in' not in site.tags: continue update_tags(site) diff --git a/src/maigret/utils/import_sites.py b/src/maigret/utils/import_sites.py index 5ed2346..d7af1b5 100644 --- a/src/maigret/utils/import_sites.py +++ b/src/maigret/utils/import_sites.py @@ -43,12 +43,9 @@ async def maigret_check(site, site_data, username, status, logger): if status == QueryStatus.CLAIMED: logger.debug(f'Not found {username} in {site}, must be claimed') - logger.debug(results[site]) - pass else: logger.debug(f'Found {username} in {site}, must be available') - logger.debug(results[site]) - pass + logger.debug(results[site]) return False return site_data diff --git a/src/maigret/utils/sites_diff.py b/src/maigret/utils/sites_diff.py index 32a69f8..525361e 100644 --- a/src/maigret/utils/sites_diff.py +++ b/src/maigret/utils/sites_diff.py @@ -24,10 +24,13 @@ def get_match_ratio(x): - return round(max([ - difflib.SequenceMatcher(a=x.lower(), b=y).ratio() - for y in desired_strings - ]), 2) + return round( + max( + difflib.SequenceMatcher(a=x.lower(), b=y).ratio() + for y in desired_strings + ), + 2, + ) RATIO = 0.6 diff --git a/src/maigret/utils/update_site_data.py b/src/maigret/utils/update_site_data.py index f197475..89bf785 100644 --- a/src/maigret/utils/update_site_data.py +++ b/src/maigret/utils/update_site_data.py @@ -3,6 +3,7 @@ This module generates the listing of supported sites in file `SITES.md` and pretty prints file with sites data. """ + import json import sys import requests @@ -14,8 +15,9 @@ from maigret.maigret import MaigretDatabase -RANKS = {str(i):str(i) for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100, 500]} -RANKS.update({ +RANKS = { + str(i): str(i) for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100, 500] +} | { '1000': '1K', '5000': '5K', '10000': '10K', @@ -23,8 +25,7 @@ '10000000': '10M', '50000000': '50M', '100000000': '100M', -}) - +} SEMAPHORE = threading.Semaphore(20) def get_rank(domain_to_query, site, print_errors=True): @@ -61,7 +62,7 @@ def get_readable_rank(r): return RANKS[str(r)] valid_step_ranks = sorted(map(int, RANKS.keys())) - if rank == 0 or rank == sys.maxsize: + if rank in [0, sys.maxsize]: return get_readable_rank(valid_step_ranks[-1]) else: return get_readable_rank(list(filter(lambda x: x >= rank, valid_step_ranks))[0]) @@ -79,7 +80,7 @@ def get_readable_rank(r): parser.add_argument('--exclude-engine', help='do not update score with certain engine', action="append", dest="exclude_engine_list", default=[]) - pool = list() + pool = [] args = parser.parse_args()