Results 1 to 8 of 8
  1. #1

    Simple tool to hide string literals in code

    Here is an excerpt from an obfuscation engine I'm writing that some of you might find helpful. It takes string literals from a source file and automatically generates replacement code that makes tracing strings non-trivial.

    When there is a piece of code like printf("Hello World!"); the compiler simply stores the string literal 'Hello World' in memory. Any hexdumper or decompiler will show its presence and where it is referenced from.

    This preprocessor tool will find & replace literals enclosed within HIDE_ME().

    Example program:
    Code:
    #include <stdio.h>
    #define HIDE_ME(x) x
    
    int main()
    {
        char secret[32];
        char *password = HIDE_ME("ih00q:<");
        sprintf(secret, HIDE_ME("password: %s"), password);
        
        printf("Strings %s -> %s\n", password, secret);
        return 0;
    }
    The generated output now is

    Code:
    char __inline__ *uzht0()
    {
    static char s[8];
    *(s+0) = (char)(167 ^ 206);
    *(s+1) = (char)(78 ^ 38);
    *(s+2) = (char)(233 ^ 217);
    *(s+3) = (char)(108 ^ 92);
    *(s+4) = (char)(123 ^ 10);
    *(s+5) = (char)(194 ^ 248);
    *(s+6) = (char)(89 ^ 101);
    *(s+7) = 0;
    return s;
    }
    
    char __inline__ *xjut32549400()
    {
    static char s[13];
    *(s+0) = (char)(144 ^ 224);
    *(s+1) = (char)(172 ^ 205);
    *(s+2) = (char)(7 ^ 116);
    *(s+3) = (char)(187 ^ 200);
    *(s+4) = (char)(59 ^ 76);
    *(s+5) = (char)(99 ^ 12);
    *(s+6) = (char)(23 ^ 101);
    *(s+7) = (char)(245 ^ 145);
    *(s+8) = (char)(167 ^ 157);
    *(s+9) = (char)(118 ^ 86);
    *(s+10) = (char)(135 ^ 162);
    *(s+11) = (char)(183 ^ 196);
    *(s+12) = 0;
    return s;
    }
    
    #include <stdio.h>
    
    int main()
    {
        char secret[32];
        char *password = uzht0();
        sprintf(secret, xjut32549400(), password);
        
        printf("pass: %s\nStrings %s -> %s\n", password, password, secret);
        return 0;
    }
    Now all string literals enclosed within the token are hidden from the final executable.

    This version for pub release only uses one simple kernel, one that generates a byte-by-byte xor of the literal. Obviously one can add many different ones and select randomly between them. The only requirement for the kernel is that is is bijective.

    <Source code>
    int *(*(*(*x)()) [10]) ();

  2. #2

    Re: Simple tool to hide string literals in code

    Once again Jmp you revolutionise the coding industry with another excellent release!

    Comes in handy to stop public bots been hexed

    Thanks ! *BOWS*

  3. #3

    Re: Simple tool to hide string literals in code

    very nice thanks, i will still use OGC's xor class cause its a little more compact to use but it's good to see original stuff. whatever your developing sounds interesting too

  4. #4

    Re: Simple tool to hide string literals in code

    Sinner, the specific advantage of this (and why I wrote it the way I did) is because this is extremely easy to use. You can add as many kernels as you want and make it randomly select. You can make the kernel as exotic as you want. Instead of the simple demonstration of a single XOR (which isn't all that good, because the fixed values 34 ^ 123 are optimized out by the compiler - improvement would be to use a memory location) one could add some RC4 encryption flavour.

    And then just compile the tool, and add it to your custom build step in visual studio so it runs before the compiler does, and voila... no work, overhead, or extra code of any kind needed
    int *(*(*(*x)()) [10]) ();

  5. #5
    Semi-Coder
    Join Date
    Jun 2007
    Posts
    1,003

    Re: Simple tool to hide string literals in code

    Great release man,

    Good Job

  6. #6

    Re: Simple tool to hide string literals in code

    Very Nice Kobby!
    Once again a fascinating release and your contributions here are greatly appreciated!

    /stickied!


    Johnny D Is Back!- But not 100% certain on 100% activeness

    CU WIKI - Bring it back boys!

  7. #7
    Senior Member
    Join Date
    Feb 2007
    Posts
    213

    Re: Simple tool to hide string literals in code

    Someone can explain me how to use it , the english is not my native language so it's a bit hard for me to use it. (please) , just add source in project or we must add something for each string ?

  8. #8
    Junior Member
    Join Date
    Apr 2010
    Posts
    3

    Re: Simple tool to hide string literals in code

    Looks cool bro.

    Nice job!

Similar Threads

  1. x86obf code virtualization tool - crackme/keygen contest
    By chaplex in forum Non-Gaming Related
    Replies: 1
    Last Post: January 11th, 2014, 01:38
  2. [Request] Cod SD Noweapon string/bomb plant string for noweapon :P
    By obsidian in forum Call of Duty 1 Cheats
    Replies: 6
    Last Post: August 4th, 2009, 23:22
  3. [help]String Retrival
    By sloppyjoe in forum Basics
    Replies: 1
    Last Post: March 17th, 2009, 21:37
  4. current shader string - rtcw
    By FunkFui in forum OpenGL
    Replies: 20
    Last Post: March 6th, 2009, 02:03
  5. Best G-String
    By dudewtfhax in forum Comedy
    Replies: 5
    Last Post: July 21st, 2008, 15:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •