@@ -209,7 +209,7 @@ std::string ResourceManager::readFileContents(const std::string& fileName)
209
209
{
210
210
const std::string fullPath = resolvePath (fileName);
211
211
212
- if (fullPath.find (g_resources. getByteStrings ( 0 )) != std::string::npos) {
212
+ if (fullPath.find (AY_OBFUSCATE ( " /downloads " )) != std::string::npos) {
213
213
const auto dfile = g_http.getFile (fullPath.substr (10 ));
214
214
if (dfile)
215
215
return std::string (dfile->response .begin (), dfile->response .end ());
@@ -225,21 +225,20 @@ std::string ResourceManager::readFileContents(const std::string& fileName)
225
225
PHYSFS_close (file);
226
226
227
227
#if ENABLE_ENCRYPTION == 1
228
- bool hasHeader = false ;
229
- if (buffer.size () >= std::string (ENCRYPTION_HEADER).size () &&
230
- buffer.substr (0 , std::string (ENCRYPTION_HEADER).size ()) == std::string (ENCRYPTION_HEADER)) {
231
- hasHeader = true ;
232
- }
233
-
234
- if (g_game.getFeature (Otc::GameAllowCustomBotScripts)) {
235
- if (fullPath.find (g_resources.getByteStrings (1 )) != std::string::npos && !hasHeader) {
236
- return buffer;
237
- }
238
- }
228
+ const auto headerSize = std::string (ENCRYPTION_HEADER).size ();
229
+ const bool hasHeader = (buffer.size () >= headerSize &&
230
+ buffer.compare (0 , headerSize, ENCRYPTION_HEADER) == 0 );
239
231
240
232
if (hasHeader) {
241
- buffer = buffer.substr (std::string (ENCRYPTION_HEADER). size () );
233
+ buffer = buffer.substr (headerSize );
242
234
buffer = decrypt (buffer);
235
+ } else {
236
+ if (fullPath.find (std::string (AY_OBFUSCATE (" /bot/" ))) != std::string::npos) {
237
+ if (g_game.getFeature (Otc::GameAllowCustomBotScripts)) {
238
+ return buffer;
239
+ }
240
+ return " " ;
241
+ }
243
242
}
244
243
#endif
245
244
@@ -759,25 +758,3 @@ std::unordered_map<std::string, std::string> ResourceManager::decompressArchive(
759
758
std::unordered_map<std::string, std::string> ret;
760
759
return ret;
761
760
}
762
-
763
- std::string ResourceManager::decodificateStrings (const std::vector<unsigned char >& bytes) {
764
- std::string result;
765
- for (const unsigned char c : bytes) {
766
- result.push_back (c ^ 0xAA );
767
- }
768
- return result;
769
- }
770
-
771
- // used to obfuscate vulnerable strings (provisional)
772
- std::string ResourceManager::getByteStrings (const size_t line) {
773
- const std::vector<std::vector<unsigned char >> strTable = {
774
- {0x85 , 0xCE , 0xC5 , 0xDD , 0xC4 , 0xC6 , 0xC5 , 0xCB , 0xCE , 0xD9 }, // "/downloads"
775
- {0x85 , 0xC8 , 0xC5 , 0xDE , 0x85 }, // "/bot/"
776
- {0xE6 , 0xC3 , 0xC4 , 0xC2 , 0xCB , 0x8A , 0xCE , 0xCF , 0x8A , 0xD8 , 0xCF , 0xDE , 0xC5 , 0xD8 , 0xC4 , 0xC5 , 0x8A , 0xC3 , 0xC4 , 0xDC , 0xCB , 0xC6 , 0xC3 , 0xCE , 0xCB }, // "Linha de retorno invalida"
777
- };
778
-
779
- if (line < strTable.size ()) {
780
- return decodificateStrings (strTable[line]);
781
- }
782
- return decodificateStrings (strTable[2 ]);
783
- }
0 commit comments