Anope IRC Services

Anope Support => 1.8.x/1.7.x Support (Read Only) => Topic started by: Greg on November 25, 2009, 03:52:19 AM

Title: [SOLVED] Read md5'd passwords from mysql
Post by: Greg on November 25, 2009, 03:52:19 AM
Hi all

I'm trying to set up something on my Web site with very basic Anope integration and I'm having trouble with nickname passwords.

I have EncModule set to enc_md5 (so not the broken md5) and MysqlSecure unset.

When I try something basic like:
SELECT * FROM anope_ns_core WHERE pass = md5('blahblahblah')
where blahblahblah is the password of my nickname, it returns zero rows.

What's the correct way to compare Anope passwords using sql?

Also- is the nc_id number given to each nickname group in the anope_ns_core table a constant number, ie. if I wipe the Anope mysql database and then update the databases, will each user's nc_id number be the same as it was before?

Cheers.
Title: Re: Read md5'd passwords from mysql
Post by: Jobe on November 25, 2009, 02:51:43 PM
If I'm not mistaken, Anope stores the raw MD5 hash of the password NOT the hex encoded MD5 hash that people associate with MD5. So I dont know about in the SQL query itself, but to get the raw MD5 hash in PHP you would use $rawmd5 = md5($password, true);

I dont know the answer to your nc_id problem though sorry. But I can tell you as far as I know, every time Anope writes to MySQL it DOES wipe the DB anyway.
Title: Re: Read md5'd passwords from mysql
Post by: Trystan Scott Lee on November 25, 2009, 08:47:22 PM
Anope stores a md5 hash into sql, thus all md5 functions from php to sql will not work. There are many examples and snippets around that will do what anope does. Search sf.net and you can find

http://sourceforge.net/projects/phpanopemd5/

which is a php script to handle hashing an md5 like anope
Title: Re: Read md5'd passwords from mysql
Post by: Greg on November 26, 2009, 03:58:55 AM
Thanks for the replies, much appreciated.

I've done a bit of experimenting and it seems that the nc_id's remain constant unless the table is wiped by myself, so I'll just have to remember to back up Anope's mysql database rather than let Anope repopulate it by itself if I ever move servers or something.

I've been able to get passwords to match by using md5('whatever', true) in PHP and LEFT(pass, 16) in mysql, it's a little messy but it does the job.