|
cobf
PE imports obfuscator
|
Go to the documentation of this file.
13 void ini_line_handler(
void* data,
unsigned int line,
const char* sec,
const char* nam,
const char* val)
21 static string s_sec =
"";
30 if (*nam !=
'#' && *val !=
'#') ret_err = p_obf_file->
obf_sym(s_sec.c_str(), nam, val);
31 else if (*nam !=
'#' && *val ==
'#') ret_err = p_obf_file->
obf_sym(s_sec.c_str(), nam, atoi(val + 1));
32 else if (*nam ==
'#' && *val !=
'#') ret_err = p_obf_file->
obf_sym(s_sec.c_str(), atoi(nam + 1), val);
33 else ret_err = p_obf_file->
obf_sym(s_sec.c_str(), atoi(nam + 1), atoi(val + 1));
36 if (ret_err != cobf_error::COBF_NO_ERROR)
40 cout <<
"[-] Error at the config at line " << line <<
": " << error << endl;
45 int main(
int argc,
char** argv)
48 if (argc < 3 || argc > 4)
51 cout << *argv <<
" <input file> <out file> [config file]" << endl;
56 char* input_file = argv[1];
57 char* out_file = argv[2];
58 char* config_file = argc == 4 ? argv[3] : (
char*)
"config.ini";
67 if ((ret_err = obf_file.
load_pe()) != cobf_error::COBF_NO_ERROR)
71 cout <<
"[-] Error at loading the file: " << error << endl;
76 cout <<
"[+] File loaded successfully." << endl;
82 cout <<
"[-] Error occurred while processing the config file." << endl;
87 if ((ret_err = obf_file.
generate(out_file)) != cobf_error::COBF_NO_ERROR)
91 cout <<
"[-] Error at obfuscating the file: " << error << endl;
96 cout <<
"[+] File obfuscated successfully." << endl;
99 if ((ret_err = obf_file.
unload_pe()) != cobf_error::COBF_NO_ERROR)
103 cout <<
"[-] Error at unloading the file: " << error << endl;
108 cout <<
"[+] File unloaded successfully." << endl;
114 cout <<
"[!] Unhandled exception occurred." << endl;
cobf_error unload_pe()
Unload the specified PE from memory.
void cobf_format_message(cobf_error err_msg, char *buffer, unsigned int size)
Format the error to a message.
cobf_error load_pe()
Load the specified PE from disk.
cobf_error generate(string out_file)
Generate the obfuscated PE.
int main(int argc, char **argv)
int parse_ini_file(const char *f_path, ini_line_cb handler, void *data)
Parse ini file, supply the data to a callback.
void ini_line_handler(void *data, unsigned int line, const char *sec, const char *nam, const char *val)
cobf_error obf_sym(string dll_name, string sym_name, string obf_name)
Obfuscate one symbol (name) with another (name).