-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub.py
51 lines (43 loc) · 1.82 KB
/
github.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
""" Quick Script for Github search on subdomains """
import time
import argparse
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
class SubGitter:
""" Run Github Search on Subdomains headless or opening actual browser """
def __init__(self, file):
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
self.browser = webdriver.Chrome(options=options)
self.file = file
def github_search(self):
""" Perform Github Search """
email = "<[email protected]>"
password = "<password>"
self.browser.get("https://github.com/login")
element = self.browser.find_element_by_id("login_field")
element.send_keys(email)
element1 = self.browser.find_element_by_id("password")
element1.send_keys(password)
self.browser.find_element_by_xpath('//*[@id="login"]/form/div[4]/input[9]').click()
f = open("subdomains.txt", "r")
for i in f:
url = "https://github.com/search?q=%%22%s%%22&type=Code" %(i.split()[0])
self.browser.get(url)
time.sleep(2)
try:
res = (self.browser.find_element_by_xpath\
('//*[@id="js-pjax-container"]/div/div[2]/nav[1]/a[2]/span')\
.text.split('\n')[0])
if res != 0:
print("%s for %s" %(res, i), end='')
except:
time.sleep(10)
f.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=\
'Quick script to find github code searches for each subdomain')
parser.add_argument('-f', '--file', required=True, help='the file consisting of subdomains')
args = parser.parse_args()
SubGitter(args.file).github_search()