mirror of
https://github.com/laramies/theHarvester.git
synced 2024-09-20 15:26:31 +08:00
added scanning history report for domain
This commit is contained in:
parent
68c32cc4e4
commit
c966acf537
|
@ -3,6 +3,7 @@
|
|||
import plotly.plotly as py
|
||||
import plotly
|
||||
import stash
|
||||
from datetime import datetime
|
||||
try:
|
||||
db=stash.stash_manager()
|
||||
db.do_init()
|
||||
|
@ -15,8 +16,13 @@ def __init__(self, domain):
|
|||
self.domain = domain
|
||||
self.bardata = []
|
||||
self.barcolumns = []
|
||||
self.scatterxhosts = []
|
||||
self.scatteryhosts = []
|
||||
self.scatterxdata = []
|
||||
self.scattercountemails = []
|
||||
self.scattercounthosts = []
|
||||
self.scattercountips = []
|
||||
self.scattercountshodans = []
|
||||
self.scattercountvhosts = []
|
||||
|
||||
|
||||
def drawlatestscangraph(self,domain,latestscandata):
|
||||
self.barcolumns= ['email','host','ip','shodan','vhost']
|
||||
|
@ -25,8 +31,6 @@ def drawlatestscangraph(self,domain,latestscandata):
|
|||
self.bardata.append(latestscandata['ip'])
|
||||
self.bardata.append(latestscandata['shodan'])
|
||||
self.bardata.append(latestscandata['vhost'])
|
||||
# for i in scandata:
|
||||
# self.bardata.append(scandata[i])
|
||||
layout = dict(title = "Last scan - number of targets identified for "+ domain +" on "+str(latestscandata["latestdate"]),
|
||||
xaxis = dict(title = 'Targets'),
|
||||
yaxis = dict(title = 'Hits'),)
|
||||
|
@ -36,43 +40,46 @@ def drawlatestscangraph(self,domain,latestscandata):
|
|||
}, auto_open=False,include_plotlyjs=False,filename='report.html', output_type='div')
|
||||
return barchartcode
|
||||
|
||||
def drawscattergraph(self,domain,latestscandata):
|
||||
scandata = latestscandata
|
||||
for i in scandata['scandetails']:
|
||||
self.scatterxhosts.append(i)
|
||||
self.scatteryhosts.append(scandata[i])
|
||||
def drawscattergraphscanhistory(self,domain,scanhistorydomain):
|
||||
scandata = scanhistorydomain
|
||||
for i in scandata:
|
||||
self.scatterxdata.append(datetime.date(datetime.strptime(i['date'],'%Y-%m-%d')))
|
||||
self.scattercountemails.append(int(i['email']))
|
||||
self.scattercounthosts.append(int(i['hosts']))
|
||||
self.scattercountips.append(int(i['ip']))
|
||||
self.scattercountshodans.append(int(i['shodan']))
|
||||
self.scattercountvhosts.append(int(i['vhost']))
|
||||
|
||||
trace0 = go.Scatter(
|
||||
x=[date1,date2,date3,date4,date5],
|
||||
y=[3, 10, 9, 17,10],
|
||||
x=self.scatterxdata,
|
||||
y=self.scattercounthosts,
|
||||
mode = 'lines+markers',
|
||||
name = 'hosts')
|
||||
|
||||
trace1 = go.Scatter(
|
||||
x=[date1,date2,date3,date4,date5],
|
||||
y=[2, 6, 9, 10, 5],
|
||||
x=self.scatterxdata,
|
||||
y=self.scattercountips,
|
||||
mode = 'lines+markers',
|
||||
name = 'IP address')
|
||||
|
||||
trace2 = go.Scatter(
|
||||
x=[date1,date2,date3,date4,date5],
|
||||
y=[1, 2, 4, 6, 2],
|
||||
x=self.scatterxdata,
|
||||
y=self.scattercountvhosts,
|
||||
mode = 'lines+markers',
|
||||
name = 'vhost')
|
||||
|
||||
trace3 = go.Scatter(
|
||||
x=[date1,date2,date3,date4,date5],
|
||||
y=[2, 3, 2, 5, 7],
|
||||
x=self.scatterxdata,
|
||||
y=self.scattercountshodans,
|
||||
mode = 'lines+markers',
|
||||
name = 'shodan')
|
||||
|
||||
trace4 = go.Scatter(
|
||||
x=[date1,date2,date3,date4,date5],
|
||||
y=[12, 14, 20, 24, 20],
|
||||
x=self.scatterxdata,
|
||||
y=self.scattercountemails,
|
||||
mode = 'lines+markers',
|
||||
name = 'email')
|
||||
|
||||
|
||||
data = [trace0, trace1, trace2, trace3, trace4]
|
||||
layout = dict(title = "Scanning history for " + domain,
|
||||
xaxis = dict(title = 'Date'),
|
||||
|
|
16
report.html
16
report.html
File diff suppressed because one or more lines are too long
60
stash.py
60
stash.py
|
@ -9,7 +9,7 @@ def __init__(self):
|
|||
self.results = ""
|
||||
self.totalresults = ""
|
||||
self.latestscandomain = {}
|
||||
self.domainscanhistory = {}
|
||||
self.domainscanhistory = []
|
||||
self.scanboarddata = {}
|
||||
|
||||
def do_init(self):
|
||||
|
@ -126,29 +126,47 @@ def getscanboarddata(self):
|
|||
finally:
|
||||
conn.close()
|
||||
|
||||
def getscanhistory(self,domain):
|
||||
'''dis needs fixing; minden datumhoz kell a count of hosts, emails, ip vhost for a specific domain'''
|
||||
def getscanhistorydomain(self,domain):
|
||||
try:
|
||||
self.getscanhistory["domain"] = domain
|
||||
conn = sqlite3.connect(self.db)
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="host"''',(domain,))
|
||||
data = c.fetchone()
|
||||
self.domainscanhistory["host"] = data[0]
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="email"''',(domain,))
|
||||
data = c.fetchone()
|
||||
self.domainscanhistory["email"] = data[0]
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="ip"''',(domain,))
|
||||
data = c.fetchone()
|
||||
self.domainscanhistory["ip"] = data[0]
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="vhost"''',(domain,))
|
||||
data = c.fetchone()
|
||||
self.domainscanhistory["vhost"] = data[0]
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="shodan"''',(domain,))
|
||||
data = c.fetchone()
|
||||
self.domainscanhistory["shodan"] = data[0]
|
||||
c.execute('''SELECT find_date FROM results WHERE domain=?''',(domain,))
|
||||
data = c.fetchone()
|
||||
#self.domainscanhistory[domain].append(domain)
|
||||
|
||||
c.execute('''SELECT DISTINCT(find_date) FROM results WHERE domain=?''',(domain,))
|
||||
dates = c.fetchall()
|
||||
#id = 1 #this is an ID for the dict
|
||||
for date in dates:
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="host" AND find_date=?''',(domain,date[0]))
|
||||
counthost = c.fetchone()
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="email" AND find_date=?''',(domain,date[0]))
|
||||
countemail = c.fetchone()
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="ip" AND find_date=?''',(domain,date[0]))
|
||||
countip = c.fetchone()
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="vhost" AND find_date=?''',(domain,date[0]))
|
||||
countvhost = c.fetchone()
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT COUNT(*) from results WHERE domain=? AND type="shodan" AND find_date=?''',(domain,date[0]))
|
||||
countshodan = c.fetchone()
|
||||
#self.domainscanhistory[str(date[0])] = date[0]
|
||||
results = {
|
||||
"date" : str(date[0]),
|
||||
"hosts" : str(counthost[0]),
|
||||
"email" : str(countemail[0]),
|
||||
"ip" : str(countip[0]),
|
||||
"vhost" : str(countvhost[0]),
|
||||
"shodan" : str(countshodan[0])
|
||||
}
|
||||
#results = domain+";"+str(date[0])+";"+str(counthost[0])+";"+str(countemail[0])+";"+str(countip[0])+";"+str(countvhost[0])+";"+str(countshodan[0])
|
||||
#self.domainscanhistory["result"+str(id)] = results
|
||||
#self.domainscanhistory.append[domain,pdate,counthost,countemail,countip,countvhost,countshodan]
|
||||
self.domainscanhistory.append(results)
|
||||
#self.domainscanhistory[str(date[0])] = date[0]
|
||||
#self.domainscanhistory["domain"] = domain
|
||||
#id += 1
|
||||
return self.domainscanhistory
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
|
|
@ -218,6 +218,7 @@ def start(argv):
|
|||
db=stash.stash_manager()
|
||||
db.store_all(word,all_hosts,'email','bing')
|
||||
db.store_all(word,all_hosts,'host','bing')
|
||||
all_emails = []
|
||||
|
||||
elif engineitem == "dogpile":
|
||||
print("[-] Searching in Dogpilesearch..")
|
||||
|
@ -267,6 +268,8 @@ def start(argv):
|
|||
print("====================")
|
||||
db=stash.stash_manager()
|
||||
db.store_all(word,people,'name','googleplus')
|
||||
all_emails = []
|
||||
all_hosts = []
|
||||
for user in people:
|
||||
print(user)
|
||||
sys.exit()
|
||||
|
@ -277,6 +280,8 @@ def start(argv):
|
|||
search.process()
|
||||
people = search.get_people()
|
||||
db=stash.stash_manager()
|
||||
all_emails = []
|
||||
all_hosts = []
|
||||
db.store_all(word,people,'name','twitter')
|
||||
print("Users from Twitter:")
|
||||
print("-------------------")
|
||||
|
@ -290,6 +295,8 @@ def start(argv):
|
|||
search.process()
|
||||
people = search.get_people()
|
||||
db=stash.stash_manager()
|
||||
all_emails = []
|
||||
all_hosts = []
|
||||
db.store_all(word,people,'name','linkedin')
|
||||
print("Users from Linkedin:")
|
||||
print("-------------------")
|
||||
|
@ -303,6 +310,8 @@ def start(argv):
|
|||
search.process_profiles()
|
||||
people = search.get_profiles()
|
||||
db=stash.stash_manager()
|
||||
all_emails = []
|
||||
all_hosts = []
|
||||
db.store_all(word,people,'name','google-profile')
|
||||
print("Users from Google profiles:")
|
||||
print("---------------------------")
|
||||
|
@ -657,6 +666,7 @@ def start(argv):
|
|||
db = stash.stash_manager()
|
||||
scanboarddata = db.getscanboarddata()
|
||||
latestscandomain = db.getlatestscandomain(word)
|
||||
scanhistorydomain = db.getscanhistorydomain(word)
|
||||
from lib import statichtmlgenerator
|
||||
generator = statichtmlgenerator.htmlgenerator(word)
|
||||
HTMLcode = generator.generatedashboardcode(scanboarddata)
|
||||
|
@ -665,7 +675,7 @@ def start(argv):
|
|||
import datetime
|
||||
graph = reportgraph.graphgenerator(word)
|
||||
HTMLcode += graph.drawlatestscangraph(word, latestscandomain)
|
||||
#HTMLcode += graph.drawscattergraph(word, latestscandata)
|
||||
HTMLcode += graph.drawscattergraphscanhistory(word, scanhistorydomain)
|
||||
HTMLcode += '<p><span style="color: #000000;">Report generated on '+ str(datetime.datetime.now())+'</span></p>'
|
||||
HTMLcode +='''
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue