Scanneur d'ip21

Description

Voilà, c'est un petit scanneur de pub,

Il est en ligne de commande ce qui permet de l'utiliser en remote :

Scanneur de Pub en ligne de commande
Utilisable en remote

Utilisation :
Dans un fichier path.txt entrez les repertoires qui doivent etre checkes
scanneur.exe ipstart ipend nbthread

Il teste l'upload, le dl avec un fichier 1mb, il met les reusltats ds results.txt

Pour le moment j'ai pas mis de compteur de vitesse mais c'est rapide, je le ferais surement quand j'aurais le temps

Source / Exemple :


import sys
import os.path
import thread
from ftplib import FTP
import time
from string import *

def testeur(i):
    fp=[]
    fp=open('path.txt', 'r').readlines()
    while 1:
        indir=1
        upok=1
        dlok=1
        logged=1
        connected=1
        
        try:
            ip=listip[0]
            del listip[0]
        except:
            print 'Thread ' + i + ' termine'
            break
        
        try:
            print 'Trying to connect on ' + ip
            ftp=FTP(ip)
            print 'Connected on ' + ip
        except:
            print 'Unabled to connect on ' + ip
            connected=0

        if(connected==1):
            try:
                print 'Trying to logon on ' + ip
                ftp.login()
                print 'Logged in on ' + ip
            except:
                print 'Unabled to logon on ' + ip
                logged=0
            
        if(logged==1 and connected==1):
            print 'Will check directories on ' + ip
            for currentdir in fp:
                currentdir=currentdir[0:len(currentdir)-1]
                indir=1
                upok=1
                dlok=1
                print 'Checking ' + currentdir + ' on ' + ip

                try:
                    ftp.cwd(currentdir)
                except:
                    print 'Directory ' + currentdir + ' does not exists or we do not have permission on ' + ip
                    indir=0
                    
                if(indir==1):
                    print 'Trying to upload on ' + ip
                    up=open('mbtest.dm', 'rb')
                    try:
                        ftp.storbinary('STOR mbtest.dm', up)
                        print 'Upload succeed on ' + ip
                    except:
                        print 'Unabled to upload on ' + ip
                        upok=0
                        
                if(upok==1 and indir==1):
                    print 'Trying to download on ' + ip
                    try:
                        ftp.retrbinary('RETR mbtest.dm', open('testdl'+i+'.dm', 'wb').write)
                        print 'Download succeed on ' + ip
                    except:
                        print 'Unabled to download on ' + ip
                        dlok=0
                if(dlok==1 and upok==1 and indir==1):
                    print ip + ' Ok!'
                    fp=open('results.txt', 'a').write(ip+'\nOndir : ' + currentdir + '\n')
                    break

if(len(sys.argv)!=4 or os.path.exists('path.txt')==False or os.path.exists('mbtest.dm')==False):
    print """DMScan21
    
    Scanneur de Pub en ligne de commande
    Utilisable en remote

    utilisation :
    dans un fichier path.txt entrez les repertoire qui doivent etre checkes
    scanneur.exe ipstart ipend nbthread
    """
    sys.exit()
else:
    ip1=sys.argv[1]
    ip2=sys.argv[2]
    nbthread=int(sys.argv[3])

print 'Initialisation...'

if(os.path.exists('results.txt')==False) : open('results.txt', 'w')

global listip
listip=[]

firstpart=[]
secondpart=[]
thirdpart=[]
fourthpart=[]

part1=[]
part1=split(ip1, '.')
part2=[]
part2=split(ip2, '.')

if(part1[0]==part2[0]):
    firstpart.append(part1[0])
    egal=1
else:
    if(part1[0]>part2[0]):
        fin=raw_input("Erreur, premiere ip superieure. Tapez une touche pour finir")
        sys.exit()
    else:
        while int(part1[0])<=int(part2[0]):
            firstpart.append(part1[0])
            part1[0]=str(int(part1[0])+1)

if(part1[1]==part2[1]):
    secondpart.append(part1[1])
    egal=1
else:
    if(part1[1]>part2[1] and egal==1):
        fin=raw_input("Erreur, premiere ip superieure. Tapez une touche pour finir")
        sys.exit()
    else:
        while int(part1[1])<=int(part2[1]):
            secondpart.append(part1[1])
            part1[1]=str(int(part1[1])+1)

if(part1[2]==part2[2]):
    thirdpart.append(part1[2])
    egal=1
else:
    if(part1[2]>part2[2] and egal==1):
        fin=raw_input("Erreur, premiere ip superieure. Tapez une touche pour finir")
        sys.exit()
    else:
        while int(part1[2])<=int(part2[2]):
            thirdpart.append(part1[2])
            part1[2]=str(int(part1[2])+1)

if(part1[3]==part2[3]):
    fourthpart.append(part1[3])
else:
    if(part1[3]>part2[3] and egal==1):
        fin=raw_input("Erreur, premiere ip superieure. Tapez une touche pour finir")
        sys.exit()
    else:
        while int(part1[3])<=int(part2[3]):
            fourthpart.append(part1[3])
            part1[3]=str(int(part1[3])+1)

for current in firstpart:
    for current2 in secondpart:
        for current3 in thirdpart:
            for current4 in fourthpart:
                listip.append(current + '.' + current2 + '.' +current3 + '.' +current4)

print 'Finish\n'

for i in range(nbthread):
    thread.start_new_thread(testeur, (str(i+1), ))
    print 'Thread ' + str(i+1) + ' lance'
    time.sleep(0.15)

raw_input('Scan Lance !\n')

Conclusion :


Voilà, je pense qu'il y a pas de prob meme si je l'ai pas reellement utilisé ^^

PS : sachez que le scan n'est pas très bien accepté ^^

Codes Sources

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.