当我在Google Python上ping端口443时说它已关闭

时间:2018-12-07 03:50:08

标签: python ping

不言自明。当我尝试使用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)

0 个答案:

没有答案