Fix crashes caused by tf2 update

- Remove SteamID Stealer
- Update Netchannel indexes
- Fix Datacenter IDS
- Switch back to Achievement based Authentication (RIP cl_drawline)
This commit is contained in:
BenCat07 2021-09-17 20:10:39 +02:00 committed by LightCat
parent 5da556c794
commit 6346ae26c3
11 changed files with 93 additions and 160 deletions

View File

@ -29,7 +29,6 @@
</LabeledObject>
<AutoVariable width="fill" target="name.namesteal.reconnect" label="Namesteal reconnect"/>
<AutoVariable width="fill" target="name.namesteal.use-newlines" label="Namesteal newlines" tooltip="Use glitchy newlines, will make your name invisible."/>
<AutoVariable width="fill" target="name.namesteal.steamid-zero" label="Invisible avatar" tooltip="Use a steamid of 0, will make your avatar invisible."/>
<AutoVariable width="fill" target="misc.random-name" label="Random name"/>
</List>
</Box>

@ -1 +1 @@
Subproject commit a2b2bf54816ec2ad780f4b5a509e53e4a3f58fba
Subproject commit ec9aaa1514eef4a9fc7406acc7dd3b0cea05161a

View File

@ -106,15 +106,15 @@ struct offsets
}
static constexpr uint32_t CanPacket()
{
return PlatformOffset(57, undefined, undefined);
return PlatformOffset(54, undefined, undefined);
}
static constexpr uint32_t SendNetMsg()
{
return PlatformOffset(41, undefined, undefined);
return PlatformOffset(38, undefined, undefined);
}
static constexpr uint32_t Shutdown()
{
return PlatformOffset(37, undefined, undefined);
return PlatformOffset(35, undefined, undefined);
}
static constexpr uint32_t IN_KeyEvent()
{
@ -178,7 +178,7 @@ struct offsets
}
static constexpr uint32_t SendDatagram()
{
return PlatformOffset(47, undefined, 47);
return PlatformOffset(44, undefined, 44);
}
static constexpr uint32_t IsPlayingTimeDemo()
{

View File

@ -44,6 +44,7 @@ SharedObject &client();
SharedObject &engine();
SharedObject &launcher();
SharedObject &steamapi();
SharedObject &steamnetworkingsockets();
SharedObject &vstdlib();
SharedObject &tier0();
SharedObject &inputsystem();

View File

@ -1,34 +0,0 @@
#pragma once
#include <optional>
#include <string>
#include <sdk.hpp>
namespace hacks::tf2::steamidstealer
{
class IDStorage
{
public:
unsigned steamid;
std::string reason;
std::string name;
IDStorage()
{
steamid = 0;
reason = "";
name = "";
}
IDStorage(unsigned steamid, std::string reason, std::string name = "")
{
this->steamid = steamid;
this->reason = reason;
this->name = name;
}
};
std::optional<IDStorage> GetSteamID();
void SetSteamID(std::optional<IDStorage> steamid);
void SendNetMessage(INetMessage &msg);
} // namespace hacks::tf2::steamidstealer

View File

@ -129,6 +129,7 @@ void LoadAllSharedObjects()
client().Load();
server().Load();
steamapi().Load();
steamnetworkingsockets().Load();
vstdlib().Load();
inputsystem().Load();
datacache().Load();
@ -176,6 +177,11 @@ SharedObject &steamapi()
static SharedObject obj("libsteam_api.so", false);
return obj;
}
SharedObject &steamnetworkingsockets()
{
static SharedObject obj("libsteamnetworkingsockets.so", true);
return obj;
}
SharedObject &client()
{
static SharedObject obj("client.so", true);

View File

@ -36,7 +36,6 @@ set(files "${CMAKE_CURRENT_LIST_DIR}/AutoJoin.cpp"
"${CMAKE_CURRENT_LIST_DIR}/NavBot.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Noisemaker.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PureBypass.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SteamIDStealer.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Trigger.cpp"
"${CMAKE_CURRENT_LIST_DIR}/UberSpam.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Walkbot.cpp"

View File

@ -21,7 +21,7 @@ static settings::Boolean enable{ "dc.enable", "false" };
/* List of preferred data centers separated by comma ',' */
static settings::String regions{ "dc.regions", "" };
/* Find servers only in data centers provided by regions */
static settings::Boolean restrict{ "dc.restrict", "true" };
static settings::Boolean restrict { "dc.restrict", "true" };
/* Enable/disable individual continents */
static settings::Boolean enable_eu{ "dc.toggle-europe", "false" };
static settings::Boolean enable_north_america{ "dc.toggle-north-america", "false" };
@ -93,32 +93,34 @@ static std::vector<std::string> asia_datacenters = { { "bom" }, { "dxb"
static std::vector<std::string> oceana_datacenters = { { "syd" }, { "vie" } };
static std::vector<std::string> africa_datacenters = { { "jnb" } };
static CatCommand print("dc_print", "Print codes of all available data centers", []() {
static auto GetPOPCount = *(int (**)(void *))(*(uintptr_t *) g_ISteamNetworkingUtils + 37);
static auto GetPOPList = *(int (**)(void *, SteamNetworkingPOPID_decl *, int))(*(uintptr_t *) g_ISteamNetworkingUtils + 41);
static CatCommand print("dc_print", "Print codes of all available data centers",
[]()
{
static auto GetPOPCount = *(int (**)(void *))(*(uintptr_t *) g_ISteamNetworkingUtils + 37);
static auto GetPOPList = *(int (**)(void *, SteamNetworkingPOPID_decl *, int))(*(uintptr_t *) g_ISteamNetworkingUtils + 41);
char region[5];
char region[5];
int count = GetPOPCount(g_ISteamNetworkingUtils);
if (count <= 0)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "List of regions is not available yet\n");
return;
}
SteamNetworkingPOPID_decl *list = new SteamNetworkingPOPID_decl[count];
GetPOPList(g_ISteamNetworkingUtils, list, count);
int count = GetPOPCount(g_ISteamNetworkingUtils);
if (count <= 0)
{
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "List of regions is not available yet\n");
return;
}
SteamNetworkingPOPID_decl *list = new SteamNetworkingPOPID_decl[count];
GetPOPList(g_ISteamNetworkingUtils, list, count);
auto it = list;
while (count--)
{
(it++)->ToString(region);
std::string region_name = dc_name_map[region];
if (region_name == "")
region_name = "Not set";
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "%s [%s]\n", region_name.c_str(), region);
}
delete[] list;
});
auto it = list;
while (count--)
{
(it++)->ToString(region);
std::string region_name = dc_name_map[region];
if (region_name == "")
region_name = "Not set";
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "%s [%s]\n", region_name.c_str(), region);
}
delete[] list;
});
static void Refresh()
{
@ -220,20 +222,20 @@ void manageRegions(std::vector<std::string> regions_vec, bool add)
static void Init()
{
enable.installChangeCallback([](settings::VariableBase<bool> &, bool on) {
static auto create_interface = (void **(*) (unsigned *) ) e8call_direct(gSignatures.GetClientSignature("E8 ? ? ? ? 83 38 00"));
static auto parameter = *(uintptr_t *) (gSignatures.GetClientSignature("C7 04 24 ? ? ? ? E8 ? ? ? ? 8B 00 8B 10 C7 44 24 ? 00 00 00 00") + 3);
if (!g_ISteamNetworkingUtils)
enable.installChangeCallback(
[](settings::VariableBase<bool> &, bool on)
{
g_ISteamNetworkingUtils = *create_interface((unsigned *) parameter);
if (!g_ISteamNetworkingUtils)
{
logging::Info("DataCenter.cpp: Failed to create ISteamNetworkingUtils!");
return;
g_ISteamNetworkingUtils = ((void *(*) ())(dlsym(sharedobj::steamnetworkingsockets().lmap, "SteamNetworkingUtils_LibV4")))();
if (!g_ISteamNetworkingUtils)
{
logging::Info("DataCenter.cpp: Failed to create ISteamNetworkingUtils!");
return;
}
}
}
Hook(on);
});
Hook(on);
});
regions.installChangeCallback([](settings::VariableBase<std::string> &, std::string regions) { OnRegionsUpdate(regions); });
restrict.installChangeCallback([](settings::VariableBase<bool> &, bool) { Refresh(); });
enable_eu.installChangeCallback([](settings::VariableBase<bool> &, bool after) { manageRegions(eu_datacenters, after); });

View File

@ -1,60 +0,0 @@
#include "common.hpp"
#include "SteamIDStealer.hpp"
namespace hacks::tf2::steamidstealer
{
static settings::String steamid_to_use("steamidstealer.steamid", "");
std::optional<IDStorage> stored;
std::optional<IDStorage> GetSteamID()
{
return stored;
}
void SetSteamID(std::optional<IDStorage> steamid)
{
stored = steamid;
}
void SendNetMessage(INetMessage &msg)
{
// Client connection packet, modify steamid
if (msg.GetType() == clc_ClientInfo)
{
uintptr_t *steamid = (uintptr_t *) (((uintptr_t) &msg) + 0x20);
char *name = (char *) (((uintptr_t) &msg) + 0x24);
unsigned desired_steamid = 0;
std::string desired_name = "";
// Override if selected
if (*steamid_to_use != "")
{
try
{
desired_steamid = std::stoul(*steamid_to_use);
}
catch (std::invalid_argument)
{
logging::Info("Bad Steamid provided!");
}
}
else
{
// No steamid stored, return
if (!stored)
return;
else
{
desired_steamid = stored->steamid;
desired_name = stored->name;
}
}
logging::Info("Changing SteamID from %u to %u", *steamid, desired_steamid);
*steamid = desired_steamid;
// Update name too if desired
if (desired_name != "")
strncpy(name, desired_name.c_str(), std::min(32, (int) desired_name.length()));
}
}
} // namespace hacks::tf2::steamidstealer

View File

@ -6,7 +6,6 @@
#include <settings/String.hpp>
#include "HookedMethods.hpp"
#include "PlayerTools.hpp"
#include "SteamIDStealer.hpp"
static settings::String ipc_name{ "name.ipc", "" };
settings::String force_name{ "name.custom", "" };
@ -14,7 +13,6 @@ std::string name_forced = "";
static settings::Int namesteal{ "name.namesteal", "0" };
static settings::Boolean namesteal_reconnect("name.namesteal.reconnect", "true");
static settings::Boolean glitchy_newlines("name.namesteal.use-newlines", "false");
static settings::Boolean use_steamidzero("name.namesteal.steamid-zero", "false");
static std::string stolen_name;
static unsigned stolen_target;
@ -95,7 +93,6 @@ bool StolenName()
// If our name is the same as current, than change it and return true
stolen_name = std::string(info.name);
stolen_target = info.friendsID;
hacks::tf2::steamidstealer::SetSteamID(hacks::tf2::steamidstealer::IDStorage(use_steamidzero ? 0 : stolen_target, "namestealer"));
return true;
}
@ -199,11 +196,6 @@ static InitRoutine init(
ch->SendNetMsg(setname, false);
}
}
// Reset steamid stealer
else
{
hacks::tf2::steamidstealer::SetSteamID(std::nullopt);
}
});
});
static Timer set_name{};

View File

@ -13,7 +13,6 @@
#include "Warp.hpp"
#include "nospread.hpp"
#include "AntiCheatBypass.hpp"
#include "SteamIDStealer.hpp"
static settings::Int newlines_msg{ "chat.prefix-newlines", "0" };
static settings::Boolean log_sent{ "debug.log-sent-chat", "false" };
@ -30,10 +29,19 @@ void SendNetMsg(INetMessage &msg);
namespace hooked_methods
{
static bool send_drawline_reply{};
static Timer reply_timer{};
static bool send_achievement_reply{};
static Timer send_achievement_reply_timer{};
void sendDrawlineKv(float x_value, float y_value)
// Welcome back Achievement based identify.
void sendAchievementKv(int value)
{
KeyValues *kv = new KeyValues("AchievementEarned");
kv->SetInt("achievementID", value);
g_IEngine->ServerCmdKeyValues(kv);
}
// Goodbye old Friend.
/*void sendDrawlineKv(float x_value, float y_value)
{
KeyValues *kv = new KeyValues("cl_drawline");
kv->SetInt("panel", 2);
@ -41,11 +49,12 @@ void sendDrawlineKv(float x_value, float y_value)
kv->SetFloat("x", x_value);
kv->SetFloat("y", y_value);
g_IEngine->ServerCmdKeyValues(kv);
}
}*/
void sendIdentifyMessage(bool reply)
{
reply ? sendDrawlineKv(CAT_REPLY, AUTH_MESSAGE) : sendDrawlineKv(CAT_IDENTIFY, AUTH_MESSAGE);
reply ? sendAchievementKv(CAT_REPLY) : sendAchievementKv(CAT_IDENTIFY);
/*reply ? sendDrawlineKv(CAT_REPLY, AUTH_MESSAGE) : sendDrawlineKv(CAT_IDENTIFY, AUTH_MESSAGE);*/
}
static CatCommand debug_drawpanel("debug_drawline", "debug",
@ -68,7 +77,7 @@ settings::Boolean identify{ "chat.identify", "true" };
settings::Boolean identify{ "chat.identify", "false" };
#endif
void ProcessSendline(IGameEvent *kv)
/*void ProcessSendline(IGameEvent *kv)
{
int player_idx = kv->GetInt("player", 0xDEAD);
@ -90,7 +99,7 @@ void ProcessSendline(IGameEvent *kv)
if (playerlist::ChangeState(info.friendsID, playerlist::k_EState::CAT))
PrintChat("\x07%06X%s\x01 Marked as CAT (Cathook user)", 0xe05938, info.name);
}
}
}*/
std::vector<KeyValues *> Iterate(KeyValues *event, int depth)
{
@ -177,17 +186,37 @@ void ParseKeyValue(KeyValues *event)
}
}
class IdentifyListener : public IGameEventListener2
void ProcessAchievement(IGameEvent *ach)
{
int player_idx = ach->GetInt("player", 0xDEAD);
int achievement = ach->GetInt("achievement", 0xDEAD);
if (player_idx != 0xDEAD && (achievement == CAT_IDENTIFY || achievement == CAT_REPLY))
{
// Always reply and set on CA7 and only set on CA8
bool reply = achievement == CAT_IDENTIFY;
player_info_s info;
if (!g_IEngine->GetPlayerInfo(player_idx, &info))
return;
if (reply && *answerIdentify /* && player_idx != g_pLocalPlayer->entity_idx*/)
{
send_achievement_reply_timer.update();
send_achievement_reply = true;
}
if (playerlist::ChangeState(info.friendsID, playerlist::k_EState::CAT))
PrintChat("\x07%06X%s\x01 Marked as CAT (Cathook user)", 0xe05938, info.name);
}
}
class AchievementListener : public IGameEventListener2
{
virtual void FireGameEvent(IGameEvent *event)
{
ProcessSendline(event);
ProcessAchievement(event);
}
}; // namespace hooked_methods
};
static CatCommand send_identify("debug_send_identify", "debug", []() { sendIdentifyMessage(false); });
static IdentifyListener event_listener{};
static AchievementListener event_listener{};
static InitRoutine run_identify(
[]()
@ -196,10 +225,10 @@ static InitRoutine run_identify(
EC::CreateMove,
[]()
{
if (send_drawline_reply && reply_timer.test_and_set(1000))
if (send_achievement_reply && send_achievement_reply_timer.check(10000))
{
sendIdentifyMessage(true);
send_drawline_reply = false;
send_achievement_reply = false;
}
// It is safe to send every 15ish seconds, small packet
if (!*identify || CE_BAD(LOCAL_E) || !identify_timer.test_and_set(15000))
@ -207,7 +236,7 @@ static InitRoutine run_identify(
sendIdentifyMessage(false);
},
"sendnetmsg_createmove");
g_IEventManager2->AddListener(&event_listener, "cl_drawline", false);
g_IEventManager2->AddListener(&event_listener, "achievement_earned", false);
EC::Register(
EC::Shutdown, []() { g_IEventManager2->RemoveListener(&event_listener); }, "shutdown_event");
});
@ -221,7 +250,6 @@ DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &msg, boo
std::string newlines{};
NET_StringCmd stringcmd;
hacks::tf2::steamidstealer::SendNetMessage(msg);
// Do we have to force reliable state?
if (hacks::tf2::nospread::SendNetMessage(&msg))
force_reliable = true;