File: os_fingerprint.py

package info (click to toggle)
python-libnmap 0.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,416 kB
  • sloc: xml: 5,572; python: 4,299; makefile: 149
file content (22 lines) | stat: -rw-r--r-- 835 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from libnmap.parser import NmapParser

rep = NmapParser.parse_fromfile("libnmap/test/files/os_scan6.xml")

print("{0}/{1} hosts up".format(rep.hosts_up, rep.hosts_total))
for _host in rep.hosts:
    if _host.is_up():
        print("{0} {1}".format(_host.address, " ".join(_host.hostnames)))
        if _host.os_fingerprinted:
            print("OS Fingerprint:")
            msg = ""
            for osm in _host.os.osmatches:
                print("Found Match:{0} ({1}%)".format(osm.name, osm.accuracy))
                for osc in osm.osclasses:
                    print("\tOS Class: {0}".format(osc.description))
                    for cpe in osc.cpelist:
                        print("\tCPE: {0}".format(cpe.cpestring))
        else:
            print("No fingerprint available")