Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decrypt password created with htpasswd

I created a protection for my web pages with apache2 in ubuntu. Now I am creating an application in c++ and I want it uses the same file that Apache2 uses for authentification, but my problem is that I don't know how to decrypt the password generated by apache2. (Maybe I need a key that is used for encryption).

Thank you.

like image 440
Mils Avatar asked Nov 11 '12 02:11

Mils


People also ask

Can you decrypt htpasswd?

htpasswd entries are HASHES. They are not encrypted passwords. Hashes are designed not to be decryptable.

How does htpasswd encryption work?

It can encrypt and display password information for use in other types of data stores, though. To use a DBM database see dbmmanage or htdbm . htpasswd encrypts passwords using either bcrypt, a version of MD5 modified for Apache, SHA1, or the system's crypt() routine.

What hash does htpasswd use?

htpasswd hashes passwords using either bcrypt, a version of MD5 modified for Apache, SHA-1, or the system's crypt() routine.


2 Answers

.htpasswd entries are HASHES. They are not encrypted passwords. Hashes are designed not to be decryptable. Hence there is no way (unless you bruteforce for a loooong time) to get the password from the .htpasswd file.

What you need to do is apply the same hash algorithm to the password provided to you and compare it to the hash in the .htpasswd file. If the user and hash are the same then you're a go.

like image 181
Sani Singh Huttunen Avatar answered Oct 24 '22 10:10

Sani Singh Huttunen


See in particular Apache HTTPd Password Formats

like image 7
David Tonhofer Avatar answered Oct 24 '22 10:10

David Tonhofer