from lib import markup from lib import graphs import re class htmlExport(): def __init__(self, users, hosts, vhosts, dnsres, dnsrev, file, domain, shodan, tldres): self.users = users self.hosts = hosts self.vhost = vhosts self.fname = file self.dnsres = dnsres self.dnsrev = dnsrev self.domain = domain self.shodan = shodan self.tldres = tldres self.style = "" def styler(self): a = """ """ self.style = a def writehtml(self): page = markup.page() # page.init (title="theHarvester # Results",css=('edge.css'),footer="Edge-security 2011")A page.html() self.styler() page.head(self.style) page.body() page.h1("theHarvester results") page.h2("for :" + self.domain) page.h3("Dashboard:") graph = graphs.BarGraph('vBar') graph.values = [len( self.users), len(self.hosts), len(self.vhost), len(self.tldres), len(self.shodan)] graph.labels = ['Emails', 'hosts', 'Vhost', 'TLD', 'Shodan'] graph.showValues = 1 page.body(graph.create()) page.h3("E-mails names found:") if self.users != []: page.ul(class_="userslist") page.li(self.users, class_="useritem") page.ul.close() else: page.h2("No emails found") page.h3("Hosts found:") if self.hosts != []: page.ul(class_="softlist") page.li(self.hosts, class_="softitem") page.ul.close() else: page.h2("No hosts found") if self.tldres != []: page.h3("TLD domains found in TLD expansion:") page.ul(class_="tldlist") page.li(self.tldres, class_="tlditem") page.ul.close() if self.dnsres != []: page.h3("Hosts found in DNS brute force:") page.ul(class_="dnslist") page.li(self.dnsres, class_="dnsitem") page.ul.close() if self.dnsrev != []: page.h3("Hosts found with reverse lookup :") page.ul(class_="dnsrevlist") page.li(self.dnsrev, class_="dnsrevitem") page.ul.close() if self.vhost != []: page.h3("Virtual hosts found:") page.ul(class_="pathslist") page.li(self.vhost, class_="pathitem") page.ul.close() if self.shodan != []: shodanalysis = [] page.h3("Shodan results:") for x in self.shodan: res = x.split("SAPO") page.h3(res[0]) page.a("Port :" + res[2]) page.pre(res[1]) page.pre.close() ban = res[1] reg_server = re.compile('Server:.*') temp = reg_server.findall(res[1]) if temp != []: shodanalysis.append(res[0] + ":" + temp[0]) if shodanalysis != []: page.h3("Server technologies:") repeated = [] for x in shodanalysis: if x not in repeated: page.pre(x) page.pre.close() repeated.append(x) page.body.close() page.html.close() file = open(self.fname, 'w') for x in page.content: try: file.write(x) except: print "Exception" + x # send to logs pass file.close return "ok"