diff --git a/htmlreport.py b/htmlreport.py new file mode 100644 index 0000000000000000000000000000000000000000..568fc01032624c9e33a29978d11d8a160e9c65de --- /dev/null +++ b/htmlreport.py @@ -0,0 +1,115 @@ +from datetime import datetime + +class HtmlReport: + + def __init__(self, filename, domain, title): + self.filename = filename + self.domain = domain + self.title = title + self.date = f"{datetime.now():%d.%m.%Y %H:%m:%S}" + self.requests_to_table = [] + self.search_success = False + + def append_table_items(self, rtt): + self.requests_to_table.append(rtt) + + def search_worked(self): + self.search_success = True + + def write_report(self): + with open(self.filename, "w", encoding="utf-8") as f: + f.write("""<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>IDA Search Bar Test: """ + self.domain + """</title> + <style> + + html { + min-height: 100%; + } + + body { + background-color: #f9f9ff; + } + + div.headers { + text-align: center; + margin-top: 4%; + } + + p.timestamp { + font-size: large; + } + + pre { + white-space: pre-wrap; + word-break: break-word; + } + + table { + margin: 5%; + border: 2px solid #cccccc; + background-color: #fff; + } + + td { + padding: 1% + } + + tr.empty { + height: 10px; + width: 100%; + background-color: #84a4c2; + } + + .center{ + display: flex; + justify-content: center; + align-items: center; + } + + footer { + position: relative; + bottom: 1%; + width: 100%; + } + </style> +</head> +<body> + <div class="headers"> + <h1>IDA Search Bar Tool - Report</h1> + <p class="timestamp"><b>""" + str(self.date) + """</b></p> + <h2>""" + self.title + """</h2> + <h2><a href='""" + self.domain + """'>""" + self.domain + """</a></h2> + <h2>Search term present: """ + str(self.search_success) + """</h2> + </div> + <table> + <colgroup> + <col width="5%"> + <col width="80%"> + </colgroup> + """) + for r in self.requests_to_table: + f.write("""<tr><td>URL: </td><td><pre>""" + r["ru"] + """</pre></td></tr>""") + if len(r["rqs"]) > 0: + f.write("""<tr><td>QS PARAMS: </td><td><pre>""") + for k,v in r["rqs"].items(): + f.write(str(k) + ": " + str(v) + "\n") + f.write("""</pre></td></tr>""") + if r["rpd"]: + f.write("""<tr><td>POST DATA: </td><td><pre>""" + str(r["rpd"]) + """</pre></td></tr>""") + f.write("""<tr class="empty"><td></td><td></td></tr>""") + + f.write("""</table>""") + if len(self.requests_to_table) == 0: + f.write("""<div class="center"><p style="font-size: larger;">Nothing to report.</p></div>""") + f.write("""<div class="center"><p style="font-size: larger; padding-bottom: 15%;">Please check the command line output for errors and inspect the website manually.</p></div>""") + f.write("""<footer class="center"><div style="text-align: center"><p>Your advertisement here!</p><p>Ver. 0.05</p></div></footer>""") + f.write("""</body>""") + f.write("""</html>""") + + + +