<p>Does anyone know of a good code obsfucator for Perl? I'm being ask to look into the option of obsfucating code before releasing it to a client. I know obsfucated code can still be reverse engineered, but that's not our main concern. </p>

<p>Some clients are making small changes to the source code that we give them and it's giving us nightmares when something goes wrong and we have to fix it, or when we release a patch that doesn't work with what they've changed. So the intention is just to make it so that it's difficult for them to make their own changes to the code(they're not supposed to be doing that anyway).</p>

[{'answer_id': 71078, 'author': 'Dave Cross', 'author_id': 7231, 'author_profile': 'https://Stackoverflow.com/users/7231', 'pm_score': 3, 'selected': False, 'text': '<p>Please don\'t do that. If you don\'t want people to alter your Perl code then put it under an appropriate licence and enforce that licence. If people change your code when you licence says that they shouldn\'t do that, then it\'s not your problem when your updates not longer work with their installation.</p>\n\n<p>See <a href="http://perldoc.perl.org/perlfaq3.html#How-can-I-hide-the-source-for-my-Perl-program%3f" rel="nofollow noreferrer">perlfaq3\'s answer to "How Can I hide the source for my Perl programs?</a> for more details.</p>\n'}, {'answer_id': 71097, 'author': 'rjray', 'author_id': 6421, 'author_profile': 'https://Stackoverflow.com/users/6421', 'pm_score': 4, 'selected': False, 'text': "<p>Don't. Just don't.</p>\n\n<p>Write it into the contract (or revise the contract if you have to), that you are not responsible for changes they make to the software. If they're f-ing up your code and then expecting you to fix it, <em>you have client problems that aren't going to be solved by obfuscating the code</em>. And if you obfuscate it and they encounter an actual problem, good luck in getting them to accurately report line number, etc., in the bug report.</p>\n"}, {'answer_id': 71116, 'author': 'Ovid', 'author_id': 8003, 'author_profile': 'https://Stackoverflow.com/users/8003', 'pm_score': 6, 'selected': True, 'text': '<p>I\'ve been down this road before and it\'s an absolute nightmare when you have to work on "obfuscated" code because it drives up costs tremendously trying to debug a problem on the client\'s server when you, the developer, can\'t read the code.  You wind up with "deobfuscators", copying the "real code" to the client\'s server or any of a number of other issues which just become a real hassle to maintain.</p>\n\n<p>I understand where you\'re coming from, but it sounds like management has a problem and they\'re looking to you to implement a chosen solution rather than figuring out what the correct solution is.</p>\n\n<p>In this case, it sounds like it\'s really a licensing or contractual issue.  Let \'em have the code open source, but make it a part of the license that any changes they submit have to come back to you and be approved.  When you push out patches, check the md5 sums of all code and if it doesn\'t match what\'s expected, they\'re in license violation and will be charged accordingly (and it should be a far, far higher rate).  (I remember one company which let us have the code open source, but made it clear that if we changed anything, we\'ve "bought" the code for $25,000 and they were no longer responsible for any bug fixes or upgrades unless we bought a new license).</p>\n'}, {'answer_id': 71133, 'author': 'freespace', 'author_id': 8297, 'author_profile': 'https://Stackoverflow.com/users/8297', 'pm_score': 3, 'selected': False, 'text': "<p>It would seem your main issue is clients modifying code which then makes it difficult for you to support it. I would suggest you ask for checksums (md5,sha, etc) of their files when they come to you for support, and similarly check files' checksums when patching. For example, you can ask the client to provide the output of a provided program which goes through their install and checksums all the files.</p>\n\n<p>Ultimately they have the code, so they can do whatever they want to it. The best you can do is enforce your licenses and to make sure you only support unmodified code.</p>\n"}, {'answer_id': 71135, 'author': 'EvdB', 'author_id': 5349, 'author_profile': 'https://Stackoverflow.com/users/5349', 'pm_score': 2, 'selected': False, 'text': '<p>In this case obfuscating is the wrong approach.</p>\n\n<p>When you release the code to the client you should keep a copy of the code you send them (either on disk or preferably in your version control as a tag/branch).</p>\n\n<p>Then if your client makes changes you can compare the code they have to the code you sent them and easily spot the changes. After all if they feel the need to make changes there is a problem somewhere and you should fix it in the master codebase.</p>\n'}, {'answer_id': 71294, 'author': 'David Webb', 'author_id': 3171, 'author_profile': 'https://Stackoverflow.com/users/3171', 'pm_score': 2, 'selected': False, 'text': '<p>An alternative to obfuscation is converting your script to a binary using something like <a href="http://www.activestate.com/Products/perl_dev_kit/index.mhtml" rel="nofollow noreferrer">ActiveState\'s Perl Dev Kit</a>. </p>\n'}, {'answer_id': 71403, 'author': 'cressie176', 'author_id': 11786, 'author_profile': 'https://Stackoverflow.com/users/11786', 'pm_score': 2, 'selected': False, 'text': '<p>This isn\'t a serious suggestion, however take a look at <a href="http://search.cpan.org/dist/Acme-Buffy" rel="nofollow noreferrer">Acme::Buffy</a>.</p>\n\n<p>It will at least brighten your day!</p>\n'}, {'answer_id': 71425, 'author': 'xdg', 'author_id': 11800, 'author_profile': 'https://Stackoverflow.com/users/11800', 'pm_score': 2, 'selected': False, 'text': '<p>Another alternative for converting your program into a binary is the free <a href="http://search.cpan.org/dist/PAR-Packer/" rel="nofollow noreferrer">PAR-Packer</a> tool on <a href="http://search.cpan.org" rel="nofollow noreferrer">CPAN</a>.  There are even filters for code obfuscation, though as others have said, that\'s possibly more trouble than it\'s worth.</p>\n'}, {'answer_id': 71747, 'author': 'Penfold', 'author_id': 11952, 'author_profile': 'https://Stackoverflow.com/users/11952', 'pm_score': 2, 'selected': False, 'text': '<p>As several folks have already said: don\'t.</p>\n\n<p>It\'s pretty much implicit, given the nature of the Perl interpreter, that anything you do to obfuscate the Perl must be undoable before Perl gets its hands on it, which means you need to leave the de-obfuscation script/binary lying around where the interpreter (and thus your customer) can find it :)</p>\n\n<p>Fix the real problem: checksums and/or a suitably worded license. And support staff trained to say \'you changed it? we\'re invoking clause 34b of our license, and that\'ll be $X,000 before we touch it\'....</p>\n\n<p>Also, read <a href="https://stackoverflow.com/questions/31882/why-should-i-use-obfuscation">why-should-i-use-obfuscation</a> for a more general answer.</p>\n'}, {'answer_id': 73457, 'author': 'piCookie', 'author_id': 8763, 'author_profile': 'https://Stackoverflow.com/users/8763', 'pm_score': 2, 'selected': False, 'text': '<p>I am running a Windows O/S and use perl2exe from IndigoSTAR. The resulting .EXE file will be unlikely to be changed on-site.</p>\n\n<p>As others have said, "how do I obfuscate it" is the wrong question. "How do I stop the customer from changing the code" is the right one.</p>\n'}, {'answer_id': 73898, 'author': 'Cosimo', 'author_id': 11303, 'author_profile': 'https://Stackoverflow.com/users/11303', 'pm_score': 2, 'selected': False, 'text': '<p>I agree with the previous suggestions.</p>\n\n<p>However if you really want to, you can look into <a href="http://search.cpan.org/dist/PAR" rel="nofollow noreferrer">PAR</a> and/or <a href="http://search.cpan.org/dist/Filter-Crypto" rel="nofollow noreferrer">Filter::Crypto</a> CPAN modules. You can also use them together.</p>\n\n<p>I used the latter (Filter::Crypto) as a really lightweight form of "protection" when we were shipping our product on optical media. It doesn\'t "protect" you, but it will stop 90% of the people that want to modify your source files.</p>\n'}, {'answer_id': 79973, 'author': 'Eric Wilhelm', 'author_id': 11580, 'author_profile': 'https://Stackoverflow.com/users/11580', 'pm_score': 2, 'selected': False, 'text': '<p>The checksum and contract ideas are good for preventing the "problems" you describe, but if the cost to you is the difficulty of rolling-out upgrades and bug-fixes, how are your clients making changes that don\'t pass the <b>comprehensive test suite</b>?  If they are capable of making these changes (or at least, making a change which expresses what they want the code to do), why not simply make it easy/automated for them to open a support ticket and upload the patch?  The customer is always right <em>about what the customer wants</em> (they might not have a clue how to do it "the right way", but that\'s why they are paying you.)</p>\n\n<p>A better reason to want an obfuscator would be for mass-market desktop deployment where you don\'t have every customer on a standing contract.  In that case, something <em>like</em> PAR -- anything which packs the encryption/obfuscation logic into a compiled binary is the way to go.</p>\n'}, {'answer_id': 83878, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>I would just invite them into my SVN tree on their own branch so they can provide changes and I can see them and integrate their changes into my development tree. </p>\n\n<p>Don't fight it, embrace it. </p>\n"}, {'answer_id': 109565, 'author': 'brian d foy', 'author_id': 2766176, 'author_profile': 'https://Stackoverflow.com/users/2766176', 'pm_score': 1, 'selected': False, 'text': '<p>As Ovid says, it\'s a contractual, social problem. If they change the code, they invalidate the warranty. Charge them a lot to fix that, but at the same time, give them a channel where they can suggest changes. Also, look at what they want to change and make that part of the configuration if you can. They have something they want to do, and until you satisfy that, they are going to keep trying to get around you.</p>\n\n<p>In <A href="http://oreilly.com/catalog/9780596527242/" rel="nofollow noreferrer">Mastering Perl</a>, I talk a bit about defeating obfucators. Even if you do things like making nonsense variables names and the like, modules such as <a href="http://search.cpan.org/dist/B-Deparse" rel="nofollow noreferrer">B::Deparse</a> and <a href="http://search.cpan.org/dist/B-Deobfuscate" rel="nofollow noreferrer">B::Deobfuscate</a>, along with Perl tools such as <a href="http://search.cpan.org/dist/Perl-Tidy" rel="nofollow noreferrer">Perl::Tidy</a>, make it pretty easy for the knowledgable and motivated person to get your source. You don\'t have to worry about the unknowledgable and unmotivated so much because they don\'t know what to do with the code anyway. </p>\n\n<p>When I talk to managers about this, we go through the normal cost benefit analysis. There is all sorts of stuff you <i>could</i> do, but not much of it costs less than the benefit you get.</p>\n\n<p>Good luck,</p>\n'}, {'answer_id': 23672411, 'author': 'pau4o', 'author_id': 1353117, 'author_profile': 'https://Stackoverflow.com/users/1353117', 'pm_score': 0, 'selected': False, 'text': '<p>Another not serious suggestion is to use <a href="https://metacpan.org/pod/Acme%3a%3aBleach" rel="nofollow">Acme::Bleach</a>, it will make your code very clean ;-)</p>\n'}]
['https://Stackoverflow.com/questions/71057', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11708/']