Giter VIP home page Giter VIP logo

cpp-obfuscator's Introduction

cpp-obfuscator

License Build Status

C++ implementation of compile time obfuscator

Compiler Support

Compiler Version
Visual Studio 2019
Clang++ 8.0
g++ 7.3
Apple Clang Mojave

Usage

Use existing single header obfuscator.hpp or run script to merge multiple headers in directory obfuscator.

python -m script.merge

Include obfuscator.hpp to use it.

#include "../obfuscator.hpp"

template <char key>
constexpr char xor_(char c) {
    return c ^ key;
}

std::cout << obfs::make_string<xor_<0x50>, xor_<0x50>>("Hello World !\n").decode();

String

Compile time string obfuscator. No more raw string in binary, sample string_obfuscator.

  1. Sample encoder, decoder
template <char key>
constexpr char xor_(char c) {
    return c ^ key;
}

template <char Key>
constexpr char add(char c) {
    return c + Key;
}

template <char(*f)(char), char(*g)(char)>
constexpr char comp(char c) {
    return f(g(c));
}
  1. Single encoder, decoder.
std::cout << obfs::make_string<xor_<0x50>, xor_<0x50>>("Hello World !\n").decode();
  1. Multiple encoder, decoder and random selection.
using table = obfs::make_table<
    obfs::encoder_seq<xor_<0x50>, add<10>, comp<xor_<0x50>, add<10>>>,
    obfs::decoder_seq<xor_<0x50>, add<-10>, comp<add<-10>, xor_<0x50>>>>;

std::cout << obfs::make_string<table>("Hello World !\n").decode();
  1. Multiple encoder, decoder as pair.
using table = obfs::make_pair_table<
    obfs::encoder_pair<xor_<0x50>, xor_<0x50>>,
    obfs::encoder_pair<add<10>, add<-10>>,
    obfs::encoder_pair<comp<xor_<0x50>, add<10>>, comp<add<-10>, xor_<0x50>>>
>;

std::cout << obfs::make_string<table>("Hello World !\n").decode();
  1. String obfuscator macro.
MAKE_STRING(str, "Hello World !\n", table);
std::cout << str.decode();

Finite state machine

Compile time finite state machine based routine obfuscator, sample state_machine.

  1. Make state table.
using namespace obfs;
using machine = StateMachine<
    Stage<state1, Next<event5 , state2, Dummy::dummy1>,
                  Next<event1 , state3, Dummy::dummy3>>,
    Stage<state2, Next<event2 , state4>>,
    Stage<state3, Next<None   , state3>>,
    Stage<state4, Next<event4 , state1>,
                  Next<event3 , state5, Dummy::dummy2>>,
    Stage<state5, Next<Trigger, Final, Action::action>>>;
  1. Run state machine, each execution returns next state.
auto next1 = machine::run(state1{}, event5{}); // dummy1 executed
auto next2 = machine::run(next1, event2{});
auto next3 = machine::run(next2, event3{});    // dummy2 executed
auto next4 = machine::run(next3, Trigger{});   // action executed

cpp-obfuscator's People

Contributors

revsic avatar

Watchers

 avatar

Forkers

om1n0us

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.