3

I'm trying to get a Perl script (.pl) out of an executable (.exe) file. The .exe file was originally coded in Perl but the .pl file was not kept. Is there a quick way to do this? I'm using Strawberry Perl for windows.

Thanks

doubleDown
  • 8,048
  • 1
  • 32
  • 48
odoc
  • 79
  • 2
  • 7
  • 1
    How was the original Perl code converted to an executable? – mob Jul 05 '13 at 21:13
  • It was converted using command prompt and typing cpan -> install pp -> pp-o output.exe input.exe – odoc Jul 05 '13 at 21:19
  • More than likely using ActiveState's PerlApp or perl2exe. The important question here is, was this exe created by the OP? If not, answering this question would be counter to the interests of the script's author. – Rob Raisch Jul 05 '13 at 21:20
  • rename `.exe` to `.zip` and check if files can be extracted – mpapec Jul 05 '13 at 21:23
  • Yes I created it weeks ago, and misplaced the .pl file (I know, horrible coding practice). Now i need to make an edit. I think I've found it but just want to be sure its the most up-to-date version. Thats why I want to take my .exe back to .pl. – odoc Jul 05 '13 at 21:24
  • Perfect! Thanks mpapec that worked wonders. I'd give you the answer rep points if I could – odoc Jul 05 '13 at 21:27

3 Answers3

5

From the PAR FAQ:

How do I extract my script out of packed executable?

In other words, "I did a `pp foo.pl' and I lost foo.pl, how do I get it back?".

The answer is to just use unzip/winzip/winrar/whatever to decompress the executable, treating it like a normal Zip file. You may need to rename the executable into a .zip extension first.

Community
  • 1
  • 1
cjm
  • 61,471
  • 9
  • 126
  • 175
5

Rename .exe to .zip and check if files can be extracted

mpapec
  • 50,217
  • 8
  • 67
  • 127
1

pp relies on PAR to create the executable. PAR relies on Archive::Zip, so at some level the file contains zipped copies of the perl scripts used to create the executable.

Typically, these programs attach a loader to the front of a zip archive which unzips the files to a temporary directory and invokes the script indicated as the program's entry point.

I'd try two things:

  • root around in all the typical Temp directories (\Users\Username\AppData\Local\Temp for instance) for a directory containing your script and it's prerequsites.

  • try to uncompress the exe as a zip, possibly removing the loader from the start of he program first, using a byte editor.

Rob Raisch
  • 17,040
  • 4
  • 48
  • 58