diff --git a/test/RSAC.cpp b/test/RSAC.cpp new file mode 100644 index 0000000..435527b --- /dev/null +++ b/test/RSAC.cpp @@ -0,0 +1,24 @@ +#pragma once +#include "pch.h" + +//单个字符异或运算 +char MakecodeChar(char c, int key) { + return c = c ^ key; +} +//单个字符解密 +char CutcodeChar(char c, int key) { + return c ^ key; +} +//加密 +void Makecode(char* pstr, int* pkey) { + int len = strlen(pstr);//获取长度 + for (int i = 0; i < len; i++) + *(pstr + i) = MakecodeChar(*(pstr + i), pkey[i % 5]); +} + +//解密 +void Cutecode(char* pstr, int* pkey) { + int len = strlen(pstr); + for (int i = 0; i < len; i++) + *(pstr + i) = CutcodeChar(*(pstr + i), pkey[i % 5]); +} \ No newline at end of file diff --git a/test/RSAC.h b/test/RSAC.h new file mode 100644 index 0000000..b6dbdab --- /dev/null +++ b/test/RSAC.h @@ -0,0 +1,4 @@ +#pragma once + +void Makecode(char* pstr, int* pkey); +void Cutecode(char* pstr, int* pkey); \ No newline at end of file diff --git a/test/framework.h b/test/framework.h index 10139e5..b298854 100644 --- a/test/framework.h +++ b/test/framework.h @@ -5,9 +5,10 @@ #include #include #include +#include +#include + #include "squirrel.h" #include "MinHook.h" -#include -#include \ No newline at end of file diff --git a/test/pch.h b/test/pch.h index bcac771..7574dda 100644 --- a/test/pch.h +++ b/test/pch.h @@ -9,7 +9,7 @@ // 娣诲姞瑕佸湪姝ゅ棰勭紪璇戠殑鏍囧ご #include "framework.h" - +#include "RSAC.h" diff --git a/test/test.vcxproj b/test/test.vcxproj index 2f56e9f..e7abbf2 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -74,17 +74,21 @@ true D:\BaiduNetdiskWorkspace\DOF-Lenheart\Plugins\ + E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath) false D:\BaiduNetdiskWorkspace\DOF-Lenheart\Plugins\ + E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath) true D:\BaiduNetdiskWorkspace\DOF-Lenheart\Plugins\ + E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath) false + E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath) @@ -94,6 +98,7 @@ true Use pch.h + Full Console @@ -113,6 +118,7 @@ pch.h MultiThreaded ProgramDatabase + Full Console @@ -131,6 +137,7 @@ true Use pch.h + Full Windows @@ -148,6 +155,7 @@ true Use pch.h + Full Windows @@ -160,6 +168,7 @@ + @@ -169,6 +178,7 @@ Create Create + diff --git a/test/test.vcxproj.filters b/test/test.vcxproj.filters index 4e26f38..204097b 100644 --- a/test/test.vcxproj.filters +++ b/test/test.vcxproj.filters @@ -21,6 +21,9 @@ 澶存枃浠 + + 澶存枃浠 + @@ -32,5 +35,8 @@ 婧愭枃浠 + + 婧愭枃浠 + \ No newline at end of file diff --git a/test/鍑芥暟鍧.cpp b/test/鍑芥暟鍧.cpp index be10a9b..1c33a81 100644 --- a/test/鍑芥暟鍧.cpp +++ b/test/鍑芥暟鍧.cpp @@ -285,29 +285,31 @@ static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror) default: SQfseek(file, 0, 2); break; // ascii } - char* nstr = (char*)"IIIAAAB <- 6648"; - //SQwrite(&add, 1, sizeof(add), file); - SQwrite(nstr, sizeof(nstr), strlen(nstr), file); - - SQfseek(file, 0, 1); - int length = SQftell(file); - SQfseek(file, 0, 2); - std::cout << "lenth:" << length << std::endl; - //char temp[256]; - char* temp = new char[length]; - //SQwrite(&add, 1, sizeof(add), file); - SQfread(temp, sizeof(temp), length, file); - temp[length] = '\0'; - printf(temp); - printf("\n"); - //std::cout << temp << std::endl; - - //char* temp = new char[16 * 4]; + SQfseek(file, 0, 1);//定位到尾 + int length = SQftell(file);//得到文件长度 + SQfseek(file, 0, 2);//定位到头 - SQfseek(file, 0, 2); - if (SQ_Compile(v, func, file, filename, printerror) >= 0) + + char* temp = new char[length+4];//new一个新的字符串 + + SQfread(temp, sizeof(temp), length, file);//把文件读到字符串里 + temp[length] = '\0';//给结尾添加结束符号 + + int key[] = { 5,2,3,5,0 };//定义解密数组 + Cutecode(temp, key);//解密 + + SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"wb+");//定义新的文件流 + SQwrite(temp, sizeof(temp), strlen(temp), newfile);//写入 + + + SQfseek(file, 0, 2);//定位到头 + SQfseek(newfile, 0, 2);//定位到头 + + if (SQ_Compile(v, func, newfile, filename, printerror) >= 0) { - SQ__Fclose(file); + SQ__Fclose(file);//关闭文件流 + SQ__Fclose(newfile);//关闭文件流 + remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件 return SQ_OK; } }