-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__main__.py
161 lines (135 loc) · 7.4 KB
/
__main__.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/python3
"""
A tool to automate OSINT tasks related to emails by combining popular industry favorite tools.
Find emails -> search local database for results
GitHub repository: https://github.com/nihilp/AutoInfoGather
Note:
-------
If you see the error "/home/kali/python/Capstone/AutoInfoGather/__main__.py" is overriding the stdlib module "__main__"PylancereportShadowedImports
while examining __main__.py in VS Code, it is because of pylance version "v2022.11.40", and it is a false possitive and does not influence usage or execution
https://pullanswer.com/questions/reportshadowedimports-triggers-on-__main
"""
__author__ = "nihilp"
__copyright__ = "Copyright (c) 2022 @nihilp"
__credits__ = ["nihilp", "maldevel", "Christian Martorella", "khast3x"]
__licence__ = "MIT"
__version__ = "v1"
__maintainer__ = "nihilp"
import os
import sys
import getch
import config # Contains all user defined paths
from Tools.tools import * # Contains all tools used
from Utilities.combine_results import * # Used to combine theHarvester & EmailHarvester results
from Utilities.json_to_csv import * # Used to convert theHarvester json output to multiple csv files
from Utilities.filter_h8mail import * # Contains tools that process h8mail terminal output
# Function for waiting for key press
def wait():
getch.getche()
# Function for clearing Linux terminal
def clear():
os.system('clear')
def main():
ans=True
while ans:
print("""
AutoInfoGather:
---------------
1. Collect information related to a specific domain
2. Check if emails found are present in local databreach
3. Exit/Quit
""")
ans=input("What would you like to do? ")
if ans=="1": # Target lookup by domain
arg=True
while arg:
arg=input("Please type a domain (ex: nihilp.com): ")
print("\nGetting information on domain... (this may take a while)")
os.chdir(config.path_to_results_file) # Change working directory to Results file
theHarvester(arg) # Run theHarvester tool using user defined domain
cleanResults() # Convert the json output of theHarvester into different, more easily readable and seperate csv files
emailHarvester(arg)
if os.path.exists("Results/EMAILS.csv"): # Check if theHarvester found emails
csv_to_txt() # Convert theHarvester emails to txt
all_emails() # Combine the results from theHarvester and EmailHarvester into one txt file
clear()
print("\nFinished, view results under Results/All_Emails.txt file")
arg=False # Go back to main menu
elif ans=="2": # Looking for matches in local database
clear()
os.chdir(config.path_to_results_file)
choice=True
while choice:
print("""
1. Default - Use results of part 1
2. Define target for local breach search
3. Go back
""")
choice=input("What would you like to do? ")
if choice=="1":
clear()
print("\nSearching if emails are present in local breach using results from part 1... (this may take a while depending on how large the local breach is)")
if os.path.exists("All_Emails.txt"):
h8mail() # Run h8mail tool using results from part 1
remove_special_char() # Remove special caharacters present in h8mail terminal output
find_creds() # Locate credentials found in h8mail output
print("\nFinished, view results under /Results/credentials_found.csv file")
choice=False
else:
print("\nNo credentials found in local breach using results from part 1")
elif choice=="2":
clear()
arg=True
while arg:
clear()
arg=input("\nPlease specify a target email or file containing emails (.txt or .csv) \n(ex: [email protected] or /home/kali/python/Capstone/AutoInfoGather/Results/All_Emails.txt) \nor press enter to go back: ")
path_pattern = re.compile(r"^((?:~?\/)|(?:(?:\\\\\?\\)?[a-zA-Z]+\:))(?:\/?(.*))?$") # Regural expression for paths
email_pattern = re.compile(r"^[\w.-]+@[\w.-]+\.\w+$") # Regural expression for emails
if (path_pattern.match(arg) and arg.endswith(".txt")) or (path_pattern.match(arg) and arg.endswith(".csv")): # Check if user defined file is txt or csv
if os.path.isfile(arg):
clear()
print("\nSearching if emails are present in local breach using specified file... (this may take a while depending on how large the local breach is)")
h8mail_user_input(arg) # Run h8mail tool using user defined file containing emails
with open(arg,'r') as firstfile, open('All_Emails.txt','a') as secondfile:
for line in firstfile:
secondfile.write(line)
remove_special_char()
find_creds()
choice=False
elif email_pattern.match(arg): # Check if user defined an email
clear()
print("\nSearching if emails are present in local breach using specified email... (this may take a while depending on how large the local breach is)")
email_file = open("All_Emails.txt", "w")
email_file.write(arg)
email_file.close()
h8mail_user_input(arg) # Run h8mail tool using user defined email
remove_special_char()
find_creds()
choice=False
else:
clear()
print("\nInput does not match existing file nor email ")
choice=False
elif choice=="3":
clear()
choice=False # go back to main menu
else:
clear()
print("\nNot a valid choice, try again")
choice = True # go back to 2nd menu
elif ans=="3":
clear()
print("\nThank you for using AutoInfoGather!")
ans = None # go back to main menu
else:
clear()
print("\nNot a valid choice, try again")
ans = True # go back to main menu
clear() # Clear screen before showing menu
# Check whether python version is greater than 3.10
if sys.version_info.major < 3 or sys.version_info.minor < 10:
print('Make sure you have Python 3.10+ installed, quitting script.')
sys.exit(1)
# Enable execution of the tool from parent folder in terminal (ex: python3 AutoInfoGather)
if __name__ == '__main__':
main()