mirror of
https://github.com/SunsetMkt/Akebi-GC.git
synced 2025-09-19 12:06:04 +08:00
minor changes
`cheat-base` add x32 build `manual map` and `load library` injection moved to `cheat-base` removed unnecessary packet sniffer functionality fixed several type conversionals `cheat-library` now is startup by default little changes in `Logger`, `PatternScanner`, `ProtoTransfer` updated detours
This commit is contained in:
@ -40,15 +40,7 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketParser.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\GenshinCM.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\SnifferWindow.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\teleport\CustomTeleports.h" />
|
||||
<ClInclude Include="src\user\cheat\visuals\Browser.h" />
|
||||
<ClInclude Include="src\user\cheat\visuals\CameraZoom.h" />
|
||||
@ -93,18 +85,10 @@
|
||||
<ClInclude Include="src\user\cheat\misc\Debug.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\Hotkeys.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\ProtectionBypass.h" />
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketInfo.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketSniffer.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\ProtoManager.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\native.h" />
|
||||
<ClInclude Include="src\user\cheat\player\GodMode.h" />
|
||||
<ClInclude Include="src\user\cheat\player\InfiniteStamina.h" />
|
||||
@ -154,14 +138,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketParser.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\SnifferWindow.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\teleport\CustomTeleports.cpp" />
|
||||
<ClCompile Include="src\user\cheat\GenshinCM.cpp" />
|
||||
<ClCompile Include="src\user\cheat\visuals\Browser.cpp" />
|
||||
@ -204,18 +180,10 @@
|
||||
<ClCompile Include="src\user\cheat\misc\Debug.cpp" />
|
||||
<ClCompile Include="src\user\cheat\misc\Hotkeys.cpp" />
|
||||
<ClCompile Include="src\user\cheat\misc\ProtectionBypass.cpp" />
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketInfo.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketSniffer.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\ProtoManager.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\native.cpp" />
|
||||
<ClCompile Include="src\user\cheat\player\GodMode.cpp" />
|
||||
<ClCompile Include="src\user\cheat\player\InfiniteStamina.cpp" />
|
||||
@ -871,8 +839,8 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>CLibrary</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\obj\$(ProjectName)\</IntDir>
|
||||
<CustomBuildBeforeTargets>Run</CustomBuildBeforeTargets>
|
||||
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
|
||||
<CustomBuildAfterTargets>FinalizeBuildStatus</CustomBuildAfterTargets>
|
||||
@ -880,8 +848,8 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>CLibrary</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\obj\$(ProjectName)\</IntDir>
|
||||
<CustomBuildBeforeTargets>Run</CustomBuildBeforeTargets>
|
||||
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
|
||||
<CustomBuildAfterTargets>FinalizeBuildStatus</CustomBuildAfterTargets>
|
||||
@ -889,8 +857,8 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_WS|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>CLibrary</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\$(Configuration)-$(PlatformShortName)\obj\$(ProjectName)\</IntDir>
|
||||
<CustomBuildBeforeTargets>Run</CustomBuildBeforeTargets>
|
||||
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
|
||||
<CustomBuildAfterTargets>FinalizeBuildStatus</CustomBuildAfterTargets>
|
||||
@ -911,6 +879,7 @@
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -949,6 +918,7 @@ powershell -nop -c "& {sleep 15}"</Command>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -986,6 +956,7 @@ powershell -nop -c "& {sleep 15}"</Command>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<DiagnosticsFormat>Classic</DiagnosticsFormat>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -48,15 +48,9 @@
|
||||
<ClInclude Include="src\framework\pch-il2cpp.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketSniffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\ProtoManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\Debug.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -195,12 +189,6 @@
|
||||
<ClInclude Include="src\user\cheat\visuals\CameraZoom.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\SnifferWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\PacketParser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\user\cheat\misc\sniffer\messages\MessageBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -255,15 +243,9 @@
|
||||
<ClCompile Include="src\framework\pch-il2cpp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketSniffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\ProtoManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\Debug.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -390,12 +372,6 @@
|
||||
<ClCompile Include="src\user\cheat\visuals\CameraZoom.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\SnifferWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\PacketParser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\user\cheat\misc\sniffer\messages\MessageBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -11651,6 +11651,16 @@ namespace app {
|
||||
struct Browser__Fields fields;
|
||||
};
|
||||
|
||||
struct Button_1 {
|
||||
struct Button_1__Class* klass;
|
||||
MonitorData* monitor;
|
||||
};
|
||||
|
||||
struct Slider_1 {
|
||||
struct Slider_1__Class* klass;
|
||||
MonitorData* monitor;
|
||||
};
|
||||
|
||||
#if !defined(_GHIDRA_) && !defined(_IDA_)
|
||||
}
|
||||
#endif
|
||||
|
@ -45,6 +45,9 @@ namespace sniffer
|
||||
while (true)
|
||||
{
|
||||
auto messagePtr = ReceiveMessage();
|
||||
if (messagePtr == nullptr)
|
||||
return {};
|
||||
|
||||
if (GetMessageIDByType<TMessage>() != messagePtr->messageID())
|
||||
{
|
||||
delete messagePtr;
|
||||
|
@ -1,145 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "PacketInfo.h"
|
||||
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
PacketInfo::PacketInfo(PacketData packetData)
|
||||
: m_Data(packetData),
|
||||
m_JObject(nlohmann::json::parse(packetData.messageJson)),
|
||||
m_Time(util::GetCurrentTimeMillisec()),
|
||||
m_DrawBeauty(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PacketIOType PacketInfo::type() const
|
||||
{
|
||||
return m_Data.ioType;
|
||||
}
|
||||
|
||||
uint32_t PacketInfo::id() const
|
||||
{
|
||||
return m_Data.messageID;
|
||||
}
|
||||
|
||||
size_t PacketInfo::size() const
|
||||
{
|
||||
return m_Data.messageRawData.size();
|
||||
}
|
||||
|
||||
int64_t PacketInfo::time() const
|
||||
{
|
||||
return m_Time;
|
||||
}
|
||||
|
||||
std::string PacketInfo::name() const
|
||||
{
|
||||
return m_Data.name;
|
||||
}
|
||||
|
||||
nlohmann::json PacketInfo::object() const
|
||||
{
|
||||
return m_JObject;
|
||||
}
|
||||
|
||||
void DrawPrimitive(const std::string& key, nlohmann::json& jsonPrimitive)
|
||||
{
|
||||
if (jsonPrimitive.is_boolean())
|
||||
{
|
||||
bool primitive = jsonPrimitive;
|
||||
ImGui::Checkbox(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_number_integer() || jsonPrimitive.is_number_unsigned())
|
||||
{
|
||||
int primitive = jsonPrimitive;
|
||||
ImGui::InputInt(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_number_float())
|
||||
{
|
||||
float primitive = jsonPrimitive;
|
||||
ImGui::InputFloat(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_string())
|
||||
{
|
||||
std::string primitive = jsonPrimitive;
|
||||
ImGui::InputText(key.c_str(), &primitive);
|
||||
}
|
||||
else if (jsonPrimitive.is_null())
|
||||
{
|
||||
ImGui::Text("%s: <null>", key.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawObject(const std::string& key, nlohmann::json& jsonObject);
|
||||
|
||||
void DrawArray(const std::string& key, nlohmann::json& jsonArray)
|
||||
{
|
||||
ImGui::PushID(key.c_str());
|
||||
|
||||
if (ImGui::TreeNode(key.c_str()))
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& el : jsonArray)
|
||||
{
|
||||
DrawObject(std::to_string(i), el);
|
||||
i++;
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void DrawObject(const std::string& key, nlohmann::json& jsonObject)
|
||||
{
|
||||
if (jsonObject.is_array())
|
||||
DrawArray(key, jsonObject);
|
||||
else if (jsonObject.is_primitive())
|
||||
DrawPrimitive(key, jsonObject);
|
||||
else
|
||||
{
|
||||
ImGui::PushID(key.c_str());
|
||||
|
||||
if (ImGui::TreeNode(key.c_str()))
|
||||
{
|
||||
for (auto& el : jsonObject.items())
|
||||
DrawObject(el.key(), el.value());
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
void PacketInfo::Draw()
|
||||
{
|
||||
ImGui::PushID(this);
|
||||
|
||||
if (m_Header.empty())
|
||||
m_Header = fmt::format("[{}] {} | {}. Size: {}", magic_enum::enum_name(type()), id(), name(), size());
|
||||
|
||||
if (ImGui::TreeNode(m_Header.c_str()))
|
||||
{
|
||||
if (ImGui::Checkbox("## Beauty", &m_DrawBeauty) && m_DrawBeauty && m_JsonMessageBeauty.empty())
|
||||
{
|
||||
m_JsonMessageBeauty = m_JObject.dump(2);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
if (m_DrawBeauty)
|
||||
ImGui::InputTextMultiline("JSON Message", &m_JsonMessageBeauty);
|
||||
else
|
||||
ImGui::InputText("JSON Message", &m_Data.messageJson);
|
||||
|
||||
|
||||
DrawObject("Data", m_JObject);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "messages/PacketData.h"
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
class PacketInfo
|
||||
{
|
||||
public:
|
||||
PacketInfo(PacketData packetData);
|
||||
|
||||
PacketIOType type() const;
|
||||
uint32_t id() const;
|
||||
size_t size() const;
|
||||
int64_t time() const;
|
||||
std::string name() const;
|
||||
nlohmann::json object() const;
|
||||
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
nlohmann::json m_JObject;
|
||||
int64_t m_Time;
|
||||
|
||||
bool m_DrawBeauty;
|
||||
std::string m_JsonMessageBeauty;
|
||||
std::string m_Header;
|
||||
|
||||
PacketData m_Data;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,240 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "PacketParser.h"
|
||||
|
||||
#include "MessageManager.h"
|
||||
namespace sniffer
|
||||
{
|
||||
|
||||
PacketParser::PacketParser(const std::string& protoDirPath, const std::string& protoIDPath)
|
||||
: m_ProtoManager()
|
||||
{
|
||||
m_ProtoManager.Load(protoIDPath, protoDirPath);
|
||||
UpdateUnionPacketIDs();
|
||||
}
|
||||
|
||||
void PacketParser::SetProtoDir(const std::string& protoDir)
|
||||
{
|
||||
m_ProtoManager.LoadProtoDir(protoDir);
|
||||
UpdateUnionPacketIDs();
|
||||
}
|
||||
|
||||
void PacketParser::SetProtoIDPath(const std::string& protoIDPath)
|
||||
{
|
||||
m_ProtoManager.LoadProtoDir(protoIDPath);
|
||||
UpdateUnionPacketIDs();
|
||||
}
|
||||
|
||||
bool PacketParser::Parse(PacketData& data)
|
||||
{
|
||||
auto name = m_ProtoManager.GetName(data.messageID);
|
||||
if (!name)
|
||||
return false;
|
||||
|
||||
auto head = m_ProtoManager.GetJson("PacketHead", data.headRawData);
|
||||
if (!head)
|
||||
return false;
|
||||
|
||||
auto message = m_ProtoManager.GetJson(data.messageID, data.messageRawData);
|
||||
if (!message)
|
||||
return false;
|
||||
|
||||
data.name = *name;
|
||||
data.headJson = *head;
|
||||
data.messageJson = *message;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketParser::IsUnionPacket(const PacketData& data)
|
||||
{
|
||||
return m_UnionPacketIds.count(data.messageID) > 0;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseUnionPacket(const PacketData& data)
|
||||
{
|
||||
if (!IsUnionPacket(data))
|
||||
return {};
|
||||
|
||||
auto parseFunction = m_UnionPacketIds[data.messageID];
|
||||
return (this->*parseFunction)(data);
|
||||
}
|
||||
|
||||
PacketData PacketParser::CreateNestedPacket(const PacketData& parent, std::string bodyEncoded, int16_t packetID)
|
||||
{
|
||||
PacketData nestedPacketData = MessageManager::CreateMessage<PacketData>();
|
||||
nestedPacketData.headRawData = parent.headRawData;
|
||||
nestedPacketData.headJson = parent.headJson;
|
||||
nestedPacketData.messageRawData = util::base64_decode(bodyEncoded);
|
||||
nestedPacketData.messageID = packetID;
|
||||
nestedPacketData.valid = true;
|
||||
nestedPacketData.ioType = parent.ioType;
|
||||
nestedPacketData.parentPacketID = parent.sequenceID();
|
||||
|
||||
if (packetID != 0)
|
||||
Parse(nestedPacketData);
|
||||
|
||||
return nestedPacketData;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseUnionCmdNotify(const PacketData& data)
|
||||
{
|
||||
nlohmann::json cmdListObject = nlohmann::json::parse(data.messageJson);
|
||||
|
||||
std::vector<PacketData> packets;
|
||||
for (auto& cmd : cmdListObject["cmdList"])
|
||||
{
|
||||
auto nestedPacketData = CreateNestedPacket(data, cmd["body"], cmd["messageId"]);
|
||||
packets.push_back(nestedPacketData);
|
||||
|
||||
if (IsUnionPacket(nestedPacketData))
|
||||
{
|
||||
auto nestedNestedPackets = ParseUnionPacket(nestedPacketData);
|
||||
packets.insert(packets.end(), nestedNestedPackets.begin(), nestedNestedPackets.end());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
std::optional<PacketData> PacketParser::ParseAbilityInvokeEntry(const PacketData& parent, const nlohmann::json& entry)
|
||||
{
|
||||
static std::map<std::string, std::string> abilityArgument2Proto =
|
||||
{
|
||||
{ "ABILITY_META_MODIFIER_CHANGE", "AbilityMetaModifierChange" },
|
||||
{ "ABILITY_META_COMMAND_MODIFIER_CHANGE_REQUEST", "AbilityMetaCommandModifierChangeRequest" },
|
||||
{ "ABILITY_META_SPECIAL_FLOAT_ARGUMENT", "AbilityMetaSpecialFloatArgument" },
|
||||
{ "ABILITY_META_OVERRIDE_PARAM", "AbilityMetaOverrideParam" },
|
||||
{ "ABILITY_META_CLEAR_OVERRIDE_PARAM", "AbilityMetaClearOverrideParam" },
|
||||
{ "ABILITY_META_REINIT_OVERRIDEMAP", "AbilityMetaReinitOverridemap" },
|
||||
{ "ABILITY_META_GLOBAL_FLOAT_VALUE", "AbilityMetaGlobalFloatValue" },
|
||||
{ "ABILITY_META_CLEAR_GLOBAL_FLOAT_VALUE", "AbilityMetaClearGlobalFloatValue" },
|
||||
{ "ABILITY_META_ABILITY_ELEMENT_STRENGTH", "AbilityMetaAbilityElementStrength" },
|
||||
{ "ABILITY_META_ADD_OR_GET_ABILITY_AND_TRIGGER", "AbilityMetaAddOrGetAbilityAndTrigger" },
|
||||
{ "ABILITY_META_SET_KILLED_SETATE", "AbilityMetaSetKilledSetate" },
|
||||
{ "ABILITY_META_SET_ABILITY_TRIGGER", "AbilityMetaSetAbilityTrigger" },
|
||||
{ "ABILITY_META_ADD_NEW_ABILITY", "AbilityMetaAddNewAbility" },
|
||||
{ "ABILITY_META_REMOVE_ABILITY", "AbilityMetaRemoveAbility" },
|
||||
{ "ABILITY_META_SET_MODIFIER_APPLY_ENTITY", "AbilityMetaSetModifierApplyEntity" },
|
||||
{ "ABILITY_META_MODIFIER_DURABILITY_CHANGE", "AbilityMetaModifierDurabilityChange" },
|
||||
{ "ABILITY_META_ELEMENT_REACTION_VISUAL", "AbilityMetaElementReactionVisual" },
|
||||
{ "ABILITY_META_SET_POSE_PARAMETER", "AbilityMetaSetPoseParameter" },
|
||||
{ "ABILITY_META_UPDATE_BASE_REACTION_DAMAGE", "AbilityMetaUpdateBaseReactionDamage" },
|
||||
{ "ABILITY_META_TRIGGER_ELEMENT_REACTION", "AbilityMetaTriggerElementReaction" },
|
||||
{ "ABILITY_META_LOSE_HP", "AbilityMetaLoseHp" },
|
||||
{ "ABILITY_ACTION_TRIGGER_ABILITY", "AbilityActionTriggerAbility" },
|
||||
{ "ABILITY_ACTION_SET_CRASH_DAMAGE", "AbilityActionSetCrashDamage" },
|
||||
{ "ABILITY_ACTION_EFFECT", "AbilityActionEffect" },
|
||||
{ "ABILITY_ACTION_SUMMON", "AbilityActionSummon" },
|
||||
{ "ABILITY_ACTION_BLINK", "AbilityActionBlink" },
|
||||
{ "ABILITY_ACTION_CREATE_GADGET", "AbilityActionCreateGadget" },
|
||||
{ "ABILITY_ACTION_APPLY_LEVEL_MODIFIER", "AbilityActionApplyLevelModifier" },
|
||||
{ "ABILITY_ACTION_GENERATE_ELEM_BALL", "AbilityActionGenerateElemBall" },
|
||||
{ "ABILITY_ACTION_SET_RANDOM_OVERRIDE_MAP_VALUE", "AbilityActionSetRandomOverrideMapValue" },
|
||||
{ "ABILITY_ACTION_SERVER_MONSTER_LOG", "AbilityActionServerMonsterLog" },
|
||||
{ "ABILITY_ACTION_CREATE_TILE", "AbilityActionCreateTile" },
|
||||
{ "ABILITY_ACTION_DESTROY_TILE", "AbilityActionDestroyTile" },
|
||||
{ "ABILITY_ACTION_FIRE_AFTER_IMAGE", "AbilityActionFireAfterImage" },
|
||||
{ "ABILITY_MIXIN_AVATAR_STEER_BY_CAMERA", "AbilityMixinAvatarSteerByCamera" },
|
||||
{ "ABILITY_MIXIN_MONSTER_DEFEND", "AbilityMixinMonsterDefend" },
|
||||
{ "ABILITY_MIXIN_WIND_ZONE", "AbilityMixinWindZone" },
|
||||
{ "ABILITY_MIXIN_COST_STAMINA", "AbilityMixinCostStamina" },
|
||||
{ "ABILITY_MIXIN_ELITE_SHIELD", "AbilityMixinEliteShield" },
|
||||
{ "ABILITY_MIXIN_ELEMENT_SHIELD", "AbilityMixinElementShield" },
|
||||
{ "ABILITY_MIXIN_GLOBAL_SHIELD", "AbilityMixinGlobalShield" },
|
||||
{ "ABILITY_MIXIN_SHIELD_BAR", "AbilityMixinShieldBar" },
|
||||
{ "ABILITY_MIXIN_WIND_SEED_SPAWNER", "AbilityMixinWindSeedSpawner" },
|
||||
{ "ABILITY_MIXIN_DO_ACTION_BY_ELEMENT_REACTION", "AbilityMixinDoActionByElementReaction" },
|
||||
{ "ABILITY_MIXIN_FIELD_ENTITY_COUNT_CHANGE", "AbilityMixinFieldEntityCountChange" },
|
||||
{ "ABILITY_MIXIN_SCENE_PROP_SYNC", "AbilityMixinScenePropSync" },
|
||||
{ "ABILITY_MIXIN_WIDGET_MP_SUPPORT", "AbilityMixinWidgetMpSupport" }
|
||||
};
|
||||
|
||||
if (entry.count("abilityData") == 0 || entry.count("argumentType") == 0)
|
||||
return {};
|
||||
|
||||
std::string argumentType = entry["argumentType"];
|
||||
if (abilityArgument2Proto.count(argumentType) == 0)
|
||||
return {};
|
||||
|
||||
PacketData nestedPacketData = CreateNestedPacket(parent, entry["abilityData"]);
|
||||
nestedPacketData.name = abilityArgument2Proto[argumentType];
|
||||
|
||||
auto jsonData = m_ProtoManager.GetJson(nestedPacketData.name, nestedPacketData.messageRawData);
|
||||
nestedPacketData.messageJson = jsonData ? *jsonData : "{}";
|
||||
return nestedPacketData;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseAbilityInvocationsNotify(const PacketData& data)
|
||||
{
|
||||
auto combatJsonObject = nlohmann::json::parse(data.messageJson);
|
||||
std::vector<PacketData> packets = {};
|
||||
for (auto& invokeEntry : combatJsonObject["invokes"])
|
||||
{
|
||||
auto abilityPacketData = ParseAbilityInvokeEntry(data, invokeEntry);
|
||||
if (abilityPacketData)
|
||||
packets.push_back(*abilityPacketData);
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
std::optional<PacketData> PacketParser::ParseCombatInvokeEntry(const PacketData& parent, const nlohmann::json& entry)
|
||||
{
|
||||
static std::map<std::string, std::string> combateTypeProtos = {
|
||||
{ "ENTITY_MOVE", "EntityMoveInfo" },
|
||||
{ "COMBAT_EVT_BEING_HIT", "EvtBeingHitInfo" },
|
||||
{ "COMBAT_ANIMATOR_STATE_CHANGED", "EvtAnimatorStateChangedInfo" },
|
||||
{ "COMBAT_FACE_TO_DIR", "EvtFaceToDirInfo" },
|
||||
{ "COMBAT_SET_ATTACK_TARGET", "EvtSetAttackTargetInfo" },
|
||||
{ "COMBAT_RUSH_MOVE", "EvtRushMoveInfo" },
|
||||
{ "COMBAT_ANIMATOR_PARAMETER_CHANGED", "EvtAnimatorParameterInfo" },
|
||||
{ "SYNC_ENTITY_POSITION", "EvtSyncEntityPositionInfo" },
|
||||
{ "COMBAT_STEER_MOTION_INFO", "EvtCombatSteerMotionInfo" },
|
||||
{ "COMBAT_FORCE_SET_POSITION_INFO", "EvtCombatForceSetPosInfo" },
|
||||
{ "COMBAT_FORCE_SET_POS_INFO", "EvtCombatForceSetPosInfo" },
|
||||
{ "COMBAT_COMPENSATE_POS_DIFF", "EvtCompensatePosDiffInfo" },
|
||||
{ "COMBAT_MONSTER_DO_BLINK", "EvtMonsterDoBlink" },
|
||||
{ "COMBAT_FIXED_RUSH_MOVE", "EvtFixedRushMove" },
|
||||
{ "COMBAT_SYNC_TRANSFORM", "EvtSyncTransform" },
|
||||
{ "COMBAT_LIGHT_CORE_MOVE", "EvtLightCoreMove" }
|
||||
};
|
||||
|
||||
if (!entry["argumentType"].is_string())
|
||||
return {};
|
||||
|
||||
std::string argumentType = entry["argumentType"];
|
||||
|
||||
if (combateTypeProtos.count(argumentType) == 0)
|
||||
{
|
||||
LOG_WARNING("Failed to find argument type %s", argumentType.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
PacketData nestedPacketData = CreateNestedPacket(parent, entry["combatData"]);
|
||||
nestedPacketData.name = combateTypeProtos[argumentType];
|
||||
|
||||
auto jsonData = m_ProtoManager.GetJson(nestedPacketData.name, nestedPacketData.messageRawData);
|
||||
nestedPacketData.messageJson = jsonData ? *jsonData : "{}";
|
||||
return nestedPacketData;
|
||||
}
|
||||
|
||||
std::vector<PacketData> PacketParser::ParseCombatInvocationsNotify(const PacketData& data)
|
||||
{
|
||||
auto combatJsonObject = nlohmann::json::parse(data.messageJson);
|
||||
std::vector<PacketData> packets = {};
|
||||
for (auto& invokeEntry : combatJsonObject["invokeList"])
|
||||
{
|
||||
auto combatPacketData = ParseCombatInvokeEntry(data, invokeEntry);
|
||||
if (combatPacketData)
|
||||
packets.push_back(*combatPacketData);
|
||||
}
|
||||
return packets;
|
||||
}
|
||||
|
||||
void PacketParser::UpdateUnionPacketIDs()
|
||||
{
|
||||
m_UnionPacketIds.clear();
|
||||
for (auto& [unionPacketName, parserFunc] : s_UnionPacketNames)
|
||||
{
|
||||
m_UnionPacketIds[m_ProtoManager.GetId(unionPacketName)] = parserFunc;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
#include "messages/PacketData.h"
|
||||
#include "ProtoManager.h"
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
class PacketParser
|
||||
{
|
||||
public:
|
||||
PacketParser(const std::string& protoDirPath, const std::string& protoIDPath);
|
||||
|
||||
void SetProtoDir(const std::string& protoDir);
|
||||
void SetProtoIDPath(const std::string& protoIDPath);
|
||||
|
||||
bool Parse(PacketData& data);
|
||||
bool IsUnionPacket(const PacketData& data);
|
||||
std::vector<PacketData> ParseUnionPacket(const PacketData& data);
|
||||
|
||||
private:
|
||||
PacketData CreateNestedPacket(const PacketData& parent, std::string bodyEncoded, int16_t packetID = 0);
|
||||
std::vector<PacketData> ParseUnionCmdNotify(const PacketData& data);
|
||||
|
||||
std::optional<PacketData> ParseAbilityInvokeEntry(const PacketData& parent, const nlohmann::json& entry);
|
||||
std::vector<PacketData> ParseAbilityInvocationsNotify(const PacketData& data);
|
||||
|
||||
std::optional<PacketData> ParseCombatInvokeEntry(const PacketData& parent, const nlohmann::json& entry);
|
||||
std::vector<PacketData> ParseCombatInvocationsNotify(const PacketData& data);
|
||||
|
||||
using UnionPacketParserFunc = std::vector<PacketData>(PacketParser::*)(const PacketData& data);
|
||||
inline static std::map<std::string, UnionPacketParserFunc> s_UnionPacketNames =
|
||||
{
|
||||
{ "UnionCmdNotify", &ParseUnionCmdNotify},
|
||||
|
||||
{ "EntityAbilityInvokeEntry", &ParseAbilityInvocationsNotify },
|
||||
{ "ClientAbilityInitFinishNotify", &ParseAbilityInvocationsNotify },
|
||||
{ "ClientAbilityChangeNotify", &ParseAbilityInvocationsNotify },
|
||||
{ "AbilityInvocationsNotify", &ParseAbilityInvocationsNotify },
|
||||
|
||||
{ "CombatInvocationsNotify", &ParseCombatInvocationsNotify}
|
||||
};
|
||||
|
||||
sniffer::ProtoManager m_ProtoManager;
|
||||
std::map<uint32_t, UnionPacketParserFunc> m_UnionPacketIds;
|
||||
|
||||
void UpdateUnionPacketIDs();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,18 +11,12 @@
|
||||
namespace cheat::feature
|
||||
{
|
||||
PacketSniffer::PacketSniffer() : Feature(),
|
||||
NF(m_CapturingEnabled, "Capturing", "PacketSniffer", false),
|
||||
NF(m_ManipulationEnabled, "Manipulation", "PacketSniffer", false),
|
||||
NF(m_PipeEnabled, "Pipe", "PacketSniffer", false)
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
, NF(m_ProtoDirPath, "Proto Dir Path", "PacketSniffer", ""),
|
||||
NF(m_ProtoIDFilePath, "Proto ID File Path", "PacketSniffer", ""),
|
||||
m_PacketParser(m_ProtoDirPath, m_ProtoIDFilePath)
|
||||
#endif
|
||||
NF(f_CaptureEnabled, "Capturing", "PacketSniffer", false),
|
||||
NF(f_ManipulationEnabled, "Manipulation", "PacketSniffer", false),
|
||||
NF(f_PipeName, "Pipe name", "PacketSniffer", "genshin_packet_pipe")
|
||||
|
||||
{
|
||||
sniffer::MessageManager::Connect("genshin_packet_pipe");
|
||||
sniffer::MessageManager::Connect(f_PipeName.value());
|
||||
|
||||
HookManager::install(app::Kcp_KcpNative_kcp_client_send_packet, KcpNative_kcp_client_send_packet_Hook);
|
||||
HookManager::install(app::MoleMole_KcpClient_TryDequeueEvent, KcpClient_TryDequeueEvent_Hook);
|
||||
@ -34,80 +28,14 @@ namespace cheat::feature
|
||||
return info;
|
||||
}
|
||||
|
||||
bool PacketSniffer::OnCapturingChanged()
|
||||
{
|
||||
#ifdef _PACKET_SNIFFER
|
||||
if (!m_CapturingEnabled)
|
||||
return true;
|
||||
|
||||
if (!m_ProtoDirPath.value().empty() && !m_ProtoIDFilePath.value().empty())
|
||||
{
|
||||
m_PacketParser.SetProtoIDPath(m_ProtoIDFilePath);
|
||||
m_PacketParser.SetProtoDir(m_ProtoDirPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PacketSniffer::DrawMain()
|
||||
{
|
||||
|
||||
//ImGui::Text("Dev: for working needs server for named pipe 'genshin_packet_pipe'.\nCheck 'packet-handler' project like example.");
|
||||
if (ConfigWidget(m_CapturingEnabled, "Enabling capturing of packet info and sending to pipe, if it exists."))
|
||||
{
|
||||
bool result = OnCapturingChanged();
|
||||
if (!result)
|
||||
{
|
||||
m_CapturingEnabled = false;
|
||||
ImGui::OpenPopup("Error");
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("Error"))
|
||||
{
|
||||
ImGui::Text("Please fill 'Proto Dir Path' and 'Proto ID File Path' before enabling capture.");
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
auto& window = sniffer::SnifferWindow::GetInstance();
|
||||
ConfigWidget(window.m_Show, "Show capturing window.");
|
||||
|
||||
ConfigWidget(m_PipeEnabled, "Enable sending of packet data to pipe with name 'genshin_packet_pipe'.\n"\
|
||||
"This feature can be used with external monitoring tools.");
|
||||
//ConfigWidget(m_ManipulationEnabled, "Enabling manipulation packet feature, that allows to replace, block incoming/outcoming packets." \
|
||||
// "\nThis feature often needs, to read-write pipe operation, so can decrease network bandwidth.");
|
||||
|
||||
if (m_CapturingEnabled)
|
||||
{
|
||||
ImGui::Text("These parameters can only be changed when 'Capturing' is disabled.");
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
|
||||
ConfigWidget(m_ProtoDirPath, "Path to directory containing Genshin .proto files.");
|
||||
ConfigWidget(m_ProtoIDFilePath, "Path to JSON file containing packet id->packet name info.");
|
||||
|
||||
if (m_CapturingEnabled)
|
||||
ImGui::EndDisabled();
|
||||
#else
|
||||
ImGui::Text("When capture is enabled, raw packet data will be send to named pipe: 'genshin_packet_pipe'.");
|
||||
ImGui::Text("'Raw' means that you should to parse protobuf structure by yourself.");
|
||||
#endif
|
||||
ImGui::Text("Dev: for working needs server for named pipe with specified name.\nCheck 'packet-handler' project like example.");
|
||||
ConfigWidget(f_PipeName, "Pipe name for connecting. Changes will apply after next game launch.");
|
||||
ConfigWidget(f_CaptureEnabled, "Enable capturing of packet info and sending to pipe, if it exists.");
|
||||
ConfigWidget(f_ManipulationEnabled, "Enable blocking and modifying packets by sniffer, can cause network lags.");
|
||||
}
|
||||
|
||||
void PacketSniffer::DrawExternal()
|
||||
{
|
||||
#ifdef _PACKET_SNIFFER
|
||||
auto& window = sniffer::SnifferWindow::GetInstance();
|
||||
if (window.m_Show)
|
||||
window.Draw();
|
||||
#endif
|
||||
}
|
||||
|
||||
PacketSniffer& PacketSniffer::GetInstance()
|
||||
{
|
||||
static PacketSniffer instance;
|
||||
@ -141,7 +69,10 @@ namespace cheat::feature
|
||||
|
||||
bool PacketSniffer::OnPacketIO(app::KcpPacket_1* packet, PacketIOType type)
|
||||
{
|
||||
if (!m_CapturingEnabled)
|
||||
if (!sniffer::MessageManager::IsConnected())
|
||||
return true;
|
||||
|
||||
if (!f_CaptureEnabled)
|
||||
return true;
|
||||
|
||||
PacketData packetData = ParseRawPacketData((char*)packet->data, packet->dataLen);
|
||||
@ -149,30 +80,10 @@ namespace cheat::feature
|
||||
return true;
|
||||
|
||||
packetData.ioType = type;
|
||||
packetData.blockModeEnabled = m_ManipulationEnabled;
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
bool parsed = m_PacketParser.Parse(packetData);
|
||||
if (!parsed)
|
||||
return true;
|
||||
|
||||
sniffer::SnifferWindow::GetInstance().OnPacketIO({packetData});
|
||||
#endif
|
||||
|
||||
packetData.blockModeEnabled = f_ManipulationEnabled;
|
||||
sniffer::MessageManager::Send(packetData);
|
||||
|
||||
bool canceled = m_ManipulationEnabled && ProcessModifiedData(packet);
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
if (m_PacketParser.IsUnionPacket(packetData))
|
||||
{
|
||||
for (auto& nestedPacketData : m_PacketParser.ParseUnionPacket(packetData))
|
||||
{
|
||||
sniffer::SnifferWindow::GetInstance().OnPacketIO({ nestedPacketData });
|
||||
sniffer::MessageManager::Send(nestedPacketData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
bool canceled = f_ManipulationEnabled && ProcessModifiedData(packet);
|
||||
|
||||
return !canceled;
|
||||
}
|
||||
|
@ -12,41 +12,25 @@
|
||||
|
||||
#include "MessageManager.h"
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
#include "PacketParser.h"
|
||||
#include "PacketInfo.h"
|
||||
#endif
|
||||
|
||||
namespace cheat::feature
|
||||
{
|
||||
|
||||
class PacketSniffer : public Feature
|
||||
{
|
||||
public:
|
||||
config::Field<bool> m_CapturingEnabled;
|
||||
config::Field<bool> m_ManipulationEnabled;
|
||||
config::Field<bool> m_PipeEnabled;
|
||||
|
||||
#ifdef _PACKET_SNIFFER
|
||||
config::Field<std::string> m_ProtoDirPath;
|
||||
config::Field<std::string> m_ProtoIDFilePath;
|
||||
#endif
|
||||
config::Field<bool> f_CaptureEnabled;
|
||||
config::Field<bool> f_ManipulationEnabled;
|
||||
config::Field<std::string> f_PipeName;
|
||||
|
||||
static PacketSniffer& GetInstance();
|
||||
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
|
||||
void DrawExternal() final;
|
||||
|
||||
private:
|
||||
#ifdef _PACKET_SNIFFER
|
||||
sniffer::PacketParser m_PacketParser;
|
||||
#endif
|
||||
PacketSniffer();
|
||||
PacketData ParseRawPacketData(char* encryptedData, uint32_t length);
|
||||
bool OnCapturingChanged();
|
||||
|
||||
PacketData ParseRawPacketData(char* encryptedData, uint32_t length);
|
||||
static char* EncryptXor(void* content, uint32_t length);
|
||||
static bool KcpClient_TryDequeueEvent_Hook(void* __this, app::ClientKcpEvent* evt, MethodInfo* method);
|
||||
static int32_t KcpNative_kcp_client_send_packet_Hook(void* kcp_client, app::KcpPacket_1* packet, MethodInfo* method);
|
||||
|
@ -1,125 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "ProtoManager.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
|
||||
class ErrorCollector : public google::protobuf::compiler::MultiFileErrorCollector
|
||||
{
|
||||
// Inherited via MultiFileErrorCollector
|
||||
virtual void AddError(const std::string& filename, int line, int column, const std::string& message) override
|
||||
{
|
||||
LOG_ERROR("Error while parsing %s file, line %d, column %d, error: %s\n", filename.c_str(), line, column, message.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
void ProtoManager::LoadProtoDir(const std::string& dirPath)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
diskTree = std::shared_ptr<google::protobuf::compiler::DiskSourceTree>(new google::protobuf::compiler::DiskSourceTree());
|
||||
if (!dirPath.empty())
|
||||
diskTree->MapPath("", dirPath);
|
||||
|
||||
auto errorCollector = new ErrorCollector();
|
||||
importer = std::shared_ptr<google::protobuf::compiler::Importer>(new google::protobuf::compiler::Importer(diskTree.get(), errorCollector));
|
||||
factory = std::shared_ptr<google::protobuf::DynamicMessageFactory>(new google::protobuf::DynamicMessageFactory(importer->pool()));
|
||||
}
|
||||
|
||||
void ProtoManager::LoadIDFile(const std::string& filepath)
|
||||
{
|
||||
if (filepath.empty())
|
||||
return;
|
||||
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
nameMap.clear();
|
||||
|
||||
std::ifstream file;
|
||||
file.open(filepath);
|
||||
if (!file.is_open())
|
||||
{
|
||||
LOG_WARNING("Failed to load proto id file.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto content = nlohmann::json::parse(file);
|
||||
for (nlohmann::json::iterator it = content.begin(); it != content.end(); ++it)
|
||||
{
|
||||
auto id = std::stoi(it.key().c_str());
|
||||
nameMap[id] = it.value();
|
||||
idMap[it.value()] = id;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
google::protobuf::Message* ProtoManager::ParseMessage(const std::string& name, std::vector<byte> data)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
auto fileDescriptor = importer->Import(name + ".proto");
|
||||
if (fileDescriptor == nullptr || fileDescriptor->message_type_count() == 0)
|
||||
return nullptr;
|
||||
|
||||
auto message = factory->GetPrototype(fileDescriptor->message_type(0))->New();
|
||||
|
||||
std::string stringData((char*)data.data(), data.size());
|
||||
message->ParseFromString(stringData);
|
||||
return message;
|
||||
}
|
||||
|
||||
ProtoManager::ProtoManager() {}
|
||||
|
||||
void ProtoManager::Load(const std::string& idFilePath, const std::string& protoDir)
|
||||
{
|
||||
LoadIDFile(idFilePath);
|
||||
LoadProtoDir(protoDir);
|
||||
}
|
||||
|
||||
std::optional <std::string> ProtoManager::GetJson(const std::string& name, std::vector<byte>& data)
|
||||
{
|
||||
auto message = ParseMessage(name, data);
|
||||
if (message == nullptr)
|
||||
{
|
||||
LOG_ERROR("Failed to parse message with name %s.", name.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string jsonMessage = {};
|
||||
google::protobuf::util::MessageToJsonString(*message, &jsonMessage);
|
||||
|
||||
delete message;
|
||||
|
||||
return jsonMessage;
|
||||
}
|
||||
|
||||
std::optional<std::string> ProtoManager::GetJson(uint32_t id, std::vector<byte>& data)
|
||||
{
|
||||
auto name = GetName(id);
|
||||
if (!name)
|
||||
return {};
|
||||
|
||||
return GetJson(*name, data);
|
||||
}
|
||||
|
||||
std::optional<std::string> ProtoManager::GetName(uint32_t id)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
if (nameMap.count(id) == 0)
|
||||
{
|
||||
LOG_WARNING("Failed to find proto with id %u", id);
|
||||
return {};
|
||||
}
|
||||
|
||||
return nameMap[id];
|
||||
}
|
||||
|
||||
uint16_t ProtoManager::GetId(const std::string& name)
|
||||
{
|
||||
return idMap.count(name) == 0 ? 0 : idMap[name];
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
#include <google/protobuf/compiler/importer.h>
|
||||
#include <google/protobuf/dynamic_message.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/util/json_util.h>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
class ProtoManager
|
||||
{
|
||||
public:
|
||||
ProtoManager();
|
||||
|
||||
std::optional<std::string> GetJson(uint32_t id, std::vector<byte>& data);
|
||||
std::optional<std::string> GetJson(const std::string& name, std::vector<byte>& byte);
|
||||
std::optional<std::string> GetName(uint32_t id);
|
||||
uint16_t GetId(const std::string& name);
|
||||
|
||||
void Load(const std::string& idFilePath, const std::string& protoDir);
|
||||
void LoadIDFile(const std::string& filepath);
|
||||
void LoadProtoDir(const std::string& dirPath);
|
||||
|
||||
private:
|
||||
std::mutex _mutex;
|
||||
std::shared_ptr<google::protobuf::compiler::Importer> importer;
|
||||
std::shared_ptr<google::protobuf::DynamicMessageFactory> factory;
|
||||
std::shared_ptr<google::protobuf::compiler::DiskSourceTree> diskTree;
|
||||
|
||||
std::map<uint16_t, std::string> nameMap;
|
||||
std::map<std::string, uint16_t> idMap;
|
||||
|
||||
google::protobuf::Message* ParseMessage(const std::string& name, std::vector<byte> data);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,547 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
#include "SnifferWindow.h"
|
||||
#include <imgui_internal.h>
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
#include <regex>
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
SnifferWindow& SnifferWindow::GetInstance()
|
||||
{
|
||||
static SnifferWindow instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static auto nameCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.name() < b.name(); };
|
||||
static auto sizeCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.size() < b.size(); };
|
||||
static auto idCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.id() < b.id(); };
|
||||
static auto typeCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.type() < b.type(); };
|
||||
static auto timeCompare = [](const PacketInfo& a, const PacketInfo& b) { return a.time() < b.time(); };
|
||||
|
||||
void SnifferWindow::OnPacketIO(const PacketInfo& info)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(m_CapturePacketLock);
|
||||
|
||||
if (m_SortValue == SortValue::Time)
|
||||
{
|
||||
m_CapturedPackets.push_back(info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.push_back(info);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m_SortValue)
|
||||
{
|
||||
case sniffer::SnifferWindow::SortValue::Name:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Size:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, sizeCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Id:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, idCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Type:
|
||||
m_CapturedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, typeCompare), info);
|
||||
if (m_FilterGroup.Execute(info))
|
||||
m_CachedPackets.insert(std::lower_bound(m_CapturedPackets.begin(), m_CapturedPackets.end(), info, nameCompare), info);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
void SnifferWindow::Draw()
|
||||
{
|
||||
|
||||
const std::lock_guard<std::mutex> lock(m_CapturePacketLock);
|
||||
|
||||
bool showPrev = m_Show;
|
||||
bool windowShowed = ImGui::Begin("Packet sniffer", m_Show);
|
||||
|
||||
if (showPrev != m_Show)
|
||||
m_Show.FireChanged();
|
||||
|
||||
if (!windowShowed)
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ComboEnum("## SortValue", &m_SortValue))
|
||||
{
|
||||
switch (m_SortValue)
|
||||
{
|
||||
case sniffer::SnifferWindow::SortValue::Name:
|
||||
m_CapturedPackets.sort(nameCompare);
|
||||
m_CachedPackets.sort(nameCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Size:
|
||||
m_CapturedPackets.sort(sizeCompare);
|
||||
m_CachedPackets.sort(sizeCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Id:
|
||||
m_CapturedPackets.sort(idCompare);
|
||||
m_CachedPackets.sort(idCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Type:
|
||||
m_CapturedPackets.sort(typeCompare);
|
||||
m_CachedPackets.sort(typeCompare);
|
||||
break;
|
||||
case sniffer::SnifferWindow::SortValue::Time:
|
||||
m_CapturedPackets.sort(timeCompare);
|
||||
m_CachedPackets.sort(timeCompare);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ComboEnum("Sort ## SortType", &m_SortType);
|
||||
|
||||
m_FilterGroup.Draw(false);
|
||||
|
||||
if (ImGui::Button("Apply filter"))
|
||||
{
|
||||
m_CachedPackets.clear();
|
||||
for (auto& info : m_CapturedPackets)
|
||||
{
|
||||
if (m_FilterGroup.Execute(info))
|
||||
{
|
||||
m_CachedPackets.push_back(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Clear history"))
|
||||
{
|
||||
m_CapturedPackets.clear();
|
||||
m_CachedPackets.clear();
|
||||
}
|
||||
|
||||
ImGui::BeginChild("Packets");
|
||||
|
||||
if (m_SortType == SortType::Asc)
|
||||
{
|
||||
for (auto& info : m_CachedPackets)
|
||||
info.Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto it = m_CachedPackets.rbegin(); it != m_CachedPackets.rend(); it++)
|
||||
it->Draw();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
SnifferWindow::SnifferWindow() :
|
||||
NF(m_Show, "Show capturing window", "SnifferWindow", false),
|
||||
m_SortType(SortType::Desc),
|
||||
m_SortValue(SortValue::Time)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Filter::Draw(bool canBeRemoved)
|
||||
{
|
||||
ImGui::PushID(this);
|
||||
ComboEnum("## ObjectType", &m_ObjectType); ImGui::SameLine();
|
||||
ComboEnum("## CompareType", &m_CompareType); ImGui::SameLine();
|
||||
|
||||
if (m_ObjectType != ObjectType::AnyValue)
|
||||
{
|
||||
ImGui::SetNextItemWidth(200);
|
||||
ImGui::InputText("## Key", &m_KeyPattern); ImGui::SameLine();
|
||||
}
|
||||
|
||||
if (m_ObjectType == ObjectType::AnyValue || m_ObjectType == ObjectType::KeyValue)
|
||||
{
|
||||
ImGui::SetNextItemWidth(200);
|
||||
ImGui::InputText("## Value", &m_ObjectPattern); ImGui::SameLine();
|
||||
}
|
||||
|
||||
bool removed = false;
|
||||
if (canBeRemoved && ImGui::Button("Remove"))
|
||||
removed = true;
|
||||
|
||||
ImGui::PopID();
|
||||
return removed;
|
||||
}
|
||||
|
||||
static std::vector<std::string> StringSplit(const std::string& delimiter, const std::string& content)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
size_t pos = 0;
|
||||
size_t prevPos = 0;
|
||||
std::string token;
|
||||
while ((pos = content.find(delimiter, prevPos)) != std::string::npos) {
|
||||
token = content.substr(prevPos, pos - prevPos);
|
||||
tokens.push_back(token);
|
||||
prevPos = pos + delimiter.length();
|
||||
}
|
||||
tokens.push_back(content.substr(prevPos));
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static bool ApplyCompareString(const std::string& value, const std::string& pattern, Filter::CompareType compare)
|
||||
{
|
||||
std::string lowerValue = value;
|
||||
std::transform(lowerValue.begin(), lowerValue.end(), lowerValue.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
std::string lowerPattern = pattern;
|
||||
std::transform(lowerPattern.begin(), lowerPattern.end(), lowerPattern.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
switch (compare)
|
||||
{
|
||||
case sniffer::Filter::CompareType::Regex:
|
||||
{
|
||||
std::regex _regex(lowerPattern.c_str());
|
||||
return std::regex_match(lowerValue, _regex);
|
||||
}
|
||||
case sniffer::Filter::CompareType::Equal:
|
||||
return lowerValue == lowerPattern;
|
||||
case sniffer::Filter::CompareType::Contains:
|
||||
return lowerValue.find(lowerPattern) != std::string::npos;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static bool ApplyCompareAnyType(const nlohmann::json& object, const T& value, Filter::CompareType compare)
|
||||
{
|
||||
switch (compare)
|
||||
{
|
||||
case sniffer::Filter::CompareType::Equal:
|
||||
return object == value;
|
||||
case sniffer::Filter::CompareType::Less:
|
||||
return object < value;
|
||||
case sniffer::Filter::CompareType::LessEqual:
|
||||
return object <= value;
|
||||
case sniffer::Filter::CompareType::More:
|
||||
return object > value;
|
||||
case sniffer::Filter::CompareType::MoreEqual:
|
||||
return object >= value;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ApplyCompareValue(const nlohmann::json& object, const std::string& pattern, Filter::CompareType compare)
|
||||
{
|
||||
if (object.is_string())
|
||||
return ApplyCompareString(object, pattern, compare);
|
||||
|
||||
if (object.is_boolean())
|
||||
{
|
||||
if (compare != Filter::CompareType::Equal)
|
||||
return false;
|
||||
|
||||
bool value = pattern == "true" || pattern == "1";
|
||||
return object == value;
|
||||
}
|
||||
|
||||
if (!object.is_number())
|
||||
return false;
|
||||
|
||||
if (object.is_number_float())
|
||||
{
|
||||
auto value = std::stof(pattern);
|
||||
return ApplyCompareAnyType(object, value, compare);
|
||||
}
|
||||
|
||||
if (object.is_number_integer())
|
||||
{
|
||||
auto value = std::stoi(pattern);
|
||||
return ApplyCompareAnyType(object, value, compare);
|
||||
}
|
||||
|
||||
if (object.is_number_unsigned())
|
||||
{
|
||||
auto value = std::stoul(pattern);
|
||||
return ApplyCompareAnyType(object, value, compare);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HasValue(const nlohmann::json& object, const std::string& pattern, Filter::CompareType compare)
|
||||
{
|
||||
if (object.is_array())
|
||||
{
|
||||
for (auto& nested : object)
|
||||
{
|
||||
if (HasValue(nested, pattern, compare))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (object.is_object())
|
||||
{
|
||||
for (auto& item : object.items())
|
||||
{
|
||||
if (HasValue(item.value(), pattern, compare))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return ApplyCompareValue(object, pattern, compare);
|
||||
}
|
||||
|
||||
bool Filter::FindAnyValue(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_ObjectPattern.empty())
|
||||
return true;
|
||||
|
||||
return HasValue(info.object(), m_ObjectPattern, m_CompareType);
|
||||
}
|
||||
|
||||
bool Filter::FindAnyKey(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_KeyPattern.empty())
|
||||
return true;
|
||||
|
||||
return !FindKeys(info, true).empty();
|
||||
}
|
||||
|
||||
bool Filter::FindKeyValue(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_KeyPattern.empty())
|
||||
return true;
|
||||
|
||||
auto objects = FindKeys(info);
|
||||
for (auto& obj : objects)
|
||||
{
|
||||
if (ApplyCompareValue(info.object(), m_ObjectPattern, m_CompareType))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::vector<nlohmann::json> FindKey(const nlohmann::json& object, const std::string& pattern, Filter::CompareType compareType, bool onlyFirst, bool recursive)
|
||||
{
|
||||
std::vector<nlohmann::json> objects;
|
||||
|
||||
if (object.is_array())
|
||||
{
|
||||
if (!recursive)
|
||||
return objects;
|
||||
|
||||
for (auto& nested : object)
|
||||
{
|
||||
auto nestedResult = FindKey(nested, pattern, compareType, onlyFirst, recursive);
|
||||
if (nestedResult.size() > 0)
|
||||
{
|
||||
objects.insert(objects.end(), nestedResult.begin(), nestedResult.end());
|
||||
if (onlyFirst)
|
||||
return objects;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (object.is_object())
|
||||
{
|
||||
for (auto& item : object.items())
|
||||
{
|
||||
bool correct = ApplyCompareString(item.key(), pattern, compareType);
|
||||
if (!correct)
|
||||
{
|
||||
if (recursive)
|
||||
{
|
||||
auto nestedResult = FindKey(item.value(), pattern, compareType, onlyFirst, recursive);
|
||||
if (nestedResult.size() > 0)
|
||||
{
|
||||
objects.insert(objects.end(), nestedResult.begin(), nestedResult.end());
|
||||
if (onlyFirst)
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
objects.push_back(item.value());
|
||||
if (onlyFirst)
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
return objects;
|
||||
|
||||
}
|
||||
|
||||
std::vector<nlohmann::json> Filter::FindKeys(const sniffer::PacketInfo& info, bool onlyFirst)
|
||||
{
|
||||
auto equalType = m_ObjectType == ObjectType::KeyValue ? CompareType::Regex : m_CompareType;
|
||||
auto tokens = StringSplit("::", m_KeyPattern);
|
||||
|
||||
std::string& mainToken = tokens[0];
|
||||
if (tokens.size() == 1)
|
||||
{
|
||||
auto mainObjects = FindKey(info.object(), mainToken, equalType, onlyFirst, true);
|
||||
return mainObjects;
|
||||
}
|
||||
|
||||
auto objects = FindKey(info.object(), m_KeyPattern, equalType, false, true);
|
||||
|
||||
for (auto it = tokens.begin() + 1; it != tokens.end(); it++)
|
||||
{
|
||||
if (objects.empty())
|
||||
return {};
|
||||
|
||||
bool last_token = (tokens.end() - 1) == it;
|
||||
bool _onlyFirst = onlyFirst && last_token;
|
||||
|
||||
objects = FindKey(objects, *it, equalType, _onlyFirst, false);
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
||||
bool Filter::Execute(const sniffer::PacketInfo& info)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (m_ObjectType)
|
||||
{
|
||||
case sniffer::Filter::ObjectType::KeyValue:
|
||||
return FindKeyValue(info);
|
||||
case sniffer::Filter::ObjectType::AnyKey:
|
||||
return FindAnyKey(info);
|
||||
case sniffer::Filter::ObjectType::AnyValue:
|
||||
return FindAnyValue(info);
|
||||
case sniffer::Filter::ObjectType::Name:
|
||||
return ApplyCompareString(info.name(), m_KeyPattern, m_CompareType);
|
||||
case sniffer::Filter::ObjectType::PacketId:
|
||||
return ApplyCompareString(std::to_string(info.id()), m_KeyPattern, m_CompareType);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (const std::regex_error& e)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nlohmann::json Filter::Serialize()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
Filter::Filter()
|
||||
: m_CompareType(CompareType::Equal),
|
||||
m_ObjectType(ObjectType::KeyValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Filter::Filter(nlohmann::json& object)
|
||||
: Filter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool FilterGroup::Draw(bool canBeRemoved)
|
||||
{
|
||||
ImGui::PushID(this);
|
||||
|
||||
bool removed = false;
|
||||
auto name = fmt::format("Group {}", magic_enum::enum_name(m_Rule));
|
||||
ImGui::BeginGroupPanel(name.c_str());
|
||||
{
|
||||
ComboEnum("Rule", &m_Rule);
|
||||
|
||||
if (canBeRemoved)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Remove"))
|
||||
removed = true;
|
||||
}
|
||||
|
||||
std::optional<IFilter*> removeFilter = {};
|
||||
for (auto& filter : m_Filters)
|
||||
{
|
||||
if (filter->Draw())
|
||||
removeFilter = filter;
|
||||
}
|
||||
|
||||
if (removeFilter)
|
||||
{
|
||||
m_Filters.remove(*removeFilter);
|
||||
delete* removeFilter;
|
||||
}
|
||||
|
||||
if (ImGui::Button("Add group", ImVec2(70, 0)))
|
||||
m_Filters.push_back(new FilterGroup());
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Add filter", ImVec2(70, 0)))
|
||||
m_Filters.push_back(new Filter());
|
||||
|
||||
}
|
||||
ImGui::EndGroupPanel();
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
bool FilterGroup::Execute(const sniffer::PacketInfo& info)
|
||||
{
|
||||
if (m_Filters.empty())
|
||||
return true;
|
||||
|
||||
for (auto& filter : m_Filters)
|
||||
{
|
||||
bool result = filter->Execute(info);
|
||||
if (m_Rule == Rule::AND && !result)
|
||||
return false;
|
||||
|
||||
if (m_Rule == Rule::NOT && result)
|
||||
return false;
|
||||
|
||||
if (m_Rule == Rule::OR && result)
|
||||
return true;
|
||||
}
|
||||
return m_Rule != Rule::OR;
|
||||
}
|
||||
|
||||
|
||||
nlohmann::json FilterGroup::Serialize()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
FilterGroup::FilterGroup() :
|
||||
m_Rule(Rule::AND),
|
||||
m_Filters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FilterGroup::FilterGroup(nlohmann::json& object) : FilterGroup()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
#pragma once
|
||||
#include "PacketInfo.h"
|
||||
|
||||
namespace sniffer
|
||||
{
|
||||
|
||||
class IFilter
|
||||
{
|
||||
public:
|
||||
virtual bool Draw(bool canBeRemoved = true) = 0;
|
||||
virtual bool Execute(const sniffer::PacketInfo& info) = 0;
|
||||
virtual nlohmann::json Serialize() = 0;
|
||||
};
|
||||
|
||||
|
||||
class Filter : public IFilter
|
||||
{
|
||||
public:
|
||||
enum class CompareType
|
||||
{
|
||||
Regex, Equal, Contains, Less, LessEqual, More, MoreEqual
|
||||
};
|
||||
|
||||
enum class ObjectType
|
||||
{
|
||||
KeyValue, AnyKey, AnyValue, Name, PacketId
|
||||
};
|
||||
|
||||
virtual bool Draw(bool canBeRemoved = true) override;
|
||||
virtual bool Execute(const sniffer::PacketInfo& info) override;
|
||||
|
||||
virtual nlohmann::json Serialize() override;
|
||||
|
||||
Filter();
|
||||
Filter(nlohmann::json& object);
|
||||
private:
|
||||
|
||||
bool FindAnyValue(const sniffer::PacketInfo& info);
|
||||
bool FindAnyKey(const sniffer::PacketInfo& info);
|
||||
bool FindKeyValue(const sniffer::PacketInfo& info);
|
||||
std::vector<nlohmann::json> FindKeys(const sniffer::PacketInfo& info, bool onlyFirst = false);
|
||||
|
||||
CompareType m_CompareType;
|
||||
ObjectType m_ObjectType;
|
||||
|
||||
std::string m_KeyPattern;
|
||||
std::string m_ObjectPattern;
|
||||
};
|
||||
|
||||
class FilterGroup : public IFilter
|
||||
{
|
||||
public:
|
||||
|
||||
enum class Rule
|
||||
{
|
||||
AND, OR, NOT
|
||||
};
|
||||
|
||||
virtual bool Draw(bool canBeRemoved = true) override;
|
||||
virtual bool Execute(const sniffer::PacketInfo& info) override;
|
||||
|
||||
virtual nlohmann::json Serialize() override;
|
||||
|
||||
FilterGroup();
|
||||
FilterGroup(nlohmann::json& object);
|
||||
|
||||
private:
|
||||
Rule m_Rule;
|
||||
std::list<IFilter*> m_Filters;
|
||||
|
||||
};
|
||||
|
||||
class SnifferWindow
|
||||
{
|
||||
public:
|
||||
config::Field<bool> m_Show;
|
||||
|
||||
SnifferWindow(SnifferWindow const&) = delete;
|
||||
void operator=(SnifferWindow const&) = delete;
|
||||
|
||||
static SnifferWindow& GetInstance();
|
||||
void OnPacketIO(const PacketInfo& info);
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
enum class SortValue
|
||||
{
|
||||
Time, Name, Size, Id, Type
|
||||
};
|
||||
|
||||
enum class SortType
|
||||
{
|
||||
Desc, Asc
|
||||
};
|
||||
|
||||
SortValue m_SortValue;
|
||||
SortType m_SortType;
|
||||
|
||||
std::list<sniffer::PacketInfo> m_CapturedPackets;
|
||||
std::list<sniffer::PacketInfo> m_CachedPackets;
|
||||
|
||||
std::mutex m_CapturePacketLock;
|
||||
|
||||
FilterGroup m_FilterGroup;
|
||||
|
||||
SnifferWindow();
|
||||
};
|
||||
}
|
||||
|
@ -5,36 +5,16 @@ void PacketData::Write(PipeTransfer* transfer)
|
||||
{
|
||||
transfer->Write(blockModeEnabled);
|
||||
transfer->Write(ioType);
|
||||
transfer->Write(dataType);
|
||||
transfer->Write(valid);
|
||||
transfer->Write(parentPacketID);
|
||||
transfer->Write(messageID);
|
||||
transfer->Write(headRawData);
|
||||
transfer->Write(messageRawData);
|
||||
|
||||
if (dataType == PacketDataType::Parsed)
|
||||
{
|
||||
transfer->Write(name);
|
||||
transfer->Write(headJson);
|
||||
transfer->Write(messageJson);
|
||||
}
|
||||
}
|
||||
|
||||
void PacketData::Read(PipeTransfer* transfer)
|
||||
{
|
||||
transfer->Read(blockModeEnabled);
|
||||
transfer->Read(ioType);
|
||||
transfer->Read(dataType);
|
||||
transfer->Read(valid);
|
||||
transfer->Read(parentPacketID);
|
||||
transfer->Read(messageID);
|
||||
transfer->Read(headRawData);
|
||||
transfer->Read(messageRawData);
|
||||
|
||||
if (dataType == PacketDataType::Parsed)
|
||||
{
|
||||
transfer->Read(name);
|
||||
transfer->Read(headJson);
|
||||
transfer->Read(messageJson);
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,13 @@ namespace cheat::feature
|
||||
static Browser& GetInstance();
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
virtual bool NeedStatusDraw() const override;
|
||||
bool NeedStatusDraw() const override;
|
||||
void DrawStatus() override;
|
||||
|
||||
private:
|
||||
SafeQueue<uint32_t> toBeUpdate;
|
||||
SafeValue<int64_t> nextUpdate;
|
||||
int f_DelayUpdate = 20.f;
|
||||
int f_DelayUpdate = 20;
|
||||
void OnGameUpdate();
|
||||
Browser();
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ namespace cheat::feature
|
||||
private:
|
||||
SafeQueue<uint32_t> toBeUpdate;
|
||||
SafeValue<int64_t> nextUpdate;
|
||||
int f_DelayUpdate = 100.f;
|
||||
int f_DelayUpdate = 100;
|
||||
|
||||
void OnGameUpdate();
|
||||
PaimonFollow();
|
||||
|
@ -27,7 +27,7 @@ namespace cheat::feature
|
||||
const FeatureGUIInfo& GetGUIInfo() const override;
|
||||
void DrawMain() override;
|
||||
|
||||
virtual bool NeedStatusDraw() const override;
|
||||
bool NeedStatusDraw() const override;
|
||||
void DrawStatus() override;
|
||||
|
||||
bool CheckFile(const std::string& name);
|
||||
@ -35,7 +35,7 @@ namespace cheat::feature
|
||||
private:
|
||||
SafeQueue<uint32_t> toBeUpdate;
|
||||
SafeValue<int64_t> nextUpdate;
|
||||
int f_DelayUpdate = 100.f;
|
||||
int f_DelayUpdate = 100;
|
||||
|
||||
void OnGameUpdate();
|
||||
ProfileChanger();
|
||||
|
Reference in New Issue
Block a user