[Script] Pypass Generador de contraseñas

Iniciado por noxonsoftwares, Marzo 03, 2016, 02:40:53 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Marzo 03, 2016, 02:40:53 PM Ultima modificación: Marzo 03, 2016, 03:52:11 PM por EPSILON
Bueno gente del foro en esta ocasión les traigo un humilde aporte de este pequeño script para generar contraseñas aleatorias solo números de hasta 8 caracteres.

Código: python

import string
import os, sys
from random import *

#######################################
# Console colors
#######################################

W = '\033[0m'  # white (normal)
R = '\033[31m'  # red
G = '\033[32m'  # green
O = '\033[33m'  # orange
B = '\033[34m'  # blue
P = '\033[35m'  # purple
C = '\033[36m'  # cyan
GR = '\033[37m'  # gray




def genera():
    characters = string.digits
    password =  "".join(choice(characters) for x in range(randint(0, 9)))
    while True:
        i = len(password)
        if i == 8:
            # Escribe y agrega los pass al diccionario
            dic = open("diccionario.txt", "a")
            dic.write(password + "\n")
            dic.close()
            break
        else:
            return genera()

def generar():
    try:
        count = 0
        max = int(input("Ingrese la cantidad de claves a generar: "))
        while (count < max):
            genera()
            count = count + 1
            print("[+]Generando clave...", count, "/", max)
            os.system("clear")
    except:
        print(R + "[!]Solo debe ingresar numeros" + W)
        sys.exit()
    finally:
        banner()
        print("[+]Claves generadas con exito.")

def banner():
    print("""
###############################################################################
#                 888888                                                      #
#                 8    8 e    e eeeee eeeee eeeee eeeee                       #
#                 8eeee8 8    8 8   8 8   8 8   " 8   "                       #
#                 88     8eeee8 8eee8 8eee8 8eeee 8eeee                       #
#                 88       88   88    88  8    88    88                       #
#                 88       88   88    88  8 8ee88 8ee88                       #
#-----------------------------------------------------------------------------#
#-------------------------------noxonsoftwares--------------------------------#
###############################################################################
""")


os.system("clear")
banner()
generar()


Aquí el vídeo de como funciona  ::)


HOLA!!!

Vamos, agregale letras, simbolos predefinidos y que el usuario pueda ingresar su propio juego de caracteres para crear su diccionario.

Algo como esto:


No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Se que podes hacerlo mejor.

GRACIAS POR LEER!!!
"Algunos creen que soy un bot, puede que tengan razon"
"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

*Shadow Scouts Team*                                                No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Esta bueno para generar contraseñas por default de routers WIFI de Fibertel.


Saludos

Gn0m3

me pareció interesante para quienes estamos aprendiendo python, y como el autor no contestó al pedido de alguna mejora, me tomé el atrevimiento de hacerle unos cambios al código y agregarle un entorno visual sencillo con tkinter.Para que se aprecie mejor en vez de crear un archivo .py hay que hacerlo .pyw para que no moleste la consola.
Saludos.
Código: python

#código realizado por tincopasan
#-*- coding: utf -8 -*-
from tkinter import *
from tkinter import messagebox
import string
import random


def generar_pass():
    pass_may=cmay.get()
    pass_min=cmin.get()
    pass_num=cnum.get()
    pass_sim=csim.get()
   
    exito= 0
   
    global argumentos
    argumentos =""
   
    if pass_may == 1:
        mayusculas=string.ascii_uppercase
        argumentos = argumentos + mayusculas
        exito=1       
         
    if pass_min == 1:
        minusculas=string.ascii_lowercase
        argumentos = argumentos + minusculas
        exito = 1
     
    if pass_sim == 1:
        simbolos="@#\/¿?¡!.,+-_"
        argumentos=argumentos + simbolos
        exito = 1

    if pass_num == 1:
        numeros=string.digits
        argumentos= argumentos + numeros
        exito=1
   
    if exito == 0:
        messagebox.showinfo("¡Error!","Debes seleccionar por lo menos 1 argumento")
       
    if exito == 1:
        cuantas = 0
        total = arg_cantidad.get()
        dic = open("diccionario.txt", "a")
        while cuantas < total:
            cuantas = cuantas + 1         
            password =  "".join(random.SystemRandom().choice(argumentos) for _ in range(arg_largo.get()))
            dic.write(password + "\n")
       
        dic.close()
        messagebox.showinfo("¿Atención!","Archivo de claves generado exitosamente")     

   
ventana=Tk()
ventana.title("Generador de Passwords")
ventana.geometry("220x190+200+150")
eleccion=Label(ventana,text="Elija que argumentos utilizar").place(x=0,y=0)

cmay=IntVar()
chkmay=Checkbutton(ventana,text="Mayúsculas",variable=cmay,onvalue=1,offvalue=0).place(x=10,y=20)

cmin=IntVar()
chkmin=Checkbutton(ventana,text="Minúsculas",variable=cmin,onvalue=1,offvalue=0).place(x=10,y=40)

cnum=IntVar()
chknum=Checkbutton(ventana,text="Números",variable=cnum,onvalue=1,offvalue=0).place(x=10,y=60)

csim=IntVar()
chksim=Checkbutton(ventana,text="Símbolos",variable=csim,onvalue=1,offvalue=0).place(x=10,y=80)

largo=Label(ventana,text="¿Largo de la contraseña?: ").place(x=10,y=100)
cantidad=Label(ventana,text="¿Cantidad de contraseñas?: ").place(x=10,y=120)
arg_largo= IntVar()
inicio=Entry(ventana,textvariable= arg_largo, width=2).place(x=160,y=100)
arg_cantidad=IntVar()
cuantas=Entry(ventana,textvariable=arg_cantidad,width=2).place(x=160,y=120)

quien=Label(ventana,text="Realizado por tincopasan").place(x=10,y=170)
boton_generar=Button(ventana,text="Generar pass",command=generar_pass).place(x=130,y=140)
boton_salir=Button(ventana,text="Salir",command=ventana.quit).place(x=10,y=140)
arg_cantidad.set(1)
arg_largo.set(1)
ventana.resizable(0,0)
   
ventana.mainloop()


Muy interesante tu aporte @No tienes permitido ver los links. Registrarse o Entrar a mi cuenta como mejora o complemento del código original.

Gracias.
Tú te enamoraste de mi valentía, yo me enamoré de tu oscuridad; tú aprendiste a vencer tus miedos, yo aprendí a no perderme en tu abismo.

Marzo 22, 2016, 08:23:58 AM #5 Ultima modificación: Marzo 22, 2016, 08:26:41 AM por 79137913
HOLA!!!

Eso es!

Aunque le faltan algunos simbolos y letras especiales creo...

Código: vb
Const Sym As String = "/\!·$%&/()='""¡¿?<>., :;-_*+" 'Simbolos
Const Num As String = "0123456789"                   'Numeros
Const Min As String = "abcdefghijklmnopqrstuvwxyz"   'Letras Minusculas
Const May As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"   'Letras Mayusculas
Const SpL As String = "áéíóúàèìòùâêîôûäëïöüçñ"       'Letras Especiales Minusculas
Const SpU As String = "ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÇÑ"       'Letras Especiales Mayusculas


Y la posibilidad de elegir el juego de caracteres a mano introduciendolo.

Por ejemplo se que la password tiene 8 caracteres y solo letras del cuadrante qweasdzxc y numeros 652 entonces coloco en la seleccion de caracteres qweasdzxc256
GRACIAS POR LEER!!!
"Algunos creen que soy un bot, puede que tengan razon"
"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

*Shadow Scouts Team*                                                No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Marzo 25, 2016, 03:15:02 PM #6 Ultima modificación: Marzo 25, 2016, 03:36:24 PM por backd0r
Hola, estoy aprendiendo a programar en Python hice un script parecido les comparto me dicen que tal les funciona, si hay errores y como puedo mejorarlo, funciona en Windows, Linux y Mac OS X El Capitan.
Cualquier duda o comentario a mi correo o un MP.
:D
Repo:
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Código: python

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import traceback
import time
from random import choice


class tcolors:
    N = '\033[0m'  # Default
    R = '\033[31;1m'  # rojo
    G = '\033[32m'  # verde
    O = '\033[33m'  # naranja
    B = '\033[34m'  # azul
    M = '\033[35m'  # magenta
    C = '\033[36;1m'  # cian
    BK = '\033[37;1m'  # blanco


def main():
    plataforma = sys.platform
    if plataforma == "darwin" or plataforma.startswith("linux"):
        print tcolors.BK + '''

                         88                  ad88     ad88
                         88                 d8"      d8"
                         88                 88       88
                 ,adPPYb,88  88       88  MM88MMM  MM88MMM
                a8"    `Y88  88       88    88       88
                8b       88  88       88    88       88
                "8a,   ,d88  "8a,   ,a88    88       88
                 `"8bbdP"Y8   `"YbbdP'Y8    88       88

                ''' + tcolors.C + '''[!] Autor: backd0r  |  https://underc0de.org/foro/profile/backd0r/
                [!] Email: [email protected]
                [!] Version: 1.0
                ''' + tcolors.R + '''+++ Duff es una herramienta para generar
                archivos con contraseñas aleatorias en su totalidad +++''' + tcolors.N
        try:
            def inicio():
                while True:
                    print '''
1) Crear contraseñas complejas utilizando el archivo de caracteres.
2) Crear solo contraseñas de números.
3) Configurar archivo de caracteres.
4) Salir!
                            '''
                    option1 = raw_input(tcolors.C + "duff > " + tcolors.N)
                    while option1 == "3":  # Muestra menú 2
                        print '''
1) Crear archivo charset.
2) Cargar nueva sección de caracteres.
3) Ver el contenido del archivo de caracteres.
4) Regresar al menú anterior.
                            '''
                        option2 = raw_input(tcolors.C + "duff > " + tcolors.N)
                        if option2 == "1":  # Crear el charset.lst por defecto.
                            outfile = "charset.lst"

                            fileout = open(outfile, "w+")
                            lib = '''hexlower = 0123456789abcdef
hexupper = 0123456789ABCDEF

numeric = 0123456789
numericspace = 0 123456789

symbols = !@#$%^&*()-_+=
symbolsspace = !@#$%^&*( )=-_+

symbolsall = !@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
symbolsallspace = !@#$%^&*()-_+=~`[]{}|\:;"'< >,.?/

ualpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ
ualphaspace = ABCDEFGHIJKLMNOPQRSTUVWXY Z
ualphanumeric = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
ualphanumericspace = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789
ualphanumericsymbol = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=
ualphanumericsymbolspace = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!@#$%^&*()=-_+
ualphanumericall = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
ualphanumericallspace = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

lalpha = abcdefghijklmnopqrstuvwxyz
lalphaspace = abcdefghijklmnopqrstuvwxy z
lalphanumeric = abcdefghijklmnopqrstuvwxyz0123456789
lalphanumericspace = abcdefghijklmnopqrstuvwxyz 0123456789
lalphanumericsymbol = abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_+=
lalphanumericsymbolspace = abcdefghijklmnopqrstuvwxyz 0123456789!@#$%^&*()=-_+
lalphanumericall = abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
lalphanumericallspace = abcdefghijklmnopqrstuvwxyz 0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

mixalpha = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
mixalphaspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
mixalphanumeric = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
mixalphanumericspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
mixalphanumericsymbol = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=
mixalphanumericsymbolspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+
mixalphanumericall = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
mixalphanumericallspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

#############################
#  U S E R   O P T I O N S  #
#############################
'''
                            fileout.write(lib)
                            fileout.close()
                            print tcolors.R + "Espere por favor." + tcolors.N
                            print tcolors.R + "Listo, he creado charset.lst." + tcolors.N
                            time.sleep(2)
                            os.system("clear")
                        elif option2 == "2":  # Añadir contenido al charset.lst
                            print tcolors.R + '''
Para usar esta opción tienes que darme los valores de la siguiente forma:
    ''' + tcolors.C + '''       ej. duff > ''' + tcolors.N + '''minuevaseccion = AQUI LOS CARACTERES A USAR'''
                            print ""
                            line = raw_input(tcolors.C + "duff > " + tcolors.N) + "\n"
                            infile = "charset.lst"
                            if line != "\n":
                                filein = open(infile, "a")
                                filein.write(line)
                                filein.close()
                            else:
                                print ""
                                print tcolors.R + "Creo que no me has dado ningún valor." + tcolors.N
                                print tcolors.R + ":(" + tcolors.N
                                print ""
                                time.sleep(3)

                        elif option2 == "3":  # cat al archivo charset.lst
                            os.system("cat charset.lst")
                        elif option2 == "4":
                            os.system("clear")
                            main()
                            inicio()



                        else:
                            print ""
                            print tcolors.R + "Lo siento comando inválido." + tcolors.N
                            print tcolors.R + "Intentemos de nuevo." + tcolors.N
                            time.sleep(2)
                            os.system("clear")
                    if option1 == "1":
                        print ""
                        print tcolors.R + "[!] Cuántos caracteres quieres que tenga la contraseña?" + tcolors.N
                        print ""
                        digitos = int(raw_input(tcolors.C + "duff > " + tcolors.N))
                        print ""
                        print tcolors.R + "[!] Cuántas contraseñas quieres generar?" + tcolors.N
                        print ""
                        numpass = int(raw_input(tcolors.C + "duff > " + tcolors.N))
                        print ""
                        print tcolors.R + '''[!] Con que caracteres debo trabajar. (usa el charset.lst)''' + tcolors.G + '''
Ejemplo:
Si debo trabajar solo con letras mayusculas me das el siguiente valor.
    ''' + tcolors.C + '''       ej. duff > ''' + tcolors.N + ''' ualpha
    ''' + tcolors.N
                        print ""
                        charsec = raw_input(tcolors.C + "duff > " + tcolors.N)
                        print ""
                        print tcolors.R + "[!] Dame el nombre de tu archivo de salida? (*.txt)" + tcolors.N
                        print ""
                        passtxt = raw_input(tcolors.C + "duff > " + tcolors.N)
                        infile = "charset.lst"
                        with open(infile) as fileopen:
                            for line in fileopen:
                                if charsec in line:
                                    listas = line.split(" = ")
                                    charoptions = listas[0]
                                    if charoptions == charsec:
                                        chars = listas[1].rstrip("\n")
                                        file_ex = open(passtxt, "w")
                                        for i in range(numpass):
                                            creapass = ''.join([choice(chars) for i in range(digitos)]) + "\n"
                                            file_ex.write(creapass)
                                        file_ex.close()

                        print ""
                        print tcolors.R + "[!] Listo he generado tu archivo se llama: " + passtxt + tcolors.N
                        time.sleep(2)
                        os.system("clear")




                    elif option1 == "2":  # Crear solo contraseñas de numeros.
                        infile = "charset.lst"
                        charsec = "numeric"
                        print ""
                        print tcolors.R + "[!] Cuántos caracteres quieres que tenga la contraseña?" + tcolors.N
                        print ""
                        digitos = int(raw_input(tcolors.C + "duff > " + tcolors.N))
                        print ""
                        print tcolors.R + "[!] Cuántas contraseñas quieres generar?" + tcolors.N
                        print ""
                        numpass = int(raw_input(tcolors.C + "duff > " + tcolors.N))
                        print ""
                        print tcolors.R + "[!] Dame el nombre de tu archivo de salida? (*.txt)" + tcolors.N
                        print ""
                        passtxt = raw_input(tcolors.C + "duff > " + tcolors.N)
                        print ""
                        with open(infile) as fileopen:
                            for line in fileopen:
                                if charsec in line:
                                    listas = line.split(" = ")
                                    charoptions = listas[0]
                                    if charoptions == charsec:
                                        chars = listas[1].rstrip("\n")
                                        file_ex = open(passtxt, "w")
                                        for i in range(numpass):
                                            creapass = ''.join([choice(chars) for i in range(digitos)]) + "\n"
                                            file_ex.write(creapass)
                                        file_ex.close()
                                        print ""
                                        print tcolors.R + "[!] Listo he generado tu archivo se llama: " + passtxt + tcolors.N
                                        time.sleep(2)
                                        os.system("clear")



                    elif option1 == "4":
                        print ""
                        print "Gracias por usar Duff, hasta la proxima."
                        print ""
                        sys.exit(0)
                    else:
                        print ""
                        print tcolors.R + "Lo siento comando inválido." + tcolors.N
                        print tcolors.R + "Intentemos de nuevo." + tcolors.N
                        time.sleep(2)
                        os.system("clear")
                        main()
                        inicio()

            inicio()
        except KeyboardInterrupt:
            print ""
            print "Gracias por usar Duff, hasta la proxima."
            print ""
        except Exception:
            traceback.print_exc(file=sys.stdout)
        sys.exit(0)
    elif plataforma.startswith("win"):
                #Comieza script para windows
                os.system("color 7")
                print '''

             88                  ad88     ad88
             88                 d8"      d8"
             88                 88       88
     ,adPPYb,88  88       88  MM88MMM  MM88MMM
    a8"    `Y88  88       88    88       88
    8b       88  88       88    88       88
    "8a,   ,d88  "8a,   ,a88    88       88
     `"8bbdP"Y8   `"YbbdP'Y8    88       88

    [!] Autor: backd0r  |  https://underc0de.org/foro/profile/backd0r/
    [!] Email: [email protected]
    [!] Version: 1.0
    ++ Duff es una herramienta para generar
    archivos con passwords aleatorias en su totalidad +++'''
                try:
                    def inicio():
                        while True:

                            print '''
1) Crear passwords complejas utilizando el archivo de caracteres.
2) Crear solo passwords de numeros.
3) Configurar archivo de caracteres.
4) Salir!
                                    '''
                            option1 = raw_input("duff > ")
                            while option1 == "3":  # Muestra menú 2
                                print '''
1) Crear archivo charset.
2) Cargar nueva seccion de caracteres.
3) Ver el contenido del archivo de caracteres.
4) Regresar al menu anterior.
                                    '''
                                option2 = raw_input("duff > ")
                                if option2 == "1":  # Crear el charset.lst por defecto.
                                    outfile = "charset.lst"

                                    fileout = open(outfile, "w+")
                                    lib = '''hexlower = 0123456789abcdef
hexupper = 0123456789ABCDEF

numeric = 0123456789
numericspace = 0 123456789

symbols = !@#$%^&*()-_+=
symbolsspace = !@#$%^&*( )=-_+

symbolsall = !@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
symbolsallspace = !@#$%^&*()-_+=~`[]{}|\:;"'< >,.?/

ualpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ
ualphaspace = ABCDEFGHIJKLMNOPQRSTUVWXY Z
ualphanumeric = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
ualphanumericspace = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789
ualphanumericsymbol = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=
ualphanumericsymbolspace = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!@#$%^&*()=-_+
ualphanumericall = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
ualphanumericallspace = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

lalpha = abcdefghijklmnopqrstuvwxyz
lalphaspace = abcdefghijklmnopqrstuvwxy z
lalphanumeric = abcdefghijklmnopqrstuvwxyz0123456789
lalphanumericspace = abcdefghijklmnopqrstuvwxyz 0123456789
lalphanumericsymbol = abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_+=
lalphanumericsymbolspace = abcdefghijklmnopqrstuvwxyz 0123456789!@#$%^&*()=-_+
lalphanumericall = abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
lalphanumericallspace = abcdefghijklmnopqrstuvwxyz 0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

mixalpha = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
mixalphaspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
mixalphanumeric = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
mixalphanumericspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
mixalphanumericsymbol = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=
mixalphanumericsymbolspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+
mixalphanumericall = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/
mixalphanumericallspace = abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

#############################
#  U S E R   O P T I O N S  #
#############################
'''
                                    fileout.write(lib)
                                    fileout.close()
                                    print "Espere por favor."
                                    time.sleep(1)
                                    print "Listo, he creado charset.lst."
                                    time.sleep(2)
                                    os.system("cls")
                                elif option2 == "2":  # Añadir contenido al charset.lst
                                    print '''
    Para usar esta opcion tienes que darme los valores de la siguiente forma:
          ej. duff > minuevaseccion = AQUI LOS CARACTERES A USAR'''
                                    print ""
                                    line = raw_input("duff > ") + "\n"
                                    infile = "charset.lst"
                                    if line != "\n":
                                        filein = open(infile, "a")
                                        filein.write(line)
                                        filein.close()
                                    else:
                                        print ""
                                        print "Creo que no me has dado ningun valor."
                                        print ":("
                                        print ""
                                        time.sleep(3)

                                elif option2 == "3":  # cat al archivo charset.lst
                                    os.system("type charset.lst")
                                elif option2 == "4":
                                    os.system("cls")
                                    main()
                                    inicio()



                                else:
                                    print ""
                                    print "Lo siento comando invalido."
                                    print "Intentemos de nuevo."
                                    time.sleep(2)
                                    os.system("cls")
                            if option1 == "1":
                                print ""
                                print "[!] Cuantos caracteres quieres que tenga la contrasena?"
                                print ""
                                digitos = int(raw_input("duff > "))
                                print ""
                                print "[!] Cuantas passwords quieres generar?"
                                print ""
                                numpass = int(raw_input("duff > "))
                                print ""
                                print '''[!] Con que caracteres debo trabajar. (usa el charset.lst)
    Ejemplo:
    Si debo trabajar solo con letras mayusculas me das el siguiente valor.
          ej. duff > ualpha
            '''
                                print ""
                                charsec = raw_input("duff > ")
                                print ""
                                print "[!] Dame el nombre de tu archivo de salida? (*.txt)"
                                print ""
                                passtxt = raw_input("duff > ")
                                infile = "charset.lst"
                                with open(infile) as fileopen:
                                    for line in fileopen:
                                        if charsec in line:
                                            listas = line.split(" = ")
                                            charoptions = listas[0]
                                            if charoptions == charsec:
                                                chars = listas[1].rstrip("\n")
                                                file_ex = open(passtxt, "w")
                                                for i in range(numpass):
                                                    creapass = ''.join([choice(chars) for i in range(digitos)]) + "\n"
                                                    file_ex.write(creapass)
                                                file_ex.close()

                                print ""
                                print "[!] Listo he generado tu archivo se llama: " + passtxt
                                time.sleep(2)
                                os.system("cls")




                            elif option1 == "2":  # Crear solo contraseñas de numeros.
                                infile = "charset.lst"
                                charsec = "numeric"
                                print ""
                                print "[!] Cuantos caracteres quieres que tenga la password?"
                                print ""
                                digitos = int(raw_input( "duff > " ))
                                print ""
                                print "[!] Cuantas passwords quieres generar?"
                                print ""
                                numpass = int(raw_input( "duff > " ))
                                print ""
                                print "[!] Dame el nombre de tu archivo de salida? (*.txt)"
                                print ""
                                passtxt = raw_input( "duff > " )
                                print ""
                                with open(infile) as fileopen:
                                    for line in fileopen:
                                        if charsec in line:
                                            listas = line.split(" = ")
                                            charoptions = listas[0]
                                            if charoptions == charsec:
                                                chars = listas[1].rstrip("\n")
                                                file_ex = open(passtxt, "w")
                                                for i in range(numpass):
                                                    creapass = ''.join([choice(chars) for i in range(digitos)]) + "\n"
                                                    file_ex.write(creapass)
                                                file_ex.close()
                                                print ""
                                                print  "[!] Listo he generado tu archivo se llama: " + passtxt
                                                time.sleep(2)
                                                os.system("cls")



                            elif option1 == "4":
                                print ""
                                print "Gracias por usar Duff, hasta la proxima."
                                print ""
                                sys.exit(0)
                            else:
                                print ""
                                print  "Lo siento comando invalido."
                                print  "Intentemos de nuevo."
                                time.sleep(2)
                                os.system("cls")
                                main()
                                inicio()

                    inicio()
                except KeyboardInterrupt:
                    print ""
                    print "Gracias por usar Duff, hasta la proxima."
                    print ""
                except Exception:
                    traceback.print_exc(file=sys.stdout)
                sys.exit(0)

    else:
        print tcolors.R + "me perdí :(" + tcolors.N
        sys.exit(0)

if __name__ == "__main__":
    main()


Saludos!
backd0r

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Muy interesante tu aporte @No tienes permitido ver los links. Registrarse o Entrar a mi cuenta como mejora o complemento del código original.

Gracias.

Interesante modificacion, la verdad que se me hizo imposible poder mejorarlo por falta de tiempo, pero veo que te quedo genial. Gracias por compartirlo