-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.cpp
More file actions
348 lines (324 loc) · 10.5 KB
/
Copy pathbase.cpp
File metadata and controls
348 lines (324 loc) · 10.5 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#include <atomic>
#include <chrono>
#include <format>
#include <fstream>
#include <iostream>
#include <string>
#include <thread>
#include <unordered_map>
#include <vector>
#include <windows.h>
using namespace std;
using namespace std::chrono;
const string xAnim1[] = {
"",
};
const string xAnim2[] = {
"",
};
const string xAnim3[] = {
"",
};
const string xImage1[] = {
"",
};
const string xImage2[] = {
"",
};
const string xImage3[] = {
"",
};
const string xMaterial1[] = {
"",
};
const string xMaterial2[] = {
"",
};
const string xMaterial3[] = {
"",
};
const string xModel1[] = {
"",
};
const string xModel2[] = {
"",
};
const string xModel3[] = {
"",
};
const string xSoundOperator1[] = {
"",
};
const string xSoundOperator2[] = {
"",
};
const string xSoundAnnouncer1[] = {
"",
};
const string xSoundAnnouncer2[] = {
"",
};
const string xSoundLanguage[] = {
"",
};
const string xSoundWeapon1[] = {
"",
};
const string xSoundWeapon2[] = {
"",
};
const string xSoundGeneric[] = {
"",
};
const string xString1[] = {
"",
};
const string xString2[] = {
"",
};
const string xString3[] = {
"",
};
const string xWeapon1[] = {
"",
};
const string xWeapon2[] = {
"",
};
const string xWeapon3[] = {
"",
};
// Change the uint and Hash/Util function in the .cpp file for the target game
// FNV1a-64 [Modern Warfare 2022 - Modified Function]
// uint64_t assetNameHash = HashMW64Util::HashMW64(assetNameCStr, assetName.length());
class HashMW64Util {
public: static const uint64_t HashMW64(const char* data, const size_t dataLen) {
const uint64_t FNVPrime = 0x100000001B3;
const uint64_t FNVOffset = 0xCBF29CE484222325;
uint64_t result = 0x47F5817A5EF961BA;
for (size_t i = 0; i < dataLen; i++) {
uint64_t value = tolower(data[i]);
if (value == '\\')
value = '/';
result = 0x100000001B3 * (value ^ result);
}
return result & 0xFFFFFFFFFFFFFFF;
}
};
// FNV1a-64 [Black Ops 4, Black Ops Cold War, Vanguard]
// uint64_t assetNameHash = HashA64Util::HashA64(assetNameCStr, assetName.length());
class HashA64Util {
public: static const uint64_t HashA64(const char* Data, uint64_t Size) {
const uint64_t FNVPrime = 0x100000001B3;
const uint64_t FNVOffset = 0xCBF29CE484222325;
uint64_t Result = FNVOffset;
for (uint64_t i = 0; i < Size; i++) {
Result ^= Data[i];
Result *= FNVPrime;
}
return Result & 0xFFFFFFFFFFFFFFF;
}
};
// FNV1-64 [Unused]
// uint64_t assetNameHash = Hash64Util::Hash64(assetNameCStr, assetName.length());
class Hash64Util {
public: static const uint64_t Hash64(const char* Data, uint64_t Size) {
const uint64_t FNVPrime = 0x100000001B3;
const uint64_t FNVOffset = 0xCBF29CE484222325;
uint64_t Result = FNVOffset;
for (uint64_t i = 0; i < Size; i++) {
Result *= FNVPrime;
Result ^= Data[i];
}
return Result & 0xFFFFFFFFFFFFFFF;
}
};
// FNV1a-32 [Modern Warfare 2022 *Bones* DO NOT USE - HIGH COLLISION RATE]
class HashA32Util {
public: static const uint32_t HashA32(const char* Data, uint32_t Size) {
const uint32_t FNVPrime = 0x01000193;
const uint32_t FNVOffset = 0x811c9dc5;
uint32_t Result = FNVOffset;
for (uint32_t i = 0; i < Size; i++) {
Result ^= Data[i];
Result *= FNVPrime;
}
return Result & 0xFFFFFFF;
}
};
// FNV1-32 [Unused: DO NOT USE - HIGH COLLISION RATE]
class Hash32Util {
public: static const uint32_t Hash32(const char* Data, uint32_t Size) {
const uint32_t FNVPrime = 0x01000193;
const uint32_t FNVOffset = 0x811c9dc5;
uint32_t Result = FNVOffset;
for (uint32_t i = 0; i < Size; i++) {
Result *= FNVPrime;
Result ^= Data[i];
}
return Result & 0xFFFFFFF;
}
};
static string path;
void CheckAsset(const string assetType, const string assetName, int& hashesFound, string& foundAssetType) {
const char* assetNameCStr = assetName.c_str();
uint64_t assetNameHash = HashA64Util::HashA64(assetNameCStr, assetName.length());
ostringstream ss;
ss << hex << assetNameHash;
string hashName = ss.str();
if (ifstream(path + "\\" + assetType + "\\" + hashName).good()) {
cout << "Found " << assetType << ": " << hashName << "," << assetName << "\n";
unordered_map<string, string> fileNames = {
{"xanim", "AnimsFound.txt"},
{"ximage", "ImagesFound.txt"},
{"xmaterial", "MaterialsFound.txt"},
{"xmodel", "ModelsFound.txt"},
{"xsound", "SoundsFound.txt"},
{"xstring", "StringsFound.txt"},
{"xweapon", "WeaponsFound.txt"}
};
string fileName = fileNames[assetType];
ofstream outfile(path + "\\" + fileName, ios_base::app);
outfile << hashName << "," << assetName << "\n";
outfile.close();
remove((path + "\\" + assetType + "\\" + hashName).c_str());
hashesFound++;
}
}
void ScanAsset(string xAsset, int& hashesFound) {
string assetType;
int intermediateTotal = 0;
int iterationsCompleted = 0;
vector<thread> threads;
threads.emplace_back([&]() {
for (const auto& xanim1 : xAnim1) {
for (const auto& xanim2 : xAnim2) {
for (const auto& xanim3 : xAnim3) {
CheckAsset("xanim", xanim1 + xanim2 + xanim3, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& ximage1 : xImage1) {
for (const auto& ximage2 : xImage2) {
for (const auto& ximage3 : xImage3) {
CheckAsset("ximage", ximage1 + ximage2 + ximage3, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xmaterial1 : xMaterial1) {
for (const auto& xmaterial2 : xMaterial2) {
for (const auto& xmaterial3 : xMaterial3) {
CheckAsset("xmaterial", xmaterial1 + xmaterial2 + xmaterial3, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xmodel1 : xModel1) {
for (const auto& xmodel2 : xModel2) {
for (const auto& xmodel3 : xModel3) {
CheckAsset("xmodel", xmodel1 + xmodel2 + xmodel3, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xsoundoperator1 : xSoundOperator1) {
for (const auto& xsoundoperator2 : xSoundOperator2) {
for (const auto& xsoundlanguage : xSoundLanguage) {
CheckAsset("xsound", xsoundoperator1 + xsoundoperator2 + xsoundlanguage, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xsoundannouncer1 : xSoundAnnouncer1) {
for (const auto& xsoundannouncer2 : xSoundAnnouncer2) {
for (const auto& xsoundlanguage : xSoundLanguage) {
CheckAsset("xsound", xsoundannouncer1 + xsoundannouncer2 + xsoundlanguage, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xsoundweapon1 : xSoundWeapon1) {
for (const auto& xsoundweapon2 : xSoundWeapon2) {
for (const auto& xsoundgeneric : xSoundGeneric) {
CheckAsset("xsound", xsoundweapon1 + xsoundweapon2 + xsoundgeneric, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xstring1 : xString1) {
for (const auto& xstring2 : xString2) {
for (const auto& xstring3 : xString3) {
CheckAsset("xstring", xstring1 + xstring2 + xstring3, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
threads.emplace_back([&]() {
for (const auto& xweapon1 : xWeapon1) {
for (const auto& xweapon2 : xWeapon2) {
for (const auto& xweapon3 : xWeapon3) {
CheckAsset("xweapon", xweapon1 + xweapon2 + xweapon3, intermediateTotal, assetType);
iterationsCompleted++;
}
}
}
});
for (auto& thread : threads) {
thread.join();
}
hashesFound = intermediateTotal;
}
int main() {
SetConsoleTitle(L"fnvHashFinder");
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED);
cout << " __,,,,_\n";
cout << " _ __..-;''`--/'/ /.',-`-.\n";
cout << " (`/' ` | \\ \\ \\ / / / / .-'/`,_\n";
cout << " /'`\\ \\ | \\ | \\| // // / -.,/_,'-,\n";
cout << " /<7' ; \\ \\ | ; ||/ /| | \\/ |`-/,/-.,_,/')\n";
cout << " / _.-, `,-\\,__| _-| / \\ \\/|_/ | '-/.;.\\'\n";
cout << " `-` f/ ; / __/ \\__ `/ |__/ |\n";
cout << " fnv `-' | -| =|\\_ \\ |-' |\n";
cout << " Hash __/ /_..-' ` ),' //\n";
cout << " Finder ((__.-'((___..-'' \\__.'\n";
cout << "\nA Versatile Tool that verifies hashes" << endl;
cout << "\nThis Project was made possible by:" << endl;
cout << "Scobalula, Cortland, ItsNatoriousB, Amorfirion" << endl;
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);
cout << "\nCPU MODE" << endl;
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED);
cout << "\nSpecify root directory: " << endl;
getline(cin, path);
cout << "Scanning for Assets..." << endl;
time_point start = steady_clock::now();
int hashesFound = 0;
thread t(ScanAsset, path.c_str(), ref(hashesFound));
t.join();
steady_clock::time_point end = steady_clock::now();
duration<double> elapsed_seconds = end - start;
int hours = static_cast<int>(elapsed_seconds.count() / 3600);
int minutes = static_cast<int>((elapsed_seconds.count() - (hours * 3600)) / 60);
int seconds = static_cast<int>(elapsed_seconds.count() - (hours * 3600) - (minutes * 60));
cout << "Scan completed in: " << setfill('0') << setw(2) << hours << ":" << setw(2) << minutes << ":" << setw(2) << seconds << endl;
cout << "Assets found: " << hashesFound << endl;
system("pause");
return 0;
}