Re: Compiling Perl?
by chromatic (Archbishop) on Apr 29, 2000 at 20:44 UTC
|
There is a CPAN module called Filter (as the Anonymous Monk notes, jogging my memory) which provides the useful Filter::Util::Exec module. What you can do with that is specify a filter to be run on your program before it is executed.
Suppose you were to finish the program you want to obfuscate, then run it through a compression/encryption scheme. You could write a small loader using Filter::Util::Exec that would uncompress/unencrypt the supplied code. You might even implement this as a separate program, and compile that.
Another option from the same family is Filter::decrypt, which may be more suited for this. (I've not seen it used, though.)
Finally, there is always the Camel-recommended dump-undump method. I've never seen that used. | [reply] |
Re: Compiling Perl?
by SuperCruncher (Pilgrim) on Apr 29, 2000 at 01:02 UTC
|
(BTW I wrote the message under AM as I couldn't find my
login) I do agree with open source - but I'm not one of the
"Everything must be open" brigade. He could potentially
use the script to compete with me, among other things. He
may also modify it and not keep my details in it. That would
really annoy me. I don't want him to have the source! Is that unreasonable (note: rhetorical question)? | [reply] |
|
Why are you worried about competition? If you are afraid someone is going to steal your ideas, get over it. If it was worth something you would either patent it or not share it. If you've written something you think is comercially viable, then I can see why you are worried but I don't see why you are giving it away.
Oh well, the way to do this is to follow the instructions on embedding a perl interpreter into a c program, and follow that route. I've seen numerous accounts on how to do this, in fact I think there is a link in the Monk Library.
And yes, C is going to need many more lines of code because C does not handle text processing very well. This doesn't make it a bad language. I'm all for knowing several languages.
| [reply] |
|
Why are you worried about competition?
If you set up a shop, do you worry about competition? Of
course. I am using this script to set up a web site and I
know that the person is considering setting up a very
similar site. I just don't need the competition!
If you are afraid someone is going to steal your ideas, get over it.
If it was worth something you would either patent it or not share it.
This program does not use a unique idea, therefore a patent wouldn't be granted. Nor
could I afford the fees. That is a completely unplausible option for this.
And yes, C is going to need many more lines of code because C does not handle
text processing very well. This doesn't make it a bad language. I'm all for knowing
several languages. I don't really mind how many lines of code the C is. It's likely
to be longer than normal anyway as it's machine-generated. The fact is that it is not even
compiling. The reason why I don't want to re-write the script in C or anything like that is
because I find C programming extremely tedious, and I already have a brilliant working version
of the program in Perl.
Thanks for your suggestion about embedding the interpreter. Any more technical details on how to do this?
| [reply] |
Re: Compiling Perl?
by turnstep (Parson) on Apr 29, 2000 at 01:06 UTC
|
This has been discussed before (link anyone?) but if you
don't want to put it into C, all you can do is obfuscate the
code. Remove newlines, add random spaces, give variables
really odd names, etc. You could also "cripple" it a bit - in other
words, don't write the best code that you can, but leave in
some errors and inefficiencies. Be redundant. The bottom line
is that your code can be read, you just have to decide how
much trouble you want to make it to do so.
| [reply] |
|
I remember the link. I think it was Protecting Perl Code.
It was a slightly different issue -- this monk is
concerned about a particular thievery-prone person,
as opposed to the earlier monk who seemed to just be
generally paranoid.
I'm curious why SuperCruncher wants the other person
to have a copy of the application at all -- is a
face-to-face demo impossible or impractical?
Stealing code against the author's wishes is SO gauche.
Frankly, I'm not sure of what the best solution is.
If the script is really big, I guess you'll have to
compile it -- other people have actual technical
suggestions on how to do this. Personally, I think it
would be rather fun to go through the code
and make it mostly-workable but wrong and bad and inefficient.
Use . instead of join, s instead of tr, arrays instead
of hashes. Put everything in one big object.
Lowercase your filehandles and capitalize your subroutines.
Indenting is a sign of brain fever. Use local when you mean my. (I could get carried away with this...)
e-mail neshura
| [reply] |
|
| [reply] |
|
|
|
This has been discussed before (link anyone?)
I read previous discussions and Q&As at this site before I posted. Some of the Q&As were
just verbatim copies of the standard perlfaq man pages! I appreciate your suggestion, but I'd hoped
there was a better solution. I'll keep it as a last resort though. I have no problem with compiling into C,
when I said I didn't like it, I meant for coding. If the code produced by perlcc compiled by me just typing:
gcc -I /include/path/ whatever.pl.c -o mybinary.exe then I'd be very happy. But I get compiler errors.
Perlcc does not even appear to be writing syntactically valid code!
| [reply] |
RE: Compiling Perl?
by cciulla (Friar) on Apr 29, 2000 at 02:52 UTC
|
| [reply] |
Re: Compiling Perl?
by ok (Beadle) on Apr 29, 2000 at 05:21 UTC
|
START RANT
So I know this isn't an answer to the original question,
but to those who wonder what the poster's motives are,
what's it to you? Just be a good monk and answer the
question if you know a solution. Productivity is a lot
more useful than philosophical debates.
Kinda reminds me of the RTFM types who have enough time to
write a long disparaging message to the asker but not enough
precious time to say "type X and hit Enter."
END RANT
As for an answer, I agree with those who say "screw up the
code." Perhaps one could write a little script to fudge up
a perl program file...s/meaningful_var_name/xcE45Fkj/,
rm_newlines(), et cetera. | [reply] |
Re: Compiling Perl?
by httptech (Chaplain) on Apr 29, 2000 at 19:15 UTC
|
I'm curious as to why perl2exe won't compile the LWP or URI
modules for you. I just compiled an LWP app with perl2exe
a few minutes ago and it worked just fine. Perhaps there is
something wrong with your installation?
| [reply] |
|
Sorry, it compiles fine. When I run it, it mysteriously fails -
either with the LWP module or the URI module.
| [reply] |
|
| [reply] |
Re: Compiling Perl?
by mcwee (Pilgrim) on Apr 29, 2000 at 18:49 UTC
|
On a legally helpful (rather than technically helpful) note:
In the US, you automatically have an explicit, exclusive copyright on any written work as soon as you pen it. Your Perl code is protected under the same laws which protect poets and novelists. As such, it should only be neccessary to make sure that your "pal" is very aware of this (i.e. "Hey, pal, before I mail this to you, please reply indicating that you are fully aware that this code is protected under US Copyright and I in no way grant you any rights to use, reprint, reproduce or make publicly availible this written work. Thanks, mom loves you, AM")
Of course in this case you'll still run the risk of him or her being inspired by your work (the risk all authors run everytime they publish), but you do have quit a bit of legal recourse in the case that your code is plagarized wholesale.
(Yeah, I know this isn't very helpful, but I think it's neat that code is considered written speech and so falls under the same legal jurisdiction. Another way in which Perl is poetry.)
The Autonomic Pilot | [reply] |
RE: Compiling Perl?
by Anonymous Monk on Apr 30, 2000 at 20:49 UTC
|
From the perlrun manpage:
-u
causes Perl to dump core after compiling your script. You can then in theory take this core dump and turn it into an executable
file by using the undump program (not supplied). This speeds startup at the expense of some disk space (which you can
minimize by stripping the executable). (Still, a ``hello world'' executable comes out to about 200K on my machine.) If you want to
execute a portion of your script before dumping, use the dump() operator instead. Note: availability of undump is platform
specific and may not be available for a specific port of Perl. It has been superseded by the new perl-to-C compiler, which is
more portable, even though it's still only considered beta.
This is probably useles on windows, but: where can I get this "undump" program? I can't find it on my debian machine..
| [reply] |
RE: Compiling Perl?
by Anonymous Monk on Apr 29, 2000 at 06:56 UTC
|
Re. the issue of the code being "stolen": under current law, your code is intellectual property. (Whether I personally agree with IP law - which I don't - isn't relevant here.) So, if you can't be assured that he won't "steal" your program, you have the option to license it to him under very strict and specific terms - "You are only allowed to USE the program, nothing more" and then sue him for copyright violation if he does anything else with it. If possible, get him to sign a contract making this explicit. (If you're in the US, you're in luck: under the DMCA, if you have any reason at all to suspect that he's breaching the license, one call to the feds and his computer gets seized. Yes, it's "censor first, ask questions later", and I don't like it one bit. But it definitely solves your problem.) | [reply] |
|
I know that pretty much everything you write is copyrighted.
Not just in the US - but any country that agrees to the
Berne Convention. However there is no way I have
the time or money to sue someone for something like this.
There's simply no way I could do it. Hence my idea of just
getting the code compiled, it solves the problem of the
Joe Perl Public with a bit of Perl knowledge from hijacking code. Sure, it
doesn't prevent the experts from reverse engineering it -- but hey, I can life with that.
| [reply] |
Re: Compiling Perl?
by Anonymous Monk on Apr 29, 2000 at 18:02 UTC
|
There this Perl Module that would encrypt/decrypt your source
code. I think its called "Filter" or something. | [reply] |
RE: Compiling Perl?
by guaguanco (Acolyte) on Apr 29, 2000 at 00:55 UTC
|
Why don't you want him to have the source? | [reply] |