htpasswd decrypt

19,610 views
Skip to first unread message

Miguel González Castaños

unread,
Jun 18, 2010, 1:08:59 PM6/18/10
to pen-...@securityfocus.com
Hi all,

For a hack lab in that I'm doing I reach a point where I get a
htpasswd file in clear in an Apache server.

Is there any tool that given the crypted password I can try to brute
force (or use a dictionary attack) and get the original password? There
are a lot of MD5 password crackers but they don't state if they work for
htpasswd generated passwords.

Thanks!

Miguel

------------------------------------------------------------------------
This list is sponsored by: Information Assurance Certification Review Board

Prove to peers and potential employers without a doubt that you can actually do a proper penetration test. IACRB CPT and CEPT certs require a full practical examination in order to become certified.

http://www.iacertification.org
------------------------------------------------------------------------

dishix

unread,
Jun 19, 2010, 8:42:37 AM6/19/10
to Miguel González Castaños, pen-...@securityfocus.com
Hi Miguel,

have you tried 'John the Ripper'?
http://www.openwall.com/john/

Best regards
dishix

Jacky Jack

unread,
Jun 19, 2010, 10:05:20 AM6/19/10
to Miguel González Castaños, pen-...@securityfocus.com
I haven't been aware of it, too.
If you know it, let me know.

It's not easy to write bruteforce decryptor as it generates new
password each time upon generation.

>./htpasswd -nb test test
Automatically using MD5 format.
test:$apr1$O9B501zi$LIb3jgek2pqVEv29qfCqO0


>./htpasswd -nb test test
Automatically using MD5 format.
test:$apr1$Rekfkt5.$8NeNTA7C/Oy4jEuCgrnBE/


>./htpasswd -nb test test
Automatically using MD5 format.
test:$apr1$PEH.OBdt$wE/nHRG.FYo2bzmAfxfIn1


>./htpasswd -nb test test
Automatically using MD5 format.
test:$apr1$BtwEARib$2WWdK3nGlAWVutTRkFyV20


2010/6/18 Miguel González Castaños <miguel_3...@yahoo.es>:

modversion

unread,
Jun 19, 2010, 10:06:39 PM6/19/10
to Jacky Jack, Miguel González Castaños, pen-...@securityfocus.com
You can try l0phtcrack.
check http://baoz.net/crack-htpasswd-with-l0phtcrack/ for details

-----邮件原件-----
发件人: listb...@securityfocus.com [mailto:listb...@securityfocus.com] 代表 Jacky Jack
发送时间: 2010年6月19日 22:05
收件人: Miguel González Castaños
抄送: pen-...@securityfocus.com
主题: Re: htpasswd decrypt

> -- This list is sponsored by: Information Assurance Certification

Christine Kronberg

unread,
Jun 20, 2010, 6:10:43 AM6/20/10
to Jacky Jack, Miguel González Castaños, pen-...@securityfocus.com

Hi,


> I haven't been aware of it, too.
> If you know it, let me know.

Why don't you just try? Took me less than two minutes:

home template # htpasswd -cbm testfile test test
Adding password for user test

home template # cat testfile
test:$apr1$qgW5z/..$7Y85TQKs.nBK6GbO.VqfK/

home template # john testfile
Created directory: /root/.john
Loaded 1 password hash (Apache MD5 [32/32])
test (test)
guesses: 1 time: 0:00:00:00 100% (1) c/s: 25.00 trying: test

So the answer is: yes, it works.

Cheers,

Christine Kronberg.

Gaurav Kumar

unread,
Jun 20, 2010, 10:48:32 AM6/20/10
to Jacky Jack, Miguel González Castaños, pen-...@securityfocus.com
Following lines from the source code confirm this (different password being generated each time)

(void) srand((int) time((time_t *) NULL));
ap_to64(&salt[0], rand(), 8);

It seems that time based seed is used to generate MD5 hash. Also, according to source, "salt" is char array and is 8 bytes long (+1 null byte). If you want to bruteforce password, you will need to bruteforce these 8 bytes too
---
Gaurav Kumar, CISSP
Email:g...@pivotalsecurity.com| Phone: +1 (425) 686-9695 |Web: www.pivotalsecurity.com

> -- This list is sponsored by: Information Assurance Certification

Miguel Gonzalez

unread,
Jun 20, 2010, 10:48:55 AM6/20/10
to Jacky Jack, Christine Kronberg, pen-...@securityfocus.com
My fault, I was following some more complicated instructions

Thanks,

Miguel

--- El dom, 20/6/10, Christine Kronberg <see...@shalla.de> escribió:

Miguel González Castaños

unread,
Jun 20, 2010, 7:49:32 PM6/20/10
to Gaurav Kumar, Jacky Jack, pen-...@securityfocus.com
On 20/06/2010 16:48, Gaurav Kumar wrote:
> Following lines from the source code confirm this (different password being generated each time)
>
> (void) srand((int) time((time_t *) NULL));
> ap_to64(&salt[0], rand(), 8);
>
> It seems that time based seed is used to generate MD5 hash. Also, according to source, "salt" is char array and is 8 bytes long (+1 null byte). If you want to bruteforce password, you will need to bruteforce these 8 bytes too
> ---
> Gaurav Kumar, CISSP
> Email:g...@pivotalsecurity.com| Phone: +1 (425) 686-9695 |Web: www.pivotalsecurity.com
>
Thank you everybody :)

John did the trick

Thanks

Miguel

Paul Melson

unread,
Jun 21, 2010, 6:47:41 AM6/21/10
to Jacky Jack, Miguel González Castaños, pen-...@securityfocus.com
2010/6/19 Jacky Jack <jackson...@gmail.com>:

> It's not easy to write bruteforce decryptor as it generates new
> password each time upon generation.

The salted hashes are only a challenge if you don't have the salt,
like in the case of generating rainbow tables.

> 2010/6/18 Miguel González Castaños <miguel_3...@yahoo.es>:
>> Hi all,
>>
>>  For a hack lab in that I'm doing  I reach a point where I get a htpasswd
>> file in clear in an Apache server.

However, the original poster has captured the file, and therefore has
the full salt and hash. So a brute-force or dictionary attack against
the captured hash using any number of the tools already mentioned in
this thread will work just fine.

PaulM

Reply all
Reply to author
Forward
0 new messages