From 21dffa8a83b9d0ab9c2981ddf588ee0cdec70173 Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Tue, 3 Mar 2015 12:09:18 +0400 Subject: [PATCH] elf dynamic symboles obfuscation. --- shared_object_obfuscation/Makefile | 15 +++++++++ shared_object_obfuscation/executable.cpp | 35 +++++++++++++++++++++ shared_object_obfuscation/interface.h | 19 +++++++++++ shared_object_obfuscation/shared_object.cpp | 29 +++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 shared_object_obfuscation/Makefile create mode 100644 shared_object_obfuscation/executable.cpp create mode 100644 shared_object_obfuscation/interface.h create mode 100644 shared_object_obfuscation/shared_object.cpp diff --git a/shared_object_obfuscation/Makefile b/shared_object_obfuscation/Makefile new file mode 100644 index 0000000..477664e --- /dev/null +++ b/shared_object_obfuscation/Makefile @@ -0,0 +1,15 @@ + +all: libshared_object.so executable.exe + +libshared_object.so : shared_object.cpp interface.h + g++ -fPIC --shared -O2 $< -o $@ + strip $@ + + +executable.exe : executable.cpp interface.h libshared_object.so + g++ -O2 -lshared_object -L. $< -o $@ + strip $@ + +run: all + LD_LIBRARY_PATH=. ./executable.exe + diff --git a/shared_object_obfuscation/executable.cpp b/shared_object_obfuscation/executable.cpp new file mode 100644 index 0000000..f4b1e5d --- /dev/null +++ b/shared_object_obfuscation/executable.cpp @@ -0,0 +1,35 @@ +/* +VIM: let g:lcppflags="-O2 -lshared_object -L." +VIM: let g:argv="" +*/ +#include +#include +#include "interface.h" + +int main ( void ) +{try{ + + MyVerySecretClass o; + + o.secret_method1(); + o.secret_method2(); + o.secret_method1(); + o.secret_method2(); + o.secret_method1(); + o.secret_method2(); + + return 0; +} +catch ( const std::exception& e ) +{ + std::cerr << std::endl + << "std::exception(\"" << e.what() << "\")." << std::endl; + return 2; +} +catch ( ... ) +{ + std::cerr << std::endl + << "unknown exception." << std::endl; + return 1; +}} + diff --git a/shared_object_obfuscation/interface.h b/shared_object_obfuscation/interface.h new file mode 100644 index 0000000..9270e35 --- /dev/null +++ b/shared_object_obfuscation/interface.h @@ -0,0 +1,19 @@ +#ifndef __INTERFACE_TO_MY_VERY_SECRET_CLASS__ +#define __INTERFACE_TO_MY_VERY_SECRET_CLASS__ + +class MyVerySecretClass +{ +private: + + int secret_var; + +public: + + MyVerySecretClass(); + ~MyVerySecretClass(); + + void secret_method1(); + void secret_method2(); +}; + +#endif diff --git a/shared_object_obfuscation/shared_object.cpp b/shared_object_obfuscation/shared_object.cpp new file mode 100644 index 0000000..9eaf474 --- /dev/null +++ b/shared_object_obfuscation/shared_object.cpp @@ -0,0 +1,29 @@ +/* +VIM: let g:lcppflags="-O2 -pthread" +VIM: let g:argv="" +*/ +#include +#include + +#include "interface.h" + +MyVerySecretClass::MyVerySecretClass() + : secret_var(0) +{ +} + +MyVerySecretClass::~MyVerySecretClass() +{ + secret_var = -1; +} + +void MyVerySecretClass::secret_method1() +{ + ++secret_var; +} + +void MyVerySecretClass::secret_method2() +{ + std::cout << "The value of secret variable is " << secret_var << std::endl; +} +