Reversing an algorithm?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thekid
    New Member
    • Feb 2007
    • 145

    Reversing an algorithm?

    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:
    Code:
    <?php
    
          //------------------------------------------------------------------------------------
          function evalCrossTotal($strMD5)
          {
              $intTotal = 0;
              $arrMD5Chars = str_split($strMD5, 1);
              foreach ($arrMD5Chars as $value)
              {
                  $intTotal += '0x0'.$value;
              }
              return $intTotal;
          }//-----------------------------------------------------------------------------------
    
    
    
          //------------------------------------------------------------------------------------
          function encryptString($strString, $strPassword)
          {
              // $strString is the content of the entire file with serials
              $strPasswordMD5 = md5($strPassword);
              $intMD5Total = evalCrossTotal($strPasswordMD5);
              $arrEncryptedValues = array();
              $intStrlen = strlen($strString);
              for ($i=0; $i<$intStrlen; $i++)
              {
                  $arrEncryptedValues[] =  ord(substr($strString, $i, 1))
                                           +  ('0x0' . substr($strPasswordMD5, $i%32, 1))
                                           -  $intMD5Total;
                  $intMD5Total = evalCrossTotal(substr(md5(substr($strString,0,$i+1)), 0, 16)
                                           .  substr(md5($intMD5Total), 0, 16));
              }
              return implode(' ' , $arrEncryptedValues);
          }//-----------------------------------------------------------------------------------
    
        ?>
    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
  • Thekid
    New Member
    • Feb 2007
    • 145

    #2
    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.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, TheKid.

      Care to tell us why you want to crack this encryption algorithm?

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        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!)

        Comment

        Working...