Shared object obfuscation concept proven.
This commit is contained in:
30
linux/shared_object_obfuscation/Makefile
Normal file
30
linux/shared_object_obfuscation/Makefile
Normal file
@@ -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
|
||||
|
||||
36
linux/shared_object_obfuscation/executable.cpp
Normal file
36
linux/shared_object_obfuscation/executable.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
VIM: let g:lcppflags="-O2 -lshared_object -L."
|
||||
VIM: let g:argv=""
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#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();
|
||||
o.secret_method3();
|
||||
|
||||
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;
|
||||
}}
|
||||
|
||||
20
linux/shared_object_obfuscation/interface.h
Normal file
20
linux/shared_object_obfuscation/interface.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#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();
|
||||
void secret_method3();
|
||||
};
|
||||
|
||||
#endif
|
||||
40
linux/shared_object_obfuscation/shared_object.cpp
Normal file
40
linux/shared_object_obfuscation/shared_object.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
VIM: let g:lcppflags="-O2 -pthread"
|
||||
VIM: let g:argv=""
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
void MyVerySecretClass::secret_method3()
|
||||
{
|
||||
char cmdln[128];
|
||||
sprintf( cmdln, "pstack %d", getpid() );
|
||||
system( cmdln );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user