PDA

View Full Version : compiling with string hashing using gcc?


nregi
05-28-2003, 01:53 AM
Hello,
is there a way to compile c code using gcc and hash/scramble any string constants in the code?

Thanks in advance.

Strike
05-28-2003, 11:07 AM
Let me guess ... trying to obfuscate an executable further (more than just compiling does)?

Anyway, I don't know of a simple way to do it, but if there isn't a built-in way to do it (which I doubt, considering that the GNU folks aren't exactly in the business of helping people obfuscate binary-only software), then it sounds like you'd have to hardcode all your strings in some encrypted form and then decrypt them as needed in the program itself. Still not totally hackproof, but it makes it harder.

nregi
05-28-2003, 02:14 PM
Are there any tools that can obfuscate strings while compliling the C source code for Linux?

Thanks again.

stuka
06-02-2003, 11:32 AM
Do these strings need to be reread by the program in 'normal' form? If it's for password-type stuff, you could use crypt() on the strings before you put them in there, then, compare the stored string vs. the crypt() of the user's input.

nregi
06-02-2003, 04:09 PM
Hello,

In genereal I want all string constants in the source code to be encrypted or converted to a form that will not be readable by someone after it is compiled.
String constants are readable in the compiled app, is there a way to prevent that?

Thanks again.

stuka
06-04-2003, 05:43 PM
Sure, you could always take some sort of encryption algorithm, and encrypt all the strings in the source code, and then pull them back out by decrypting. A (faked) example:const string foo = "%sC94@3";
cout << decrypt(foo);You'd have to have a manual encryption routine (or maybe a scriptable one, for automating the process) in order to encrypt all the constants, but it'd be doable, at a small(?) cost in runtime performance.