Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

PerlApp decompile?

by chinman (Monk)
on Jul 16, 2001 at 04:13 UTC ( [id://96925]=perlquestion: print w/replies, xml ) Need Help??

chinman has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monksters,

I have done a bad, bad thing and I want to see if I can rescue myself. I blew away (by accident) some perl code that I had written, but alas, I had used Active State's PerlApp to compile a freestanding executable of that code. Does anyone know if there any way to decompile the executable back to Perl source? Many thanks for any bread crums of wisdom. Yeah, yeah, I'm backing up, I'm backing up.

chinman

#!/usr/bin/perl -w $camel = $hump do { theHumpty($camel); }

Replies are listed 'Best First'.
Re: PerlApp decompile?
by tachyon (Chancellor) on Jul 16, 2001 at 14:52 UTC

    Hi,

    I've disassembled your app. It is quite complex and consists of a large number of included modules plus three script components that represent the core app. To Active State's credit these are encoded in some way to make disassembly more of a challenge. To facilitate reversing the encoding could you please run PerlApp on the following small perl program and send me the output. Also for my peace of mind please supply the names of the component scripts and any other details you feel relevant that establish that this app was originally written by you as I would naturally be reluctant to reverse a commercial script.

    #!"#$%&'()*+,-./0123456789:;<=>?@ #ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` #abcdefghijklmnopqrstuvwxyz{|}~ #!"#$%&'()*+,-./0123456789:;<=>?@ #ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` #abcdefghijklmnopqrstuvwxyz{|}~ #!"#$%&'()*+,-./0123456789:;<=>?@ #ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` #abcdefghijklmnopqrstuvwxyz{|}~ print "Show me the encoding!\n";

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Hi Tachyon, I have read all the threads about decompiling perlapp exe. I have a very similar problem as described: Due to a disk crash I lost 2 perl programs. I only got the perlapp exe's left. I tried to do as described but I am not that experienced yet and I can not get it to work. I am realy at my knees now... begging for help! kind regards Soren
Re: PerlApp decompile?
by tachyon (Chancellor) on Jul 16, 2001 at 07:34 UTC

    Yes there probably is. I am only familiar with perl2exe but *presume* AS perl app will be similar. Basically to generate the .exe all that has probably been done is to bundle the perl code with the perl.dll and the perl.exe that forms the basis of perl under Win32 + any required modules. It is probably quite straight forward to disassemble it and retrieve the original code - it certainly is from perl2exe executables - but as I say I have not looked at the output of perlapp.

    Email the code and I'll have a look for you (email address on my home node).

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I'd like to reopen this thread, if I might... I have several executables that were compiled using what appears to be Perl2Exe. Can you give me an idea of how to decompile these? They do appear to be straightforward, as you say, but I'm under a time crunch & don't have a lot of time to take deciphering them. I'd appreciate any advice you can give.

        For a drag and drool decompiler have a look here This will give you the ?encoded? script, so all you need to do is ?decode? it. It will also give you the decoding algorithm in assembler.....

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: PerlApp decompile?
by tachyon (Chancellor) on Jul 17, 2001 at 03:05 UTC

    You have to love a story with a happy ending. Thanks to the work of the monks at A real challenge the encoding has been cracked and chinman's scripts regenerated. They have be duly emailed to him.

    I guess one take home message is if security is your prime concern don't depend on making your perl script a .exe providing this as it is quite possible to regenerate the source code verbatim.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Wow!

      I am very impressed and very, very grateful for the help!! I am at a loss. Thanks to everyone, particularly tachyon for taking this bull by the horns! Saintdom can't be far off.

      #!/usr/bin/perl -w $camel = $hump do { theHumpty($camel); }
Re: PerlApp decompile?
by tachyon (Chancellor) on Jul 16, 2001 at 17:06 UTC

    Hmm,

    Like Alice in wornderland the problem is quite interesting. The sample script is not encoded in a repetitive pattern. Indeed the 343 chars are encoded as 333 in the source code. For details see A real challenge. Here is another script to compile, to look for pattern repeats. It's fairly boring!

Re: PerlApp decompile?
by John M. Dlugosz (Monsignor) on Jul 21, 2001 at 02:03 UTC
    Can't you just look in the temp directory where PerlApp extracted everything, while the script is running? That is, you should not need to peek into the exe itself (it stores everything as Win32 resources, and the source that does it is PerlApp.pl so you can read it for yourself)?
      Yep, I thought about that, and I located the temp directory where that stuff (assorted DLL's, Bill Gate's phone #, etc) get sent. But, the only time you see perl source there is if you use the -bind option and you have not specified the -clean option. On Win2K it appears that things get sent to: "C:\Documents and Settings\MyLoginName\Local Settings\Temp"

      chinman

      #!/usr/bin/perl -w $camel = $hump do { theHumpty($camel); }
        What I mean is while it's still running, before it has a chance to clean up. I suppose it uses the system's normal temp directory.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://96925]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found