Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: [SOLVED] Read md5'd passwords from mysql  (Read 9186 times)

0 Members and 1 Guest are viewing this topic.

Greg

  • Anope User
  • Offline Offline
  • Posts: 3
[SOLVED] Read md5'd passwords from mysql
« 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.
« Last Edit: November 26, 2009, 03:59:19 AM by Greg »
Logged

Jobe

  • Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1023
    • Anope IRC Services
Re: Read md5'd passwords from mysql
« Reply #1 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.
Logged
Your IP: ()
My IRC Status:

Come along and visit http://www.anopequotes.org/

Trystan Scott Lee

  • Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 343
Re: Read md5'd passwords from mysql
« Reply #2 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
Logged
my God my tourniquet, return to me salvation

Greg

  • Anope User
  • Offline Offline
  • Posts: 3
Re: Read md5'd passwords from mysql
« Reply #3 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.
Logged
Pages: [1]   Go Up