Skip to content

Commit

Permalink
Merge pull request #119 from jzold/report
Browse files Browse the repository at this point in the history
Update new report module
  • Loading branch information
laramies authored Dec 17, 2018
2 parents 84f8374 + c2c36b7 commit 2c0eb31
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 685 deletions.
61 changes: 0 additions & 61 deletions oldreport.html

This file was deleted.

1 change: 0 additions & 1 deletion oldreport.xml

This file was deleted.

130 changes: 71 additions & 59 deletions lib/reportgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -15,74 +16,85 @@ 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']
self.bardata.append(latestscandata['email'])
self.bardata.append(latestscandata['host'])
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'),)
barchartcode = plotly.offline.plot({
"data": [go.Bar(x=self.barcolumns,y=self.bardata)],
"layout": layout,
}, auto_open=False,include_plotlyjs=False,filename='report.html', output_type='div')
return barchartcode
try:
self.barcolumns= ['email','host','ip','shodan','vhost']
self.bardata.append(latestscandata['email'])
self.bardata.append(latestscandata['host'])
self.bardata.append(latestscandata['ip'])
self.bardata.append(latestscandata['shodan'])
self.bardata.append(latestscandata['vhost'])
layout = dict(title = "Last scan - number of targets identified for "+ domain +" on "+str(latestscandata["latestdate"]),
xaxis = dict(title = 'Targets'),
yaxis = dict(title = 'Hits'),)
barchartcode = plotly.offline.plot({
"data": [go.Bar(x=self.barcolumns,y=self.bardata)],
"layout": layout,
}, auto_open=False,include_plotlyjs=False,filename='report.html', output_type='div')
return barchartcode
except Exception as e:
print("Error generating HTML bar graph code for domain: " + str(e))

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):
try:
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],
mode = 'lines+markers',
name = 'hosts')
trace0 = go.Scatter(
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],
mode = 'lines+markers',
name = 'IP address')
trace1 = go.Scatter(
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],
mode = 'lines+markers',
name = 'vhost')
trace2 = go.Scatter(
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],
mode = 'lines+markers',
name = 'shodan')
trace3 = go.Scatter(
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],
mode = 'lines+markers',
name = 'email')
trace4 = go.Scatter(
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'),
yaxis = dict(title = 'Results'),
)
scatterchartcode = plotly.offline.plot({
"data": data,
"layout": layout}, auto_open=False,include_plotlyjs=False,filename='report.html', output_type='div')
return scatterchartcode
data = [trace0, trace1, trace2, trace3, trace4]
layout = dict(title = "Scanning history for " + domain,
xaxis = dict(title = 'Date'),
yaxis = dict(title = 'Results'),
)
scatterchartcode = plotly.offline.plot({
"data": data,
"layout": layout}, auto_open=False,include_plotlyjs=False,filename='report.html', output_type='div')
return scatterchartcode
except Exception as e:
print("Error generating HTML for the historical graph for domain: " + str(e))

except Exception as e:
print(e)
print("Error in the reportgraph module: " + str(e))

Loading

0 comments on commit 2c0eb31

Please sign in to comment.