Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[Important] Prevent SQL injection with E
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

Unknown User
2019-09-08 19:42:47
This is based on Demonoid's email change recovery. I tried to create a similar method they use for the secret key which is 64 characters long.

Right now there is a SQL injection into account-ce.php which has the following build:

$id = (int) $_GET["id"];
$md5 = $_GET["secret"];
$email = $_GET["email"];


So the url [ICODE]/account-ce.php?id=1&secret=1bd58e7017f3661a5b32bb66b352fea7&email=new_admin_mail@mail.com[/ICODE] will change the admin email and give access to the attacker to the admin mail which they can reset via password reset.

secret is generated by[ICODE] md5($email)[/ICODE] which can easily be decrypted.
--------------------------------

My fix is instead of generating email hash via md5, to generate a really strong cryptographically secure key.

1. Go to database, users -> change column 'edit_secret' and set varchar to 64.

2. Find the following in the account.php -
if ($changedemail) {
               $sec = mksecret();
               $hash = md5($sec . $email . $sec);
               $obemail = rawurlencode($email);
               $updateset[] = "editsecret = " . sqlesc($sec);
               $thishost = $_SERVER["HTTP_HOST"];
               $thisdomain = preg_replace('/^www\./is', "", $thishost);
$body = <<<EOD
You have requested that your user profile (username {$CURUSER["username"]})
on {$site_config["SITEURL"]} should be updated with this email address ($email) as
user contact.
If you did not do this, please ignore this email. The person who entered your
email address had the IP address {$_SERVER["REMOTE_ADDR"]}. Please do not reply.
To complete the update of your user profile, please follow this link:
{$site_config["SITEURL"]}/account-ce.php?id={$CURUSER["id"]}&secret=$hash&email=$obemail
Your new email address will appear in your profile after you do this. Otherwise
your profile will remain unchanged.
EOD;
               sendmail($email, "$site_config[SITENAME] profile update confirmation", $body, "From: $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
               $mailsent = 1;
           } //changedemail


Replace with: -

// Here we generate a cryptographically secure key via random_bytes
 function crypt_secret(int $length = 64){ // 64 = 32
       $length = ($length < 4) ? 4 : $length;
       return bin2hex(random_bytes(($length-($length%2))/2));
   }

// Here we get the new hash method
if ($changedemail) {
               $hash = crypt_secret();
               $obemail = rawurlencode($email);
               $updateset[] = "editsecret = " . sqlesc($hash);
               $thishost = $_SERVER["HTTP_HOST"];
               $thisdomain = preg_replace('/^www\./is', "", $thishost);
$body = <<<EOD
You have requested that your user profile (username {$CURUSER["username"]})
on {$site_config["SITEURL"]} should be updated with this email address ($email) as
user contact.
If you did not do this, please ignore this email. The person who entered your
email address had the IP address {$_SERVER["REMOTE_ADDR"]}. Please do not reply.
To complete the update of your user profile, please follow this link:
{$site_config["SITEURL"]}/account-ce.php?id={$CURUSER["id"]}&secret=$hash&email=$obemail
Your new email address will appear in your profile after you do this. Otherwise
your profile will remain unchanged.
EOD;
               sendmail($email, "$site_config[SITENAME] profile update confirmation", $body, "From: $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
               $mailsent = 1;
           } //changedemail


3. Open account-ce.php
Find [ICODE]if ($md5 != md5($sec . $email . $sec)) [/ICODE]
Replace with [ICODE]if ($md5 != $sec)[/ICODE]
Unknown User
2019-09-08 21:27:43
Have you tested this is actually a problem because for me i am having difficulty making the flaw work. By looking at the write it, it means the editsecret column must be empty, but in the version 2.08 i have seen we check to prevent that from being empty.
Unknown User
2019-09-08 22:25:53
"mostvotedplaya, post: 67192, member: 20335":

Have you tested this is actually a problem because for me i am having difficulty making the flaw work. By looking at the write it, it means the editsecret column must be empty, but in the version 2.08 i have seen we check to prevent that from being empty.

Edit_secret is defined when you change email in account.php form. Once you receive email and update the new email from mail link, edit secret is removed for security reasons that no one else from outside can generate email change.
Unknown User
2019-09-09 16:30:48
If i remember correctly this is already patched in v2.08-FINAL by myself

[ATTACH type="full" alt="5166"]5166[/ATTACH]

As you can see in the image, the edit secret cannot be empty which means the secret will never just match md5(email)
Screen Shot 2019-09-09 at 17.26.45.png
Screen Shot 2019-09-09 at 17.26.45.png
Unknown User
2019-09-09 17:30:08
It won't work with mksecret + $email if you use it with encrypt email mod from [USER=20288]@m-jay[/USER]
Unknown User
2019-09-09 17:34:48
That is a issue that he would have to resolve, but in terms of the exploit that was available here that was resolved.
Unknown User
2019-09-09 21:35:17
"mostvotedplaya, post: 67201, member: 20335":

That is a issue that he would have to resolve, but in terms of the exploit that was available here that was resolved.

I still prefer pseudo-crypto hash rather than mksecret which is based on loop + mt_rand
2019-09-10 04:32:49
I removed all md5, in theory you should be able to change functions mksecret and the passhash md5 with a new algorithm
Then it's a case of changing in text editor all md5 to new crypt and mksecret to new cyrpt function.

Some vars are named $md5
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728