-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgithubEmailFinder.py
More file actions
50 lines (43 loc) · 1.5 KB
/
Copy pathgithubEmailFinder.py
File metadata and controls
50 lines (43 loc) · 1.5 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
#!/usr/bin/env python3
#Python libraries
import requests
import re
from pandas import DataFrame
#Color setup
class bcolors:
OKGREEN = '\033[92m'
FAIL = '\033[91m'
BOLD = '\033[1m'
ENDC = '\033[0m'
def checkGithubAPIStatut():
"""
This function check GitHub API statut : ONLINE / OFFLINE.
"""
response = requests.get('https://api.github.com')
if response.status_code == 200:
print("GitHub API is " + f"{bcolors.OKGREEN}{bcolors.BOLD}ONLINE{bcolors.ENDC}")
else:
print("GitHub API is " + f"{bcolors.FAIL}{bcolors.BOLD}OFFLINE{bcolors.ENDC}")
def checkGithubAPI():
"""
This function allows to search for the potential presence of mail in the public events pushed by your target on Github.
"""
#Looking for input from user and requests to the Github API without authentication
AccountName = input("Please give me a github username: ")
print("Looking for email(s) for the following github account: https://github.com/"+str(AccountName))
response = requests.get('https://api.github.com/users/'+str(AccountName)+'/events/public')
#Search for the email in the answer
findEmailField = re.findall(r"\"email\":\"(.*?)\",\"name\":\"(.*?)\"", response.text)
my_list = list(set(findEmailField))
if not my_list:
print("No emails found")
else:
print("The email of your target can possibly be found in the list below: ")
df = DataFrame (my_list,columns=['Email','Username'])
print(df)
# Entry point of the script
def main():
checkGithubAPIStatut()
checkGithubAPI()
if __name__ == '__main__':
main()