Slashdot Mirror


'Protecting' Perl Code?

An anonymous reader asks: "Ok, so here is the scenario: my company has some software that is used internally and it is written in Perl. We now need to put this code on a server that has 'public' access (it's a university machine). We provide root access to the system for the purpose of learning, but we need to keep the code from being viewed or edited. Is there anything to do besides the 'perl2exe' and the ActiveState compiler? How effective are those really at protecting code?"

106 comments

  1. I know chmod! by Cyclone66 · · Score: 2, Funny

    CHMOD?

    1. Re:I know chmod! by NitsujTPU · · Score: 1

      There's this funny thing about root access...

    2. Re:I know chmod! by Cyclone66 · · Score: 1

      Maybe the university should have a fundraiser and put their important data on a computer where everyone doesn't have root? THEN... CHMOD!
      Or he could try a Perl obfuscator. I never used one for Perl though.

    3. Re:I know chmod! by Johnno74 · · Score: 3, Funny

      "Or he could try a Perl obfuscator"

      People have written perl obfuscators? Why? I've never seen perl code that needed an obfuscator.

    4. Re:I know chmod! by NitsujTPU · · Score: 1

      Two thoughts.

      The first, root can remount the filesystem.

      The second, I've actually never seen ONLY execute. I've seen disallowing only execute though.

    5. Re:I know chmod! by Naikrovek · · Score: 0

      in order to execute a file, you have to be able to read it from the disk.

    6. Re:I know chmod! by drsmithy · · Score: 2, Funny
      People have written perl obfuscators?

      Comes standard with every unix install.

      man 1 cat

    7. Re:I know chmod! by clem · · Score: 1

      How about placing the code on a tightly controlled system and making it available to the insecure system via NFS? The root squash setting should prevent the root users from accessing it and you can set execute-only permissions for the other users.

      --
      Your courageous and selfless spelling corrections have made me a better person.
    8. Re:I know chmod! by zaguar · · Score: 1
      The Parent, Grandparent and Great-Grandparent have all recieved +3, Funny!

      My Turn!

      --
      "Sure there's porn and piracy on the Web but there's probably a downside too."
    9. Re:I know chmod! by aled · · Score: 1

      Perl have this autoofuscating thing. Just write as usual, the result is ofuscated enough.

      --

      "I think this line is mostly filler"
    10. Re:I know chmod! by Anonymous Coward · · Score: 0

      Hogwash. Seagate drives have a fine 16-bit processor. Compile perl for the Siemens processor on the disk, flash it, and run it in place on the disk.

    11. Re:I know chmod! by NitsujTPU · · Score: 1

      What about when the code is downloaded to the local machine for execution?

      So, I write a hacked version of NFS. I take allowed machine off the network (since I'm root). I clone its mac, I have its SSH keys (since I'm root), I set up with identical IPs and what not. My hacked version of NFS downloads the code and now I have it.

      I don't see a way that they can do this aside from obfuscation, with modern technology. Even crypto requires the file to be decrypted to execute (something that I attended a talk on just last week).

      Either way, I sincerely don't believe that there is anything to be learned from a PERL script that you can't even look at.

    12. Re:I know chmod! by jrockway · · Score: 1

      However, on many systems, the +r bit need not be set. If only +x is set, you can execute the program, but not cat or gdb it. Remember that executing a program is something that involves the OS reading the file, not some program running on the behalf of the user who wants to execute the program.

      --
      My other car is first.
    13. Re:I know chmod! by Mr+Z · · Score: 1

      That's true for object code executables. I don't think it's true for interpreted languages like Perl.

    14. Re:I know chmod! by jrockway · · Score: 1

      You're right. (Tested on OS X.)

      But you can write a setuid/setgid program in C and have that C program exec the perl interpreter as a user/group that can read the script. Assuming your wrapper is properly coded (I've gotten root on a large server due to the wrapper using gets...), you should achieve the desired effect. This technique doesn't apply to this article, though, because the person you're trying to hide stuff from is root. Root can install a rootkit (heh) and bypass any protections he wants to. In other words, this is impossible.

      --
      My other car is first.
    15. Re:I know chmod! by Anonymous+Coed · · Score: 1

      That might have been funny the first six thousand times and two times it was said. The six thousand and third time, not so much.

    16. Re:I know chmod! by mrmeval · · Score: 1

      Actually cat code.pl | caesar 19 > hi.ca

      --
      I'd go on a Vegan diet but the delivery time from Vega is too long. --brownkitty
  2. Dr. Greene once said by Anonymous Coward · · Score: 3, Interesting

    You could scambling the code un-readable uncompiled.

    One of my professors told me a story about how he once worked with a guy that mantained a project. To help keep his job he would always submit the code scrambled with all names of variables and functions seemingly meaningless. He showed him this one day and asked, "How can you read this?" He said, "I can't. I write the code, put the source through a filter program and then submit the result. If they need someone to fix it or read it or improve it, they will have to go through me." This was back in the early 80's.

    1. Re:Dr. Greene once said by bcat24 · · Score: 1

      LOL. Nice story, AC.

    2. Re:Dr. Greene once said by Anonymous Coward · · Score: 0

      Yeah and that's why he's still making big bucks in industry and not teaching, right ?

      Remember, a lot of what you are supposed to learn in college is learning by example . . . BAD example . . .

    3. Re:Dr. Greene once said by aled · · Score: 1

      That's one of the thing Java ofuscators do. No reason to someone write a similar ofuscator for Perl.

      --

      "I think this line is mostly filler"
    4. Re:Dr. Greene once said by stevey · · Score: 2, Informative

      There are people selling such things for Perl, the first to spring to mind is perl-obfus carried upon Freshmeat.

      That is slated pretty thoroughly over at Perl Monks.

      I wonder how many people have paid for this .. umm .. fine product?

  3. Perl comes with an obfuscator by default.. by mkavanagh2 · · Score: 5, Funny

    ..and it's called "Perl". You don't need to do anything at all for your code to be unreadable.

    1. Re:Perl comes with an obfuscator by default.. by Phroggy · · Score: 2, Interesting

      OK, but that doesn't mean you CAN'T take explicit action to make it even MORE unreadable.

      #!/usr/bin/perl

      use strict;
      use warnings;

      ($,,$",$_,@_)=reverse qw(164 163 165 112),",\n",split '','\ ';

      my $music='Art';
      my($swing,$rock)=q
      s/hacker/performer/; # another creator of art...
      my $blues=~/^.(\w+).*#\s(\w+)/;
      my $jazz=substr((grep m($music)=>qx($^X$,-v))[$[],$?,scalar @_);
      my $pop=eval qq("\\@_");

      print $pop, $rock, $jazz, $swing;
      print;

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
  4. is this for real? by Anonymous Coward · · Score: 0

    uh......put the os on a cd....

  5. Why protect Perl code? by bcat24 · · Score: 2, Insightful

    Nobody can read it anyway!

    But seriously, if you provide root access to the system, what good is a Perl obfuscator/encryptor/compiler going to do? Nothing can really stop someone with a will and enough free time from decrypting the code.

  6. Goes against the machine's purpose by klui · · Score: 4, Insightful

    If it's for learning and people have root, why put it on this server if you don't want people to learn from it?? Still want to do it? Move this perl code to another box and call it via RPC.

  7. Not Possible, Permissions, Jails/Sandboxes, Others by MBCook · · Score: 4, Insightful
    My first though was it isn't possible. After all, it's root. Root is supposed to be able to do anything.

    My second though was permissions. Why do the students need root access? Couldn't you make some new account that had permissions to do anything but access that one directory?

    My last thought is a sandbox (or I think the BSD concept of a Jail is the same idea). If you were to run Linux on Linux (Xen, or just some other sandbox, maybe even chroot) then you could give them root, while keeping them out of the true root.

    It's a tough situation. Does it really have to be on that server? You can't stick it on a new server your company buys for the purpose and donates (what is more important, My last idea (a bit extreme, I would think) would be to modify the Perl interpreter to run the perl code through a decryption algorithm first (so the source on disk would be encrypted so it couldn't be read). With open source software, there is no reason this isn't possible (would hurt performance though).

    Does Perl support some kind of tolkenizing? When you run a Python script you get the .pyo (I think) file that is basically the cached compiled Python byte code. Can you do that with Perl? It isn't perfect (can be disassembled back into Perl, but without variable names, etc) but it is better than plain text.

    --
    Comment forecast: Bits of genius surrounded by a sea of mediocrity.
  8. Change your business by _undan · · Score: 1

    "We leave our doors open, but how can we stop people from stealing things?"

    I'd re-consider allowing such open access to root.

    1. Re:Change your business by hahiss · · Score: 1

      > "We leave our doors open, but how can we stop people from stealing things?"

      >I'd re-consider allowing such open access to root.

      Or you could find the equivalent of standing in the doorway with a loaded shotgun.

      --
      "Every decent man is ashamed of the government he lives under." - H.L. Mencken
  9. Closed Source? by Unordained · · Score: 1, Insightful

    It occurs to me that asking a bunch of pro-open-source geeks how to best maintain control over closed-source code in an sub-ideal environment is perhaps not the best idea ever. In fact, I would suggest that you double-check any answers you get here, as, for all you know, they're purposefully sub-par solutions designed to lull you into a false sense of security so the code can be more easily nabbed.

    1. Re:Closed Source? by bryanporter · · Score: 0

      Mod this parent down.

      He's not asking "How do I release my program as closed source?". He's asking, "How do I keep abunch of 20 year olds who are going to be playing on a unix box, with root access, from editing my program all the damn time and blowing it all to hell?".

      Different question.

  10. ADJE webmail by bofkentucky · · Score: 1

    Those dudes had a fairly nasty pack/unpack decryption sequence in their pay webmail system that I never got around to cracking. If those tards figured it out surely someone else can.

    Beyond that, make the perl script on the box be a wraper that lwp's a request to your box and spits out the output as a cgi.

    --
    09f911029d74e35bd84156c5635688c0
    1. Re:ADJE webmail by jonadab · · Score: 2, Insightful

      > Those dudes had a fairly nasty pack/unpack decryption sequence in their pay webmail system
      > that I never got around to cracking.

      A student who knows Perl and has a long weekend on his hands can buzz through that sort of thing with ease, or a student with a bit less Perl knowledge could post it on the Perlmonks Obfuscated Code section and claim it's "unbreakable", practically guaranteeing it would be broken within fifteen minutes. (Deobfuscation is a recreational activity for some people, and obfuscated Perl code is incredibly susceptible to it, especially if the obfuscation is automatic, as with the sort of thing you're talking about; in fact, for someone who's reached the point of thinking in Perl, obfuscated Perl code is almost easier to read than normal code in another language (such as C).)

      --
      Cut that out, or I will ship you to Norilsk in a box.
  11. Heard of B::Deparse? Time to learn. by dondelelcaro · · Score: 4, Informative

    This is such a frequently asked question that there's even a faq in the documentation that is distributed in almost every single perl distribution.

    perldoc -q 'hide the source'

    If that's not simple enough, then see the thread on perlmonks.org about it.

    If you still think that obfuscating the source code is going to gain your company anything, then I doubt anyone really wants to see your code at all. (You don't happen to work for Blackboard, do you?)

    --
    http://www.donarmstrong.com
  12. MOD PARENT DOWN by 19thNervousBreakdown · · Score: 2, Funny

    That's nonsense, don't listen to this guy.

    Look, just to show how nice we are, why don't you upload it to my FTP server, give me the root password and IP of this machine, and I'll take care of the rest.

    --
    <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
  13. Me thinks we have a fool.... by countach · · Score: 0


    Re Viewing - me thinks this fool is trying to implement security by obscurity. Why else this silly request?

    Re Editing - of course if you have root access you can edit *anything*. Of course if you turn it into a binary, they won't be able to directly edit it, but they could reverse engineer it, re-create it, and edit that. Why stop them? Me thinks this fool wants security by obscurity.

    1. Re:Me thinks we have a fool.... by cornface · · Score: 1

      Me thinks you sound pompous and ridiculous.

  14. Repeat after me by booch · · Score: 1

    The method for protecting your code from being copied is called "copyright". Really, that's the whole reason for the existence of copyright.

    --
    Software sucks. Open Source sucks less.
    1. Re:Repeat after me by Anonymous Coward · · Score: 0
      Really, that's the whole reason for the existence of copyright.


      It is not.
  15. Re-examine your need by orkysoft · · Score: 4, Informative

    If you are giving root access to the machine to students, you do not need to put your preciousss perl application on the same machine. In fact, you need to NOT put it there, because even if you obfuscate it, encrypt it, or compile it, it's possible to reverse the process. Obfuscated code can be analyzed and understood, plus it's going to take some real talent and time if you want to do it right, so it's expensive. Encrypted code needs to be decrypted before it can be executed. Compiled code can be decompiled.

    You might use something like a BSD Jail or some other kind of server virtualization, so it merely looks like your software is on another machine. If it is really important that this program remains your dirty little secret, don't put it on a machine which you don't control. Really.

    But if you really want to put it on the same machine, try compiling it into a binary, and not draw any attention to it, to avoid people getting curious about it. Still, if someone finds it and takes enough of an interest in it, all bets are off.

    --

    I suffer from attention surplus disorder.
    1. Re:Re-examine your need by Wieland · · Score: 1

      But if you really want to put it on the same machine, try compiling it into a binary, and not draw any attention to it, to avoid people getting curious about it.

      Considering the fact that we're discussing it on /., I think we can safely assume that's no longer an option...

  16. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  17. Giving those students root... by HotNeedleOfInquiry · · Score: 1

    Is like giving teenager boys whiskey and car keys. I think P.J. O'Rourke said it first about politicians and money...

    --
    "Eve of Destruction", it's not just for old hippies anymore...
  18. Its Perl... by gbrandt · · Score: 1

    ...no one will understand it anyway.

    How much safer can it get?

    Gregor

  19. well by croddy · · Score: 1
    if you need to prevent them from altering it, that's easy. put it on read-only media (a CD, not just mount -o ro).

    if you want to give them root and prevent them definitively from reading it, you're going to need to come up with a better plan.

    with a debugger (which i presume they'll have and understand, since these are obviously CS students of some flavor) they'll be able to attach to the process with an all-seeing-eye, so running it on the system where they've got root is just not what you want.

    depending on what sort of script this is, could you store it on a different, restricted box, and only let them interact with it over the network? if they have no need to alter it or read it, then what need is there to even store it on the same machine? if the script needs access to the filesystem, you could export it through your favorite network FS to the restricted machine running the script.

    encryption and obfuscation are rarely going to be as effective -- and will usually be more of a headache -- compared simply moving it to a more controlled box.

    1. Re:well by lpcustom · · Score: 1

      "if you need to prevent them from altering it, that's easy. put it on read-only media (a CD, not just mount -o ro)." If the student is root they can copy the script to another mounted filesystem and edit it all they want.

      --
      Beer! It's what's for breakfast!
    2. Re:well by munpfazy · · Score: 1

      >If the student is root they can copy
      >the script to another mounted filesystem
      >and edit it all they want.

      But, at least then they can't modify the original copy, which in some interpretations is what the article poster is actually worried about. (Not my own interpretation.)

      At least, they can't modify the original copy once you've use epoxy and some kind of watermark to keep them from simply replacing it with a similar looking CD.

      At least, until they replace the system's CD drive with an loop device to a modified image of the CD.

      As others have said, I'd claim the task as described is impossible.

      What's more, there's no code in the world worth protecting that isn't worth more money than the cost of a cheap stand alone machine on which to run it.

      The software version is to create a bsd jail / user mode linux system for the rooted public to use.

  20. What are these students learning anyway by NitsujTPU · · Score: 1

    Just a quick question... what are these students supposedly learning from this script anyway?

    If it was a systems program, well it probably wouldn't have been written in perl, lets be honest.

    AI? If the students can't learn about the algorithm, it's not much use.

    Theory? What will you prove about a black box perl script?

  21. conflict of ... ideas? by monkeyserver.com · · Score: 3, Insightful

    It sounds like you're a bit confused, if the people are supposed to have access to learn, then why are you denying them access to learn from this script. It sounds like you really just shouldn't have this script on there, as was said before, you should move it elsewhere and call it remotely.

    But MOST IMPORTANTLY, I wouldn't put anything of value or importance onto a machine where uni students have root access. If you remote call, whose to say they won't break the call, if you obfuscate, whose to say that they won't just break the script or delete or replace it. It just seems silly...

    Perhaps you should give them access to a root-like group, then not put this file in that group. I think you problem is that you want more complex permissions then you've relegated yourself to having.

    --
    http://monkeyserver.com --- weeeeee
    1. Re:conflict of ... ideas? by fbjon · · Score: 1

      I'm thinking that it's a black box script that provides an example. The students are then probbly supposed to make their own that does the same. In this case it might actually work with heavy obfuscation, because the simple requirement of well-commented submissions will defeat any deparsing/-compiling attempts.

      --
      True confidence comes not from realising you are as good as your peers, but that your peers are as bad as you are.
    2. Re:conflict of ... ideas? by fbjon · · Score: 1

      Ah, it's a company that's setting up the machine, forget what I said. :)

      --
      True confidence comes not from realising you are as good as your peers, but that your peers are as bad as you are.
  22. GrSecurity by BusDriver · · Score: 3, Informative

    Why don't you install yourself a nice Kernel with grsecurity.

    Using it's permissions system, you can allow root to login and do whatever you'd like, you but can set grsec so that only certain other groups/systems are able to view/run etc your perl code.

    The permissions system is very configurable and it's a steep learning curve with not a real lot of documentation. But playing with it for a few days should get you all figured out.

    Using grsec it's possible to allow root to login and really do zero damage, it's a great system. I don't think any Linux box should be allowed on the 'net without this patch! There are other systems (SeLinux) that offer the same sort of thing, so if GrSec isn't quite what you need be sure to look at the others.

    Using a system like this means all those "they have root forget about it" isn't true anymore, you can configure it so root can do very little damage to the working system, but still have access to edit all those files the normal pleb user accounts can't.

    Tim

  23. Not in Perl, you'd need SuidPerl... by SanityInAnarchy · · Score: 3, Insightful

    The problem with Perl is that it's an interpreted language. That is, you need an interpreter to read the code and then run it. And if the perl binary can read the code, then so can you.

    An obfuscator could work, but then someone could easily nuke the program, or just generally mess with it.

    Honestly, I think it's a retarded idea to begin with. First, drop ALL the root access, no excuses. Add stuff back in with Sudo as needed, giving each command careful review. Then, rewrite your app to work with suidperl, and run that with setuid root, or with sudo.

    That's the technical answer. But honestly, why are you afraid of them looking at your code?

    --
    Don't thank God, thank a doctor!
    1. Re:Not in Perl, you'd need SuidPerl... by Haeleth · · Score: 1

      The problem with Perl is that it's an interpreted language. That is, you need an interpreter to read the code and then run it. And if the perl binary can read the code, then so can you.

      The bazillions of cracks out there for games and applications written in C++ imply, to me, that this problem is not limited to interpreted languages.

      If your computer can run something - anything - then it can be deciphered by any sufficiently motivated human, period. There is only one "solution" in sight for those who are determined to take away our power to find out what is being done on our computers, and that is turning our computers against us by infecting them with "trusted computing" modules. Till then, there ain't no such thing as secure code.

  24. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  25. Depends by miu · · Score: 1

    If you have embeded passwords or hostnames in the app then there is nothing you can realistically do to protect that info. If you are trying to keep thieving students from stealing your code and calling their own then copyright is probably a better answer. We don't even know what the code does, is it possible to host it on a protected machine and run it via cgi or any other rmi?

    --

    [Set Cain on fire and steal his lute.]
  26. You're screwed. by coaxial · · Score: 1

    Root can do anything. If you don't want people to have write access to your perl script, then don't give them root access! Think about it. Even if you used something like perl2exe, root could simply delete your script, and replace it with something that did something nasty. Do you really want that? No.

  27. MOD PARENT UP!! by Anonymous Coward · · Score: 0

    LOL!!!! FUNNY!!!! PERL IS MESSY!!! ONE OF A KIND JOKE.

    Oh wait, on second thought, the joke was already used here, here, here, etc...

  28. -1 Flamebait by amling · · Score: 1

    EOM

    --
    70e808a22cb027cde4a6abddf6435d55
  29. Um by Kawahee · · Score: 1

    You provide access to it for learning purposes, but don't want anybody to view it? Just put it inside a password protected archive or something.

    --
    I'll subscribe to Slashdot when I see a month without a dupe, a typo, or an article the "editors" didn't read.
  30. Perl Packager... by OneFix · · Score: 1

    I think you want Perl Packager with the --filter option...there are a few filters that can be used with that (specifically PAR::Filter::Bleach), but if one of these won't work, then I'm afraid you are asking for something that simply doesn't exist...no security through obscurity and all of that...

    1. Re:Perl Packager... by dotnetwolf2003 · · Score: 1

      .. or use a commercial Stunnix Perl-Obfus - obfuscator and encoder for Perl - instead.

  31. Remote execution / client-server by erice · · Score: 1

    Does the script have to run fully on the unsecured box? If not, then you may be able to break it into two pieces. Run the user interface locally have it call a second script on a secure machine. This may be a simple as ssh or as complex as a full blow client server app depending on your needs. The principle is to perform all "interesting" processing on a remote machine that is secure.

  32. here's a way, regardless of the language by Fry-kun · · Score: 1

    a) download perl source
    b) in perl source, modify all control symbols to other control symbols. e.g. "-" treated as "+", "+" treated as "@", etc.
    c) make a script to modify your code's control symbols with the same mapping and obfuscate all variable names to randomly generated ones
    d) run the obfuscated script on obfuscated perl

    by the time they'll decode everything that version of your code will be outdated :)

    --
    Did you know that "FTW" ("for the win") is a direct translation of "Sieg Heil"?
    1. Re:here's a way, regardless of the language by jonadab · · Score: 1

      You've got to be kidding, a substitution cipher? Any CS student who can't break that in five minutes is in serious need of a counsellor to tell him to change majors. That's third-grade puzzle-book stuff you're talking about.

      And, quite aside from that, modifying perl is completely unnecessary for that; anyone who knows much Perl could do it trivially with a source filter.

      --
      Cut that out, or I will ship you to Norilsk in a box.
  33. Assuming the poster is competant.. by dreamer-of-rules · · Score: 2, Insightful

    This sounds like such a BAD setup: security through obscurity (in Perl?!), basic inability to understand root. After all, if hackers can reverse-engineer DVD software to decrypt all movies, your Perl script doesn't stand a chance. And I bet you're putting a password in it!!

    But assuming you know what you're talking about, it's an interesting puzzle.

    Read-only as root? Mount a write-protected media. CD, floppy, USB dongle. Some hard drives let you set a write-protect jumper. Or you could go with that modified kernal that someone else mentioned here.

    Obfuscating Perl? Install a Sony rootkit! :) Modify the script to load once, delete the file, and respond to requests. See perldoc -q 'hide the source'.

    --
    Everyone is entitled to his own opinions, but not his own facts.
  34. Re:Not Possible, Permissions, Jails/Sandboxes, Oth by chromatic · · Score: 3, Informative

    Perl is already Tolkienized -- just look at the start of every source file!

    More seriously, you can save the internal representation, but it's easy for someone skilled to turn that back in to mostly-readable source code. You don't even lose the variable names; Perl keeps them around. (For globals, you have to -- you always have to do a symbol lookup. Lexicals don't have symbolic access; the compiler turns these into indexes into pads attached to the internal representations of code objects. However, these lexical pads do keep the variable names around as they're important for error messages, among other things.)

    (Guess who just wrote about lexical pads in a Perl book not more than ten minutes ago?)

  35. SELinux by Julian+Morrison · · Score: 1

    If you must provide root, how about using a system like SELinux that provides "mandatory access control" that root can't override? Then you can lock the kiddies out of messing with anything that could wreck the machine, while leaving them free rein in everything else.

  36. RPC by korbatz · · Score: 1

    1) implement soap interface to your program,
    2) put it on secure machine (without "public" accounts)
    3) write client to use your "web service" and put it on university server.
    4) done

    --
    you are not your sig
  37. some suggestions by rsax · · Score: 1

    A lot of people have recommended not giving the students root access. How about just limiting their admin priviliges using sudo? If you're using Linux then you could use SELinux or systrace on OpenBSD to limit what root can do.

  38. Activestate's PDK by jhurani · · Score: 1

    A memory dump of a running process that is using Perl Dev Kit produced DLLs will also show the embedded Perl code. This happened with the PDK I used a year back. Memory dump was created by Visual Studio 2003 after attaching to the process.

  39. use Module::Crypt; by maedls.at · · Score: 1

    Try using Module::Crypt, it just entered CPAN few weeks ago! I've tested it, it works well.

    #!/usr/bin/perl -w

    use strict;
    use lib '/home/vservers/modules';
    use Module::Crypt;

      CryptModule(
            name => 'NCM::Crypttest',
            file => '/home/vservers/crypttest/maedls.at/Crypttest.pm',

      );

  40. Best protection by Tux2000 · · Score: 2, Interesting

    The best protection for any kind of application you hand over to a customer is a clear license agreement stating what is allowed and what not, together with a good lawyer. It is probably the best way to make the lawyer write the license agreement together with you.

    Just as a good hint for you and your customer(s), you may digitally sign your code with a private key (using PGP or similar). Refuse any kind of support when the signature validation fails, i.e. the code is modified. Think of it as a "warranty void if seal broken" in code. Don't check the signature in the code, this is just stupid. The first step of modifying your code would be to remove the signature checker. The signature checker is a separate application on your computer(s) that you do not give away. It may be just a simple shell script using PGP and your public key.

    Don't even think about encrypting your code, this is plain stupid. Your application needs to know how to decrypt the code, and the decryption engine must be unencrypted to run. So with a minimal modification of the decryption engine, your customer can read your code anyway. A binary decryption engine (XS in Perl) is not directly readable, but it makes the job just a little bit harder. There are decompilers out there.

    Tux2000 <- gave away 100.000 lines of code to paying customers, multiple times

    --
    Denken hilft.
    1. Re:Best protection by Anonymous Coward · · Score: 0

      > The best protection for any kind of application you hand over to a customer is a clear license agreement stating what is allowed and what not, together with a good lawyer. It is probably the best way to make the lawyer write the license agreement together with you.

      Of course, your name gave it away: you're clueless about non open-source business issues. Speaking as someone that had a very important piece of software (protected by a pile of legaleses) copied by a big company (that I now work for, ah-ah) , I can tell you that nobody cares about that legalese, this is called 'cost of doing business'

      I the OP don't want the code to be copied, he should not give access. If he is just trying to avoid casual copy, he should obfuscate it.

  41. It's in the FAQ by merlyn · · Score: 3, Insightful
    How does something that is answered in the PerlFAQ make it to a slashdot question?

    [boggle]

  42. *Sigh* by baadger · · Score: 1

    Yet another Ask Slashdot submission with not enough information about your circumstances or reasoning to offer any kind of truly insightful response... except perhaps this one.

    - What does the code do? Why is it important it is protected?
    - Do these students actually need root access, or is it just management laziness on your/your companies/the universities part?
    - Would these students actually care enough to bother doing anything with this code?
    - Have you considered a jail/sandbox/some kind of secure system emulator?
    - What is wrong with perl2exe (Windows only?) or the ActiveState compiler?
    - Why can you not get the students to sign a user (non-disclosure?) agreement in good faith (agree not use the box for malicious purposes, intentionally damage the system, or steal your code etc)? Is this not covered already by the unniversity network's user agreement?

    I personally can't invision a program that could be SO mission critical that you are considering puting on an open box AT ALL. Presumeably it isn't that critical, so why not persaude your company to make an exception in licensing in this case and let it go.
    Who knows one of the students might find some obscure bug and make a suggestion on how you can fix it, or help you make some other such improvement.

  43. Best Way to Hide a File by ShaggyB · · Score: 0

    If this is a windows machine, you could install a certain DRM program and start the file name of your perl script with $sys$.

  44. uhm, that's just plain stupid by Ender+Ryan · · Score: 2, Insightful
    What the hell? That's the stupidest fucking thing I've ever heard. You allow root access, but you want to "protect" code running on the machine? What the fuck?

    You're as bad as all the damn proprietary software vendors who try to prevent people from examining their compiled code in a hex editor or decompiling it.

    Why do you want to do this? Is the code proprietary? Does the code contain security sensitive information?

    If the latter, then jeez, that's just plain piss poor design. In the case of the former, just put a license warning in the code. It's impossible to "protect" overall design and algorithms anyway.

    You can obfuscate the code of course, but really, that's just an exercise in futility.

    --
    Sticking feathers up your butt does not make you a chicken - Tyler Durden
  45. ActiveState is good enough by Anonymous Coward · · Score: 0

    We use the ActiveState compiler at my work for pretty much only this purpose ( well, it also gives you the benefit of not having to depend on all the modules since they are compiled into the binary).

    The code is pretty much unreadable, it is just a ton of binary garbage. I am sure someone with enough ninja-like skills could step-trace it through and get the original Perl instructions, since there is probably a perl VM compiled in with it. But this is not the kind of protection you are looking for, all you want to do is stop 05% of the people. The other 5% can reverse engineer *anything* anyways, even a compiled C++ app.

  46. Another way around this by n9hmg · · Score: 2, Interesting

    The only non-stupid reason this MUST be on the machine is that it is required that these users be permitted to run it, on this machine.
    If it is on the machine, root shall be able to read it. If it is possible to execute it, the method of easily decrypting it is present on the machine.
    Place it on another machine, executeable only through a network interface, thus making your program itself purely a "black box".

    Example 1: Your program is an encryptor, and it takes a key and a data file.
    The interface code could be as simple as a shell script that reads the key and filename, and uses a restricted ssh key (on application hosting server, the key is tied to a specific commandline) to transfer the file to a staging location on the application server through scp, run the command, and retrieve the resulting file.

    Example 2: Your program passes down a directory tree and creates new files related to existing files.
    Simplest solution is like example 1 - script tars up the directory tree and feeds it through ssh to an untar and calls your program on the new remote tree - it could even be a pipe then - you feed your tar directly to a script on the other end that picks a staging location, untars the stream, runs your program on the tree, and sends back the result as a new tar stream. Obviously, it wouldn't be a true stream since the output wouldn't even start until sometime after the completion of input.
    If the tree is too big, you put a modified version of your command on the remote that does only the secret part, and a modified version that's publically available to do the obvious part, and outsource the secret work, again through restricted ssh keys.

    Example 3: Your program really is a pipe.
    You provide a script on your end that just execs an over to that other box with a restricted ssh key limited to running only your command, and runs it.

    In my solutions, ssh is a theme - because I don't know the environment, and go with the most secure and flexible solution using service that's likely already approved. For many tasks, you could wrap your stuff up as a cgi script and call it through wget. Maybe write it to listen on a socket and be a plain old service on the box that you control.
    If the customer insists that the program itself be present on a box to which he has privileged access and rejects all solutions that don't include that condition, he wants the code. Both of you drop the charade and start negotiating based on that fact.

  47. Re:Not Possible, Permissions, Jails/Sandboxes, Oth by jonadab · · Score: 2, Informative
    My last idea (a bit extreme, I would think) would be to modify the Perl interpreter to run the perl code through a decryption algorithm first (so the source on disk would be encrypted so it couldn't be read). With open source software, there is no reason this isn't possible (would hurt performance though). Does Perl support some kind of tolkenizing?


    <p>Yeah, this is called a source filter. There are a large number of them on the CPAN. They're all done for fun-related purposes, mostly humor. Some examples include ACME::Bleach (the program is encoded entirely in whitespace), or ACME::Buffy (for vampire fans), and ACME::Eyedrops (my personal favorite, and different from the others in that the module doesn't have to be installed on the system where the code is to be executed; it produces code that abuses (severely) the regular expression engine to accomplish what the original code accomplished).
    </p>

    <p>However, none of these will prevent someone with full access to the system, who understands Perl, from being able to reverse the process and demangle the code to obtain it in the form the interpreter sees. And yes, there's a performance hit, although with most of them (notably excepting Eyedrops) it's upfront (when the program is first launched), not continuous (thoughout the execution of the program), so it's not as bad as you might think.
    </p>
    --
    Cut that out, or I will ship you to Norilsk in a box.
  48. LIDS by alder · · Score: 2, Informative

    Alternatively you can try LIDS. One of the many features of LIDS is ACLs that are applicable to root as well. Configuring LIDS section of their FAQ gives a number of interesting examples of putting a heavy "lid" on access to the system, while keeping it useable.

  49. Tolkienized? by rpresser · · Score: 2, Funny

    Perl is already Tolkienized -- just look at the start of every source file!

    What, do you have to run it on a Tolkien Ring network instead of Ethernet?

    "One Ring to rule them all,
      One Ring to find them,
      One Ring to bring them all
      And in the darkness bind them."

    1. Re:Tolkienized? by Anonymous Coward · · Score: 0

      Ash nazg durbatuluk, Ash nazg gimbatul, Ash nazg thimbatuluk ag burzum ishi krimpatul.

  50. perlcc by Anonymous Coward · · Score: 0

    You may try perlcc

  51. Proxy, proxy, proxy... by mengel · · Score: 1
    The only way to do what you want is for the script in question to actually live on another box, and you provide a proxy that calls into the other box and runs the script remotely. (i.e. "rsh otherhost -l restricted-account /real/path/to command")

    If they have root on that system, they can read anything on that system, and that's the end of it. You can hide it/obfuscate it N different ways, but they're all fixable -- in order to run it on that box, the perl text (or some equivalent transformation) has to be obtainable on that box for perl to execute it. And if it can be obtained to run it, it can be obtained to read it.

    You might have enough limits with a BSD jail, or a virtual machine layer, to keep them in a subtree somewhere, but you're still going to have to call out of the jail/virtual machine to let them run the script, so it's the same archetecture, just a different network.

    --
    - "History shows again and again how nature points out the folly of men" -- Blue Oyster Cult, 'Godzilla'
  52. Perl Compiler? by Futurepower(R) · · Score: 1

    Aren't there true compilers for Perl?

  53. Convert it to Morse code by colonwq · · Score: 1

    You could use this module to convert your code to Morse code.

    :wq

    --
    -- Phase 1: Collect under pants Phase 2: ? Phase 3: Profit
  54. Uuhhhh...... by Now.Imperfect · · Score: 0

    You give a bunch of college kids root access to a public access server?

    how many porn sites do you host?

  55. perlcc -B by Anonymous Coward · · Score: 0

    'perlcc -B' may do (it's quite broken, but it works fine with many scripts).
    And no, one cannot run Deparse on it.

  56. Not really, but check out Filter::decrypt by shotgunefx · · Score: 1

    It can't really be done. You can make it harder, but never bulletproof.

    You can use Filter::decrypt or similar to encrypt the source, but if someone's really determined, they can you the B:: modules to look at the opcodes and convert it back to Perl.

    --

    -William Shatner can be neither created nor destroyed.
  57. perlcc by Anonymous Coward · · Score: 0

    PERLCC(1) Perl Programmers Reference Guide PERLCC(1)

    NAME
                  perlcc - generate executables from Perl programs

    DESCRIPTION
                  perlcc creates standalone executables from Perl programs, using the
                  code generators provided by the B module. At present, you may either
                  create executable Perl bytecode, using the "-B" option, or generate and
                  compile C files using the standard and 'optimised' C backends.

                  The code generated in this way is not guaranteed to work. The whole
                  codegen suite ("perlcc" included) should be considered very experimen-
                  tal. Use for production purposes is strongly discouraged.

  58. Let learners use UML or Bochs by davidwr · · Score: 2, Informative

    Root for learning is a great idea but these days give people their own virtual machines. Bochs, User-Mode Linux, and a variety of other solutions are out there.

    Besides, most students have PCs and they can install Linux on their boxes if they want to. Maybe you can negotiate a university license for VMWare or MS's VirtualPC so they can have both MS-Windows and Linux up concurrently in their own dorms.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    1. Re:Let learners use UML or Bochs by mrmeval · · Score: 1

      Qemu rocks, it emulates a PC and does it well. It does NOT emulate a good video card but all else does work.

      I run 98SE with it.

      --
      I'd go on a Vegan diet but the delivery time from Vega is too long. --brownkitty
  59. thats quite freaky by petantik+f00l · · Score: 2, Interesting

    I just posted on comp.lang.python asking about available protection schemes for python code

    Python obfuscation thread at comp.lang.python


    petantik.blogsome.com - A Lucid Look at Reality

  60. Lateral Thinking by HogynCymraeg · · Score: 2, Informative

    Give them root on a XEN machine, not the primary box. Allow them to access you perl code in whatever fashion it was intended.

  61. No perfect solution by dynamo · · Score: 1

    But Acme::Bleach and Acme::Eyedrops can at least make it a pain in the ass to work out what it's doing.

    However it could be copied verbatim and it would still work.

    As with all other things perl, see CPAN and perlmonks for more information.

    - Paul

  62. MUHAHAHHAHAHAHAHAHA by perlhax · · Score: 0, Troll

    Whatever. Please switch to python, please..they need more companies like yours ,and the perl community needs many less. muhahahahahahahaahah

  63. perlcc -B file by bogeskov · · Score: 1

    man perlcc

    This however only applies for .pl not for .pm (as far as I can see).
    But no one can stop you from including all your pm's into one .pl file..
    Ugly but usable.

    I've never gotten the perlcc to binary (only to bytecode) to work with modules.

    --

    1. Re:perlcc -B file by dotnetwolf2003 · · Score: 1
      The output of perlcc -B can be easily reversed in 1 second using B::Deparse..

      Just use obfuscators for renaming symbols in your code, there is no other way.

  64. Um... by Anonymous Coward · · Score: 0

    You want to *protect* something on a machine you're giving root access to?

    You work for Microsoft, don't you?

  65. Well, it's obvious. by Ciaran_H · · Score: 1

    Acme::DonMartin is the way to go.

    "The first time you run a program under Acme::DonMartin, your source code is magically transformed into Don Martin cartoon sound effects. [...] This can also be construed as a security feature. It is expected that a hacker will be laughing too hard to be able to recover the source code."

  66. SUMMARY: Using obfuscators is the only option! by dotnetwolf2003 · · Score: 1
    There are no options besides obfuscation. Consider the following:

    1. perlcc to compiled code doesn't work for compiling to C for most of code (and generates 5-10Mb of C code that compiles for 10 minutes by gcc) and result doesn't work almost all of the time. Output of 'perlcc -B' can be reversed using B::Deparse..

    2. ActiveState PerlApp just extracts all your project's files to a temporary directory during execution of your "compiled" code. Just copy them from there, with all comments and documentation. Simply LOL. Why nobody is sueing ActiveState for this?

    3. Using PAR even with --filter option produces rather readable code, that doesn't work most of the time for real projects.

    4. Using perl2exe is questionable due to existnance of exe2perl (search on google for it). If it won't work for current version of perl2exe, memory dump of running process should do the trick and one will get cleartext of your scripts with comments and everything.

    The only reliable and unreversable solution is the use of obfuscator - like Stunnix Perl-Obfus. Obfuscators replace names of variables and functions (and other names like names of file handles) with some random-generated identifiers (this is one-way function, it can't be reversed), also removing comments, white spaces and replacing strings and integers with expressions or their uglified versions.

  67. But wait! by Anonymous Coward · · Score: 0

    I know two complete applications written in Perl. Solarwinds TFTP (http://www.solarwinds.net/ and Whitehorn TFTP (http://www.pegsol.com./ Use TFTPD32! Loosers.

  68. Blackboard? by Anonymous Coward · · Score: 0

    I'm trying to use that pile of shit to mark some assignments right now. Here's a hint. DON'T EVER USE BLACKBOARD VOLUNTARILY. It is an impediment to productivity.