Blog of The SJG

Saturday, February 04, 2006

PHP: Protecting your code (Zend Encoder/IonCube/SourceCop)

SourceCop Decoder

Personally, I have never found need to encode/encrypt/obfuscate any PHP. I do however know that there is a large audience of developers and/or organizations out there that do rely on such obfuscation to protect their works. Not being sure if it has hit the news or not, as I have been too busy of late to even open up my RSS aggregator to skim the headlines, know that there is at least one service in the wild that can successfully decode Zend Encoder and IonCube encoded files. It's not perfect by any means, as it is reconstructing the code based on the opcodes, but it does return it in a format that is true to the original as far as execution and reasonably easy for a human to parse.

I wrote this little number the other day after running across a script I was wanting to use, in which one component was obviously dependant upon register_globals. My gosh, if I only had the code I could fix that! Fortunately it was obfuscated with an application called SourceCop, which provides very little in the way of protection. Come on guys, you could at least obfuscate the code itself first, munging whitespace, variable and function names. As it was, it took a mere 20 minutes to write a script that would replace an encoded file with a pristine copy of the original. At any rate, here is the script, do note that it was a quick hack and as such it may or may not work for you. It will also simply overwrite any SourceCop encoded files fed to it, so you will want to create a backup first, you have been warned.

Update: 2/23/2006, revised script

17 Comments:

  • How do you get your Sourcecop script to actually work? Whatever I tried I was unable to get this script to even attempt to spit out de-sourcecop'ed code...

    By Anonymous Anonymous, at 3:29 AM  

  • This comment has been removed by a blog administrator.

    By Blogger sjg, at 8:07 AM  

  • Hi there, I too am having difficulty operating your code, could you possible post how to feed a file to it.

    thanks

    By Anonymous Anonymous, at 10:29 AM  

  • That is great work! I think that those who use these methods to protect their work should actually support that work if they want it to continue to have value.
    If they leave customers high and dry they should expect necessity to drive the need for change and modification with their help or in spite of the lack of it. Bravo!

    By Anonymous Anonymous, at 9:58 AM  

  • How can I get the getopt() function to work on a windows machine, or even run it on a hosted linux server?

    By Anonymous Anonymous, at 9:33 PM  

  • I don't think this is for windows based systems linux only

    I have tried but get can read file all the time

    By Anonymous Anonymous, at 10:14 PM  

  • hey can you please explain me how to use this script please? im having troubles with a client website and i dont know where to get help, ill apreciate any help from yours! God Bless you!

    By Blogger Unknown, at 4:05 AM  

  • the script did not work.

    PHP Notice: Undefined offset: 0 in /srv/www/htdocs/super-domain.net/login/decode.php on line 46

    - no output.

    By Anonymous Anonymous, at 5:39 AM  

  • Dummy solution for windows platforms:

    replace
    $options = getopt('f:');
    with
    // $options = getopt('f:');
    $options['f']='file.php';
    // where file.php is the file you want to decode.

    Damn, i'm gettin busy searching for a good encoder, belive or not, the "best" (no decoder found yet)TrueBug PHP Encoder, is http://www.truebug.com/. I'm 100% sure that is not decodable yet because nobody really tried to decode it.

    By Anonymous Anonymous, at 5:17 AM  

  • Simply change the last line eval to highlight_string and the souce code will be shown to you.

    for example:

    change:

    eval(y0666f0acdeed38d4cd9084ade1739498('0B4D11779BA2E22C 7',$REXISTHEDOG4FBI));

    to

    highlight_string(y0666f0acdeed38d4cd9084ade1739498('0B4D11779BA2E22C 7',$REXISTHEDOG4FBI));

    By Anonymous Anonymous, at 5:51 AM  

  • Look for something similar like this, and put this one its own line and commend it out, and change the last line eval to highlight_string as described in previous post, you will get the souce code.

    // g0666f0acdeed38d4cd9084ade1739498(f0666f0acdeed38d4cd9084ade1739498(__FILE__));

    By Anonymous Anonymous, at 6:20 AM  

  • Look for something similar like this, and put this one its own line and commend it out, and change the last line eval to highlight_string as described in previous post, you will get the souce code.

    g0f0ade1739498(f0666f498(__FILE__));
    (line was shorten so it will appear on the post)

    By Anonymous Anonymous, at 6:23 AM  

  • Look for something similar like this, and put this one its own line and commend it out, and change the last line eval to highlight_string (or simply use echo) as described in previous post, you will get the souce code.

    g0f0ade1739498(f0666f498(__FILE__));
    (line was shorten so it will appear on the post)

    By Anonymous Anonymous, at 6:33 AM  

  • I couldn't figure this out...Can you post where to place the file that will be decoded.

    By Anonymous Anonymous, at 4:16 PM  

  • Script decoder not function more

    By Anonymous Anonymous, at 4:32 AM  

  • tks for ur share,it worked for me :)
    and have anyone code by php to decode php lockit ?

    By Anonymous Anonymous, at 3:31 AM  

  • what program are you using to decode the text............eval(y0666f0acdeed38d4cd9084ade1739498('103B1F6CAAA9E82C38',$REXISTHEDOG4FBI));?>

    By Anonymous Anonymous, at 1:34 PM  

Post a Comment

<< Home