记录下,端口扫描脚本单线程版,刚学python,慢慢来
#!/usr/bin/python3
# coding=utf-8
import socket
ip_list = []
rs_list = []
f = open('ip.txt')
for each in f.readlines():
tmp_ip = each.replace('\n','')
ip_list.append(tmp_ip)
f.close()
def port_scan(ip):
port_list = range(0,65536)
for port in port_list:
try:
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.settimeout(0.1)
s.connect((ip,port))
result = str(ip)+":"+str(port)+" OPEN"
print(result)
rs_list.append(result)
s.close()
except:
pass
def main():
for ip in ip_list:
port_scan(ip)
if __name__=='__main__':
main()
来源:CSDN
作者:梦之履行地
链接:https://blog.csdn.net/qq_40007043/article/details/103774085