if data.find('!scan') != -1:
nick = data.split('!')[ 0 ].replace(':','')
targetip = socket.gethostbyname(str(arg))
sck.send('PRIVMSG ' + chan + " :" ' scanning host' + targetip + '\r\n')
for i in range(20, 1025):
s = socket(AF_INET, SOCK_STREAM)
result = s.connect_ex((targetip, i))
if (result == 0) :
s.send('PRIVMSG ' + chan + " :" 'port %d: OPEN' % (i,) + '\r\n')
s.close()
我收到此错误:
targetip = socket.gethostbyname(str(arg))
socket.gaierror: [Errno 11003] getaddrinfo failed
答案 0 :(得分:1)
在Windows上,socket.gethostbyname()
调用getaddrinfo()
Winsock API调用,并且错误11003 - WSANO_RECOVERY可能是由未设置的SYSTEMROOT环境变量引起的。
在调用socket.gethostbyname之前检查os.environ是否包含SYSTEMROOT,例如:
import os
assert 'SYSTEMROOT' in os.environ