Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Embedding an Executable file in Perl program

by meetraz (Hermit)
on Mar 25, 2003 at 21:20 UTC ( [id://245793]=note: print w/replies, xml ) Need Help??


in reply to Embedding an Executable file in Perl program

I agree that this is a bad idea. Whatever method you use to get the username and password from the executable file, somebody else can use as well. Not very secure.

But, for completeness, here's an example how to do it:

use strict; open (EXE, "> myexefile.exe"); binmode(EXE); print EXE getexe(); close (EXE); my $login = `myexefile.exe`; unlink('myexefile.exe'); sub getexe { return "\x4d\x5a\x90\x00\x03\x00\x00\x00\x04\x00\x00\x00\xff\xff\x00\x00 +\xb8\x00\x00\x00" ."\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00\x00\x00" ."\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00\x00\x00" ."\xd0\x00\x00\x00\x0e\x1f\xba\x0e\x00\xb4\x09\xcd\x21\xb8\x01\x4c +\xcd\x21\x54\x68" ."\x69\x73\x20\x70\x72\x6f\x67\x72\x61\x6d\x20\x63\x61\x6e\x6e\x6f +\x74\x20\x62\x65" ."\x20\x72\x75\x6e\x20\x69\x6e\x20\x44\x4f\x53\x20\x6d\x6f\x64\x65 +\x2e\x0d\x0a\x24" ."\x00\x00\x00\x00\x00\x00\x00\x89\x97\xcf\x9d\xcd\xf6\xa1\xce\xcd +\xf6\xa1\xce\xcd" ."\xf6\xa1\xce\xcd\xf6\xa0\xce\xc0\xf6\xa1\xce\x94\xd5\xb2\xce\xc4 +\xf6\xa1\xce\x9b" ."\xfe\xa7\xce\xcc\xf6\xa1\xce\xcd\xf6\xa1\xce\xcc\xf6\xa1\xce\x52 +\x69\x63\x68\xcd" ."\xf6\xa1\xce\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00\x00\x00" ## (more data here) ; }

Replies are listed 'Best First'.
Re: Re: Embedding an Executable file in Perl program
by peacemaker1820 (Pilgrim) on Mar 26, 2003 at 18:13 UTC
    Thanks for the answer but I do not understand a couple of things.
    What does the sub getexe() do, what are those wierd characters, what should I put in the getexe() because u specified  ##(more data here); ?

    Thanks
      Your original request asked how to "embed an executable file". The easiest way to do this is to convert your binary executable into a text-based string. One such way is to escape each byte using \xNN syntax. If your binary executable is 30k, you will have a string made up of 30,000 variations of "\xNN". The getexe() function is just returning this binary data to the main part of the program so it can be extracted to disk. You don't have to do it this way - I just thought it made it easier to read. I put the ##(more data here) in there because the post would have been really huge if I posted all 30k. Your executable code will be different anyway.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found