This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 : from nmapprocess import NmapProcess | |
2 : from nmapparser import NmapParser, NmapHost | |
3 : nm = NmapProcess("localhost", options="-sT") | |
4 : rc = nm.run() | |
5 : rc | |
---------------- | |
12: parsed = NmapParser(nm.stdout) | |
13: parsed.parse() | |
14: | |
for h in parsed.get_hosts(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __repr__(self): | |
return ("{0}: [{1} - {2}/{3} {4} ({5})]".format( | |
self.__class__.__name__, | |
self.state, | |
str(self.port), | |
self.protocol, | |
self.service, | |
self.banner | |
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libnmap import NmapParser, NmapReport | |
d = NmapParser.parse_fromfile('/root/dev/python-nmap-lib/libnmap/test/files/1_hosts.xml') | |
r = NmapReport('t1', d) | |
for record in r.db().db_get(): | |
print record |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libnmap import NmapParser, NmapReport | |
from libnmap import ReportDecoder, ReportEncoder | |
import json | |
d = NmapParser.parse_fromfile('/root/dev/python-nmap-lib/libnmap/test/files/1_hosts.xml') | |
r = NmapReport('t1', d) | |
# create a json object from an NmapReport instance | |
j = json.dumps(r, cls=ReportEncoder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libnmap import NmapParser, NmapReport | |
import json | |
from libnmap import ReportEncoder | |
d = NmapParser.parse_fromfile('/root/dev/python-nmap-lib/libnmap/test/files/1_hosts.xml') | |
r = NmapReport('t1', d) | |
j = json.dumps(r, cls=ReportEncoder) | |
r.db().db_insert(json.loads(j)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libnmap.parser import NmapParser | |
from libnmap.report import NmapReport | |
import json | |
r = NmapParser.parse_fromfile('/root/dev/python-nmap-lib/libnmap/test/files/1_hosts.xml') | |
rec = r.db().get('51828e572c15d015af53a4a3') | |
j = rec[0] | |
del j['_id'] | |
s = json.dumps(j) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raise NmapParserException("Unknown data type provided. \ | |
Please check documentation for \ | |
supported data types.") | |
Traceback (most recent call last): | |
File "./pp.py", line 11, in test_parse | |
nmapobj = NmapParser.parse(xml_string1, "zz") | |
File "/root/pydev/lib/python2.6/site-packages/libnmap/parser.py", line 36, in parse | |
supported data types.") | |
NmapParserException: Unknown data type provided. Please check documentation for supported data types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libnmap.parser import NmapParser | |
from libnmap.plugins.backendpluginFactory import BackendPluginFactory | |
report = NmapParser.parse_fromfile('/root/dev/python-nmap-lib/libnmap/test/files/1_hosts.xml') | |
monbackend = BackendPluginFactory().create() | |
monbackend.insert(report) | |
rec = monbackend.get('518a2cee2c15d01d3a0edbf5')[0] | |
del rec['_id'] | |
report2 = NmapParser.parse_fromdict(rec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from libnmap.parser import NmapParser | |
def nested_obj(objname): | |
rval = None | |
splitted = objname.split("::") | |
if len(splitted) == 2: | |
rval = splitted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://jsfiddle.net/CJxAk/3/ |
OlderNewer