Giter VIP home page Giter VIP logo

cpp11-compile-time-string-obfuscation's Introduction

cpp11-obfuscation

a mini project to obfuscate strings/hex and const char strings/objective c strings look at the obfuscate.h file

Note you will need to enable c++11

In obfuscate.h change the key to anything you want .) HASH(("UIApplicationDidBecomeActiveNotification") HASH(("definitely not a key .)")

    OBFUSCATE("som text"); // OBFUSCATE const char strings
    OBFUSCATE("hidden");
    OBFUSCATE("0x123456"); // can do conversions
     
    /*
     * only ios can use FBEncrypt
     */
    FBEncrypt("some text"); // OBFUSCATE NSStrings disable
    FBEncrypt("hidden");
    FBEncrypt("0x123456"); // can do conversions

    OBFUSCATEHEX("0x12"); // OBFUSCATE hex 0x123456
    OBFUSCATEHEX("0x123456");
    OBFUSCATEHEX("0x123456789"); // can encrypt long hex

    #define getRealOffset(offset) getAbsoluteOffset(OBFUSCATEHEX(offset))
    uint64_t getAbsoluteOffset(uint64_t offset);
    uint64_t getAbsoluteOffset(uint64_t offset){
        return (base + offset); // base is an actual value.
    }

    #define protectAbsoluteChar(str1, str2, str3) protectMeChar(OBFUSCATE(str1), OBFUSCATE(str2), OBFUSCATE(str3))
    void protectMeChar(const char *, const char *, const char *);
    void protectMeChar(const char *str1, const char *str2, const char *str3){
        OBFUSCATE("hidden");
        OBFUSCATE("absolutely hidden");

        str1 = (const char *)"str1 VALUE NOT HIDDEN";
        str2 = (const char *)"str2 VALUE NOT HIDDEN";
        str3 = (const char *)"str3 VALUE NOT HIDDEN";

        str1 = OBFUSCATE("str1 VALUE HIDDEN");
        str2 = OBFUSCATE("str2 VALUE HIDDEN");
        str3 = OBFUSCATE("str3 VALUE HIDDEN");

        const char *mainValueH = OBFUSCATE("HIDDEN");                         // Contains a value to hide
        const char *mainValueNH = (const char *)"NOT HIDDEN";                 // Contains a value not to hide
        NSLog(@"mainValueNH: %s\nmainValueH: %s\n", mainValueNH, mainValueH); // iOS
        LOGD("mainValueNH: %s\nmainValueH: %s\n", mainValueNH, mainValueH);   // Android
    }

    /*
     * iOS Only.
     */
    #define protectAbsoluteNSString(str1, str2, str3) protectMeChar(FBEncrypt(str1), FBEncrypt(str2), FBEncrypt(str3))
    void protectMeNSString(NSString *, NSString *, NSString *);
    void protectMeNSString(NSString *str1, NSString *str2, NSString *str3){
        FBEncrypt("hidden");
        FBEncrypt("absolutely hidden");

        str1 = @"str1 VALUE NOT HIDDEN";
        str2 = @"str2 VALUE NOT HIDDEN";
        str3 = @"str3 VALUE NOT HIDDEN";

        str1 = FBEncrypt("str1 VALUE HIDDEN");
        str2 = FBEncrypt("str2 VALUE HIDDEN");
        str3 = FBEncrypt("str3 VALUE HIDDEN");

        NSString *mainValueH = FBEncrypt("HIDDEN");                         // Contains a value to hide
        NSString *mainValueNH = @"NOT HIDDEN";                 // Contains a value not to hide
        NSLog(@"mainValueNH: %@\nmainValueH: %@\n", mainValueNH, mainValueH); // iOS
    }

    int main(){
       // Calling getRealOffset("hex")
       // Calling getAbsoluteOffset(0x123)

       uint64_t realOffset = getRealOffset("0x123456"); // must only be hex
       NSLog(@"getRealOffset: 0x%llx", realOffset);     // iOS
       LOGD("getRealOffset: 0x%llx", realOffset);       // Android(must define it)
  
       uint64_t absoluteOffset = getAbsoluteOffset(OBFUSCATEHEX("0x12345")); //    
       NSLog(@"absoluteOffset: 0x%llx", absoluteOffset);                     // iOS
       LOGD("absoluteOffset: 0x%llx", absoluteOffset);                       // Android(must define it)

      // calling our void functions
      protectAbsoluteChar("hidden", "hidden", "hidden");
      protectMeChar("NOT HIDDEN", "NOT HIDDEN", "NOT HIDDDEN");
      protectMeChar(OBFUSCATE("HIDDEN"), OBFUSCATE("HIDDEN"), OBFUSCATE("HIDDDEN"));

      // iOS only obj c
      protectAbsoluteNSString("HIDDEN", "HIDDEN", "HIDDEN");
      protectMeNSString(@"NOT HIDDEN", @"NOT HIDDEN", @"NOT HIDDEN");
      protectMeNSString(FBEncrypt("HIDDEN"), FBEncrypt("HIDDEN"), FBEncrypt("HIDDEN"));

    }

#ORIGINAL SOURCE: http://www.rohitab.com/discuss/topic/39611-malware-related-compile-time-hacks-with-c11/ for those who didn't read the .h file here's original source you might have issues compiling it depending on your compiler but i have fixed it a bit and made it a bit more complex

cpp11-compile-time-string-obfuscation's People

Contributors

rednick16 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.