From 67b4092b96a3fbf899dce3844a4f4123f297f4cb Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Tue, 3 Mar 2015 22:23:02 +0400 Subject: [PATCH] Shared object obfuscation concept proven. --- linux/shared_object_obfuscation/Makefile | 30 +++++++++++++++++++ .../shared_object_obfuscation}/executable.cpp | 1 + .../shared_object_obfuscation}/interface.h | 1 + .../shared_object.cpp | 11 +++++++ shared_object_obfuscation/Makefile | 15 ---------- 5 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 linux/shared_object_obfuscation/Makefile rename {shared_object_obfuscation => linux/shared_object_obfuscation}/executable.cpp (96%) rename {shared_object_obfuscation => linux/shared_object_obfuscation}/interface.h (91%) rename {shared_object_obfuscation => linux/shared_object_obfuscation}/shared_object.cpp (70%) delete mode 100644 shared_object_obfuscation/Makefile diff --git a/linux/shared_object_obfuscation/Makefile b/linux/shared_object_obfuscation/Makefile new file mode 100644 index 0000000..9086fdf --- /dev/null +++ b/linux/shared_object_obfuscation/Makefile @@ -0,0 +1,30 @@ + +all: libshared_object.so executable.exe + +clean: + rm *.o *.so *.exe + +libshared_object.so : shared_object.o + g++ -fPIC --shared -O2 $< -o $@ + strip $@ + +shared_object.o : shared_object.cpp interface.h + g++ -fPIC -O2 $< -c -o $@ + objcopy --redefine-sym _ZN17MyVerySecretClass14secret_method1Ev=m1 \ + --redefine-sym _ZN17MyVerySecretClass14secret_method2Ev=m2 \ + --redefine-sym _ZN17MyVerySecretClass14secret_method3Ev=m3 $@ + + +executable.exe : executable.o libshared_object.so + g++ -O2 -lshared_object -L. $< -o $@ + strip $@ + +executable.o : executable.cpp interface.h + g++ -O2 -lshared_object -L. $< -c -o $@ + objcopy --redefine-sym _ZN17MyVerySecretClass14secret_method1Ev=m1 \ + --redefine-sym _ZN17MyVerySecretClass14secret_method2Ev=m2 \ + --redefine-sym _ZN17MyVerySecretClass14secret_method3Ev=m3 $@ + +run: all + LD_LIBRARY_PATH=. ./executable.exe + diff --git a/shared_object_obfuscation/executable.cpp b/linux/shared_object_obfuscation/executable.cpp similarity index 96% rename from shared_object_obfuscation/executable.cpp rename to linux/shared_object_obfuscation/executable.cpp index f4b1e5d..6abcf47 100644 --- a/shared_object_obfuscation/executable.cpp +++ b/linux/shared_object_obfuscation/executable.cpp @@ -17,6 +17,7 @@ int main ( void ) o.secret_method2(); o.secret_method1(); o.secret_method2(); + o.secret_method3(); return 0; } diff --git a/shared_object_obfuscation/interface.h b/linux/shared_object_obfuscation/interface.h similarity index 91% rename from shared_object_obfuscation/interface.h rename to linux/shared_object_obfuscation/interface.h index 9270e35..99f8704 100644 --- a/shared_object_obfuscation/interface.h +++ b/linux/shared_object_obfuscation/interface.h @@ -14,6 +14,7 @@ public: void secret_method1(); void secret_method2(); + void secret_method3(); }; #endif diff --git a/shared_object_obfuscation/shared_object.cpp b/linux/shared_object_obfuscation/shared_object.cpp similarity index 70% rename from shared_object_obfuscation/shared_object.cpp rename to linux/shared_object_obfuscation/shared_object.cpp index 9eaf474..f5c0e77 100644 --- a/shared_object_obfuscation/shared_object.cpp +++ b/linux/shared_object_obfuscation/shared_object.cpp @@ -2,6 +2,10 @@ VIM: let g:lcppflags="-O2 -pthread" VIM: let g:argv="" */ +#include +#include +#include + #include #include @@ -27,3 +31,10 @@ void MyVerySecretClass::secret_method2() std::cout << "The value of secret variable is " << secret_var << std::endl; } +void MyVerySecretClass::secret_method3() +{ + char cmdln[128]; + sprintf( cmdln, "pstack %d", getpid() ); + system( cmdln ); +} + diff --git a/shared_object_obfuscation/Makefile b/shared_object_obfuscation/Makefile deleted file mode 100644 index 477664e..0000000 --- a/shared_object_obfuscation/Makefile +++ /dev/null @@ -1,15 +0,0 @@ - -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 -