コード例 #1
0
ファイル: _nmap.py プロジェクト: Kagami/shitsu
 def run(self, host):
     """<host>
     Scan host with nmap.
     """
     host = utils.fix_host(host)
     if not host:
         return
     args = self.nmap_args + [host]
     try:
         popen = subprocess.Popen(
             args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
         stdout = popen.communicate()[0]
     except OSError:
         return "Nmap run failed. Has it installed?"
     lines = stdout.splitlines()[3:]
     return "\n".join(lines)
コード例 #2
0
ファイル: _nmap.py プロジェクト: Kagami/shitsu
 def run(self, host, port):
     """<host> <port>
     Check host's port.
     """
     host = utils.fix_host(host)
     if not host:
         return
     try:
         port = int(port)
     except ValueError:
         return
     if not 0 < port < 65536:
         return
     try:
         sock = socket.create_connection((host, port), timeout=3)
     except socket.error:
         return "port %d closed" % port
     else:
         sock.close()
         return "port %d open" % port