back ^^
hello,
i have done some changes (have add try/except and add two settimeouts) and have test it on a friend's website , and it seems to work .
Here is the code:
from socket import *
print "Simple port scanner"
print "-------------------"
print ""
address = raw_input("Enter address (or localhost): ")
ip = gethostbyname(address)
print address,"has the IP:",ip
alpha = int(raw_input("Port (min):"))
omega = int(raw_input("Port (max):"))
def scanner(ip,alpha, omega):
count = 0
for ports in range(alpha, omega):
try:
print "Scanning port :%d" % (ports,)
s = socket(AF_INET, SOCK_STREAM)
s.settimeout(3)
s.connect((ip, ports))
s.settimeout(3)
print "Port %d: is OPEN" % (ports,)
count = count + 1
except:
print "Port %d is CLOSED" % (ports,)
s.close()
print "Scanning finished !"
print ""
print "Found %d open ports" % (count)
print ""
print "Begin to scan..."
scanner(ip,alpha,omega)
And the output is:
Simple port scanner
-------------------
Enter address (or localhost): xxx.xxx.org
xxx.xxx.org has the IP: xx.xx.xxx.xxx
Port (min):79
Port (max):82
Begin to scan...
Scanning port :79
Port 79 is CLOSED
Scanning port :80
Port 80: is OPEN
Scanning port :81
Port 81 is CLOSED
Scanning finshed !
Found 1 open ports
>>> ================================ RESTART ================================
>>>
Simple port scanner
-------------------
Enter address (or localhost): xxx.xxx.org
xxx.xxx.org has the IP: xx.xx.xxx.xxx
Port (min):440
Port (max):445
Begin to scan...
Scanning port :440
Port 440 is CLOSED
Scanning port :441
Port 441 is CLOSED
Scanning port :442
Port 442 is CLOSED
Scanning port :443
Port 443: is OPEN
Scanning port :444
Port 444 is CLOSED
Scanning finished !
Found 1 open ports
>>>
Now im trying to improve with threads (but same.... never used it ^^)
not sure if it's understandable , but i try
ex: if i want to scan 100 ports , i want to divide it , and scan 10 with thread 1 , 10 with tread 2, etc .....
Have a nice day