-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleMain.cpp
More file actions
65 lines (59 loc) · 2.42 KB
/
ConsoleMain.cpp
File metadata and controls
65 lines (59 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include "Obfusk8Core.hpp"
#include "ObfuscationOptions.hpp"
#include "ObfuscationInline.hpp"
using namespace std;
static std::vector<char> readBinaryFile(const std::string& filename) {
std::ifstream file(filename, std::ios::binary);
if (!file) throw std::runtime_error(OBFUSCATE_STRING("Cannot open input file: ") + filename);
return std::vector<char>((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
}
static void writeBinaryFile(const std::string& filename, const std::vector<char>& data) {
std::ofstream file(filename, std::ios::binary);
if (!file) throw std::runtime_error(OBFUSCATE_STRING("Cannot open output file: ") + filename);
file.write(data.data(), data.size());
}
int main(int argc, char* argv[]) {
if (argc > 1) {
for (int i = 1; i < argc; ++i) {
string inputFile = argv[i];
if (inputFile.find(".exe") != string::npos) {
string outputFile = inputFile.substr(0, inputFile.find_last_of('.')) + "_obfuscated.exe";
char key = 0x42;
try {
vector<char> data = readBinaryFile(inputFile);
ObfuscationOptions opts;
obfuscate(data, key, opts);
writeBinaryFile(outputFile, data);
cout << "Obfuscated: " << outputFile << endl;
} catch (const exception& e) {
cerr << "Error processing " << inputFile << ": " << e.what() << endl;
}
}
}
return 0;
}
cout << "Binary Obfuscator - GUI available in obfuscatorv5_gui" << endl;
cout << "Enter input .exe file path (or 'quit' to exit): " << endl;
while (true) {
string inputFile;
getline(cin, inputFile);
if (inputFile == "quit" || inputFile == "exit") break;
if (inputFile.empty()) continue;
string outputFile = inputFile.substr(0, inputFile.find_last_of('.')) + "_obfuscated.exe";
char key = 0x42;
try {
vector<char> data = readBinaryFile(inputFile);
ObfuscationOptions opts;
obfuscate(data, key, opts);
writeBinaryFile(outputFile, data);
cout << "Obfuscated: " << outputFile << endl;
} catch (const exception& e) {
cerr << "Error: " << e.what() << endl;
}
}
return 0;
}