aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorauth12 <[email protected]>2020-08-05 03:17:00 +0100
committerauth12 <[email protected]>2020-08-05 03:17:00 +0100
commit6b11856dbd89628ab198820c7dd1f117077a5420 (patch)
treed34ddff8f3658956b5c435a33c2829208ab2fc4f
parentAdded ui. (diff)
downloadloader-6b11856dbd89628ab198820c7dd1f117077a5420.tar.xz
loader-6b11856dbd89628ab198820c7dd1f117077a5420.zip
More ui improvements.
Under the hood improvements.
-rw-r--r--client/client.vcxproj8
-rw-r--r--client/client.vcxproj.filters6
-rw-r--r--client/src/client/client.h11
-rw-r--r--client/src/client/packet.h7
-rw-r--r--client/src/hwid/hwid.h38
-rw-r--r--client/src/injection/mapper.cpp21
-rw-r--r--client/src/injection/pe.h5
-rw-r--r--client/src/injection/process.cpp2
-rw-r--r--client/src/main.cpp203
-rw-r--r--client/src/security/security.cpp36
-rw-r--r--client/src/security/security.h2
-rw-r--r--client/src/ui/imgui/imgui_stdlib.cpp76
-rw-r--r--client/src/ui/imgui/imgui_stdlib.h22
-rw-r--r--client/src/ui/ui.cpp23
-rw-r--r--client/src/ui/ui.h4
-rw-r--r--client/src/util/io.cpp2
-rw-r--r--client/src/util/io.h6
-rw-r--r--client/src/util/native.h9
-rw-r--r--server/src/main.cpp4
-rw-r--r--server/src/server/server.cpp2
20 files changed, 347 insertions, 140 deletions
diff --git a/client/client.vcxproj b/client/client.vcxproj
index 9d82bee..cd28e6d 100644
--- a/client/client.vcxproj
+++ b/client/client.vcxproj
@@ -135,9 +135,9 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>$(DXSDK_DIR)include\;$(SolutionDir);$(SolutionDir)wolfssl;$(SolutionDir)..\shared;$(SolutionDir)..\shared\spdlog\include;$(IncludePath)</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ExceptionHandling>Sync</ExceptionHandling>
- <Optimization>MaxSpeed</Optimization>
+ <Optimization>Full</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -148,6 +148,8 @@
<AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64\;$(SolutionDir)lib\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ <SectionAlignment>
+ </SectionAlignment>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -165,6 +167,7 @@
<ClInclude Include="src\ui\imgui\imgui_impl_dx11.h" />
<ClInclude Include="src\ui\imgui\imgui_impl_win32.h" />
<ClInclude Include="src\ui\imgui\imgui_internal.h" />
+ <ClInclude Include="src\ui\imgui\imgui_stdlib.h" />
<ClInclude Include="src\ui\imgui\imstb_rectpack.h" />
<ClInclude Include="src\ui\imgui\imstb_textedit.h" />
<ClInclude Include="src\ui\imgui\imstb_truetype.h" />
@@ -186,6 +189,7 @@
<ClCompile Include="src\ui\imgui\imgui_draw.cpp" />
<ClCompile Include="src\ui\imgui\imgui_impl_dx11.cpp" />
<ClCompile Include="src\ui\imgui\imgui_impl_win32.cpp" />
+ <ClCompile Include="src\ui\imgui\imgui_stdlib.cpp" />
<ClCompile Include="src\ui\imgui\imgui_widgets.cpp" />
<ClCompile Include="src\ui\ui.cpp" />
<ClCompile Include="src\util\apiset.cpp" />
diff --git a/client/client.vcxproj.filters b/client/client.vcxproj.filters
index 9a17701..9689b6f 100644
--- a/client/client.vcxproj.filters
+++ b/client/client.vcxproj.filters
@@ -111,6 +111,9 @@
<ClInclude Include="src\ui\imgui\imstb_truetype.h">
<Filter>src\ui\imgui</Filter>
</ClInclude>
+ <ClInclude Include="src\ui\imgui\imgui_stdlib.h">
+ <Filter>src\ui\imgui</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cpp">
@@ -158,5 +161,8 @@
<ClCompile Include="src\ui\imgui\imgui_widgets.cpp">
<Filter>src\ui\imgui</Filter>
</ClCompile>
+ <ClCompile Include="src\ui\imgui\imgui_stdlib.cpp">
+ <Filter>src\ui\imgui</Filter>
+ </ClCompile>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/client/src/client/client.h b/client/src/client/client.h
index a7dedc6..372affc 100644
--- a/client/src/client/client.h
+++ b/client/src/client/client.h
@@ -24,7 +24,7 @@ struct game_data_t {
namespace tcp {
enum client_state {
- connecting = 0, idle, logged_in, waiting, imports_ready, image_ready, injected
+ connecting = 0, idle, logging_in, logged_in, imports_ready, waiting, image_ready, injected
};
enum login_result {
@@ -59,7 +59,7 @@ namespace tcp {
game_data_t selected_game;
std::string session_id;
- event<packet_t&> receive_event;
+ event<packet_t> receive_event;
event<> connect_event;
uint16_t ver = 4672;
@@ -115,10 +115,6 @@ namespace tcp {
}
static void monitor(client& client) {
- while (!client) {
- std::this_thread::sleep_for(std::chrono::microseconds(100));
- }
-
std::array<char, message_len> buf;
while (client) {
int ret = client.read(&buf[0], buf.size());
@@ -132,9 +128,8 @@ namespace tcp {
break;
}
std::string msg(buf.data(), ret);
- packet_t packet(msg, packet_type::read);
- client.receive_event.call(packet);
+ client.receive_event.call(packet_t{msg, packet_type::read});
}
}
};
diff --git a/client/src/client/packet.h b/client/src/client/packet.h
index b185c81..fa119ef 100644
--- a/client/src/client/packet.h
+++ b/client/src/client/packet.h
@@ -23,7 +23,7 @@ namespace tcp {
struct packet_t {
uint8_t seq;
- uint8_t id;
+ uint8_t id;
std::string message;
std::string session_id;
@@ -50,6 +50,11 @@ namespace tcp {
json["message"] = msg.data();
message = json.dump();
+ if (message.size() > message_len) {
+ message.clear();
+ return;
+ }
+
session_id = session;
id = action;
diff --git a/client/src/hwid/hwid.h b/client/src/hwid/hwid.h
index 8fae489..445635d 100644
--- a/client/src/hwid/hwid.h
+++ b/client/src/hwid/hwid.h
@@ -1,10 +1,38 @@
#pragma once
-
+#include "../ui/ui.h"
namespace hwid {
- __forceinline std::string fetch() {
- nlohmann::json j;
- j["uid"] = 0;
- return j.dump();
+ struct hwid_data_t {
+ std::string gpu;
+
+ uint64_t uid;
+ };
+
+ __forceinline bool fetch(hwid_data_t& out) {
+ IDXGIDevice* dxgi_device;
+ if (ui::device->QueryInterface(&dxgi_device) != S_OK) {
+ return false;
+ }
+
+ IDXGIAdapter* adapter;
+ if (dxgi_device->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&adapter)) != S_OK) {
+ return false;
+ }
+
+ DXGI_ADAPTER_DESC desc;
+ if (adapter->GetDesc(&desc) != S_OK) {
+ return false;
+ }
+
+ out.uid += desc.VendorId >> 1;
+ out.uid += desc.DeviceId >> 1;
+ out.uid += desc.DedicatedVideoMemory << 5;
+
+ out.gpu = util::wide_to_multibyte(desc.Description);
+
+ adapter->Release();
+ dxgi_device->Release();
+
+ return true;
}
}; \ No newline at end of file
diff --git a/client/src/injection/mapper.cpp b/client/src/injection/mapper.cpp
index 732395d..4821350 100644
--- a/client/src/injection/mapper.cpp
+++ b/client/src/injection/mapper.cpp
@@ -5,10 +5,6 @@
#include "mapper.h"
void mmap::thread(tcp::client& client) {
- while (!client) {
- std::this_thread::sleep_for(std::chrono::microseconds(100));
- }
-
while (client) {
if (client.state != tcp::client_state::imports_ready) {
std::this_thread::sleep_for(std::chrono::seconds(5));
@@ -27,6 +23,8 @@ void mmap::thread(tcp::client& client) {
}
void mmap::map32(tcp::client& client) {
+ client.state = tcp::client_state::waiting;
+
std::vector<util::process_data_t> dat;
if (!util::fetch_processes(dat)) {
io::log_error("failed to fetch processes.");
@@ -39,6 +37,7 @@ void mmap::map32(tcp::client& client) {
});
io::log("waiting for {}.", client.selected_game.process_name);
+
while (needle == dat.end()) {
std::this_thread::sleep_for(std::chrono::seconds(5));
if (!client) {
@@ -89,7 +88,11 @@ void mmap::map32(tcp::client& client) {
for (auto& i : value) {
auto name = i.get<std::string>();
- final_imports[name] = proc.module_export(proc.map(key), name);
+ auto addr = proc.module_export(proc.map(key), name);
+
+ io::log("{}->{}->{:x}", key, name, addr);
+
+ final_imports[name] = addr;;
}
}
imports.clear();
@@ -157,6 +160,8 @@ void mmap::map32(tcp::client& client) {
}
void mmap::map64(tcp::client& client) {
+ client.state = tcp::client_state::waiting;
+
std::vector<util::process_data_t> dat;
if (!util::fetch_processes(dat)) {
io::log_error("failed to fetch processes.");
@@ -222,7 +227,11 @@ void mmap::map64(tcp::client& client) {
for (auto& i : value) {
auto name = i.get<std::string>();
- final_imports[name] = proc.module_export(proc.map(key), name);
+ auto addr = proc.module_export(proc.map(key), name);
+
+ io::log("{}->{}->{:x}", key, name, addr);
+
+ final_imports[name] = addr;
}
}
imports.clear();
diff --git a/client/src/injection/pe.h b/client/src/injection/pe.h
index fab41bb..6d2b655 100644
--- a/client/src/injection/pe.h
+++ b/client/src/injection/pe.h
@@ -79,6 +79,7 @@ namespace pe {
size_t v_size;
uint32_t rva;
uint32_t va;
+ uint32_t characteristics;
};
class virtual_image {
@@ -129,9 +130,9 @@ namespace pe {
for (size_t i = 0; i < n; i++) {
auto sec = secs[i];
-
+
auto name = reinterpret_cast<const char*>(sec.Name);
- m_sections.emplace_back(section_t{ name, sec.SizeOfRawData, sec.Misc.VirtualSize, sec.PointerToRawData, sec.VirtualAddress });
+ m_sections.emplace_back(section_t{ name, sec.SizeOfRawData, sec.Misc.VirtualSize, sec.PointerToRawData, sec.VirtualAddress, sec.Characteristics });
}
};
diff --git a/client/src/injection/process.cpp b/client/src/injection/process.cpp
index 3f3c96e..c37e131 100644
--- a/client/src/injection/process.cpp
+++ b/client/src/injection/process.cpp
@@ -332,7 +332,7 @@ uintptr_t util::process<T>::map(const std::string_view module_name) {
for (auto& func : funcs) {
auto addr = module_export(map(mod), func.name);
- //io::log("{}:{}->{:x}", mod, func.name, addr);
+ io::log("[mapper] {}->{}->{:x}", mod, func.name, addr);
*reinterpret_cast<T*>(&remote_image[func.rva]) = addr;
}
diff --git a/client/src/main.cpp b/client/src/main.cpp
index c5f3036..9c023e1 100644
--- a/client/src/main.cpp
+++ b/client/src/main.cpp
@@ -10,17 +10,10 @@
#include "security/security.h"
#include "ui/ui.h"
-
-bool init(tcp::client& client) {
- client.start("127.0.0.1", 6666);
-
- if (!client) {
- return false;
- }
-
+void add_handlers(tcp::client& client) {
client.connect_event.add([&]() { io::log("connected."); });
- client.receive_event.add([&](tcp::packet_t& packet) {
+ client.receive_event.add([&](tcp::packet_t packet) {
if (!packet) return;
auto message = packet();
auto id = packet.id;
@@ -46,9 +39,21 @@ bool init(tcp::client& client) {
return;
}
- auto hwid = hwid::fetch();
+ hwid::hwid_data_t data;
+ if (!hwid::fetch(data)) {
+ client.session_result = tcp::session_result::hwid_fail;
+
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+
+ client.shutdown();
+ return;
+ }
+
+ nlohmann::json json;
+ json["uid"] = data.uid;
+ json["gpu"] = data.gpu;
- int ret = client.write(tcp::packet_t(hwid, tcp::packet_type::write, client.session_id, tcp::packet_id::hwid));
+ int ret = client.write(tcp::packet_t(json.dump(), tcp::packet_type::write, client.session_id, tcp::packet_id::hwid));
if (ret <= 0) {
client.session_result = tcp::session_result::hwid_fail;
@@ -105,30 +110,37 @@ bool init(tcp::client& client) {
}
if (id == tcp::packet_id::ban) {
- io::log_error("your computer is blacklisted, please contact a developer.");
client.shutdown();
+
return;
}
io::log("{}:{}->{} {}", packet.seq, packet.session_id, message, id);
- });
+ });
}
int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
- AllocConsole();
-
FILE* fp = nullptr;
- freopen_s(&fp, "CONIN$", "r", stdin);
- freopen_s(&fp, "CONOUT$", "w", stdout);
- freopen_s(&fp, "CONOUT$", "w", stderr);
+ freopen_s(&fp, "log", "w", stdout);
g_syscalls.init();
tcp::client client;
- if (!init(client)) {
- MessageBoxA(0, "Server error.", "client", MB_OK);
+ client.start("127.0.0.1", 6666);
+ if (!client) {
+ MessageBoxA(0, "failed to connect to the the server..", "client", MB_OK);
+
+ return 0;
+ }
+
+ add_handlers(client);
+
+ auto hwnd = ui::create(inst, { 400, 300 });
+
+ if (!ui::create_device(hwnd)) {
+ MessageBoxA(0, "internal graphics error, please check your video drivers.", "client", MB_OK);
return 0;
}
@@ -142,17 +154,6 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
std::thread sec_thread{ security::thread, std::ref(client) };
sec_thread.detach();
- auto hwnd = ui::create(inst, { 430, 330 });
-
- if (!ui::create_device(hwnd)) {
- io::log_error("failed to create device.");
-
- std::cin.get();
-
- return 0;
- }
-
-
ShowWindow(hwnd, show_cmd);
ImGui::CreateContext();
@@ -160,10 +161,14 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
ImGui::StyleColorsDark();
ImGui::GetIO().IniFilename = nullptr;
+ ImGui::GetStyle().WindowRounding = 0.f;
ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(ui::device, ui::device_context);
+ int offset_x = 0;
+ int offset_y = 0;
+
MSG msg;
std::memset(&msg, 0, sizeof(msg));
while (msg.message != WM_QUIT) {
@@ -176,22 +181,45 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
if (!client)
break;
- // Start the Dear ImGui frame
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
- ImGui::SetNextWindowSize(ImVec2{400, 250}, ImGuiCond_::ImGuiCond_Always);
- ImGui::SetNextWindowPos(ImVec2{0, 0}, ImGuiCond_::ImGuiCond_Always);
- ImGui::Begin("##main", 0, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
- ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar);
+ if (ImGui::IsMouseClicked(0)) {
+ POINT point;
+ RECT rect;
+
+ GetCursorPos(&point);
+ GetWindowRect(hwnd, &rect);
+
+ offset_x = point.x - rect.left;
+ offset_y = point.y - rect.top;
+ }
+
+ ImGui::SetNextWindowSize(ImVec2{ 400, 300 }, ImGuiCond_::ImGuiCond_Always);
+ ImGui::SetNextWindowPos(ImVec2{ 0, 0 }, ImGuiCond_::ImGuiCond_Always);
+
+ ImGui::Begin("##main", 0, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove |
+ ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar);
+
+ if (ImGui::BeginMenuBar()) {
+ ImGui::Text("client");
+ ImGui::EndMenuBar();
+ }
+
+ if (ImGui::IsMouseDragging(ImGuiMouseButton_::ImGuiMouseButton_Left)) {
+ POINT point;
+ GetCursorPos(&point);
+
+ SetWindowPos(hwnd, nullptr, point.x - offset_x, point.y - offset_y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ }
if (client.state == tcp::client_state::connecting) {
if (client.session_result == -1) {
ImGui::Text("connecting...");
}
-
+
if (client.session_result == tcp::session_result::hwid_fail) {
ImGui::Text("internal client error.");
}
@@ -202,14 +230,16 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
}
if (client.state == tcp::client_state::idle) {
- static std::array<char, 128> u;
- ImGui::InputText("Username", &u[0], u.size());
+ static std::string u;
+ ImGui::Text("username :");
+ ImGui::InputText("##username", &u);
- static std::array<char, 128> p;
- ImGui::InputText("Password", &p[0], p.size());
+ static std::string p;
+ ImGui::Text("password :");
+ ImGui::InputText("##password", &p, ImGuiInputTextFlags_Password);
if (ImGui::Button("login")) {
- auto l = fmt::format("{},{}", u.data(), p.data());
+ auto l = fmt::format("{},{}", u, p);
int ret = client.write(tcp::packet_t(l, tcp::packet_type::write,
client.session_id,
@@ -218,12 +248,26 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
if (ret <= 0) {
ImGui::Text("failed to send request, please try again.");
}
+ else {
+ client.state = tcp::client_state::logging_in;
+ }
}
+ if (ImGui::Button("exit")) {
+ client.shutdown();
+ }
+ }
+
+ if (client.state == tcp::client_state::logging_in) {
auto res = client.login_result;
- if (res != -1) {
+ if (res == -1) {
+ ImGui::Text("logging in...");
+ }
+ else {
if (res == tcp::login_result::banned) {
- MessageBoxA(hwnd, "your account is banned.", "client", MB_OK);
+ ImGui::Text("your account is banned.");
+
+ std::this_thread::sleep_for(std::chrono::seconds(5));
client.shutdown();
break;
@@ -234,14 +278,18 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
}
if (res == tcp::login_result::hwid_mismatch) {
- MessageBoxA(hwnd, "please reset your hwid on the forums.", "client", MB_OK);
+ ImGui::Text("please reset your hwid on the forums.");
+
+ std::this_thread::sleep_for(std::chrono::seconds(5));
client.shutdown();
break;
}
if (res == tcp::login_result::server_error) {
- MessageBoxA(hwnd, "internal server error, please contact a developer.", "client", MB_OK);
+ ImGui::Text("internal server error, please contact a developer.");
+
+ std::this_thread::sleep_for(std::chrono::seconds(5));
client.shutdown();
break;
@@ -254,56 +302,59 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
}
if (client.state == tcp::client_state::logged_in) {
- ImGui::BeginChild("list", ImVec2(150, 300));
- static auto getter = [](void* data, int idx, const char** out_text) -> bool {
- auto game_data = reinterpret_cast<game_data_t*>(data);
- if (out_text)
- *out_text = game_data[idx].name.c_str();
- return true;
- };
-
- static int i = -1;
- ImGui::ListBox("##dd", &i, getter, (void*)client.games.data(), client.games.size());
+ ImGui::BeginChild("list", ImVec2(150, 0), true);
+ static int selected = 0;
+ for (int i = 0; i < client.games.size(); i++) {
+ auto& game = client.games[i];
+ if (ImGui::Selectable(game.name.c_str(), selected == i)) {
+ selected = i;
+ }
+ }
ImGui::EndChild();
ImGui::SameLine();
- ImGui::BeginChild("dat", ImVec2(250, 300));
- if (i >= 0 && i < client.games.size()) {
- auto game = client.games[i];
- ImGui::Text("version %d", game.version);
+ ImGui::BeginGroup();
+ ImGui::BeginChild("data", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()));
+ auto game = client.games[selected];
+ ImGui::Text("%s", game.name);
+ ImGui::Separator();
- if (ImGui::Button("inject")) {
- client.selected_game = game;
+ ImGui::Text("version %d", game.version);
- nlohmann::json j;
- j["id"] = client.selected_game.process_name;
- j["x64"] = client.selected_game.x64;
+ if (ImGui::Button("inject")) {
+ client.selected_game = game;
- int ret = client.write(tcp::packet_t(j.dump(), tcp::packet_type::write,
- client.session_id,
- tcp::packet_id::game_select));
+ nlohmann::json j;
+ j["id"] = client.selected_game.process_name;
+ j["x64"] = client.selected_game.x64;
- if (ret <= 0) {
- ImGui::Text("Failed to send request, please try again.");
- }
+ int ret = client.write(tcp::packet_t(j.dump(), tcp::packet_type::write,
+ client.session_id,
+ tcp::packet_id::game_select));
- client.state = tcp::client_state::waiting;
+ if (ret <= 0) {
+ ImGui::Text("Failed to send request, please try again.");
}
}
+
ImGui::EndChild();
+ if (ImGui::Button("exit")) {
+ client.shutdown();
+ }
+ ImGui::EndGroup();
}
if (client.state == tcp::client_state::waiting) {
- ImGui::Text("please wait.");
+ ImGui::Text("waiting for the process...");
}
if (client.state == tcp::client_state::imports_ready) {
- ImGui::Text("please wait.");
+ ImGui::Text("please wait...");
}
if (client.state == tcp::client_state::image_ready) {
- ImGui::Text("please wait.");
+ ImGui::Text("please wait...");
}
@@ -317,7 +368,7 @@ int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmd_args, int show_cmd) {
ui::device_context->OMSetRenderTargets(1, &ui::main_render_target, NULL);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
- ui::swap_chain->Present(1, 0);
+ ui::swap_chain->Present(0, 0);
}
ImGui_ImplDX11_Shutdown();
diff --git a/client/src/security/security.cpp b/client/src/security/security.cpp
index 624e41a..f0adfe9 100644
--- a/client/src/security/security.cpp
+++ b/client/src/security/security.cpp
@@ -3,16 +3,23 @@
#include "../client/client.h"
#include "../injection/process.h"
#include "../util/apiset.h"
+#include "../util/syscalls.h"
#include "security.h"
+#define SEC_NO_CHANGE 0x00400000
+
+std::unordered_map<std::string, std::vector<char>> security::parsed_images;
+
void security::thread(tcp::client& client) {
- std::unordered_map<std::string, pe::image<true>> raw_images;
- std::unordered_map<std::string, std::vector<char>> parsed_images;
+ std::list<std::string> whitelist = { "d3dcompiler_43.dll", "xinput1_3.dll" };
std::unordered_map<std::string, pe::virtual_image> images;
+ std::unordered_map<std::string, pe::image<true>> raw_images;
pe::get_all_modules(images);
+
for (auto& [name, vi] : images) {
- if (name != "ntdll.dll" || name != "kernel32.dll") {
+ auto it = std::find(whitelist.begin(), whitelist.end(), name);
+ if (it != whitelist.end()) {
continue;
}
@@ -49,10 +56,6 @@ void security::thread(tcp::client& client) {
raw_images.clear();
images.clear();
- while (!client) {
- std::this_thread::sleep_for(std::chrono::microseconds(100));
- }
-
while (client) {
if (client.session_id.empty()) {
continue;
@@ -63,6 +66,11 @@ void security::thread(tcp::client& client) {
std::vector<patch_t> patches;
for (auto& [name, limage] : loaded_images) {
+ auto it = std::find(whitelist.begin(), whitelist.end(), name);
+ if (it != whitelist.end()) {
+ continue;
+ }
+
auto& parsed = parsed_images[name];
if (parsed.empty()) {
continue;
@@ -103,24 +111,18 @@ void security::thread(tcp::client& client) {
}
}
nlohmann::json j;
- j["patches"] = patches.size();
- for (int i = 0; i < patches.size(); ++i) {
- auto patch = patches[i];
- io::log("found patch in {} at {:x}.", patch.module, patch.va);
- }
+ j["patches"] = patches.size();
- const auto ret = client.write(tcp::packet_t("qsd", tcp::packet_type::write, client.session_id, tcp::packet_id::security_report));
+ /*const auto ret = client.write(tcp::packet_t(j.dump(), tcp::packet_type::write, client.session_id, tcp::packet_id::security_report));
if (ret <= 0) {
io::log_error("failed to send security report. {}", ret);
client.shutdown();
- io::log("press enter...");
- std::cin.get();
break;
- }
+ }*/
std::this_thread::sleep_for(std::chrono::seconds(5));
}
-}
+} \ No newline at end of file
diff --git a/client/src/security/security.h b/client/src/security/security.h
index 6a765d9..009622a 100644
--- a/client/src/security/security.h
+++ b/client/src/security/security.h
@@ -2,6 +2,8 @@
namespace security {
+ extern std::unordered_map<std::string, std::vector<char>> parsed_images;
+
struct patch_t {
uintptr_t va;
uint8_t original_op;
diff --git a/client/src/ui/imgui/imgui_stdlib.cpp b/client/src/ui/imgui/imgui_stdlib.cpp
new file mode 100644
index 0000000..cb1fe17
--- /dev/null
+++ b/client/src/ui/imgui/imgui_stdlib.cpp
@@ -0,0 +1,76 @@
+// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
+// This is also an example of how you may wrap your own similar types.
+
+// Compatibility:
+// - std::string support is only guaranteed to work from C++11.
+// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture)
+
+// Changelog:
+// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
+
+#include "imgui.h"
+#include "imgui_stdlib.h"
+
+struct InputTextCallback_UserData
+{
+ std::string* Str;
+ ImGuiInputTextCallback ChainCallback;
+ void* ChainCallbackUserData;
+};
+
+static int InputTextCallback(ImGuiInputTextCallbackData* data)
+{
+ InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData;
+ if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
+ {
+ // Resize string callback
+ // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want.
+ std::string* str = user_data->Str;
+ IM_ASSERT(data->Buf == str->c_str());
+ str->resize(data->BufTextLen);
+ data->Buf = (char*)str->c_str();
+ }
+ else if (user_data->ChainCallback)
+ {
+ // Forward to user callback, if any
+ data->UserData = user_data->ChainCallbackUserData;
+ return user_data->ChainCallback(data);
+ }
+ return 0;
+}
+
+bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+{
+ IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
+ flags |= ImGuiInputTextFlags_CallbackResize;
+
+ InputTextCallback_UserData cb_user_data;
+ cb_user_data.Str = str;
+ cb_user_data.ChainCallback = callback;
+ cb_user_data.ChainCallbackUserData = user_data;
+ return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
+}
+
+bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+{
+ IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
+ flags |= ImGuiInputTextFlags_CallbackResize;
+
+ InputTextCallback_UserData cb_user_data;
+ cb_user_data.Str = str;
+ cb_user_data.ChainCallback = callback;
+ cb_user_data.ChainCallbackUserData = user_data;
+ return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data);
+}
+
+bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+{
+ IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
+ flags |= ImGuiInputTextFlags_CallbackResize;
+
+ InputTextCallback_UserData cb_user_data;
+ cb_user_data.Str = str;
+ cb_user_data.ChainCallback = callback;
+ cb_user_data.ChainCallbackUserData = user_data;
+ return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
+}
diff --git a/client/src/ui/imgui/imgui_stdlib.h b/client/src/ui/imgui/imgui_stdlib.h
new file mode 100644
index 0000000..f860b0c
--- /dev/null
+++ b/client/src/ui/imgui/imgui_stdlib.h
@@ -0,0 +1,22 @@
+// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
+// This is also an example of how you may wrap your own similar types.
+
+// Compatibility:
+// - std::string support is only guaranteed to work from C++11.
+// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture)
+
+// Changelog:
+// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
+
+#pragma once
+
+#include <string>
+
+namespace ImGui
+{
+ // ImGui::InputText() with std::string
+ // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity
+ IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+ IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+ IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+}
diff --git a/client/src/ui/ui.cpp b/client/src/ui/ui.cpp
index 3e46a67..242bb5c 100644
--- a/client/src/ui/ui.cpp
+++ b/client/src/ui/ui.cpp
@@ -8,26 +8,15 @@ ID3D11RenderTargetView* ui::main_render_target;
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-LRESULT WINAPI ui::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
+LRESULT ui::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
if (ImGui_ImplWin32_WndProcHandler(hwnd, message, wparam, lparam))
return true;
switch (message)
{
- case WM_SIZE:
- if (wparam != SIZE_MINIMIZED) {
- cleanup_target();
- swap_chain->ResizeBuffers(0, (UINT)LOWORD(lparam), (UINT)HIWORD(wparam), DXGI_FORMAT_UNKNOWN, 0);
- create_target();
- }
- return 0;
- case WM_SYSCOMMAND:
- if ((wparam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
+ case WM_DESTROY:
+ PostQuitMessage(0);
return 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
}
return DefWindowProc(hwnd, message, wparam, lparam);
@@ -47,9 +36,9 @@ HWND ui::create(HINSTANCE instance, const std::pair<int, int> size, const std::p
RegisterClassEx(&wc);
- auto flag = WS_OVERLAPPEDWINDOW;
- flag &= ~WS_MAXIMIZEBOX;
- flag &= ~WS_SIZEBOX;
+ auto flag = WS_POPUP;
+ /*flag &= ~WS_MAXIMIZEBOX;
+ flag &= ~WS_SIZEBOX;*/
return CreateWindowEx(WS_EX_TOPMOST, wc.lpszClassName, "client", flag, pos.first, pos.second, size.first, size.second, 0, 0, wc.hInstance, 0);
}
diff --git a/client/src/ui/ui.h b/client/src/ui/ui.h
index 3383c25..7fd3248 100644
--- a/client/src/ui/ui.h
+++ b/client/src/ui/ui.h
@@ -4,6 +4,7 @@
#include "imgui/imgui_impl_win32.h"
#include "imgui/imgui_impl_dx11.h"
+#include "imgui/imgui_stdlib.h"
#include <d3d11.h>
namespace ui {
@@ -12,11 +13,10 @@ namespace ui {
extern IDXGISwapChain* swap_chain;
extern ID3D11RenderTargetView* main_render_target;
- LRESULT WINAPI wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
+ LRESULT wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
HWND create(HINSTANCE instance, const std::pair<int, int> size, const std::pair<int, int> pos = { 400, 400 });
-
bool create_device(HWND hwnd);
void create_target();
void cleanup_target();
diff --git a/client/src/util/io.cpp b/client/src/util/io.cpp
index 47d9dbe..bfd58db 100644
--- a/client/src/util/io.cpp
+++ b/client/src/util/io.cpp
@@ -1,6 +1,8 @@
#include "../include.h"
#include "io.h"
+std::mutex io::file_mutex;
+
bool io::read_file(const std::string_view path, std::vector<char>& out) {
std::ifstream file(path.data(), std::ios::binary);
if (!file.good()) {
diff --git a/client/src/util/io.h b/client/src/util/io.h
index adb63f7..2b99434 100644
--- a/client/src/util/io.h
+++ b/client/src/util/io.h
@@ -3,7 +3,13 @@
#include <fmt/format.h>
#include <fmt/color.h>
+#include "../client/enc.h"
+
+
+
namespace io {
+ extern std::mutex file_mutex;
+
template<typename... Args>
void log(const std::string_view str, Args... params) {
static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
diff --git a/client/src/util/native.h b/client/src/util/native.h
index b5b0768..aa41b65 100644
--- a/client/src/util/native.h
+++ b/client/src/util/native.h
@@ -157,6 +157,11 @@ namespace native {
uint8_t Flags;
};
+ enum SECTION_INHERIT {
+ ViewShare = 1,
+ ViewUnmap = 2
+ };
+
using NtQuerySystemInformation = NTSTATUS(__stdcall*)(SYSTEM_INFORMATION_CLASS, PVOID, SIZE_T, PULONG);
using NtOpenProcess = NTSTATUS(__stdcall*)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, CLIENT_ID*);
using NtOpenThread = NTSTATUS(__stdcall*)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, CLIENT_ID*);
@@ -169,4 +174,8 @@ namespace native {
using NtWaitForSingleObject = NTSTATUS(__stdcall*)(HANDLE, BOOLEAN, PLARGE_INTEGER);
using NtCreateThreadEx = NTSTATUS(__stdcall*)(PHANDLE, ACCESS_MASK, PVOID, HANDLE, LPTHREAD_START_ROUTINE, PVOID, ULONG, ULONG_PTR, SIZE_T, SIZE_T, PVOID);
+ using NtCreateSection = NTSTATUS(__stdcall*)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PLARGE_INTEGER, ULONG, ULONG, HANDLE);
+ using NtMapViewOfSection = NTSTATUS(__stdcall*)(HANDLE, HANDLE, PVOID *, ULONG_PTR, SIZE_T, PLARGE_INTEGER, PSIZE_T, SECTION_INHERIT, ULONG, ULONG);
+ using NtUnmapViewOfSection = NTSTATUS(__stdcall*)(HANDLE, PVOID);
+
}; // namespace native \ No newline at end of file
diff --git a/server/src/main.cpp b/server/src/main.cpp
index 4f531da..2fcd42f 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -396,10 +396,10 @@ int main(int argc, char* argv[]) {
client_server().erase(it);
}
- if (client.security_timeout()) {
+ /*if (client.security_timeout()) {
io::logger->warn("{} failed to send security packet in time, dropping...",
client.get_ip());
- }
+ }*/
io::logger->info("{} timed out.", client.get_ip());
});
diff --git a/server/src/server/server.cpp b/server/src/server/server.cpp
index 204ee17..898d6fe 100644
--- a/server/src/server/server.cpp
+++ b/server/src/server/server.cpp
@@ -155,7 +155,7 @@ void tcp::server::receive() {
void tcp::server::check_timeout() {
auto it = std::find_if(client_stack.begin(), client_stack.end(),
- [&](client& c) { return c.timeout() || c.security_timeout(); });
+ [&](client& c) { return c.timeout() /*|| c.security_timeout()*/; });
if (it != client_stack.end()) {
timeout_event.call(*it);