har html
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.agent {
|
||||
padding: 1.5em;
|
||||
float: left;
|
||||
margin: 1em;
|
||||
width: 20em;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 1.5em;
|
||||
float: left;
|
||||
display: inline;
|
||||
margin: 1em;
|
||||
width: 45em;
|
||||
background-color: #eeeeee;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.bug {
|
||||
padding: 0.5em;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.data {
|
||||
margin-left: 0.5em;
|
||||
margin-right: 0.5em;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.code {
|
||||
word-wrap: break-word;
|
||||
padding-top: 1.5em;
|
||||
padding-bottom: 1.5em;
|
||||
}
|
||||
|
||||
.ad {
|
||||
background-color: rgba(0, 191, 243, 0.9);
|
||||
}
|
||||
|
||||
.analytics {
|
||||
background-color: rgba(163, 170, 64, 0.9);
|
||||
}
|
||||
|
||||
.tracker {
|
||||
background-color: rgba(208, 18, 49, 0.9);
|
||||
}
|
||||
.widget {
|
||||
background-color: rgba(0, 154, 138, 0.9);
|
||||
}
|
||||
.privacy {
|
||||
background-color: rgba(251, 88, 37, 0.9);
|
||||
}
|
||||
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="+++/har_lestyle.css"/>
|
||||
<title>Bugs Forensics Catalogue</title>
|
||||
</head>
|
||||
<body>
|
||||
[[content]]
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,116 @@
|
||||
import sys, csv, json, os, re
|
||||
|
||||
def emit_header(browser, exporter, data_time):
|
||||
str_s = '<div class="agent">'
|
||||
str_s += '<b>Date</b>:<br>'
|
||||
str_s += data_time + '\n'
|
||||
str_s += '<br>\n'
|
||||
str_s += '<b>Browser</b>:<br>'
|
||||
str_s += browser['name']+ '-' + browser['version'] + '\n'
|
||||
str_s += '<br>\n'
|
||||
str_s += '<b>Exporter</b>:<br>'
|
||||
str_s += exporter['name']+ '-' + exporter['version'] + '\n'
|
||||
str_s += '<br>\n'
|
||||
str_s += '</div>\n'
|
||||
return str_s
|
||||
|
||||
|
||||
def emit_bug(b):
|
||||
|
||||
bug = b['bug']
|
||||
str_s = '<div class="bug ' + bug['type'] + '">'
|
||||
|
||||
# bug
|
||||
str_s += '<b>Bug</b>'
|
||||
str_s += '<br>'
|
||||
str_s += '<div class="data">\n'
|
||||
str_s += 'type: ' + bug['type'] + '<br>' + 'property: ' + bug['name']
|
||||
str_s += '</div>'
|
||||
|
||||
str_s += '<br>'
|
||||
|
||||
# request
|
||||
req = b['request']
|
||||
str_s += '<b>Request</b>'
|
||||
str_s += '<br>'
|
||||
str_s += '<div class="data">\n'
|
||||
str_s += req['method'] + '<br>' + req['url'] + '<br>' + req['user_agent']
|
||||
str_s += '<br>'
|
||||
if 'referer' in req:
|
||||
str_s += '<br>'
|
||||
str_s += 'Ref: ' + req['referer']
|
||||
str_s += '<br>'
|
||||
str_s += '</div>'
|
||||
|
||||
str_s += '<br>'
|
||||
|
||||
# response
|
||||
res = b['response']
|
||||
str_s += '<b>Response</b>'
|
||||
str_s += '<br>'
|
||||
str_s += '<div class="data">\n'
|
||||
if 'server_agent' in res:
|
||||
str_s += str(res['status']) + '<br>' + str(res['server_ip']) + '<br>' + res['server_agent'] + '<br>'
|
||||
else:
|
||||
str_s += str(res['status']) + '<br>' + str(res['server_ip']) + '<br>'
|
||||
str_s += '</div>'
|
||||
|
||||
str_s += '<br>'
|
||||
|
||||
# content
|
||||
c = b['content']
|
||||
str_s += '<b>Content</b>'
|
||||
str_s += '<br>'
|
||||
str_s += '<div class="data">\n'
|
||||
str_s += 'mime type: ' + c['mime_type'] + '<br>'
|
||||
str_s += 'size: ' + str(c['size']) + '<br>'
|
||||
|
||||
if len(c['data']) > 500:
|
||||
str_s += '<div class="code">\n'
|
||||
str_s += html_escape(c['data']) + '\n'
|
||||
str_s += '</div>\n'
|
||||
|
||||
str_s += '</div>'
|
||||
str_s += '</div>'
|
||||
return str_s
|
||||
|
||||
def html_escape(text):
|
||||
html_escape_table = {
|
||||
"&": "&",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
">": ">",
|
||||
"<": "<",
|
||||
"[": "[",
|
||||
"]": "]"
|
||||
}
|
||||
return "".join(html_escape_table.get(c,c) for c in text)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
fp = sys.stdin
|
||||
try:
|
||||
data = json.loads(fp.read())
|
||||
except Exception, ee:
|
||||
sys.exit('Error loading data... Aborting.')
|
||||
|
||||
try:
|
||||
template = open(os.path.join('.', 'index_template.html'), 'r+');
|
||||
except:
|
||||
print('error opening template file. aborting...');
|
||||
sys.exit(0);
|
||||
|
||||
content = ""
|
||||
content += emit_header(data['browser'], data['exporter'], data['date_time'])
|
||||
|
||||
bugs = data['data']
|
||||
|
||||
for b in bugs:
|
||||
card = "<div class='card'>\n"
|
||||
card += emit_bug(b)
|
||||
card += "</div>\n"
|
||||
content += card
|
||||
|
||||
html = template.read().replace('[[content]]', content);
|
||||
|
||||
print (html).encode("utf-8")
|
||||
Reference in New Issue
Block a user