0

I want to make a PHP script for decoding a jQuery script.

$('#kustom').append(jQuery.dec("U2FsdGVkX1//1HRj/CjenuJJZTO6lLC6jDX5MSh4S/Ike7H0t6pdFWtyGEJ69bIgvVsg8q42h6ydE+sxt9FNHjsTc+PWzvpXmOUdZzkijM73KGAjmGnGzYdKouVrq0GAOWAiX5GB3mC/iL0GLHIm5fO1M9j1SIEdYlgp+5tMQOLHKIKHrwBgmbo1pb2gL50WWHkWEGCZdjmPj+igPHw5Sg8RJiq1vxU5DNzTC2Ysdh3qKjew8I2OrGq8Ys6dzwseGTLNmaN399PZyVx5V+lfnoT3O8BO3zMheChLjsWLYPbsdjsOL7nj1IKSGCoXhV3wmu2aNxvank8v6sQW5BW42Nzwj166dxT5Voa3mFJbla7QgCM7QWR8DPrY32BMTUo6cfITnSwxtIhrRYIsNN4ZBUgPGdrHDU2lPCZL0sztWut7byPRrLtQoCi3yD81NrzuMnjWMDT4W4YEZwPLu0OtnNdFUp9qw/qAALxYbhwXxUpYfSmuP/vb1Mg/bOFZSAjZfSNznZndvkh9/AGsogAvRCbdixjI+RxrNrNUiBftAeFH0yp9iD47SnXu+QiDHea2ZJwSRNz6jNkpyOrHyTx6HAduekqdS8jxLiOj3CyKgDCx10Aks17cRT27IChj0QwG7IGfQJ8Zz2eyxuz5QmMJkjBnH7DvDsF7CAEsGB/QYxbCHHYE6GEt3ESMGj4phCDNq2nm0VcP6fOKO/Ow+8OrUNty0h4wzm1s2fWB1+1zg4E=", "38riuBP"));

Check this for better understand http://jsfiddle.net/0sx7rd9u/

That's the code which creates an image and an input field only associated with the jQuery file. Any way to decode it via PHP?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • It is not a standard jquery's function - somebody added additional code (follows after `A.jQuery=A.$=c})(window);`) to the attached `jquery-1.4.2.min.js` file. – Cheery Nov 19 '14 at 18:31
  • i need to convert this to php, any way to make a file_get_contents and then get the code wich will be the result of the jquery – Marco Siegfried Nov 19 '14 at 18:36
  • This is a part responsible for decoding. I do not think that anybody would be interested in conversion of the code to php form - http://pastebin.com/T7mec0qK – Cheery Nov 19 '14 at 18:38

1 Answers1

1

Ok, I can tell you how to do it with command line, but you have to find php implementation by yourself. It is encrypted with openssl library. Save the data into the file as

file_put_contents('encfile.txt', base64_decode($str)); // $str is encoded data

After that you can do the following in the shell

openssl aes-256-cbc -d -in encfile.txt -out decfile.txt

It will ask you for the password (38riuBP) and decoded content will be in decfile.txt. There are a few topics related to the decoding of the openssl encoded data, you have to test and to choose the working one.

Decrypt File Made With PHP openssl_encrypt on Command Line

How to make Ruby AES-256-CBC and PHP MCRYPT_RIJNDAEL_128 play well together

PHP Encrypt Data, Bash Decrypt it

and so on and so on..

ps: you are lucky. this code works

echo decrypt($key, $str);

function decrypt($password, $edata) {

    $data = base64_decode($edata);
    $salt = substr($data, 8, 8);
    $ct = substr($data, 16);
    /**
     * From https://github.com/mdp/gibberish-aes
     *
     * Number of rounds depends on the size of the AES in use
     * 3 rounds for 256
     *        2 rounds for the key, 1 for the IV
     * 2 rounds for 128
     *        1 round for the key, 1 round for the IV
     * 3 rounds for 192 since it's not evenly divided by 128 bits
     */
    $rounds = 3;
    $data00 = $password.$salt;
    $md5_hash = array();
    $md5_hash[0] = md5($data00, true);
    $result = $md5_hash[0];
    for ($i = 1; $i < $rounds; $i++) {
      $md5_hash[$i] = md5($md5_hash[$i - 1].$data00, true);
        $result .= $md5_hash[$i];
    }
    $key = substr($result, 0, 32);
    $iv  = substr($result, 32,16);

    return openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv);
}
Community
  • 1
  • 1
Cheery
  • 16,063
  • 42
  • 57