运行环境

Python3

用到模块

socket

threading

代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import socket
import threading

def main(target):
print('开始扫描IP: %s'% target)
for port in range(1,65535):
t = threading.Thread(target=hackport, args=(target, port))
t.start()
def hackport(target,port):
try:
res = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # 创建socket套接字
res.connect((target,port)) # 建立TCP连接
print("[*HACK ONE提示*] %s:%d 端口开放"%(target,port))
res.close()
except:
pass
if __name__ == '__main__':
target=input("请输入IP:")
main(target)
print('*************HACK ONE提醒您,扫描完毕...*************')

运行实例:

图片