不安全选项在设置为 True 时激活safe_mode (libnmap)



我正在尝试映射IP和主机名,但我不断收到错误,"在设置为True时激活了不安全的选项safe_mode"。我尝试在nmap扫描中输入safe_mode=False和safe_mode=True,以及没有该选项。这是我的代码:

from libnmap.parser import NmapParser
from libnmap.process import NmapProcess
def menu():
    print "Enter 1 for IP input, 2 for Hostname input"
    return input ("Number: ")
#Begin NMAP scan
def nmaprun():
    print ip
    nm = NmapProcess(ip, options="-sV -oX test.xml safe_mode=False")
    rc = nm.run()
def nmapparse():
    print "Nmap Information: "
    rep = NmapParser.parse_fromfile('test.xml')
#Parses the NMAP Information in a readable format
    for _host in rep.hosts:
            if _host.is_up():
                print("Host: {0} {1}".format(_host.address,
                                       " "      .join(_host.hostnames)))
        # get CPE from service if available
            for s in _host.services:
                    print("    Service: {0}/{1} ({2}) ({3}) {4}".format(s.port,
                                                                s.protocol,
                                                                s.state,
                                        s.service,
                                        s.banner))
            # NmapService.cpelist returns an array of CPE objects
                    for _serv_cpe in s.cpelist:
                        print("        CPE: {0}".format(_serv_cpe.cpestring))

            if _host.os_fingerprinted:
                    print("  OS Fingerprints")
                    for osm in _host.os.osmatches:
                        print("    Found Match:{0} ({1}%)".format(osm.name,
                                                          osm.accuracy))
                # NmapOSMatch.get_cpe() method return an array of string
                # unlike NmapOSClass.cpelist which returns an array of CPE obj
                        for cpe in osm.get_cpe():
                                print("t    CPE: {0}".format(cpe))
loop = 1
while loop == 1:
    choice = menu()
    if choice == 1:
        ip = raw_input("Enter your IP: n")
        loop = 0
    elif choice == 2:
        hostname = raw_input("Enter your hostname: n")
        loop = 0
    elif choice > 2 or choice < 1:
        print "No options selected"
        loop = 0
nmaprun()
nmapparse()

safe_modeNmapProcess的参数,而不是一个选项:

nm = NmapProcess(ip, options="-sV -oX test.xml", safe_mode=False)

我通过查看源代码找到了答案:

class NmapProcess(Thread):
    def __init__(self, targets="127.0.0.1",
                 options="-sT", event_callback=None, safe_mode=True, fqp=None):

最新更新