Created
October 24, 2013 14:01
-
-
Save eliezerfot123/cab1cf592209ba6db689 to your computer and use it in GitHub Desktop.
Programa que genera todas las posibles combinaciones y guardarlo en un archivo. Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, math | |
from time import time, localtime, strftime | |
########################### CONFIGURACION ######################### | |
# LONGITUD DEBE SER MINIMO 8 | CLAVES WPA/2 SON DE MINIMO 8 CARACTERES | |
LONGITUD = 10 | |
ALFABETO = "qwertyuioplkjhgfdsazxcvbnm" | |
########################## FUNCIONES ############################### | |
def getVariacionesConRepeticion(ALFABETO , LONGITUD): | |
producto = 1 | |
sumatoria = 0 | |
if (LONGITUD > 7): | |
for i in range(LONGITUD-7): | |
producto = 1 | |
for j in range(LONGITUD-i): | |
producto = producto * len(ALFABETO) | |
if (j+1 == LONGITUD-i): | |
sumatoria = sumatoria + producto | |
else: | |
sumatoria = 0 | |
return sumatoria | |
def getPeso(ALFABETO , LONGITUD): | |
producto = 1 | |
sumatoria = 0 | |
if (LONGITUD > 7): | |
for i in range(LONGITUD-7): | |
producto = 1 | |
for j in range(LONGITUD-i): | |
producto = producto * len(ALFABETO) | |
if (j+1 == LONGITUD-i): | |
sumatoria = sumatoria + producto * (LONGITUD+1-i) | |
else: | |
sumatoria = 0 | |
return sumatoria | |
def eventoPalabraGenerada(palabra): | |
print "prueba: ", palabra | |
f = open("rango.txt", "a") | |
f.write(palabra+'\n') | |
f.close() | |
##################### VARS AUXILIARES ############################## | |
DEBUG = True | |
VERBOSE = True | |
variacionesConRepeticion = getVariacionesConRepeticion(ALFABETO , LONGITUD) | |
inicioReloj = time() | |
cont = 0 | |
progreso = 0 | |
b = getPeso(ALFABETO , LONGITUD) | |
kb = round((b / 1024) , 1) | |
mb = round((kb / 1024) , 1) | |
gb = round((mb / 1024) , 1) | |
#################################################################### | |
sys.stderr.write("\n\t\t- CREADOR DE DICCIONARIOS WPA/WPA2 V 2.0 -\n\n") | |
sys.stderr.write(" - Creando Combinaciones de Longitud: "+str(range(8, LONGITUD+1))+"\n") | |
sys.stderr.write(" - Combinando los Caracteres: "+str(ALFABETO)+"\n") | |
sys.stderr.write(" - Numero de Combinaciones totales: "+str(variacionesConRepeticion)+"\n") | |
if (b < 1024): | |
sys.stderr.write(" - Peso aproximado: "+str(b)+" Bytes.\n") | |
elif (b < 1048576): | |
sys.stderr.write(" - Peso aproximado: "+str(kb)+" KB.\n") | |
elif (b < 1073741824): | |
sys.stderr.write(" - Peso aproximado: "+str(mb)+" MB.\n\n") | |
sys.stderr.write(" Te sugiero tener "+str(round((mb + 0.02 * mb) , 1))+" MB libres para asegurarte de crear el archivo entero.") | |
else: | |
sys.stderr.write(" - Peso aproximado: "+str(gb)+" GB.\n\n") | |
sys.stderr.write(" Te sugiero tener "+str(round((gb + 0.02 * gb) , 1))+" GB libres para asegurarte de crear el archivo entero.") | |
while (LONGITUD > 7): | |
try: | |
contadores = [] | |
for i in range(LONGITUD): | |
contadores.append(0) | |
fin = False | |
while not fin: | |
if DEBUG == True: | |
palabra=[] | |
for i in range(LONGITUD): | |
palabra.append(ALFABETO[contadores[i]]) | |
eventoPalabraGenerada("".join(palabra)) | |
if (cont == 1): | |
sys.stderr.write("\n") | |
if VERBOSE == True: | |
if (cont % 1400000 == 0 and cont != 0 or cont == 1): | |
progreso = cont*100.0/variacionesConRepeticion | |
progreso = round(progreso , 1) | |
finReloj = time() - inicioReloj | |
velocidad = cont / finReloj | |
velocidad = round(velocidad,1) | |
estimado = finReloj * variacionesConRepeticion / cont | |
restante = estimado - finReloj | |
restante = restante / 60 / 60 | |
restante = round(restante , 2) | |
if (restante > 1): | |
sys.stderr.write("\n Avance: "+str(progreso)+"% | Horas restantes: "+str(restante)+" | Creando: "+str(velocidad)+" Palabras/segundo.") | |
elif (restante*60 < 1): | |
sys.stderr.write("\n Avance: "+str(progreso)+"% | Segundos restantes: "+str(restante*60*60)+" | Creando: "+str(velocidad)+" Palabras/segundo.") | |
else: | |
sys.stderr.write("\n Avance: "+str(progreso)+"% | Minutos restantes: "+str(restante*60)+" | Creando: "+str(velocidad)+" Palabras/segundo.") | |
cont = cont + 1 | |
actual = LONGITUD - 1 | |
contadores[actual] = contadores[actual] + 1 | |
while(contadores[actual] == len(ALFABETO)) and not fin: | |
if(actual == 0): | |
fin = True | |
else: | |
contadores[actual] = 0 | |
actual = actual - 1 | |
contadores[actual] = contadores[actual] + 1 | |
LONGITUD = LONGITUD - 1 | |
except KeyboardInterrupt: | |
sys.stderr.write("\n Interrumpido por el usuario\n") | |
fin = True | |
LONGITUD = 6 | |
if VERBOSE == True: | |
sys.stderr.write("\n\n Terminado al "+str(progreso)+"% - Realizadas "+str(cont)+" combinaciones de "+str(variacionesConRepeticion)+"\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment