Esempio n. 1
0
 def __init__(self, portdb, dirdb=None):
     self.portdb = portdb
     self.dirdb = dirdb
     self.report_dir = os.path.dirname(self.portdb)
     self.report_tpl_dir = os.path.join(os.path.dirname(__file__),
                                        "template")
     self.port_db = sqlite3_db(self.portdb)
     self.dir_db = sqlite3_db(self.dirdb) if self.dirdb else None
Esempio n. 2
0
 def get_scan_result(self):
     results = {}
     db = sqlite3_db(self.portdb)
     rs = db.queryall("select * from asset")
     for id, ip, port, domain, banner, protocol, service, assettype, position, schema in rs:
         if results.get(ip, None):
             results.get(ip).append({
                 "port": port,
                 "domain": domain,
                 "banner": base64.b64decode(banner),
                 "protocol": protocol,
                 "service": service,
                 "assettype": assettype,
                 "position": position,
                 "schema": schema
             })
         else:
             results.update({
                 ip: [{
                     "port": port,
                     "domain": domain,
                     "banner": base64.b64decode(banner),
                     "protocol": protocol,
                     "service": service,
                     "assettype": assettype,
                     "position": position,
                     "schema": schema
                 }]
             })
     return results
Esempio n. 3
0
 def init_db(self):
     self.portdb = os.path.join(
         os.path.dirname(__file__), 'repertory',
         time.strftime("%Y-%m-%d_%H_%M_%S", time.localtime()), "rs.db")
     if not os.path.exists(os.path.dirname(self.portdb)):
         os.makedirs(os.path.dirname(self.portdb))
     self.db = sqlite3_db(self.portdb)
     self.db.create_table(SQL)
     logger.info("database initialization completed")
Esempio n. 4
0
 def init_db(self):
     self.db = sqlite3_db(self.portdb)
     self.db.create_table(SQL1)
     self.db.create_table(SQL2)
     logger.info("database (port.db) initialization completed")
     name = "assetscan_task_{0}".format(self.uuid_hash)
     self.db.insert('porttask', {"name":name,"status":1}, filter=False)
     rs = self.db.query_row("select id from porttask where name='{0}'".format(name))
     self.taskid = rs[0]
Esempio n. 5
0
def query_service_and_banner(port,protocol):
    db = sqlite3_db(portdb)
    rs = db.queryrow("select * from portdb where PORT='{0}' and PROTOCOL='{1}'".format(port,protocol))
    if rs:
        service = rs[1] if rs[1] else "unknown"
        banner = rs[4] if rs[4] else ""
    else:
        service = "unknown"
        banner = ""
    return service,banner
Esempio n. 6
0
 def init_db(self):
     self.fuzzdb = sqlite3_db(self.fuzzdb)
     self.fuzzdb.create_table(SQL3)
     logger.info("database (fuzz.db) initialization completed")