By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

Reversing an algorithm?

Thekid
100+
P: 145
Is it difficult to reverse an algorithm in php? There is an example of what the encrypted text looks like below it and an example of how it should print out. Or could I get some kind of explanation on what the code is doing? Thanks

The PHP-code which is used for the encryption:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.       //------------------------------------------------------------------------------------
  4.       function evalCrossTotal($strMD5)
  5.       {
  6.           $intTotal = 0;
  7.           $arrMD5Chars = str_split($strMD5, 1);
  8.           foreach ($arrMD5Chars as $value)
  9.           {
  10.               $intTotal += '0x0'.$value;
  11.           }
  12.           return $intTotal;
  13.       }//-----------------------------------------------------------------------------------
  14.  
  15.  
  16.  
  17.       //------------------------------------------------------------------------------------
  18.       function encryptString($strString, $strPassword)
  19.       {
  20.           // $strString is the content of the entire file with serials
  21.           $strPasswordMD5 = md5($strPassword);
  22.           $intMD5Total = evalCrossTotal($strPasswordMD5);
  23.           $arrEncryptedValues = array();
  24.           $intStrlen = strlen($strString);
  25.           for ($i=0; $i<$intStrlen; $i++)
  26.           {
  27.               $arrEncryptedValues[] =  ord(substr($strString, $i, 1))
  28.                                        +  ('0x0' . substr($strPasswordMD5, $i%32, 1))
  29.                                        -  $intMD5Total;
  30.               $intMD5Total = evalCrossTotal(substr(md5(substr($strString,0,$i+1)), 0, 16)
  31.                                        .  substr(md5($intMD5Total), 0, 16));
  32.           }
  33.           return implode(' ' , $arrEncryptedValues);
  34.       }//-----------------------------------------------------------------------------------
  35.  
  36.     ?>
  37.  
Example of encrypted text:
-176 -199 -123 -173 -94 -204 -165 -162 -159 -143 -155 -174 -134 -215 -139 -206 -104 -232 -203 -200 -141 -119 -146 -183 -210 -180 -192 -178 -169 -151 -138 -152 -206 -146 -160 -155 -206 -210 -179 -215 -190 -153 -172 -247 -173 -180 -142 -157 -115 -167 -155 -178 -176 -161 -179 -167 -205 -185 -186 -257 -192 -119 -166 -193 -187 -208 -178 -166 -184 -189 -170 -177 -89 -148 -154 -188 -197 -189 -144 -240 -153 -170 -179 -171 -171 -148 -108 -193 -173 -171 -166 -198 -128 -122 -166 -200 -227 -151 -186 -247

This is how it should print out:
99Z-KH5-OEM-240-1.1
QGG-V33-OEM-0B1-1.1
Z93-Z29-OEM-BNX-1.1
IQ0-PZI-OEM-PK0-1.1
UM4-VDL-OEM-B9O-1.1
L0S-4R2-OEM-UQL-1.1
JBL-EYQ-OEM-ABB-1.1
NL1-3V3-OEM-L4C-1.1
7CQ-1ZR-OEM-U3I-1.1
XX0-IHL-OEM-5XK-1.1
KJQ-RXG-OEM-TW8-1.1
OZR-LW1-OEM-5EM-1.1
0B8-6K5-OEM-EFN-1.1
OE2-20L-OEM-SSI-1.1
0ME-HAE-OEM-9XB-1.1
Sep 19 '08 #1
Share this Question
Share on Google+
3 Replies


Thekid
100+
P: 145
Ok, so I guess it's not about reversing the algorithm as I was initially told, it's more about brute forcing it:
Be assured, you can't reverse this. It's basically a big binary tree with a lot of "dead branches" (impossible combinations). Since this can be solved with the right hash, that will be your goal, then everything else is plugged in to the algorithm(given). For that hash, looping is not what needs to be done though, think of an alternative.
Take a good look at how the sample output file is structured and use it to eliminate dead ends in your brute forcing.
Sep 19 '08 #2

pbmods
Expert 5K+
P: 5,821
Heya, TheKid.

Care to tell us why you want to crack this encryption algorithm?
Sep 19 '08 #3

RedSon
Expert 5K+
P: 5,000
I'm not sure I quite understand what you are looking to do. md5 is considered a "one-way" hash so it is impossible to reverse or break without some kind of rainbow table. You should read up on md5 on wikipedia or something so you have an idea what you are looking at.

Unless I missed the whole point of the post...(it could happen!)
Sep 19 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.