Hello i'm so confused on why i am getting this error
Code:
#!/usr/bin/python -w
import random
import socket
from random import randint
username = 'admin'
password = 'admin'
print 'Format:'
print '101.109'
range = raw_input("Range: ")
def main():
return '%s.%i.%i' % (range, rand(), rand())
def rand():
return randint (1,254)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
print 'Scanning %s:%s - %s' % (username, password, main())
port = (5900)
s.connect((main(), port))
Error code:
Format:
101.109
Range: 101.109
Scanning admin:admin - 101.109.154.9
Traceback (most recent call last):
File "C:\Users\Aries\Desktop\crap\Reflect.py", line 24, in <module>
s.connect((main(), port))
File "C:\Python27\lib\socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
So my friend wanted me to make a VNC IP scanner so thats what im doing and im making it try to connect to it finds actual VNC ips but when its doing that i get an error as you see at the top
EDIT: MORE INFO
I need to know how i can make it not give me an error if the connection is not up
Wrap your connect
in a try/except
block:
Host = main()
try:
s.connect((Host, port))
print "Port {} is open on host {}".format(port, Host)
except:
print "Connection failed" # or just pass