port scanner

Il linguaggio di nuova generazione, opinioni, dubbi e aiuti.

Moderator: checkm

port scanner

Postby dekster on Fri Nov 17, 2006 2:33 pm

ecco un semplice port scanner...x ora elenca solo le porte aperte e e chiuse in un sistema poi verrà aggiunta qualke altra funzione
Code: Select all
from socket import *

def scan(host, port, ports):
   porte=range(port, ports+1)
   for i in porte:
      c=socket(AF_INET, SOCK_STREAM)   
      try:
         c.connect((host, i))
         print'[+] Porta %d aperta [+]'%(i)
         i=i+1
      except:
         print'[~] Porta %d chiusa [~]'%(i)
         continue
         c.close()
while 1:
   print'DekScan 1.0'
   print'Powered by dekster'
   print
   print
   print'Host:'
   host=raw_input()
   print'Porta iniziale:'
   port=input()
   print'Porta finale:'
   ports=input()
   scan(host, port, ports)   


e questo è l'output

Code: Select all
dekster@debian:~$ python DekScan.py
DekScan 1.0
Powered by dekster


Host:
127.0.0.1
Porta iniziale:
20
Porta finale:
30
[~] Porta 20 chiusa [~]
[~] Porta 21 chiusa [~]
[~] Porta 22 chiusa [~]
[~] Porta 23 chiusa [~]
[~] Porta 24 chiusa [~]
[+] Porta 25 aperta [+]
[~] Porta 26 chiusa [~]
[~] Porta 27 chiusa [~]
[~] Porta 28 chiusa [~]
[~] Porta 29 chiusa [~]
[~] Porta 30 chiusa [~]
dekster@debian:~$ cat /etc/debian_version
lenny/sid
dekster@debian:~$ uname -a
Linux debian 2.6.18-4-k7 #1 SMP Mon Mar 26 17:57:15 UTC 2007 i686 GNU/Linux
dekster@debian:~$
User avatar
dekster
Newbies
 
Posts: 38
Joined: Fri Jul 14, 2006 12:45 am

port scanner

Sponsor

Sponsor


Postby k8 on Fri Nov 17, 2006 3:17 pm

Che spettacolo ^^
molto carino, azz in poche righe di codice col python si fanno faville :lol:
Big-Bug cerca collaboratori.
Scrivete senza abbreviazioni e senza k, grazie.
k8
Admin
 
Posts: 2127
Joined: Tue Jun 06, 2006 4:00 pm

Postby NorbiX on Thu Feb 01, 2007 4:16 pm

Mr.Keit wrote:Che spettacolo ^^
molto carino, azz in poche righe di codice col python si fanno faville :lol:


ecco perchè mi sta così antipatico, come il VB del resto
User avatar
NorbiX
Array[]
 
Posts: 722
Joined: Fri Jul 14, 2006 11:14 am
Location: Inside the N.A.K.

Postby sk1l on Fri Feb 23, 2007 11:24 pm

carino, comunque se volete vedere lo sviluppo di un portscanner veramente idiota, ma che vi introduce bene in python potete visitare il mio blog, e anzi ora vi posto anche l'ultima versione (la migliore e più accurata).

cmq dekster se vuoi un consiglio:

non dubito della funzionalità del tuo script visto come programma, ma dovresti migliorare il codice^^

byez ;)[/url]
::sk1l::
User avatar
sk1l
Python Programmer
 
Posts: 11
Joined: Fri Feb 23, 2007 11:11 pm

il mio port/range scanner

Postby ^4st3r1X^ on Tue Apr 15, 2008 1:41 pm

eccolo
Last edited by ^4st3r1X^ on Tue Apr 15, 2008 1:42 pm, edited 1 time in total.
^4st3r1X^
User avatar
^4st3r1X^
Newbies
 
Posts: 14
Joined: Thu Apr 12, 2007 4:35 pm

port

Postby ^4st3r1X^ on Tue Apr 15, 2008 1:41 pm

Code: Select all
#!/usr/bin/python
import socket
from time import strftime
print """
\n--------------------------
Scan di porte by ^4st3r1X^
Versione V.8.4.09
--------------------------\n"""
data = strftime("%d-%m-%Y %H:%M:%S")
log = open('scanlog.log', 'a')
print """
\n--------------------------
1)Scan di porte su un host
2)Scan di porte su un range 82.83.*.*
---------------------------\n"""
info = {
  1:'TCP Multiplexor',
  7: 'Echo',
  20: 'FTP',
  21: 'FTP',
  22: 'SSH',
  23: 'Telnet',
  25: 'SMTP',
  53: 'DNS',
  67: 'BOOTP Server',
  68: 'BOOTP Client',
  69: 'TFTP',
  70: 'Gopher',
  79:  'Finger',
  80: 'HTTP',
  88: 'Kerebros',
  110: 'POP-3',
  113: 'Auth',
  119: 'NNTP',
  139: 'Netbios',
  143: 'IMAP-4',
  443: 'HTTPS',
  445: 'Microsoft-DS',
  465: 'SMTP',
  631: 'Cups',
  666: 'Doom game',
  993: 'IMAP-4',
  995: 'POP-3',
  1011: 'Doly trojan',
  1012: 'Doly trojan',
  1080: 'Socks proxy',
  1234: 'Netbus',
  1337: 'Waste',
  1353: 'IBM lotus',
  1433:'SQL Server',
  1434: 'SQL Monitor',
  1521: 'Oracle',
  2081: 'Cpanel',
  2086: 'Web host manager',
  3050: 'Firebird database system',
  3128: 'HTTP Squid cache',
  3306: 'MySQL database system',
  3389: '(RDP) desktop remoto',
  4590: 'ICQ trojan',
  4662: 'eMule',
  4672: 'eMule',
  4711: 'eMule Web server',
  5000: 'plug-and-play',
  5060: 'SIP',
  5190: 'AOL instant messenger',
  5222: 'XMPP/Jabber Client Connection',
  5223: 'XMPP/Jabber SSL',
  5269: 'XMPP/Jabber Server Connection',
  5432: 'PostgreSQL Database system',
  5631: 'Symantec PcAnywhere',
  5632: 'Symantec PcAnywhere',
  5800: 'Ultra VNC (HTTP)',
  5900: 'Ultra VNC (Main)',
  6000: 'X-11',
  6660: 'IRC',
  6661: 'IRC',
  6662: 'IRC',
  6663: 'IRC',
  6664: 'IRC',
  6665: 'IRC',
  6666: 'IRC',
  6667: 'IRC',
  6668: 'IRC',
  6669: 'IRC',
  6881: 'Bit torrent',
  6969: 'Bit torrent',
  8000: 'iRDMI',
  8080: 'Proxy',
  8118: 'Privoxy',
  9009: 'Pichat',
  9050: 'Tor',
  12345: 'Netbus',
  12346: 'Netbus',
  27960: 'Quake 3',
  31337: 'Back Orifice',
  41951: 'TVersity Media Server',
}
scelta = input()
if scelta == 1:
   ip = raw_input("Inserisci l'host: ")
   inizio = input("Inserisci la porta d'inzio scansione: ")
   fine = input("Inserisci la porta di fine scansione: ")
   print "\nInzio scansione dalla porta %s alla porta %s sull'host %s\n" % (inizio, fine, ip)
   log.write("%s - Inzio scansione dalla porta %s alla porta %s sull'host %s\n" % (data, inizio, fine, ip))
   if fine < inizio:
       fine = inizio
   porte = []
   for p in range(inizio, fine+1):
       s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
       try:
           s.connect((ip,p))   
           porte.append(p)
           if len(porte) > 0:
              if p in info:
                 print "Aperta la porta %s Info: %s" % (p, info[p])
                 log.write("Aperta la porta %s Info: %s\r" % (p, info[p]))
              else:
                 print "Aperta la porta %s Info: Sconosciuta" % (p)
                 log.write("Aperta la porta %s Info: Sconosciuta\r" % (p))
       except socket.error,msg:
           pass
       finally:
           s.close()
   if not porte:
      print "\nNon ci sono porte aperte"
      log.write("Nessuna porta aperta\n")
   print "\nScansione terminata"
   log.write("Scansione terminata\n\n")
   exit()
if scelta == 2:
   porte = []
   ip = raw_input("Inserisci il range (es: 82.84): ")
   porta = input("Inserisci la porta: ")
   limite = 256
   print "\nInzio scansione della porta %s sul range %s.*.*\n" % (porta, ip)
   log.write("\nInizio scansione della porta %s sul range %s.*.*\n" % (porta,ip))
   for host in range(0,limite+1):
      for host1 in range(0,limite+1):
          ips = "%s.%s.%s" % (ip, host, host1)
          s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          try:
              s.connect((ips, porta))
              porte.append(porta)
              if len(porte) > 0:
                 if porta in info:
                    print "%s - Aperta la porta %s Info: %s" % (ips, porta, info[porta])
                    log.write("%s - Aperta la porta %s Info: %s\r" % (ips, porta, info[porta]))
                 else:
                    print "%s - Aperta la porta %s Info: Sconosciuta" % (ips, porta)
                    log.write("%s - Aperta la porta %s Info: Sconosciuta\r" % (ips, porta))
          except socket.error,msg:
              pass
          finally:
              s.close()
      if not porte:
         print "\nNon ci sono porte aperte"
         log.write("Nessuna porta aperta\n")
         print "\nScansione terminata"
         log.write("Scansione terminata\n\n")
         exit()
else:
   print "scelta errata"
   exit()
^4st3r1X^
User avatar
^4st3r1X^
Newbies
 
Posts: 14
Joined: Thu Apr 12, 2007 4:35 pm


Return to Python

Who is online

Users browsing this forum: No registered users and 1 guest