def add_corpus():
"""add files in corpus to database"""
db = get_db()
files = os.listdir("corpus")
basenames = set()
for filename in files:
basenames.add(filename.split('.')[0])
for basename in basenames:
basepath = os.path.join('corpus', basename)
with open(basepath + '.nmap', "r") as f:
nmap = f.read()
try:
with open(basepath + '.xml', "r") as f:
xml = f.read()
except IOError:
xml = ""
try:
with open(basepath + '.gnmap', "r") as f:
gnmap = f.read()
except IOError:
gnamp = ""
for i in range(0, 100):
rando_ip = "%d.%d.%d.%d" % (random.randrange(1,254),
random.randrange(1,254),
random.randrange(1,254),
random.randrange(1,254))
(ip, real_ctime) = nmap_to_ip_ctime(nmap)
for i in range(0, random.randrange(1, 10)):
rando_ctime = real_ctime - random.randrange(3600, 3600*24*365)
create_sighting(nmap, xml, gnmap, rando_ctime, rando_ip)
评论列表
文章目录