#python #sockets
Вопрос:
я пытаюсь разобраться с простым сканером портов, и код:
import socket as s
from IPy import IP
def scan(ip):
ipc=controllo(target)
print("scanning: " str(ipc))
for port in range(75,85):
port_scanner(ipc, port)
def controllo(ip):
try:
IP(ip)
return(ip)
except ValueError:
return s.gethostbyname(ip)
def port_scanner(ipa, port):
try:
sock=s.socket()
sock.settimeout(0.5)
sock.connect((ipa, port))
print("[ ] La porta " str(port) " è aperta ")
except:
pass
target=input("inserisci il sito, se desideri inserire più siti, separali con una , : ")
if "," in target:
for ipaddress in target.split(","):
scan(ipaddress.strip(" "))
else:
scan(target)
в любом случае, когда я запускаю его, я получаю эту ошибку:
Traceback (most recent call last):
File "C:UsersvittoPycharmProjectspythonProject1main.py", line 10, in controllo
IP(ip)
File "C:UsersvittoPycharmProjectspythonProject1venvlibsite-packagesIPy.py", line 249, in __init__
(self.ip, parsedVersion) = parseAddress(ip, ipversion)
File "C:UsersvittoPycharmProjectspythonProject1venvlibsite-packagesIPy.py", line 1422, in parseAddress
bytes = [int(x) for x in bytes]
File "C:UsersvittoPycharmProjectspythonProject1venvlibsite-packagesIPy.py", line 1422, in <listcomp>
bytes = [int(x) for x in bytes]
ValueError: invalid literal for int() with base 10: 'google'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersvittoPycharmProjectspythonProject1main.py", line 25, in <module>
scan(ipaddress.strip(" "))
File "C:UsersvittoPycharmProjectspythonProject1main.py", line 4, in scan
ipc=controllo(target)
File "C:UsersvittoPycharmProjectspythonProject1main.py", line 13, in controllo
return s.gethostbyname(ip)
socket.gaierror: [Errno 11001] getaddrinfo failed
как я могу решить эту проблему?
ps: в целевом вводе это итальянский перевод для чего-то вроде:
введите свою цель, если вы хотите отсканировать несколько целей, разделите их на ,