I'm new in Python and I'm trying to execute this piece of code importing Socket:
import socket
def retBanner(ip, port):
try:
socket.setdefaulttimeout(2)
s = socket.socket()
s.connect((ip,port))
banner = s.recv(1024)
return banner
except Exception as e:
return str(e)
def main():
ip1 = '10.0.0.12'
ip2 = '10.0.0.11'
port = 21
banner1 = retBanner(ip1, port)
if banner1:
print('[+] ' + ip1 + ': ' + banner1)
banner2 = retBanner(ip2, port)
if banner2:
print("[+] " + ip2 + ': ' + banner2)
if __name__ == '__main__':
main()
Even if I just try in shell,
>>> import socket
>>> socket.setdefaulttimeout(2)
>>> s = socket.socket()
>>> s.connect(("10.0.0.12",21))
it throws the following Exception
[+] 10.0.0.12: [WinError 10061] No connection could be made because the target machine actively refused it
I'd like to know why, I have my Firewalls off..
Greetings!