python 3 banner scanner code example
Example: python get banners of ports
import socket
ip = input('IP Address: ')
starting_port = ('Starting port: ')
ending_port = ('Ending port: ')
for port in range(starting_port, ending_port):
try:
print(f'Getting service information for port: {port}')
s = socket.socket()
s.connect((ip, port))
banner = s.recv(1024)
print(f"{ip}: {banner}")
except:
print(f'Cannot connect to port: {port}')