Added support for multiple clients, and a filter count display at the bottom-right of the page
This commit is contained in:
@@ -7,27 +7,28 @@ import re
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Convert your nmap scans into a sqlite database!')
|
||||
parser.add_argument('-d', type=str, help='The database file to use',default='app/scanned.db')
|
||||
parser.add_argument('-x', type=str, help='The xml file to read from, please use -oX with nmap')
|
||||
parser.add_argument('-d', type=str, help='The database file to use',default='app/scanned.db')
|
||||
parser.add_argument('-i', type=str, help='The name to use for the client',default="default")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
if(args.d == None or args.x == None):
|
||||
raise("Must have a database and xml file!")
|
||||
|
||||
|
||||
class target:
|
||||
def __init__(self, os,hostname,address,ports):
|
||||
def __init__(self, os,hostname,address,ports,clientId):
|
||||
self.os = os
|
||||
self.hostname = hostname
|
||||
self.address = address
|
||||
self.ports = ports
|
||||
self.clientId = clientId
|
||||
|
||||
def ptarg(self):
|
||||
print("{}\n{}\n{}\n{}\n".format(self.os,self.hostname,self.address,self.ports))
|
||||
print("{}\n{}\n{}\n{}\n{}\n".format(self.os,self.hostname,self.address,self.ports,clientId))
|
||||
|
||||
def add(self,conn):
|
||||
add_item(conn,self.os,self.hostname,self.address,self.ports)
|
||||
add_item(conn,self.os,self.hostname,self.address,self.ports,self.clientId)
|
||||
|
||||
|
||||
def create_connection(database):
|
||||
@@ -48,11 +49,11 @@ def create_table(conn, create_table_sql):
|
||||
except Error as e:
|
||||
print(e)
|
||||
|
||||
def add_item(conn, os, hostname, address, ports):
|
||||
def add_item(conn, os, hostname, address, ports, clientId):
|
||||
""" Create a table in the database """
|
||||
values = (os,hostname,address,ports)
|
||||
query = """ INSERT into targets (os,hostname,address,ports)
|
||||
VALUES(?,?,?,?); """
|
||||
values = (os,hostname,address,ports,clientId)
|
||||
query = """ INSERT into targets (os,hostname,address,ports,clientId)
|
||||
VALUES(?,?,?,?,?); """
|
||||
try:
|
||||
c = conn.cursor()
|
||||
c.execute(query, values)
|
||||
@@ -75,7 +76,8 @@ def main():
|
||||
os text,
|
||||
hostname text,
|
||||
address text,
|
||||
ports text
|
||||
ports text,
|
||||
clientId text
|
||||
); """
|
||||
create_table(conn, targetTableCreate)
|
||||
|
||||
@@ -90,6 +92,7 @@ def main():
|
||||
hostname = None
|
||||
address = None
|
||||
ports = []
|
||||
clientId = args.i
|
||||
|
||||
for o in host.iter('osclass'):
|
||||
os = str(o.attrib['osfamily'])
|
||||
@@ -104,14 +107,12 @@ def main():
|
||||
for port in host.iter('port'):
|
||||
ports.append(str(port.attrib['portid']))
|
||||
|
||||
|
||||
|
||||
targets.append(target(os, hostname, address, '|'+'|'.join(ports)+'|'))
|
||||
targets.append(target(os, hostname, address, '|'+'|'.join(ports)+'|',clientId))
|
||||
# Write the targets to the database
|
||||
for tar in targets:
|
||||
tar.add(conn)
|
||||
#print(tar.ptarg())
|
||||
print(f"[*] Added {len(targets)} targets")
|
||||
print(f"[*] Added {len(targets)} targets to {args.i}")
|
||||
|
||||
# Close the database connection
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user