4

I'm looking for an idea. An idea that can--in some form--allow me to pepper my Perl code with hard-to-remove copyright comments all over the place so that it's almost illegible and is difficult to remove using a regex--with the code still being executable.


As one of the commenters has pointed out below the following trick can be applied to any such normal technique:

perl -MO=Deparse obfuscated.pl > plaintext.pl

Perhaps someone here can find a work around.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
user3333975
  • 125
  • 10
  • I'm working with someone who I've seen take credit for work that was not his own. It's a long story. – user3333975 Mar 03 '14 at 17:22
  • The expression can look odd, just as long as it has my name and is legible. – user3333975 Mar 03 '14 at 17:31
  • What would be interesting is if each instance of the copyright was written in a different way according to some algorithm. Like, perhaps I can make a code processing program that takes in my code and then spits out a copy-righted mess that is all "random," but nonetheless executes. – user3333975 Mar 03 '14 at 17:42
  • 2
    You're searching for a technical solution to a social problem. If you really want something bullet-proof, register your copyright with the [U.S. Copyright Office](http://www.copyright.gov/) (or the equivalent in your country of residence). It looks like it costs $35 to register a single work online. Of course, if this code is for your employer, they may already have rights to it. If that's the case, perhaps you should consult with your boss about your worry that your code will be stolen by someone you work with. – ThisSuitIsBlackNot Mar 03 '14 at 17:54
  • and several more $$$ to litigate an alleged copyright violation. – mob Mar 03 '14 at 17:56
  • @ThisSuitIsBlackNot, it's not for my boss. Also, I'm aware of this. Just looking for something that would deter people who are sharp enough in their wit to understand what I'm doing. A lot of code gets tossed around in a close-knit community, and sometimes people think it's the coolest thing. I don't have time to register it with the U.S. Copyright Office. Actually, you know what... I don't care anymore. I know myself well enough that I can live humbly even if it gets ripped off. I guess this whole intellectual property business is a pride thing. I don't seem to value pride these days. – user3333975 Mar 03 '14 at 18:15
  • Also, I don't intend on ever having a boss... – user3333975 Mar 03 '14 at 18:17
  • Is your really that one time never written before, does something so unique that it can be patented? Copyrght is joke, "it was a dark and stormy night", Either people know its your code or they do not. – alexmac Mar 03 '14 at 21:06
  • 2
    Not to rain on your parade, but regardless of the copious amounts of comments in a file, you can still do `perl -MO=Deparse obfuscated.pl > plaintext.pl` which is fairly simple, and not too obscure. – TLP Mar 04 '14 at 01:05
  • Not at all, that is good to know. Thanks for the trick. I'll remember that. ^_^ – user3333975 Mar 04 '14 at 01:35

3 Answers3

7

My contribution, easy to work around, but may trip up a sloppy code stealer: introduce subtle bugs into the code if the copyright notice has been tampered with

Example:

sub square_root {
    my $arg = shift;
    return sqrt($arg + 0.1 * apply_fudge_factor());
}

sub apply_fudge_factor {
    return 8410 != unpack("%32W*", ($::D//=join'',<DATA>));
}

print "sqrt(9)=",square_root(9);

__END__
=head1 NAME

my_program.pl - a program by me, and not by you

=head1 AUTHOR

Copyright (c) 2014 by Me

=cut

The checksum of the pod is 8410. If you make any changes after the __END__ token, the output of the program is

sqrt(9)=3.01662062579967
mob
  • 117,087
  • 18
  • 149
  • 283
  • irrespective of the copyright notice above, all content on Stack Exchange sites, including sample code, is licensed to Stack Exchange under the Creative Commons Attribution Share Alike license. – mob Mar 03 '14 at 23:26
2

As has been pointed out in the comments, it is easy to remove all comments.

What you want to do is leave your trademark in an unmistakable way. You may want to give Acme::EyeDrops a whirl.

Zaid
  • 36,680
  • 16
  • 86
  • 155
1

Someone deliberately looking to take credit for your work is likely not going to think twice about removing your copyright notices no matter how you add them. You've actually got a larger problem that is not easily resolved by code.

That said, one trick I used once was to use a hex editor to add text to the tail end of JPEG images used by my application. Many programs simply ignore this extra info and because it is added outside of the usual EXIF fields it can be difficult to detect using image editors alone, though text search can be done to find it of you use easily discerned text. See the following link for more info...

http://en.wikipedia.org/wiki/Steganography

Another option is an old trick of loading data into something called "alternate data streams" if you are on a Windows system.

Rick Sarvas
  • 769
  • 10
  • 20
  • Yes, I've read of this. Actually, I first heard of it on [Hacker News](https://news.ycombinator.com/). I'm curious, what is this "old trick"? – user3333975 Mar 03 '14 at 18:07
  • It's just an acquaintance I'm dealing with. He asked if he could use some of my code to process something he's working with in his own code. I guess it's like being a master carpenter working on all the ornate and detailed trimming, railing, cabinets, and so on, in a mansion that is owned by a man who later claims that some aspect of the ornateness was his own doing... Or something... It sort of would rake at the heart of a carpenter wouldn't it? – user3333975 Mar 03 '14 at 18:40
  • Probably the best way to see "alternate data streams" in action is to use notepad to create a file called "text.txt" somewhere and then add some text and save it. Next, use notepad to create a file called "text.txt:SomeOtherFileStream" at the same location. Note the colon, that's the important bit. Add some text and save it. Open up "text.txt" and see the first bit of text you typed. Open up "text.txt:SomeOtherFileStream" and see the other text. 2 data streams, but only one file shows. Copy the file to another location and both streams copy. – Rick Sarvas Mar 03 '14 at 19:51
  • Keep in mind that this is somewhat NTFS specific and will not work if files are copied to other file systems. Also, many application are not aware of these other file streams and will simply ignore them when encountered if used to transfer data to other systems. – Rick Sarvas Mar 04 '14 at 14:42