Dz Coder & Developer

[Python] scan ports and get the state and the city




import socket
import subprocess
import sys
import os
import urllib2
from datetime import datetime

def aaa() :
 if == ‘nt’:
        os.system(‘color a’)
print “””
[+] CoDeD By SoUiLaHxXx_Dz
[+] Gr33T’z : All My Friends

remoteServer    = raw_input(“Enter a remote host to scan [ip]: “)
start    = input(“Enter a start port: “)
end    = input(“Enter a end port: “)
remoteServerIP  = socket.gethostbyname(remoteServer)

print “-” * 60
print “Please wait, scanning remote host”, remoteServerIP
print “-” * 60
t1 =

cc = urllib2.urlopen(“”+remoteServer)
cc1 =
print cc1+”\n”.strip()
    for port in range(int(start),int(end)):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = sock.connect_ex((remoteServerIP, port))
        if result == 0:
            print “Port {}: \t Open”.format(port)
except KeyboardInterrupt:
    print “You pressed Ctrl+C”
except socket.gaierror:
    print ‘Hostname could not be resolved. Exiting’
except socket.error:
    print “Couldn’t connect to server”
t2 =

total =  t2 – t1
print ‘\n’
print ‘Scanning Completed in: ‘, total
print ‘./SoUiLaHxXx_Dz ^^’
raw_input(“Press ny key to ExiT…”)






or :



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s