aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Migrating from MLdonkey.  (Read 2695 times)

redleader

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
Migrating from MLdonkey.
« on: February 01, 2008, 05:40:41 PM »

I've compiled amule's last CVS version (30 january 2008) and since the daemon and gui seems to work quite well now, i want to give it a try.

Problem: I've been using mldonkey for a very long time and would like to keep my credits and downloaded file list.
So I have 2 questions:

1.- Keeping the credits:

From what I read, to keep my credits I need to use client_md4 and client_private_key info values from MLdonkey.

client_private_key seems to be easily used in amule just copying the value in cryptkey.dat, but I dont know exactly what to do with "client_md4".
I read somewhere that the other file in amule related with client info is preferences.dat, but I checked my current one in the amule directory and it doesnt look like what i have in client_md4.

client_md4 looks like "CE60F5BDExxxxxxxxxxxxxxxxxxxxxxx" (last chars replaced with x by me), while amule's preferences.dat has some strange chars.

Anyone knows how/where to put client_md4 info into amule?

2.- Keeping the list of downloaded files.
MLdonkey keeps the list of hashes from downloaded files in a text file.
Amule stores it in the known.met file (if im not mistaken) but it uses some other kind of binary format.
Can anyone give me some info on how the hashes are stored there, so I can try to make an app or something to convert the file?

Thanks in advance.

« Last Edit: February 01, 2008, 05:44:55 PM by redleader »
Logged

redleader

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
Re: Migrating from MLdonkey.
« Reply #1 on: February 02, 2008, 12:37:55 AM »

Just checked some code from amule and found out known.met files store more things than just the hash from the complete file  (like the hash for every part of the file, last modification date and a lot of tags that i dont even understand :D ).

So forget about point 2. Cant be done without having the downloaded files.

Still would love to get an answer for question 1 :D
Logged

skolnick

  • Global Moderator
  • Hero Member
  • *****
  • Karma: 24
  • Offline Offline
  • Posts: 1188
  • CentOS 6 User
Re: Migrating from MLdonkey.
« Reply #2 on: February 03, 2008, 04:22:16 PM »

Regarding 1, I think you just have to use the same userhash as with mldonkey, and you will be OK regarding your credits. For point 2, I wrote a little app that can display the contents of a known.met file. It will not modify it, just display its contents in a table.

Regards.
Logged

redleader

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
Re: Migrating from MLdonkey.
« Reply #3 on: February 04, 2008, 02:58:34 PM »

For point 1, I need both the userhash and the private key. Since I've been using secure id, if I try to use that userhash the other clients will ask me to identify myself using the private key. If I dont, the identification will fail and my credits wont be taken into account.

About point 2, I think that app of yours can help me to be sure of what the contents of met files are. Can you please tell me where to find it?

Thanks.
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: Migrating from MLdonkey.
« Reply #4 on: February 04, 2008, 03:43:57 PM »

redleader: Do you know some C++ (you need the ability to read it as well to write a little bit)?
Have a look at the file ClientCreditsList.cpp, there's the function CClientCreditsList::CreateKeyPair() starting in line 259 (current developmental version), which is probably used to create the key. You should be able to figure out how the cryptkey is created by reading the source there.
Logged

redleader

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
Re: Migrating from MLdonkey.
« Reply #5 on: February 04, 2008, 10:09:43 PM »

redleader: Do you know some C++ (you need the ability to read it as well to write a little bit)?
Have a look at the file ClientCreditsList.cpp, there's the function CClientCreditsList::CreateKeyPair() starting in line 259 (current developmental version), which is probably used to create the key. You should be able to figure out how the cryptkey is created by reading the source there.

I dont think I need to change anything there since the private key seems to be written in text in cryptkey.dat. I can just go there and replace it with "vi".

The problem is the userhash, that is stored in preferences.dat in some binary format and also that amule creates new userhashes following a pattern so it can be identified as an amule userhash, instead of just creating a random userhash as every other client does (except emule ofc).

So even if I make some changes to store my old MLdonkey userhash into amule, im not sure if it will break something with other amule users since my userhash wont follow the pattern I mentioned above.
Logged

skolnick

  • Global Moderator
  • Hero Member
  • *****
  • Karma: 24
  • Offline Offline
  • Posts: 1188
  • CentOS 6 User
Re: Migrating from MLdonkey.
« Reply #6 on: February 05, 2008, 02:57:11 AM »

Here's my little app:

http://pwp.etb.net.co/gpulido/javamet.jar

run it with: java -jar /path/to/javamet.jar

it will show the contents of some met files managed by amule.

And I do not understand your previous post. There is no "pattern" followed by amule to create the userhash, it's just a pseudo-random hash generated by amule when it starts. And to obtain it, you could do it just capturing with wireshark the traffic your amule produces when connecting to a server (not using obfuscation). Wireshark will decode the protocol data and give you the userhash. Then, you could analyze the preferences.dat file with hexdump and try to figure how is it sitred there.

Regards.
« Last Edit: February 05, 2008, 03:07:31 AM by skolnick »
Logged

redleader

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
Re: Migrating from MLdonkey.
« Reply #7 on: February 05, 2008, 12:57:41 PM »

What worries me is this:

Code: [Select]
void CPreferences::CreateUserHash()
{
for (int i = 0;i != 8; i++) {
uint16 random = rand();
memcpy(s_userhash.GetHash()+(i*2),&random,2);
}
// mark as emule client. that will be need in later version
s_userhash[5] = 14;
s_userhash[14] = 111;
}

The comment there says that the new userhashes created by amule will follow a pattern (its not completely random, or pseudo-random I think you called it). The problem is my old userhash (the one I'm bringing from MLdonkey) wont have those "marks".  The comment also says that those marks in the hash will be needed later.  I dont know how long that comment has been there, so if it was added (for example) 2 years ago, then the userhash marks might be needed now.

I found this, for example, at line 880 in Preferences.cpp:

This comes AFTER loading the userhash from the Preferences.dat file:

Code: [Select]
        LoadPreferences(); // Line 865

       ...   ....    ....    ...   ...
 
s_userhash[5] = 14; // Line 880
s_userhash[14] = 111;
if (s_userhash.IsEmpty()) {
CreateUserHash();
}

Im not sure why someone would want to modify the userhash after creating or loading it, since it should be correct, but the fact is that will end my effort to modify the userhash on the file with the one I got from MLdonkey.  Of course, I could modify this code too, but still I dont know if there are more places in the code where that happens or where the code tests that the userhash is "emulish".

PS: Thanks for javamet.jar
« Last Edit: February 05, 2008, 01:08:00 PM by redleader »
Logged

Xaignar

  • Admin and Code Junky
  • Hero Member
  • *****
  • Karma: 19
  • Offline Offline
  • Posts: 1103
Re: Migrating from MLdonkey.
« Reply #8 on: February 05, 2008, 03:01:41 PM »

Of course, I could modify this code too, but still I dont know if there are more places in the code where that happens or where the code tests that the userhash is "emulish".
Check "CUpDownClient::GetHashType()" in BaseClient.cpp
Logged

redleader

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
Re: Migrating from MLdonkey.
« Reply #9 on: February 05, 2008, 03:57:20 PM »

Will do, thanks.
Logged