This forum is in archive mode. You will not be able to post new content.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - christian25r

Pages: [1]
1
hello,

here is a new source i have done for my port-scanner (always free for use in legal way for white-hats)



Code: [Select]

from socket import *


open_p, closed_p = [], []
reponse = ["OPEN PORTS","CLOSED PORTS","SCANNING PORTS:","TYPE","SCANNING","ADDRESS"]

address = raw_input ("{}: ".format(reponse[5]))
ip = gethostbyname(address)

print "{0}:{1}\n".format(reponse[4],ip)



def scan_c(address,port): 
    s = socket(AF_INET,SOCK_STREAM)
    s.settimeout(0.17)
    result = s.connect_ex((address,port))   
    if result == 0:
        open_p.append(port)
        s.shutdown(2)
    else:
        closed_p.append(port)   
    s.close


def main():
    print reponse[2]
    for port in range (0,101):
        print port,
        scan_c(address,port)

   
if __name__ == "__main__":
    main()


print "\n\n{}".format(reponse[0])
for elements in open_p:
    print "{0} {1} :{2}".format(elements,reponse[3],getservbyport(elements))


this range system was only for test , will change it next to add a user input range system ,and a port list system too
now i want to do multithreading and queue on it (but no clue how to do it , i'm still noob in python !! ), and next add all options i had on one of the first versions (whois,bannergrabing,nslookup,etc..  only in python )
if someone have an idea how to thread and queue this new source ^^

Have a nice day all :)

2
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:


Code: [Select]
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:

Code: [Select]
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

3
yes i'm not native English speaking , i come from France ^^
thank you for you anwser Kenjoe41.
just have take few other source-codes to improve my script.
ex: (http://stackoverflow.com/questions/16045946/modified-violent-python-port-scanner-prints-but-doesnt-run)
and:(http://www.pythonforpentesting.com/2013/10/port-scanning-with-python.html)
wil try to add try/exceot and banner grabbing , and also the time taken to do all the processes.
and open all my ebooks and websites to find more informations .
i have also done my introduction in the member introduction section






4
hello,

i'm new to python programming and here is a fisrt code i've done

so,here is a port scanner i've done , it works fine on localhost ,
but when i try to scan a website , after waiting 10 minutes there is nothing
what is wrong with my code.



Code: [Select]
from socket import *

print "Simple port scanner"
print "-------------------"
print ""
adress = raw_input("Enter adress (or localhost): ")
ip = gethostbyname(adress)
print adress,"has the IP:",ip
alpha = int(raw_input("Port (min):"))
omega = int(raw_input("Port (max):"))
   

def scanner(ip,min_port, max_port):
    count = 0
    for ports in range(alpha, omega):
        s = socket(AF_INET, SOCK_STREAM)
        result = s.connect_ex((ip, ports))
        if(result == 0) :
            print 'Port %d: is OPEN' % (ports,)
            count = count + 1
        s.close()
    print "Scanning finshed !"
    print ""
    print "Found",count,"open ports"           
       
       
 
   
print ""
print "Beggin to scan..."
scanner(ip,alpha,omega)

   

Here is the output for localhost:

Code: [Select]
Simple port scanner
-------------------

Enter adress (or localhost): localhost
localhost has the IP: 127.0.0.1
Port (min):0
Port (max):100

Beggin to scan...
Port XX: is OPEN
Port XX: is OPEN
Scanning finshed !

Found 2 open ports


and the output for google (for example)
and there is the problem , there is NOTHING :(

Code: [Select]
Simple port scanner
-------------------

Enter adress (or localhost): google.com
google.com has the IP: 74.125.195.100
Port (min):24
Port (max):82

Beggin to scan...


Thank you for helping me .

Pages: [1]


Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.