-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cpp
More file actions
206 lines (173 loc) · 8.4 KB
/
Copy pathapp.cpp
File metadata and controls
206 lines (173 loc) · 8.4 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// NMSHacking tarafından yazıldı.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#ifdef _WIN32
#include <windows.h>
#define CHECK_COMMAND_GPP "g++ --version"
#define CHECK_COMMAND_CS "csc -help"
#define CHECK_COMMAND_CC "gcc --version"
#define CHECK_COMMAND_PY "python --version"
#define CHECK_COMMAND_GO "go version"
#define INSTALL_COMMAND "choco install mingw -y && choco install python -y && choco install dotnet-sdk -y && choco install golang -y"
#elif __linux__
#include <unistd.h>
#define CHECK_COMMAND_GPP "g++ --version"
#define CHECK_COMMAND_CS "mcs -help"
#define CHECK_COMMAND_CC "gcc --version"
#define CHECK_COMMAND_PY "python3 --version"
#define CHECK_COMMAND_GO "go version"
#define INSTALL_COMMAND "sudo apt-get install -y g++ gcc mono-mcs python3 python3-pip dotnet-sdk-5.0 golang"
#elif __APPLE__
#include <unistd.h>
#define CHECK_COMMAND_GPP "clang++ --version"
#define CHECK_COMMAND_CS "mcs -help"
#define CHECK_COMMAND_CC "gcc --version"
#define CHECK_COMMAND_PY "python3 --version"
#define CHECK_COMMAND_GO "go version"
#define INSTALL_COMMAND "brew install gcc python dotnet go mono"
#endif
void xorEncryptDecrypt(const std::string &key, std::vector<char> &data) {
size_t keyLen = key.size();
for (size_t i = 0; i < data.size(); ++i) {
data[i] ^= key[i % keyLen];
}
}
std::string generateRandomKey(size_t length) {
std::string key;
static const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (size_t i = 0; i < length; ++i) {
key += charset[rand() % (sizeof(charset) - 1)];
}
return key;
}
void encryptFile(const std::string &inputFileName, const std::string &outputFileName, std::string &key) {
std::ifstream inputFile(inputFileName, std::ios::binary);
std::vector<char> data((std::istreambuf_iterator<char>(inputFile)), std::istreambuf_iterator<char>());
inputFile.close();
key = generateRandomKey(16); // Generate a random key of length 16
xorEncryptDecrypt(key, data);
std::ofstream outputFile(outputFileName, std::ios::binary);
outputFile.write(data.data(), data.size());
outputFile.close();
}
void decryptFile(const std::string &inputFileName, const std::string &outputFileName, const std::string &key) {
std::ifstream inputFile(inputFileName, std::ios::binary);
std::vector<char> data((std::istreambuf_iterator<char>(inputFile)), std::istreambuf_iterator<char>());
inputFile.close();
xorEncryptDecrypt(key, data);
std::ofstream outputFile(outputFileName, std::ios::binary);
outputFile.write(data.data(), data.size());
outputFile.close();
}
bool checkCompiler(const std::string& command) {
return (std::system(command.c_str()) == 0);
}
void compileFile(const std::string &fileName, const std::string &language) {
std::string command;
if (language == "C++") {
#ifdef _WIN32
command = "g++ -o output.exe " + fileName;
#else
command = "g++ -o output " + fileName;
#endif
} else if (language == "C") {
#ifdef _WIN32
command = "gcc -o output.exe " + fileName;
#else
command = "gcc -o output " + fileName;
#endif
} else if (language == "C#") {
#ifdef _WIN32
command = "csc -out:output.exe " + fileName;
#else
command = "mcs -out:output.exe " + fileName;
#endif
} else if (language == "Python") {
command = "pyinstaller --onefile " + fileName;
} else if (language == "Go") {
command = "go build -o output " + fileName;
}
std::system(command.c_str());
}
void installCompilers() {
std::system(INSTALL_COMMAND);
}
int main() {
srand(time(0)); // Seed the random number generator
std::cout << R"(
███╗ ██╗███╗ ███╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗███████╗███████╗ ██████╗██╗ ██╗██████╗ ███████╗
████╗ ██║████╗ ████║██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝██╔════╝██╔════╝██║ ██║██╔══██╗██╔════╝
██╔██╗ ██║██╔████╔██║███████╗██║ ██║ ██║██║ ██║█████╗ ███████╗█████╗ ██║ ██║ ██║██████╔╝█████╗
██║╚██╗██║██║╚██╔╝██║╚════██║██║ ██║ ██║██║ ██║██╔══╝ ╚════██║██╔══╝ ██║ ██║ ██║██╔══██╗██╔══╝
██║ ╚████║██║ ╚═╝ ██║███████║╚██████╗╚██████╔╝██████╔╝███████╗███████║███████╗╚██████╗╚██████╔╝██║ ██║███████╗
╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
)" << std::endl;
std::cout << "Derleyiciler yükleniyor...\n";
installCompilers();
std::cout << "Derleyiciler yüklendi.\n";
int choice;
std::string inputFileName, outputFileName, key, language;
while (true) {
std::cout << "Seçenekler:\n";
std::cout << "1. Kod Şifrele\n";
std::cout << "2. Kod Çöz\n";
std::cout << "3. Şifreli Kodu Derle\n";
std::cout << "4. Derleyicileri Kontrol Et\n";
std::cout << "Seçiminizi girin: ";
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "Girdi dosyasının adını girin: ";
std::cin >> inputFileName;
std::cout << "Çıktı dosyasının adını girin: ";
std::cin >> outputFileName;
encryptFile(inputFileName, outputFileName, key);
std::cout << "Dosya başarıyla şifrelendi.\n";
std::cout << "Şifreleme anahtarı: " << key << "\n";
break;
case 2:
std::cout << "Girdi dosyasının adını girin: ";
std::cin >> inputFileName;
std::cout << "Çıktı dosyasının adını girin: ";
std::cin >> outputFileName;
std::cout << "Şifreleme anahtarını girin: ";
std::cin >> key;
decryptFile(inputFileName, outputFileName, key);
std::cout << "Dosya başarıyla çözüldü.\n";
break;
case 3:
std::cout << "Derlenecek şifreli dosyanın adını girin: ";
std::cin >> inputFileName;
std::cout << "Şifreleme anahtarını girin: ";
std::cin >> key;
decryptFile(inputFileName, "decrypted_temp.cpp", key);
std::cout << "Derleme dili seçin (C++, C, C#, Python, Go [Go Stabil Değil]): ";
std::cin >> language;
compileFile("decrypted_temp.cpp", language);
std::remove("decrypted_temp.cpp");
std::cout << "Şifreli dosya başarıyla derlendi.\n";
break;
case 4:
std::cout << "Derleyiciler kontrol ediliyor...\n";
if (checkCompiler(CHECK_COMMAND_GPP) &&
checkCompiler(CHECK_COMMAND_CS) &&
checkCompiler(CHECK_COMMAND_CC) &&
checkCompiler(CHECK_COMMAND_PY) &&
checkCompiler(CHECK_COMMAND_GO)) {
std::cout << "Tüm derleyiciler mevcut.\n";
} else {
std::cerr << "Derleyiciler bulunamadı veya kurulumda sorun var.\n";
}
break;
default:
std::cerr << "Geçersiz seçenek.\n";
break;
}
}
return 0;
}