Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Implemented async cheat loading & minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumaus committed Mar 6, 2021
1 parent 52b0f66 commit 3d611aa
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 68 deletions.
56 changes: 11 additions & 45 deletions Le_Chiffre/Le_Chiffre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "misc/utils.hpp"
#include "misc/config.hpp"
#include "misc/xor.hpp"
// #include "sig_scanner.hpp"
#include "sig_scanner.hpp"
// #include <cstddef>
// #include "overlay/overlay.hpp"

Expand All @@ -22,23 +22,6 @@ struct hacks_coords {
COORD no_flash, activate_trigger, use_trigger, /*team_wh,*/ enemy_wh, radar_hack, bunny_hop, aimbot, process, game, version;
};

typedef struct Params {
ConsoleIO* io;
COORD coords;
} PRINT_PARAMS;

DWORD WINAPI print_version_status(LPVOID lpParam) {
PRINT_PARAMS* params = (PRINT_PARAMS*)lpParam;
std::pair<bool, bool> latest = is_latest();

(params->io)->set_cursor_position(params->coords);
if (latest.first) (params->io)->write_str("ERROR", FOREGROUND_RED);
else if (latest.second) (params->io)->write_str("LATEST", FOREGROUND_GREEN);
else (params->io)->write_str("OUTDATED", FOREGROUND_GREEN | FOREGROUND_RED);

return 0;
}

struct hacks_state {
bool no_flash = false;
bool activate_trigger = false;
Expand All @@ -50,16 +33,11 @@ struct hacks_state {
bool aimbot = false;
};

int main() {
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
srand((unsigned int)time(NULL));
ConsoleIO io;
cout << XorStr("Loading...");
std::pair<bool, bool> latest = is_latest();

AntiAC ac;
srand((unsigned int)time(NULL));

Memory mem;

Client client(&mem);
Hacks hacks(&mem, &client);
// Overlay ol(&mem);
Expand All @@ -78,16 +56,15 @@ int main() {
char* no = XorStr("NO");

cout << std::string(10, '\b');

/*SigScanner ss(mem.tProcess);
::std::ptrdiff_t dwEntityList = (intptr_t)ss.find("55 8B EC 51 53 8A 5D 08", mem.clientBaseAddr, mem.clientSize);
cout << "dwEntityList " << dwEntityList << endl; */
char* dwEntityList = ss.find("55 8B EC 51 53 8A 5D 08", (char*)mem.clientBaseAddr, mem.clientSize);
for (int i = 0; i < strlen(dwEntityList); ++i) cout << dwEntityList[i];
cout << endl;*/

cout << XorStr("Le Chiffre ") << CHEAT_VERSION << XorStr(" [3 Mar, 2021]") << endl << endl;
cout << XorStr("Le Chiffre ") << CHEAT_VERSION << XorStr(" [6 Mar, 2021]") << endl << endl;
cout << XorStr("The official website: https://lechiffre.now.sh") << endl;
cout << XorStr("Support the developer: https://donationalerts.com/r/fuckblm") << endl << endl;

// TODO: Refactor
cout << XorStr("State:");
cout << XorStr("\n Connected to CS:GO process: ");
coords.process = io.get_cursor_position();
Expand All @@ -99,10 +76,10 @@ int main() {

cout << XorStr("\n Version: ");
coords.version = io.get_cursor_position();
// io.write_str("LOADING", FOREGROUND_GREEN | FOREGROUND_RED);
if (latest.first) io.write_str(XorStr("ERROR"), FOREGROUND_RED);
else if (latest.second) io.write_str(XorStr("LATEST"), FOREGROUND_GREEN);
else io.write_str(XorStr("OUTDATED"), FOREGROUND_GREEN | FOREGROUND_RED);
io.write_str("LOADING", FOREGROUND_GREEN | FOREGROUND_RED);

std::thread print_ver(print_version_status, &io, coords.version);
print_ver.detach();

cout << XorStr("\n\nCheat functions:");
cout << XorStr("\n Bunny hop (F2): ");
Expand Down Expand Up @@ -139,20 +116,9 @@ int main() {

cout << XorStr("\n Panic mode (END): ");
io.write_str(XorStr("PRESS"), FOREGROUND_GREEN | FOREGROUND_RED);

// TODO: Fix.
// Printing cheat version status asynchronously
/* PRINT_PARAMS pd = {};
pd.io = &io;
pd.coords = coords.version;
HANDLE print_ver = CreateThread(NULL, NULL, print_version_status, &pd, NULL, NULL); */

while (true) {
ac.check_for_debug();

while (mem.tProcess != NULL && mem.clientBaseAddr != NULL && mem.engineBaseAddr != NULL) {
ac.check_for_debug();

if (!pHandle) {
pHandle = true;
io.set_cursor_position(coords.process);
Expand Down
4 changes: 2 additions & 2 deletions Le_Chiffre/Le_Chiffre.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AssemblyDebug>false</AssemblyDebug>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
Expand Down Expand Up @@ -161,7 +161,7 @@
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
Expand Down
18 changes: 16 additions & 2 deletions Le_Chiffre/hacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class Hacks {

int target_team = target.get_team();

if (player_team == target_team && glow_on_teammate) _regular_glow(&target, glow_obj);
else if (player_team != target_team && glow_on_enemy) _enemy_glow(&target, glow_obj);
// if (player_team == target_team && glow_on_teammate) _regular_glow(&target, glow_obj);
if (player_team != target_team && glow_on_enemy) _enemy_glow(&target, glow_obj);

if (player_team != target_team && radar_hack && !target.is_spotted()) target.set_spotted(true);
}
Expand All @@ -153,6 +153,20 @@ class Hacks {
Sleep(5);
}

/* void get_spectators() {
int player_team = player.get_team();
for (short i = 0; i < 32; ++i) {
PlayerEntity target(memory, memory->read_mem<DWORD>(memory->clientBaseAddr + signatures::dwEntityList + (short)0x10 * i));
if (target.valid_player()) {
int target_team = target.get_team();
if (player_team != target_team) continue;
}
}
} */

void aim_bot() {
PlayerEntity target = _get_closest_enemy();

Expand Down
4 changes: 2 additions & 2 deletions Le_Chiffre/misc/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "xor.hpp"

namespace {
const ::std::string CHEAT_VERSION = XorStr("v1.1.6");
const ::std::string CHEAT_VERSION = XorStr("v1.1.7");
const wchar_t* HOST = L"api.github.com";
const wchar_t* PATH = L"/repos/blaumaus/le_chiffre/tags?per_page=1";
const wchar_t* TARGET = L"csgo.exe";
const wchar_t* CLIENT_DLL = L"client.dll";
const wchar_t* ENGINE_DLL = L"engine.dll";
LPCSTR WINDOW_NAME = XorStr("Counter-Strike: Global Offensive");
LPCSTR WINDOW_NAME = "Counter-Strike: Global Offensive";

struct coords_vector {
float x, y, z;
Expand Down
19 changes: 12 additions & 7 deletions Le_Chiffre/misc/console_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class ConsoleIO {
private:
HWND console_window;
HANDLE screen_buffer;
short screen_width;
short screen_height;
const short screen_width = 62;
const short screen_height = 19;
FILE* fp;

// adjusts window to desired width and height
void _set_window() { // https://stackoverflow.com/a/40634467
Expand All @@ -19,10 +20,10 @@ class ConsoleIO {
SMALL_RECT const minimal_window = { 0, 0, 1, 1 }; // to get rid of scroll bars
SetConsoleWindowInfo(screen_buffer, TRUE, &minimal_window);

SetConsoleScreenBufferSize(screen_buffer, size);

SMALL_RECT const window = { 0, 0, size.X - 1, size.Y - 1 };
SetConsoleWindowInfo(screen_buffer, TRUE, &window);

SetConsoleScreenBufferSize(screen_buffer, size);
}

void _set_cursor() {
Expand All @@ -32,14 +33,18 @@ class ConsoleIO {

public:
ConsoleIO() {
console_window = GetConsoleWindow();
AllocConsole();
screen_buffer = GetStdHandle(STD_OUTPUT_HANDLE);
screen_width = 62;
screen_height = 20;
console_window = GetConsoleWindow();

SetWindowLong(console_window, GWL_STYLE, GetWindowLong(console_window, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX);
_set_window();
_set_cursor();
freopen_s(&fp, "CONOUT$", "w", stdout);
}

~ConsoleIO() {
fclose(fp);
}

void write_str(const char* str, WORD colour, bool clear_right = true) {
Expand Down
10 changes: 10 additions & 0 deletions Le_Chiffre/misc/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once
#include "config.hpp"
#include "web_utils.hpp"
#include "console_io.hpp"
#include <iostream>

// Manually gets the value of a key from a JSON string
Expand Down Expand Up @@ -43,4 +44,13 @@ std::pair<bool, bool> is_latest() {
if (ver == "ERROR") return std::make_pair(true, false);
return std::make_pair(false, ver == CHEAT_VERSION);
}

void print_version_status(ConsoleIO* io, COORD coords) {
std::pair<bool, bool> latest = is_latest();

io->set_cursor_position(coords);
if (latest.first) io->write_str(XorStr("ERROR"), FOREGROUND_RED);
else if (latest.second) io->write_str(XorStr("LATEST"), FOREGROUND_GREEN);
else io->write_str(XorStr("OUTDATED"), FOREGROUND_GREEN | FOREGROUND_RED);
}
#endif // !UTILS_HPP
2 changes: 1 addition & 1 deletion Le_Chiffre/overlay/overlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Overlay {
if (!GetWindowRect(mem->tHWND, &rect)) return false;
// std::cout << "x: [" << rect.left << ", " << rect.top << "]; y: [" << rect.right << ", " << rect.bottom << "]" << std::endl;
_register_ñlass();

if (!_init_instance(rect.right - rect.left, rect.bottom - rect.top)) return false;
paint = Paint(hwnd, mem->tHWND, rect.right - rect.left, rect.bottom - rect.top);

Expand Down
18 changes: 9 additions & 9 deletions Le_Chiffre/sig_scanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class SigScanner {
return 0;
}

BYTE* _find_signature(char* pattern, char* mask, BYTE* begin, intptr_t size) {
BYTE* match { nullptr };
char* _find_signature(char* pattern, char* mask, char* begin, intptr_t size) {
char* match { nullptr };
SIZE_T bytesRead;
DWORD oldprotect;
char* buffer{ nullptr };
Expand All @@ -39,7 +39,7 @@ class SigScanner {

VirtualQueryEx(process, (LPCVOID)begin, &mbi, sizeof(mbi));

for (BYTE* current = begin; current < begin + size; current += mbi.RegionSize) {
for (char* current = begin; current < begin + size; current += mbi.RegionSize) {
if (!VirtualQueryEx(process, (LPCVOID)current, &mbi, sizeof(mbi))) continue;
if (mbi.State != MEM_COMMIT || mbi.Protect == PAGE_NOACCESS) continue;

Expand Down Expand Up @@ -72,21 +72,21 @@ class SigScanner {
this->process = process;
}

BYTE* find (const char* signature, BYTE* begin, intptr_t size) {
char* find (const char* signature, char* begin, intptr_t size) {
char pattern[50];
char mask[50];
char lastChar = ' ';
char last_char = ' ';
unsigned int j = 0;

for (unsigned int i = 0; i < strlen(signature); ++i, ++j) {
if ((signature[i] == '?' || signature[i] == '*') && (lastChar != '?' && lastChar != '*')) {
if ((signature[i] == '?' || signature[i] == '*') && (last_char != '?' && last_char != '*')) {
pattern[j] = mask[j] = '?';
} else if (isspace(lastChar)) {
pattern[j] = lastChar = (char)strtol(&signature[i], 0, 16);
} else if (isspace(last_char)) {
pattern[j] = last_char = (char)strtol(&signature[i], 0, 16);
mask[j] = 'x';
}

lastChar = signature[i];
last_char = signature[i];
}
pattern[j] = mask[j] = '\0';

Expand Down

1 comment on commit 3d611aa

@vercel
Copy link

@vercel vercel bot commented on 3d611aa Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.