2016-02-01 1 views
0

J'essaye de nmap IPs et hostnames, mais je continue à recevoir une erreur, "les options peu sûres activées pendant que safe_mode est réglé vrai". J'ai essayé de mettre safe_mode = False et safe_mode = True, ainsi que sans l'option dans l'analyse de nmap. Voici mon code:options non sécurisées activées pendant que safe_mode est défini Vrai (libnmap)

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() 

Répondre

1

safe_mode est un argument pour NmapProcess, pas une option:

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

Je compris la réponse en regardant le source code:

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

Remerciez vous pour l'aide. :) –