1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#!/usr/bin/env python3
import json
from datetime import datetime
from libnmap.parser import NmapParser
from libnmap.plugins.es import NmapElasticsearchPlugin
from libnmap.reportjson import ReportDecoder
nmap_report = NmapParser.parse_fromfile("libnmap/test/files/1_hosts.xml")
mindex = datetime.fromtimestamp(nmap_report.started).strftime("%Y-%m-%d")
db = NmapElasticsearchPlugin(index=mindex)
dbid = db.insert(nmap_report)
nmap_json = db.get(dbid)
nmap_obj = json.loads(json.dumps(nmap_json), cls=ReportDecoder)
print(nmap_obj)
# print(db.getall())
|