www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Obfuscating function names and the like inside exe file

reply bobef <_asd_ASd_ASD_Asdasd_ASd asdasda___dasd.com> writes:
Hello all,

I was wondering if someone know of way to obfuscate all the strings and
function names and class names inside DMD Windows generated exe file. Opening
the file with notepad shows all kinds of strings and names in clear text and
since my application handles some sensitive data it gives me an extra feeling
of insecurity. Any suggestions?

Thanks
Mar 20 2010
next sibling parent reply Bane <branimir.milosavljevic gmail.com> writes:
bobef Wrote:

 Hello all,
 
 I was wondering if someone know of way to obfuscate all the strings and
function names and class names inside DMD Windows generated exe file. Opening
the file with notepad shows all kinds of strings and names in clear text and
since my application handles some sensitive data it gives me an extra feeling
of insecurity. Any suggestions?
 
 Thanks
Compress/encode sensitive data and give meaningless names to function/classes ? :)
Mar 20 2010
parent Steve Teale <steve.teale britseyeview.com> writes:
On Sat, 20 Mar 2010 09:53:17 -0400, Bane wrote:

 Compress/encode sensitive data and give meaningless names to
function/classes ? :)
Bane, You have become a changed person - these days you are tolerant to a fault. Do try to keep a balance! Steve
Mar 20 2010
prev sibling next sibling parent reply "Robert Jacques" <sandford jhu.edu> writes:
On Sat, 20 Mar 2010 10:12:14 -0300, bobef  
<_asd_ASd_ASD_Asdasd_ASd asdasda___dasd.com> wrote:
 Hello all,

 I was wondering if someone know of way to obfuscate all the strings and  
 function names and class names inside DMD Windows generated exe file.  
 Opening the file with notepad shows all kinds of strings and names in  
 clear text and since my application handles some sensitive data it gives  
 me an extra feeling of insecurity. Any suggestions?

 Thanks
Regarding function names/etc. I'd expect any industry standard obfuscator would scramble them for you. A bigger problem is the data segment which stores any constant strings, etc. If you really have to include them in your program, I'd recommend writing a compile time encrypt and runtime decrypt function pair. i.e. string name = rt_decrypt(ct_encrypt!"important name");
Mar 20 2010
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 03/20/2010 11:24 AM, Robert Jacques wrote:
 On Sat, 20 Mar 2010 10:12:14 -0300, bobef
 <_asd_ASd_ASD_Asdasd_ASd asdasda___dasd.com> wrote:
 Hello all,

 I was wondering if someone know of way to obfuscate all the strings
 and function names and class names inside DMD Windows generated exe
 file. Opening the file with notepad shows all kinds of strings and
 names in clear text and since my application handles some sensitive
 data it gives me an extra feeling of insecurity. Any suggestions?

 Thanks
Regarding function names/etc. I'd expect any industry standard obfuscator would scramble them for you. A bigger problem is the data segment which stores any constant strings, etc. If you really have to include them in your program, I'd recommend writing a compile time encrypt and runtime decrypt function pair. i.e. string name = rt_decrypt(ct_encrypt!"important name");
Doesn't that just put "important name" in the mangled name of ct_encrypt (albeit in hex)?
Mar 20 2010
parent BCS <none anon.com> writes:
Hello Ellery,

 On 03/20/2010 11:24 AM, Robert Jacques wrote:
 
 On Sat, 20 Mar 2010 10:12:14 -0300, bobef
 <_asd_ASd_ASD_Asdasd_ASd asdasda___dasd.com> wrote:
 Hello all,
 
 I was wondering if someone know of way to obfuscate all the strings
 and function names and class names inside DMD Windows generated exe
 file. Opening the file with notepad shows all kinds of strings and
 names in clear text and since my application handles some sensitive
 data it gives me an extra feeling of insecurity. Any suggestions?
 
 Thanks
 
Regarding function names/etc. I'd expect any industry standard obfuscator would scramble them for you. A bigger problem is the data segment which stores any constant strings, etc. If you really have to include them in your program, I'd recommend writing a compile time encrypt and runtime decrypt function pair. i.e. string name = rt_decrypt(ct_encrypt!"important name");
Doesn't that just put "important name" in the mangled name of ct_encrypt (albeit in hex)?
Use a CTFE compression function and that problem should go away (as long as you can force CTFE). -- ... <IXOYE><
Mar 20 2010
prev sibling next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
bobef wrote:
 I was wondering if someone know of way to obfuscate all the strings and
 function names and class names inside DMD Windows generated exe file. Opening
 the file with notepad shows all kinds of strings and names in clear text and
 since my application handles some sensitive data it gives me an extra feeling
 of insecurity. Any suggestions?
1. make sure you're not compiling with debug info (-g) on. 2. you can just use a bit editor to stomp on those names in the executable (replace them with XXXXX or whatever). The exe files are not checksummed, so this should be straightforward. 3. rename your sensitive classes to obscure names, then alias them to a readable name. The alias name shouldn't appear in the executable: class CXX97ASDFXX { } alias CXX97ASDFXX mySensitiveName;
Mar 20 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:ho34du$2lij$1 digitalmars.com...
 bobef wrote:
 I was wondering if someone know of way to obfuscate all the strings and
 function names and class names inside DMD Windows generated exe file. 
 Opening
 the file with notepad shows all kinds of strings and names in clear text 
 and
 since my application handles some sensitive data it gives me an extra 
 feeling
 of insecurity. Any suggestions?
1. make sure you're not compiling with debug info (-g) on. 2. you can just use a bit editor to stomp on those names in the executable (replace them with XXXXX or whatever). The exe files are not checksummed, so this should be straightforward. 3. rename your sensitive classes to obscure names, then alias them to a readable name. The alias name shouldn't appear in the executable: class CXX97ASDFXX { } alias CXX97ASDFXX mySensitiveName;
Wouldn't compiler errors still refer to the obfuscated name?
Mar 20 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Nick Sabalausky wrote:
 3. rename your sensitive classes to obscure names, then alias them to a 
 readable name. The alias name shouldn't appear in the executable:

     class CXX97ASDFXX { }
     alias CXX97ASDFXX mySensitiveName;
Wouldn't compiler errors still refer to the obfuscated name?
Sometimes.
Mar 20 2010
parent Mike James <foo bar.com> writes:
Walter Bright Wrote:

 Nick Sabalausky wrote:
 3. rename your sensitive classes to obscure names, then alias them to a 
 readable name. The alias name shouldn't appear in the executable:

     class CXX97ASDFXX { }
     alias CXX97ASDFXX mySensitiveName;
Wouldn't compiler errors still refer to the obfuscated name?
Sometimes.
Ah... An obfuscated answer to an obfuscation question.
Mar 21 2010
prev sibling next sibling parent Bane <branimir.milosavljevic gmail.com> writes:
Walter Bright Wrote:

 Nick Sabalausky wrote:
 3. rename your sensitive classes to obscure names, then alias them to a 
 readable name. The alias name shouldn't appear in the executable:

     class CXX97ASDFXX { }
     alias CXX97ASDFXX mySensitiveName;
Wouldn't compiler errors still refer to the obfuscated name?
Sometimes.
Lol :)))) There goes determinism down the drain.
Mar 20 2010
prev sibling next sibling parent Daniel Keep <daniel.keep.lists gmail.com> writes:
bobef wrote:
 Hello all,
 
 I was wondering if someone know of way to obfuscate all the strings and
function names and class names inside DMD Windows generated exe file. Opening
the file with notepad shows all kinds of strings and names in clear text and
since my application handles some sensitive data it gives me an extra feeling
of insecurity. Any suggestions?
 
 Thanks
module seakrit; char[] supar_enkript(char[] mah_secret) { char[] result = mah_secret.dup; for( size_t i=0; i<result.length; ++i ) result[i] = ~result[i]; return result; } alias supar_enkript supar_dekript; const supar_seakrit_password = supar_enkript("O HAI THAR"); import tango.io.Stdout; void main() { Stdout("Tha supar seakrit password is: ") (supar_dekript(supar_seakrit_password)).newline; } Note that simply using supar_enkript("O HAI THAR") isn't sufficient; you have to make sure you trigger compile-time evaluation or you'll end up with the seakrit in the object file. For extra sekuritee, put supar_enkript in another module that you never link to. Of course, the reason for all the bad spelling is to indicate that this isn't really something I can imagine helping. If your program handles sensitive data, protect the data, not your program. If your program *contains* sensitive information, don't give it to the wrong people. If someone is really, seriously determined to get at that information, there's nothing you can do to stop them.
Mar 20 2010
prev sibling parent reply bobef <_asd_ASd_ASD_Asdasd_ASd asdasda___dasd.com> writes:
Walter Bright Wrote:

 
 1. make sure you're not compiling with debug info (-g) on.
 
Bye bye stack traces... :(
 2. you can just use a bit editor to stomp on those names in the executable 
 (replace them with XXXXX or whatever). The exe files are not checksummed, so 
 this should be straightforward.
 
Too much manual work. Any clues how I can automate this? At least where I should look for info?
 3. rename your sensitive classes to obscure names, then alias them to a
readable 
 name. The alias name shouldn't appear in the executable:
 
      class CXX97ASDFXX { }
      alias CXX97ASDFXX mySensitiveName;
Nice idea. Didn't thought about it. But it won't work for external libraries. For example if I'm using dcrypt it will be obvious I'm using one of its supported ciphers for my encrypted data. I wouldn't wish this to be so obvious, at least not for people without reverse-engineering skills. Thanks.
Mar 21 2010
next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
bobef wrote:
 Walter Bright Wrote:
>> 2. you can just use a bit editor to stomp on those names in the executable
  (replace them with XXXXX or whatever). The exe files are not checksummed,
 so this should be straightforward.
 
Too much manual work. Any clues how I can automate this? At least where I should look for info?
You can write a simple D program that contains a list of strings to patch. It reads the exe file, patches it, and writes it back out.
Mar 21 2010
prev sibling parent BCS <none anon.com> writes:
Hello bobef,

 Walter Bright Wrote:
 
 1. make sure you're not compiling with debug info (-g) on.
 
Bye bye stack traces... :(
Only for release builds.
 2. you can just use a bit editor to stomp on those names in the
 executable (replace them with XXXXX or whatever). The exe files are
 not checksummed, so this should be straightforward.
 
Too much manual work. Any clues how I can automate this? At least where I should look for info?
If you know what to look for, some kind of find/replace might work.
 3. rename your sensitive classes to obscure names, then alias them to
 a readable name. The alias name shouldn't appear in the executable:
 
 class CXX97ASDFXX { }
 alias CXX97ASDFXX mySensitiveName;
Nice idea. Didn't thought about it. But it won't work for external libraries. For example if I'm using dcrypt it will be obvious I'm using one of its supported ciphers for my encrypted data. I wouldn't wish this to be so obvious, at least not for people without reverse-engineering skills.
I'd assume anyone who can identify the cypher from function names and apply it to strings in the file already has reverse-engineering skills. And if you are considering the attacker knowing what cypher you are using to be a security issue, don't bother I anyone able to think about cracking any real cypher can get that from the binary no matter what you do. -- ... <IXOYE><
Mar 21 2010