-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgitgrab.py
More file actions
96 lines (81 loc) · 2.74 KB
/
gitgrab.py
File metadata and controls
96 lines (81 loc) · 2.74 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# Git Grab 2018
#
# Henry Samuelson, Christopher Hansen
# Git got grabbed
import os, pygithub3
import requests
gh = None
def gather_clone_urls(organization, no_forks=True):
all_repos = gh.repos.list(user=organization).all()
return all_repos
def fullSearch(userName, usrSearch):
# First get repo list
repoList = gather_clone_urls(userName)
for repo in repoList:
# Make os call to run bash script
repo = str(repo)
repoName = repo[repo.find("(")+1:repo.find(")")]
individualSearch(userName, repoName, usrSearch)
def individualSearch(userName, repoName, usrSearch):
command = "bash yomam.sh https://github.com/" + userName + "/" + repoName + " " + repoName + " " + usrSearch
os.system(command)
def webGrab(webUrl, query):
command = "bash httrackDump.sh " + webUrl + " " + query
os.system(command)
def orgMembers(userName, usrSearch):
#Run all org repos
print("\n" + userName + " Repos Search:")
fullSearch(userName, usrSearch)
# Find all member names
command = "https://api.github.com/orgs/" + userName + "/members"
r = requests.get(command).json()
for member in r:
memb = str(member['login'])
print("Repos for: " + memb + "...")
fullSearch(memb, usrSearch)
#
############# MAIN PROGRAM /UI ######
#
os.system('clear')
print('')
print(' ________.__ __ ________ ___. ')
print(' / _____/|__|/ |_ / _____/___________ \_ |__ ')
print('/ \ ___| \ __\/ \ __\_ __ \__ \ | __ \ ')
print('\ \_\ \ || | \ \_\ \ | \// __ \| \_\ \ ')
print(' \______ /__||__| \______ /__| (____ /___ / ')
print(' \/ \/ \/ \/ v.01')
print("")
print("Christopher Hansen, Henry Samuelson")
print("")
print("*")
print("Search git repos for key text")
print("*")
print("")
print("")
print("Select 0: webGrab")
print("Select 1: gitGrab")
initialSelect = raw_input("Select> ")
if(int(initialSelect) == 0):
url = raw_input("Target url> ")
query = raw_input("Query Text> ")
webGrab(url, query)
if(int(initialSelect) == 1):
print("Select 0: full search")
print("Select 1: for individual repo search")
print("Select 2: for a search of all memebers of an org")
menuSelect = raw_input("Select Search> ")
selectText = raw_input("Search phrase> ")
userName = raw_input("Target User> ")
if(int(menuSelect) == 0):
gh = pygithub3.Github()
print("Results:")
fullSearch(userName, selectText)
elif(int(menuSelect) == 2):
gh = pygithub3.Github()
print("Results:")
orgMembers(userName, selectText)
else:
repoName = raw_input("Target Repo> ")
print("Results: \n")
individualSearch(userName, repoName, selectText)