不言自明。当我尝试使用Python 2 Ping端口443时,出现端口关闭的错误。我正在使用它来尝试获取横幅信息。这与另一个问题不同,因为我导入了套接字。
import optparse
from socket import *
from threading import *
tgtHost = gethostbyname('www.google.com')
tgtPort = 443
screenLock = Semaphore(value=1)
x = 1
def connScan(tgtHost, tgtPort):
try:
connSkt = socket(AF_INET, SOCK_STREAM)
connSkt.connect((tgtHost, tgtPort))
connSkt.send('ViolentPython\r\n')
results = connSkt.recv(1)
screenLock.acquire()
print ('[+] %d/tcp open' % tgtPort)
print ('[+] ' + str(results))
print('fin')
except:
print('[-] %d/tcp closed' % tgtPort)
finally:
connSkt.close()
connScan(tgtHost,tgtPort)