Inicio
Buscar
Ingresar
Registrarse
Starfield: el juego que revolucionará el espacio y la tecnología
Hack x Crack - Comunidad de Seguridad informática
»
Programación
»
Scripting
»
Python
»
MD5HashMaster
Imprimir
Páginas: [
1
]
Ir Abajo
Autor
Tema: MD5HashMaster (Leído 3275 veces)
tatoluckyfox
universo infinito... curioso cuanto menos...
{ L2 } Nativo Digital
Mensajes: 119
¿Por qué subir, pudiendo bajar?
MD5HashMaster
«
en:
Septiembre 01, 2016, 01:37:03 pm »
Hola,
en esta ocasión os traigo un script que genera strings aleatorias de 8 caracteres de longitud y calcula su hash MD5, y las escribe a un archivo.
Es fácilmente modificable para que calcule también sha1, sha256, sha384 y sha512 ofrecidas por hashlib.
El formato es: string:md5hash
Este es el código:
Código: Python
#!/usr/bin/env python
#Autor: Tatoluckyfox
import
hashlib
import
random
ftw
=
open
(
"database.txt"
,
"w"
)
char
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
caracters
=
[
]
for
a
in
char:
caracters.
append
(
a
)
print
"[T] HashMaster MD5 Dicctionary Generator by Tatoluckyfox"
print
"[*] Current char: {}"
.
format
(
char
)
print
"[!] Working, stop this program with Ctrl+C"
try
:
while
True
:
f1
=
random
.
choice
(
caracters
)
;
f2
=
random
.
choice
(
caracters
)
;
f3
=
random
.
choice
(
caracters
)
;
f4
=
random
.
choice
(
caracters
)
;
f5
=
random
.
choice
(
caracters
)
;
f6
=
random
.
choice
(
caracters
)
;
f7
=
random
.
choice
(
caracters
)
;
f8
=
random
.
choice
(
caracters
)
;
generated
=
f1+f2+f3+f4+f5+f6+f7+f8
ftw.
write
(
"{}:{}"
.
format
(
generated
,
hashlib.
md5
(
generated
)
.
hexdigest
(
)
)
+
"
\n
"
)
except
KeyboardInterrupt
:
print
"[:)] Bye!"
El código me gusta bastante pero me gustaría mejorar el bloque de las líneas 19-23 para hacerlo mucho más compacto. Haced sugerencias, por favor.
Edito:
Código más eficiente más abajo
«
Última modificación: Septiembre 03, 2016, 09:30:34 am por Tatoluckyfox
»
En línea
b10s_0v3rr1d3
Administrador
{ L6 } Flooder del foro
Mensajes: 885
why not die?
Re:MD5HashMaster
«
Respuesta #1 en:
Septiembre 03, 2016, 01:08:11 am »
hi,
la parte que comentas 19-23, puedes usar para generarlas, funciones de 'itertools' que tienes en python que permiten generar todo el tema de combinaciones, permutaciones, etc...
si quieres el link hacia la info ->
link
nos leemos ;)
En línea
tatoluckyfox
universo infinito... curioso cuanto menos...
{ L2 } Nativo Digital
Mensajes: 119
¿Por qué subir, pudiendo bajar?
Re:MD5HashMaster
«
Respuesta #2 en:
Septiembre 03, 2016, 01:24:28 am »
Grax
En línea
tatoluckyfox
universo infinito... curioso cuanto menos...
{ L2 } Nativo Digital
Mensajes: 119
¿Por qué subir, pudiendo bajar?
Re:MD5HashMaster
«
Respuesta #3 en:
Septiembre 03, 2016, 09:28:12 am »
Muchísimas gracias b10s_0v3rr1d3, he dado con la tecla y ahora ha quedado mucho mejor.
Dejo aquí el código:
Código: Python
#!/usr/bin/env python
#Autor: Tatoluckyfox
import
hashlib
import
random
import
itertools
ftw
=
open
(
"database.txt"
,
"w"
)
char
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
caracters
=
[
]
#Funcion provista por https://docs.python.org/2/library/itertools.html Grax b10s_0v3rr1d3
def
random_combination
(
iterable
,
r
)
:
"Random selection from itertools.combinations(iterable, r)"
pool
=
tuple
(
iterable
)
n
=
len
(
pool
)
indices
=
sorted
(
random
.
sample
(
xrange
(
n
)
,
r
)
)
return
tuple
(
pool
[
i
]
for
i
in
indices
)
#---------------------------------------------------------------------
for
a
in
char:
caracters.
append
(
a
)
print
"[T] HashMaster MD5 Dicctionary Generator by Tatoluckyfox"
print
"[Disclaimer] Use it at your own risk!"
print
"[*] Current char: {}"
.
format
(
char
)
print
"[!] Working, stop this program with Ctrl+C"
try
:
while
True
:
generated
=
random_combination
(
caracters
,
8
)
# Donde 8 es la longitud, modificar al gusto
fully
=
""
for
letra
in
generated:
fully
=
fully + letra
ftw.
write
(
"{}:{}"
.
format
(
fully
,
hashlib.
md5
(
fully
)
.
hexdigest
(
)
)
+
"
\n
"
)
except
KeyboardInterrupt
:
print
"[:)] Bye!"
P.D: No modifico el anterior ya que funciona y es como la "beta" del programa.
En línea
Imprimir
Páginas: [
1
]
Ir Arriba
Hack x Crack - Comunidad de Seguridad informática
»
Programación
»
Scripting
»
Python
»
MD5HashMaster
Va un mudo y le dice a un sordo: Hack x Crack usa cookies. Pues eso...
OK
Learn more