Spaghetti code for fun and profit?
May. 27th, 2006 06:25 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Something I've been wondering for awhile.
Discussions of the Halting Problem tend to talk about the paradox of a program that asks about itself, and then contradicts the answer. But that doesn't seem very interesting except as a proof! I'd really like, say, a program which is surprisingly difficult to pry apart and understand, or to make some desired modification without screwing it up.
For example, I hear some UNIX vendors sold systems with the source code, filtered so it was an obfuscated mess. You could compile and run it, but it would have been more effort to do your own dev work. Another one are viruses that decrypt themselves. This is still pretty primitive since either way, the machine language winds up as "plaintext" in memory anyway, and then you can just fire up your hardware debugger...
So is it possible to foil even that? Say you have the parse tree for some C++, is there some way to preserve what it does while seriously obscuring how it does it after compilation, and without requiring prior decryption? Preferably this would have to be many-to-few sort of thing, so you couldn't tell what a construct represented in the source, and semi-randomized. It should be a like a hash, where many bits of code depend on many other bits of code—dependencies, self-modification and side effects everywhere.
Now I don't suppose this would be all that useful, except for the really paranoid of the closed-source folks. More of a joke otherwise... heh! Maybe in that vein a C-to-Unlambda or Intercal or even Befunge compiler would work... XD
Other than that, I can't think of a good way to do it. Ahwell.
Discussions of the Halting Problem tend to talk about the paradox of a program that asks about itself, and then contradicts the answer. But that doesn't seem very interesting except as a proof! I'd really like, say, a program which is surprisingly difficult to pry apart and understand, or to make some desired modification without screwing it up.
For example, I hear some UNIX vendors sold systems with the source code, filtered so it was an obfuscated mess. You could compile and run it, but it would have been more effort to do your own dev work. Another one are viruses that decrypt themselves. This is still pretty primitive since either way, the machine language winds up as "plaintext" in memory anyway, and then you can just fire up your hardware debugger...
So is it possible to foil even that? Say you have the parse tree for some C++, is there some way to preserve what it does while seriously obscuring how it does it after compilation, and without requiring prior decryption? Preferably this would have to be many-to-few sort of thing, so you couldn't tell what a construct represented in the source, and semi-randomized. It should be a like a hash, where many bits of code depend on many other bits of code—dependencies, self-modification and side effects everywhere.
Now I don't suppose this would be all that useful, except for the really paranoid of the closed-source folks. More of a joke otherwise... heh! Maybe in that vein a C-to-Unlambda or Intercal or even Befunge compiler would work... XD
Other than that, I can't think of a good way to do it. Ahwell.