|
11 | 11 | gh_user = os.getenv('GH_USER', None) |
12 | 12 | gh_pass = os.getenv('GH_PWD', None) |
13 | 13 | gh_token = os.getenv('GH_TOKEN', None) |
14 | | -gh_dorks_file = "github-dorks.txt" |
15 | 14 |
|
16 | 15 | gh = github.GitHub(username=gh_user, password=gh_pass, token=gh_token) |
17 | 16 |
|
18 | 17 |
|
19 | | -def search(repo_to_search=None, user_to_search=None): |
| 18 | +def search(repo_to_search=None, user_to_search=None, gh_dorks_file=None): |
| 19 | + if gh_dorks_file is None: |
| 20 | + gh_dorks_file = 'github-dorks.txt' |
| 21 | + if not os.path.isfile(gh_dorks_file): |
| 22 | + raise Exception('Error, the dorks file path is not valid') |
| 23 | + |
20 | 24 | found = False |
21 | 25 | with open(gh_dorks_file, 'r') as dork_file: |
22 | 26 | for dork in dork_file: |
23 | 27 | dork = dork.strip() |
| 28 | + if not dork or dork[0] in '#;': |
| 29 | + continue |
24 | 30 | addendum = '' |
25 | 31 | if repo_to_search is not None: |
26 | 32 | addendum = ' repo:' + repo_to_search |
@@ -88,10 +94,19 @@ def main(): |
88 | 94 | help='Github repo to search within. Eg: techgaun/github-dorks' |
89 | 95 | ) |
90 | 96 |
|
| 97 | + parser.add_argument( |
| 98 | + '-d', |
| 99 | + '--dork', |
| 100 | + dest='gh_dorks_file', |
| 101 | + action='store', |
| 102 | + help='Github dorks file. Eg: github-dorks.txt' |
| 103 | + ) |
| 104 | + |
91 | 105 | args = parser.parse_args() |
92 | 106 | search( |
93 | 107 | repo_to_search=args.repo_to_search, |
94 | | - user_to_search=args.user_to_search |
| 108 | + user_to_search=args.user_to_search, |
| 109 | + gh_dorks_file=args.gh_dorks_file |
95 | 110 | ) |
96 | 111 |
|
97 | 112 | if __name__ == '__main__': |
|
0 commit comments