The main entry.
| 43 | |
| 44 | // The main entry. |
| 45 | int main(int argc, char** argv) |
| 46 | { |
| 47 | // Expecting the input file, out file and the config file. |
| 48 | if (argc < 3 || argc > 4) |
| 49 | { |
| 50 | // Print help. |
| 51 | cout << *argv << " <input file> <out file> [config file]" << endl; |
| 52 | return 1; |
| 53 | }; |
| 54 | |
| 55 | // Getting the data. |
| 56 | char* input_file = argv[1]; |
| 57 | char* out_file = argv[2]; |
| 58 | char* config_file = argc == 4 ? argv[3] : (char*)"config.ini"; |
| 59 | |
| 60 | // Needed locals. |
| 61 | cobf_error ret_err; |
| 62 | char error[MAX_PATH]; |
| 63 | try |
| 64 | { |
| 65 | // Loading the input file. |
| 66 | cobf obf_file = cobf(input_file); |
| 67 | if ((ret_err = obf_file.load_pe()) != cobf_error::COBF_NO_ERROR) |
| 68 | { |
| 69 | // Error at loading. |
| 70 | cobf_format_message(ret_err, error, sizeof(error)); |
| 71 | cout << "[-] Error at loading the file: " << error << endl; |
| 72 | return 1; |
| 73 | }; |
| 74 | |
| 75 | // Log. |
| 76 | cout << "[+] File loaded successfully." << endl; |
| 77 | |
| 78 | // Process the config file. |
| 79 | if (!parse_ini_file(config_file, ini_line_handler, &obf_file)) |
| 80 | { |
| 81 | // Error at processing the config. |
| 82 | cout << "[-] Error occurred while processing the config file." << endl; |
| 83 | return 1; |
| 84 | }; |
| 85 | |
| 86 | // Obfuscating it. |
| 87 | if ((ret_err = obf_file.generate(out_file)) != cobf_error::COBF_NO_ERROR) |
| 88 | { |
| 89 | // Error at obfuscating. |
| 90 | cobf_format_message(ret_err, error, sizeof(error)); |
| 91 | cout << "[-] Error at obfuscating the file: " << error << endl; |
| 92 | return 1; |
| 93 | }; |
| 94 | |
| 95 | // Log. |
| 96 | cout << "[+] File obfuscated successfully." << endl; |
| 97 | |
| 98 | // Unloading it. |
| 99 | if ((ret_err = obf_file.unload_pe()) != cobf_error::COBF_NO_ERROR) |
| 100 | { |
| 101 | // Error at unloading. |
| 102 | cobf_format_message(ret_err, error, sizeof(error)); |
nothing calls this directly
no test coverage detected