解密完成

This commit is contained in:
Yosin-Lenheart 2022-02-17 13:17:46 +08:00
parent b2d797c480
commit 765d63c28d
7 changed files with 71 additions and 24 deletions

24
test/RSAC.cpp Normal file
View File

@ -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]);
}

4
test/RSAC.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
void Makecode(char* pstr, int* pkey);
void Cutecode(char* pstr, int* pkey);

View File

@ -5,9 +5,10 @@
#include <windows.h>
#include <iostream>
#include <string>
#include <malloc.h>
#include <stdio.h>
#include "squirrel.h"
#include "MinHook.h"
#include <malloc.h>
#include <stdio.h>

View File

@ -9,7 +9,7 @@
// 添加要在此处预编译的标头
#include "framework.h"
#include "RSAC.h"

View File

@ -74,17 +74,21 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>D:\BaiduNetdiskWorkspace\DOF-Lenheart\Plugins\</OutDir>
<LibraryPath>E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>D:\BaiduNetdiskWorkspace\DOF-Lenheart\Plugins\</OutDir>
<LibraryPath>E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>D:\BaiduNetdiskWorkspace\DOF-Lenheart\Plugins\</OutDir>
<LibraryPath>E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>E:\Testnixiang\test\test\OpenSSL-Win32\lib;E:\Testnixiang\test\test\OpenSSL-Win32\lib\VC;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -94,6 +98,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<Optimization>Full</Optimization>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -113,6 +118,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Full</Optimization>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -131,6 +137,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<Optimization>Full</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -148,6 +155,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<Optimization>Full</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -160,6 +168,7 @@
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="RSAC.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
@ -169,6 +178,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="RSAC.cpp" />
<ClCompile Include="函数块.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -21,6 +21,9 @@
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="RSAC.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@ -32,5 +35,8 @@
<ClCompile Include="函数块.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="RSAC.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -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;
}
}