forked from dvopsway/datasploit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_searcher.py
64 lines (54 loc) · 1.57 KB
/
git_searcher.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
52
53
54
55
56
57
58
59
60
61
62
import requests
import sys
import config as cfg
import json
import time
'''
Code is not working as of now, need some modifications.
'''
username = sys.argv[1]
access_token = cfg.github_access_token
print username
def find_repos(username):
print "\t\t\t[+]Finding repos for %s" % (username)
list_repos = []
url = "https://api.github.com/users/%s/repos?access_token=%s" % (username, access_token)
req = requests.get(url)
for repos in json.loads(req.content):
repos['full_name']
if repos['fork'] == False:
list_repos.append(repos['full_name'])
return list_repos
def find_commits(repo_name):
print "\t\t\t[+]Finding commits for %s..." % (repo_name)
list_commits = []
for x in xrange(1,10):
url = "https://api.github.com/repos/%s/commits?page=%s&access_token=%s" % (repo_name, x, access_token)
req = requests.get(url)
data = json.loads(req.content)
for commits in data:
try:
list_commits.append(commits['sha'])
except:
print "Empty Repo"
if (len(data) != 30):
return list_commits
else:
print "[+]..Heading to next page..."
return list_commits
print "Too many commits, search manually."
master_dict = {}
list_repos = find_repos(username)
print "Following repos found :"
print list_repos
print "\n-----------------------------\n"
for repo_name in list_repos:
master_dict[repo_name] = find_commits(repo_name)
print "\n-----------------------------\n"
print "Done. Printing master list. {Repo:[commit1,commit2]}.."
#finding commits from list
for abc in master_dict.keys():
print "Commits for %s:" % (abc)
for xyz in master_dict[abc]:
print xyz
print "\n"