-
Notifications
You must be signed in to change notification settings - Fork 20
/
infoga.py
279 lines (261 loc) · 9.4 KB
/
infoga.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Infoga: Email Information Gathering
#
# @url: https://github.com/The404Hacking/Infoga
# @author: Momo Outaadi (The404Hacking)
#
# Infoga is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation version 3 of the License.
#
# Infoga is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Infoga; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import json
import os
import sys
import getopt
import socket
import re
import requests
import urlparse
from core.lib import http
from core.lib import parser
from core.lib import colors
from core.lib import printer
from core.recon import google
from core.recon import bing
from core.recon import pgp
from core.recon import yahoo
from core.recon import netcraft
from requests.packages.urllib3.exceptions import InsecureRequestWarning
class Infoga(object):
color = colors.colors()
printf = printer.printer()
allemail = []
def banner(self):
print self.color.red(1)+" __ ___ "+self.color.reset()
print self.color.red(1)+" |__.-----.' _.-----.-----.---.-. "+self.color.reset()
print self.color.red(1)+" | | | _| _ | _ | _ | "+self.color.reset()
print self.color.red(1)+" |__|__|__|__| |_____|___ |___._| "+self.color.reset()
print self.color.red(1)+" |_____| "+self.color.reset()
print self.color.white(0)+" "+self.color.reset()
print self.color.white(0)+"|| Infoga - Email Information Gathering"+self.color.reset()
print self.color.white(0)+"|| Infoga v4.1 - \"Mr.Robot\" "+self.color.reset()
print self.color.white(0)+"|| Momo Outaadi (The404Hacking) "+self.color.reset()
print self.color.white(0)+"|| https://github.com/The404Hacking/Infoga "+self.color.reset()
print self.color.white(0)+" "+self.color.reset()
def usage(self):
name = os.path.basename(sys.argv[0]).split(".")[0]
self.banner()
print "Usage: %s -t [target] -s [source]\n"%(name)
print "\t-t --target\tDomain to search"
print "\t-s --source\tData source: [all,google,bing,yahoo,pgp]"
print "\t-i --info\tGet email informatios"
print "\t-h --help\tShow this help and exit\n"
print "Examples:"
print "\t %s --target site.com --source all"%(name)
print "\t %s --target site.com --source [google,bing,...]"%(name)
print "\t %s --info test123@site.com"%(name)
print ""
sys.exit()
def info(self):
if self.allemail == []:
self.printf.error("Not found email :(")
sys.exit(0)
allemail = []
for x in self.allemail:
if x not in allemail:
allemail.append(x)
try:
for x in range(len(allemail)):
self.printf.plus("Email: %s"%(allemail[x]))
data = {'lang':'en'}
data['email'] = allemail[x]
req = requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
req = requests.post("http://mailtester.com/testmail.php",data=data,verify=False)
regex = re.compile("[0-9]+(?:\.[0-9]+){3}")
ip = regex.findall(req.content)
new = []
for e in ip:
if e not in new:
new.append(e)
for s in range(len(new)):
req = requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
req = requests.get("https://api.shodan.io/shodan/host/"+new[s]+"?key=UNmOjxeFS2mPA3kmzm1sZwC0XjaTTksy",verify=False)
jso = json.loads(req.content,"utf-8")
try:
self.sock = socket.gethostbyaddr(new[s])[0]
except socket.herror as err:
try:
self.sock = jso["hostnames"][0]
except KeyError as err:
pass
if "country_code" and "country_name" in jso:
self.printf.ip("IP: %s (%s)"%(new[s],self.sock))
self.printf.info("Country: %s (%s)"%(jso["country_code"],jso["country_name"]))
self.printf.info("City: %s (%s)"%(jso["city"],jso["region_code"]))
self.printf.info("ASN: %s"%(jso["asn"]))
self.printf.info("ISP: %s"%(jso["isp"]))
self.printf.info("Geolocation: %s"%("https://www.google.com/maps/@%s,%s,9z"%(jso["latitude"],jso["longitude"])))
self.printf.info("Hostname: %s"%(jso["hostnames"][0]))
self.printf.info("Organization: %s"%(jso["org"]))
self.printf.info("Ports: %s"%(jso["ports"]))
if "vulns" in jso:
self.printf.info("Vulns: %s"%(jso["vulns"][0]))
print ""
elif "No information available for that IP." or "error" in jso:
self.printf.ip("IP: %s (%s)"%(new[s],self.sock))
self.printf.info("No information available for that ip :(",color="r")
print ""
else:
self.printf.ip("IP: %s (%s)"%(new[s],self.sock))
print ""
except Exception as error:
pass
sys.exit()
def checkurl(self,url):
scheme = urlparse.urlsplit(url).scheme
netloc = urlparse.urlsplit(url).netloc
path = urlparse.urlsplit(url).path
if netloc == "":
if path.startswith("www."):
return path.split("www.")[1]
else:
return path
if netloc != "":
if netloc.startswith("www."):
return netloc.split("www.")[1]
else:
return netloc
def checkemail(self,email):
if '@' not in email:
self.banner()
sys.exit(self.printf.error("Invalid email! Check your email"))
return email
def getinfo(self,email):
self.printf.test("Checking email info...")
try:
data = {'lang':'en'}
data['email'] = email
req = requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
req = requests.post("http://mailtester.com/testmail.php",data=data,verify=False)
regex = re.compile("[0-9]+(?:\.[0-9]+){3}")
ip = regex.findall(req.content)
new = []
for e in ip:
if e not in new:
new.append(e)
self.printf.plus("Email: %s"%email)
for s in range(len(new)):
req = requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
req = requests.get("https://api.shodan.io/shodan/host/"+new[s]+"?key=UNmOjxeFS2mPA3kmzm1sZwC0XjaTTksy",verify=False)
jso = json.loads(req.content)
try:
self.sock = socket.gethostbyaddr(new[s])[0]
except socket.herror as err:
try:
self.sock = jso["hostnames"][0]
except KeyError as err:
pass
if "country_code" and "country_name" in jso:
self.printf.ip("IP: %s (%s)"%(new[s],self.sock))
self.printf.info("Country: %s (%s)"%(jso["country_code"],jso["country_name"]))
self.printf.info("City: %s (%s)"%(jso["city"],jso["region_code"]))
self.printf.info("ASN: %s"%(jso["asn"]))
self.printf.info("ISP: %s"%(jso["isp"]))
self.printf.info("Geolocation: %s"%("https://www.google.com/maps/@%s,%s,9z"%(jso["latitude"],jso["longitude"])))
self.printf.info("Hostname: %s"%(jso["hostnames"][0]))
self.printf.info("Organization: %s"%(jso["org"]))
self.printf.info("Ports: %s"%(jso["ports"]))
if 'vulns' in jso:
self.printf.info("Vulns: %s"%(jso["vulns"][0]))
print ""
elif "No information available for that IP." or "error" in jso:
self.printf.ip("IP: %s (%s)"%(new[s],self.sock))
self.printf.info("No information available for that ip :(",color="r")
print ""
else:
self.printf.ip("IP: %s (%s)"%(new[s],self.sock))
except Exception as error:
pass
sys.exit()
def main(self,kwargs):
if len(sys.argv) <= 1:
self.usage()
try:
opts,args = getopt.getopt(kwargs,"t:s:i:h:",["target=","source=","info=","help"])
except Exception as error:
self.usage()
for opt,arg in opts:
if opt in ("-t","--target"):
self.target = self.checkurl(arg)
if opt in ("-s","--source"):
source = arg
if source not in ("all","google","bing","yahoo","pgp"):
self.banner()
sys.exit(self.printf.error("Invalid search engine! Try with: all, google, bing, yahoo or pgp"))
self.banner()
netcraft.netcraft(self.target).search()
if source == "google":
self.google()
self.info()
elif source == "bing":
self.bing()
self.info()
elif source == "yahoo":
self.yahoo()
self.info()
elif source == "pgp":
self.pgp()
self.info()
elif source == "all":
self.all()
self.info()
if opt in ("-i","--info"):
email = self.checkemail(arg)
self.banner()
self.getinfo(email)
if opt in ("-h","--help"):
self.usage()
def google(self):
self.printf.test("Searching \"%s\" in Google..."%(self.target))
search = google.google(self.target)
search.process()
emails = search.getemail()
self.allemail.extend(emails)
def bing(self):
self.printf.test("Searching \"%s\" in Bing..."%(self.target))
search = bing.bing(self.target)
search.process()
emails = search.getemail()
self.allemail.extend(emails)
def yahoo(self):
self.printf.test("Searching \"%s\" in Yahoo..."%(self.target))
search = yahoo.yahoo(self.target)
search.process()
emails = search.getemail()
self.allemail.extend(emails)
def pgp(self):
self.printf.test("Searching \"%s\" in Pgp..."%(self.target))
search = pgp.pgp(self.target)
search.process()
emails = search.getemail()
self.allemail.extend(emails)
def all(self):
self.google()
self.bing()
self.yahoo()
self.pgp()
if __name__ == "__main__":
try:
Infoga().main(sys.argv[1:])
except KeyboardInterrupt:
sys.exit("CTRL+C.... :(")