示例#1
0
 def recordNmapScan(self, scan, descriptor):
     #Performs the NMap scan using python-nmap library. Returns the exitnodes with the open ports found in the scanning process.
     for host in scan.all_hosts():
         torNode = TorNodeData()
         torNode.host = host
         torNode.nickName = descriptor.nickname
         torNode.fingerprint = descriptor.fingerprint
         torNode.torVersion = descriptor.tor_version
         if descriptor.contact is not None:
             torNode.contactData = descriptor.contact.decode("utf-8", "replace")
         if scan[host].has_key('status'):
             torNode.state = scan[host]['status']['state']
             torNode.reason = scan[host]['status']['reason']
             for protocol in ["tcp", "udp", "icmp"]:
                 if scan[host].has_key(protocol):
                     ports = scan[host][protocol].keys()
                     for port in ports:
                         torNodePort = TorNodePort()
                         torNodePort.port = port
                         torNodePort.state = scan[host][protocol][port]['state']
                         if scan[host][protocol][port].has_key('reason'):
                             torNodePort.reason = scan[host][protocol][port]['reason']
                         if scan[host][protocol][port].has_key('name'):
                             torNodePort.name = scan[host][protocol][port]['name']
                         if scan[host][protocol][port].has_key('version'):
                             torNodePort.version = scan[host][protocol][port]['version']
                         if 'open' in (scan[host][protocol][port]['state']):
                             torNode.openPorts.append(torNodePort)
                         else:
                             torNode.closedFilteredPorts.append(torNodePort)
                     self.exitNodes.append(torNode)
         else:
             self.cli.logger.warn(term.format("[-] There's no match in the Nmap scan with the specified protocol %s" %(protocol), term.Color.RED))
示例#2
0
 def recordNmapScan(self, scan, descriptor):
     #Performs the NMap scan using python-nmap library. Returns the exitnodes with the open ports found in the scanning process.
     for host in scan.all_hosts():
         torNode = TorNodeData()
         torNode.host = host
         torNode.nickName = descriptor.nickname
         torNode.fingerprint = descriptor.fingerprint
         torNode.torVersion = descriptor.tor_version
         if descriptor.contact is not None:
             torNode.contactData = descriptor.contact.decode(
                 "utf-8", "replace")
         if scan[host].has_key('status'):
             torNode.state = scan[host]['status']['state']
             torNode.reason = scan[host]['status']['reason']
             for protocol in ["tcp", "udp", "icmp"]:
                 if scan[host].has_key(protocol):
                     ports = scan[host][protocol].keys()
                     for port in ports:
                         torNodePort = TorNodePort()
                         torNodePort.port = port
                         torNodePort.state = scan[host][protocol][port][
                             'state']
                         if scan[host][protocol][port].has_key('reason'):
                             torNodePort.reason = scan[host][protocol][
                                 port]['reason']
                         if scan[host][protocol][port].has_key('name'):
                             torNodePort.name = scan[host][protocol][port][
                                 'name']
                         if scan[host][protocol][port].has_key('version'):
                             torNodePort.version = scan[host][protocol][
                                 port]['version']
                         if 'open' in (scan[host][protocol][port]['state']):
                             torNode.openPorts.append(torNodePort)
                         else:
                             torNode.closedFilteredPorts.append(torNodePort)
                     self.exitNodes.append(torNode)
         else:
             self.cli.logger.warn(
                 term.format(
                     "[-] There's no match in the Nmap scan with the specified protocol %s"
                     % (protocol), term.Color.RED))