elf dynamic symboles obfuscation.
This commit is contained in:
15
shared_object_obfuscation/Makefile
Normal file
15
shared_object_obfuscation/Makefile
Normal file
@@ -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
|
||||||
|
|
||||||
35
shared_object_obfuscation/executable.cpp
Normal file
35
shared_object_obfuscation/executable.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
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();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}}
|
||||||
|
|
||||||
19
shared_object_obfuscation/interface.h
Normal file
19
shared_object_obfuscation/interface.h
Normal file
@@ -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
|
||||||
29
shared_object_obfuscation/shared_object.cpp
Normal file
29
shared_object_obfuscation/shared_object.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
VIM: let g:lcppflags="-O2 -pthread"
|
||||||
|
VIM: let g:argv=""
|
||||||
|
*/
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user