Implemented #20 into hack.hpp now featuring a better entity loop and fixing known bugs while cleaning the code.
Added simple config system to enable team esp, automatic updates, and render distance. Also moved the offsets to the updater namespace and read/writte methods to the offsets.json Implemented Handle Hijacking method requested by #19 to improve the security. Credits to Apxaey on github for the source
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
namespace updater {
|
||||
bool check_and_update(bool prompt_update) {
|
||||
bool check_and_update(bool automatic_update) {
|
||||
json commit;
|
||||
if (!get_last_commit_date(commit)) {
|
||||
std::cout << "[updater] error getting last commit information from GitHub" << std::endl;
|
||||
@@ -30,30 +30,38 @@ namespace updater {
|
||||
// Check if the local file is older than the last GitHub commit
|
||||
if (lastModifiedClockTime < commitTimePoint) {
|
||||
std::cout << "[updater] Local file is older than the last GitHub commit." << std::endl;
|
||||
if (prompt_update) {
|
||||
|
||||
char response;
|
||||
if (!automatic_update) {
|
||||
std::cout << "[updater] Do you want to download the latest offsets? (y/n): ";
|
||||
char response;
|
||||
std::cin >> response;
|
||||
if (response == 'Y' || response == 'y') {
|
||||
if (download_file(raw_updated_offets.c_str(), "offsets.json")) {
|
||||
std::cout << "[updater] Successfully downloaded latest offsets.json file\n" << std::endl;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
std::cout << "[updater] Error: Failed to download file, try downloading manually from " << raw_updated_offets << "\n" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (automatic_update || (response == 'Y' || response == 'y')) {
|
||||
if (download_file(raw_updated_offets.c_str(), "offsets.json")) {
|
||||
std::cout << "[updater] Successfully downloaded latest offsets.json file\n" << std::endl;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
std::cout << "[updater] Error: Failed to download file, try downloading manually from " << raw_updated_offets << "\n" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
std::cout << "[updater] Local file is up to date.\n" << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "[updater] Do you want to download the latest offsets? (y/n): ";
|
||||
|
||||
|
||||
char response;
|
||||
std::cin >> response;
|
||||
if (response == 'Y' || response == 'y') {
|
||||
if (!automatic_update) {
|
||||
std::cout << "[updater] Do you want to download the latest offsets? (y/n): ";
|
||||
std::cin >> response;
|
||||
}
|
||||
|
||||
if (automatic_update || (response == 'Y' || response == 'y')) {
|
||||
if (download_file(raw_updated_offets.c_str(), "offsets.json")) {
|
||||
std::cout << "[updater] Successfully downloaded latest offsets.json file\n" << std::endl;
|
||||
return true;
|
||||
@@ -156,4 +164,62 @@ namespace updater {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool read() {
|
||||
if (!updater::file_good(file_path)) {
|
||||
save();
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream f(file_path);
|
||||
|
||||
json data;
|
||||
try {
|
||||
data = json::parse(f);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
save();
|
||||
}
|
||||
|
||||
if (data.empty())
|
||||
return false;
|
||||
|
||||
if (data["dwLocalPlayer"].is_number())
|
||||
offsets::dwLocalPlayer = data["dwLocalPlayer"];
|
||||
if (data["dwEntityList"].is_number())
|
||||
offsets::dwEntityList = data["dwEntityList"];
|
||||
if (data["dwViewMatrix"].is_number())
|
||||
offsets::dwViewMatrix = data["dwViewMatrix"];
|
||||
|
||||
if (data["dwPawnHealth"].is_number())
|
||||
offsets::dwPawnHealth = data["dwPawnHealth"];
|
||||
if (data["dwPlayerPawn"].is_number())
|
||||
offsets::dwPlayerPawn = data["dwPlayerPawn"];
|
||||
if (data["dwSanitizedName"].is_number())
|
||||
offsets::dwSanitizedName = data["dwSanitizedName"];
|
||||
if (data["m_iTeamNum"].is_number())
|
||||
offsets::m_iTeamNum = data["m_iTeamNum"];
|
||||
if (data["m_vecOrigin"].is_number())
|
||||
offsets::m_vecOrigin = data["m_vecOrigin"];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void save() {
|
||||
json data;
|
||||
|
||||
data["dwLocalPlayer"] = offsets::dwLocalPlayer;
|
||||
data["dwEntityList"] = offsets::dwEntityList;
|
||||
data["dwViewMatrix"] = offsets::dwViewMatrix;
|
||||
|
||||
data["dwPawnHealth"] = offsets::dwPawnHealth;
|
||||
data["dwPlayerPawn"] = offsets::dwPlayerPawn;
|
||||
data["dwSanitizedName"] = offsets::dwSanitizedName;
|
||||
data["m_iTeamNum"] = offsets::m_iTeamNum;
|
||||
data["m_vecOrigin"] = offsets::m_vecOrigin;
|
||||
|
||||
std::ofstream output(file_path);
|
||||
output << std::setw(4) << data << std::endl;
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,28 @@ namespace fs = std::filesystem;
|
||||
|
||||
|
||||
namespace updater {
|
||||
const std::string file_path = "offsets.json";
|
||||
|
||||
bool check_and_update(bool prompt_update);
|
||||
bool get_last_commit_date(json& commit);
|
||||
bool download_file(const char* url, const char* localPath);
|
||||
bool file_good(const std::string& name);
|
||||
|
||||
extern bool read();
|
||||
extern void save();
|
||||
|
||||
inline std::string github_repo_api = "https://api.github.com/repos/IMXNOOBX/cs2-external-esp/commits";
|
||||
inline std::string raw_updated_offets = "https://github.com/IMXNOOBX/cs2-external-esp/raw/main/offsets/offsets.json";
|
||||
|
||||
namespace offsets {
|
||||
inline std::ptrdiff_t dwLocalPlayer = 0x187AC28;
|
||||
inline std::ptrdiff_t dwEntityList = 0x178D8C8;
|
||||
inline std::ptrdiff_t dwViewMatrix = 0x187B710;
|
||||
|
||||
inline std::ptrdiff_t dwPawnHealth = 0x808;
|
||||
inline std::ptrdiff_t dwPlayerPawn = 0x7FC;
|
||||
inline std::ptrdiff_t dwSanitizedName = 0x720;
|
||||
inline std::ptrdiff_t m_iTeamNum = 0x3bf;
|
||||
inline std::ptrdiff_t m_vecOrigin = 0x1204;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
#include "config.hpp"
|
||||
|
||||
namespace config {
|
||||
using json = nlohmann::json;
|
||||
const std::string file_path = "offsets.json";
|
||||
|
||||
bool read() {
|
||||
if (!updater::file_good(file_path)) {
|
||||
save();
|
||||
@@ -23,23 +20,12 @@ namespace config {
|
||||
if (data.empty())
|
||||
return false;
|
||||
|
||||
if (data["dwLocalPlayer"].is_number())
|
||||
dwLocalPlayer = data["dwLocalPlayer"];
|
||||
if (data["dwEntityList"].is_number())
|
||||
dwEntityList = data["dwEntityList"];
|
||||
if (data["dwViewMatrix"].is_number())
|
||||
dwViewMatrix = data["dwViewMatrix"];
|
||||
|
||||
if (data["dwPawnHealth"].is_number())
|
||||
dwPawnHealth = data["dwPawnHealth"];
|
||||
if (data["dwPlayerPawn"].is_number())
|
||||
dwPlayerPawn = data["dwPlayerPawn"];
|
||||
if (data["dwSanitizedName"].is_number())
|
||||
dwSanitizedName = data["dwSanitizedName"];
|
||||
if (data["m_iTeamNum"].is_number())
|
||||
m_iTeamNum = data["m_iTeamNum"];
|
||||
if (data["m_vecOrigin"].is_number())
|
||||
m_vecOrigin = data["m_vecOrigin"];
|
||||
if (data["team_esp"].is_boolean())
|
||||
team_esp = data["team_esp"];
|
||||
if (data["automatic_update"].is_boolean())
|
||||
automatic_update = data["automatic_update"];
|
||||
if (data["render_distance"].is_number())
|
||||
render_distance = data["render_distance"];
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -47,16 +33,11 @@ namespace config {
|
||||
void save() {
|
||||
json data;
|
||||
|
||||
data["dwLocalPlayer"] = dwLocalPlayer;
|
||||
data["dwEntityList"] = dwEntityList;
|
||||
data["dwViewMatrix"] = dwViewMatrix;
|
||||
|
||||
data["dwPawnHealth"] = dwPawnHealth;
|
||||
data["dwPlayerPawn"] = dwPlayerPawn;
|
||||
data["dwSanitizedName"] = dwSanitizedName;
|
||||
data["m_iTeamNum"] = m_iTeamNum;
|
||||
data["m_vecOrigin"] = m_vecOrigin;
|
||||
data["team_esp"] = team_esp;
|
||||
data["automatic_update"] = automatic_update;
|
||||
data["render_distance"] = render_distance;
|
||||
|
||||
|
||||
std::ofstream output(file_path);
|
||||
output << std::setw(4) << data << std::endl;
|
||||
output.close();
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
#include "json.hpp"
|
||||
#include "auto_updater.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace config {
|
||||
const std::string file_path = "config.json";
|
||||
|
||||
extern bool read();
|
||||
extern void save();
|
||||
|
||||
inline std::ptrdiff_t dwLocalPlayer = 0x17DB108;
|
||||
inline std::ptrdiff_t dwEntityList = 0x178C888;
|
||||
inline std::ptrdiff_t dwViewMatrix = 0x187A6E0;
|
||||
|
||||
inline std::ptrdiff_t dwPawnHealth = 0x808;
|
||||
inline std::ptrdiff_t dwPlayerPawn = 0x7FC;
|
||||
inline std::ptrdiff_t dwSanitizedName = 0x720;
|
||||
inline std::ptrdiff_t m_iTeamNum = 0x3bf;
|
||||
inline std::ptrdiff_t m_vecOrigin = 0x1204;
|
||||
inline bool automatic_update = false;
|
||||
inline bool team_esp = false;
|
||||
inline float render_distance = -1.f;
|
||||
}
|
||||
Reference in New Issue
Block a user