Yet Another Brute Force Tool (mysql)

February 4, 2009

Desta vez foi a curiosidade que me levou a este brute… seguindo praticamente a mesma linha de todos os outros (no código em si), mas com um pouco de evolução, este brute force para hash de mysql (double SHA1) além de utilizar wordlist para o brute, adicionei uma opcao que transforma qualquer texto em hash no formato mysql… talvez seja inútil, mas vai saber… alguem pode precisar disso eheheh… 

smashed

 

 

 

 

 

 

 

 

 

 

 

MySQL double SHA1 hash wordlist brute forcer (mysqlsha1brute.py.txt) [download]

- This cracker works against hash created by MySQL to store passwords.

 

Baixando os sources do mysql e descompactando fiz um:

$ grep -ir "password" mysql-5.1.30/*

Que me levou ao arquivo “mysql-5.1.30/sql/password.c“ onde traz exatamente o que é preciso para replicar a função que gera o hash em si, repare que utiliza uma RFC (2289, 3174)  que padroniza o processo, segue abaixo um trecho do código…

/*
MySQL 4.1.1 password hashing: SHA conversion (see RFC 2289, 3174) twice
applied to the password string, and then produced octet sequence is
converted to hex string.
The result of this function is used as return value from PASSWORD() and
is stored in the database.
SYNOPSIS
make_scrambled_password()
buf OUT buffer of size 2*SHA1_HASH_SIZE + 2 to store hex string
password IN NULL-terminated password string
*/

void
make_scrambled_password(char *to, const char *password)
{
SHA1_CONTEXT sha1_context;
uint8 hash_stage2[SHA1_HASH_SIZE];

mysql_sha1_reset(&sha1_context);
/* stage 1: hash password */
mysql_sha1_input(&sha1_context, (uint8 *) password, (uint) strlen(password));
mysql_sha1_result(&sha1_context, (uint8 *) to);
/* stage 2: hash stage1 output */
mysql_sha1_reset(&sha1_context);
mysql_sha1_input(&sha1_context, (uint8 *) to, SHA1_HASH_SIZE);
/* separate buffer is used to pass 'to' in octet2hex */
mysql_sha1_result(&sha1_context, hash_stage2);
/* convert hash_stage2 to hex string */
*to++= PVERSION41_CHAR;
octet2hex(to, (const char*) hash_stage2, SHA1_HASH_SIZE);
}

 
Opção que adicionei na tool (inútil? eheheh):

$ ./mysqlsha1brute.py -t darkc0de
[*] MySQL double SHA1 hasher (by thebug)
[*] word: darkc0de
[*] hash: *E742BF513935907CB8E6DA91CCB4217BC4702AF6

 

Como utilizar?

$ ./mysqlsha1brute.py -H *850AD02B26C1626F64E7D28390E103EC7034C573 -w wordlist.txt
[*] MySQL double SHA1 hash brute force (by thebug)
[*] hash: *850AD02B26C1626F64E7D28390E103EC7034C573
[*] 3107 word(s) loaded.
[*] brute force started.
[*] got it!
[*] password is: gandalf

 

Espero que a tool tenha alguma utilidade para os esquecidos de plantão e simpatizantes…

Enjoy! ;)

4 Responses to “Yet Another Brute Force Tool (mysql)”

  1. Fernando Ike Says:

    Creio que para olhar um código, não necessariamente você aponta para /tmp, certo? Eu tiraria ele dali no seu grep password. ;)

  2. guto Says:

    Bacana a tool Ulisses, parabéns ;)

    []’s
    Guto

  3. Marcio P. Says:

    Fala cara, bele? tava precisando de um brute force pra hash do mysql, perguntei ao google e aqui estou.. o problema eh q nao tenho um box linux pra rodar isso ae, voce nao teria uma versao windows x86? te agradeceria muito pois preciso disso pra defesa do meu trabalho de conclusao de curso… fico no aguardo o email tai.. valeu ae =)


Leave a Reply