|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +# From jesuiscamille, and a part of the AutoSQLi project |
| 4 | +# Not the best piece of code I ever made, but do the job pretty well |
| 5 | +# I should do some adjustement on the ddgr and googler path thing |
| 6 | +# you should see a dorkoutput.txt file sitting on your $(pwd) after running this :) |
| 7 | +import subprocess |
| 8 | +import json |
| 9 | +import time |
| 10 | + |
| 11 | +# here is the path thing |
| 12 | +ddgr_path = "ddgr/ddgr" |
| 13 | +googler_path = "googler/googler" |
| 14 | + |
| 15 | +def main(): |
| 16 | + filename = input("Enter your dork file name: ") |
| 17 | + print("Reading " + filename + " ...") |
| 18 | + # filename = "testdorks.txt" |
| 19 | + dorkFromFile(filename) |
| 20 | + |
| 21 | +def dorkFromFile(filename): |
| 22 | + f = open(filename, 'r') |
| 23 | + lines = f.readlines() # read all the lines of the file into 'lines' |
| 24 | + f.close() |
| 25 | + dorkLines(lines) |
| 26 | + |
| 27 | +def dorkLines(lines): |
| 28 | + # remove annoying trailing characters |
| 29 | + google_ban = False |
| 30 | + duck_ban = False |
| 31 | + |
| 32 | + index = 0 |
| 33 | + for i in lines: |
| 34 | + lines[index] = lines[index].rstrip() |
| 35 | + index += 1 |
| 36 | + |
| 37 | + results = [] |
| 38 | + # dorking ! |
| 39 | + for dork in lines: |
| 40 | + if google_ban == True and duck_ban == True: |
| 41 | + break |
| 42 | + |
| 43 | + print(" |__ dork: " + dork) |
| 44 | + # dorking with google and writing to file |
| 45 | + if not google_ban: |
| 46 | + print(" |__ googly dorking...") |
| 47 | + result = googleSearch(dork) |
| 48 | + try: |
| 49 | + result_clean = json.loads(result) |
| 50 | + except: |
| 51 | + google_ban = True |
| 52 | + print("Google banned us, but don't worry, it's temporary") |
| 53 | + for x in result_clean: |
| 54 | + url = x['url'] |
| 55 | + writeToFile(url) |
| 56 | + results.append(url) |
| 57 | + |
| 58 | + if not duck_ban: |
| 59 | + print(" |__ ducky dorking...") |
| 60 | + result = duckSearch(dork) |
| 61 | + try: |
| 62 | + result_clean = json.loads(result) |
| 63 | + except: |
| 64 | + duck_ban = True |
| 65 | + print("DuckduckGo banned us, but don't worry, it's temporary") |
| 66 | + |
| 67 | + for x in result_clean: |
| 68 | + url = x['url'] |
| 69 | + writeToFile(url) |
| 70 | + results.append(url) |
| 71 | + |
| 72 | + # waiting 15 seconds to not get caught |
| 73 | + print(" -- waiting 15 seconds --") |
| 74 | + time.sleep(15) |
| 75 | + |
| 76 | + print("check out ./dorkoutput.txt :3") |
| 77 | + print("Thx 4 d0rk1ng ! Have fun") |
| 78 | + return results |
| 79 | + |
| 80 | + |
| 81 | +def execute(command): |
| 82 | + """ command shall be an array """ |
| 83 | + """ returns the stdout of command """ |
| 84 | + result = subprocess.run(command, stdout=subprocess.PIPE) |
| 85 | + return result.stdout.decode('utf-8') |
| 86 | + |
| 87 | +def googleSearch(dork): |
| 88 | + """ dork shall be a string which contains... a dork. """ |
| 89 | + """ returns the google json response for the specified dork """ |
| 90 | + return execute([googler_path, "-n", "100", dork, "--noprompt", "--json"]) |
| 91 | + |
| 92 | +def duckSearch(dork): |
| 93 | + """ dork shall be a string which contains... a dork. """ |
| 94 | + """ returns the duckduckgo json response for the specified dork """ |
| 95 | + return execute([ddgr_path, dork, "--unsafe", "--json", "--np", "--num", "25"]) |
| 96 | + |
| 97 | +def writeToFile(text): |
| 98 | + """ write text to dorkoutput.txt """ |
| 99 | + output = open("dorkoutput.txt", 'a') |
| 100 | + output.write(text) |
| 101 | + output.write('\n') |
| 102 | + output.close() |
| 103 | + |
| 104 | +if __name__ == "__main__": |
| 105 | + main() |
0 commit comments