diff options
-rw-r--r-- | CMD/CMD.cpp | 207 | ||||
-rw-r--r-- | CMD/CMD.vcxproj | 184 | ||||
-rw-r--r-- | CMD/CMD.vcxproj.filters | 30 | ||||
-rw-r--r-- | CMD/pch.cpp | 5 | ||||
-rw-r--r-- | CMD/pch.h | 14 | ||||
-rw-r--r-- | KMemDriver.sln | 6 |
6 files changed, 0 insertions, 446 deletions
diff --git a/CMD/CMD.cpp b/CMD/CMD.cpp deleted file mode 100644 index a007952..0000000 --- a/CMD/CMD.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include "pch.h" -#include "KMemDriver.h" -#include "KInterface.h" -#include "DLLHelper.h" - -#include <iostream> -#include <iomanip> -#include <chrono> -#include <thread> -#include <windows.h> - -static BOOL running = false; -static const wchar_t *wName = L"desk"; /* name of the CMD windows */ - - -static bool consoleHandler(int signal) { - if (signal == CTRL_C_EVENT) { - if (!running) - exit(EXIT_FAILURE); - running = false; - std::wcout << L"Waiting for graceful shutdown .." << std::endl; - } - return true; -} - -static BOOL CALLBACK enumWindowsProc(HWND hWnd, LPARAM lParam) -{ - int length = GetWindowTextLength(hWnd); - TCHAR* buffer; - buffer = new TCHAR[length + 1]; - memset(buffer, 0, (length + 1) * sizeof(TCHAR)); - GetWindowText(hWnd, buffer, length + 1); - //wprintf(L"Window: '%ls'\n", buffer); - if (!wcscmp(buffer, wName)) - *(HWND *)lParam = hWnd; - delete[] buffer; - return TRUE; -} - -int wmain(int argc, wchar_t **argv) -{ - HANDLE targetPID = 0; - PVOID buf; - HANDLE kevent; - HANDLE uevent; - - KInterface& ki = KInterface::getInstance(); - std::vector<MEMORY_BASIC_INFORMATION> pages; - std::vector<MODULE_DATA> modules; - - std::wcout << L"Waiting for window title: '" << wName << L"'" << std::endl; - - HWND targetHWND = NULL; - while (1) { - if (!EnumWindows(enumWindowsProc, (LPARAM)&targetHWND)) { - return 1; - } - if (targetHWND) { - std::wcout << L"Found window '" << wName << L"' with Handle 0x" - << std::hex << targetHWND << std::endl; - break; - } - Sleep(1000); - } - GetWindowThreadProcessId(targetHWND, (LPDWORD)&targetPID); - - SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE); - - if (!ki.Init()) { - std::wcout << L"Kernel Interface Init() failed" << std::endl; - return 1; - } - - try { - buf = ki.getBuffer(); - kevent = ki.getKHandle(); - uevent = ki.getUHandle(); - } - catch (std::runtime_error& err) { - std::wcout << err.what() << std::endl; - return 1; - } - - std::wcout << L"Buffer.: " << buf << std::endl; - std::wcout << L"KHandle: " << kevent << std::endl; - std::wcout << L"UHandle: " << uevent << std::endl; - - if (!ki.Handshake()) { - std::wcout << L"Kernel Interface Handshake() failed" << std::endl; - return 1; - } - - if (!ki.Modules(targetPID, modules)) - std::wcout << L"Kernel Interface Modules() failed with 0x" - << std::hex << ki.getLastNtStatus() << std::endl; - else std::wcout << L"Got " << std::dec << modules.size() << L" modules for pid 0x" - << std::hex << targetPID << std::endl; -#if 0 - if (!ki.Pages(targetPID, pages)) - std::wcout << L"Kernel Interface Pages() failed with 0x" - << std::hex << ki.getLastNtStatus() << std::endl; - else std::wcout << L"Got " << std::dec << pages.size() << L" mapped pages for pid 0x" - << std::hex << targetPID << std::endl; -#endif - - MODULE_DATA *dll = NULL; - for (MODULE_DATA& md : modules) { - std::wcout << "DLLName: " << md.BaseDllName << ", " - << "DLLPath: " << md.FullDllPath << std::endl; - if (strncmp(md.BaseDllName, "msvcrt.dll", sizeof md.BaseDllName) == 0) { - std::wcout << L"FOUND MSVCRT DLL at " << std::hex << md.DllBase << "!!!" << std::endl; - dll = &md; - break; - } - } - - running = TRUE; - do { - if (dll) { - DWORD dwRData = 0x76000; - //DWORD dwRData = 0x8f000; - PVOID rdata = (PVOID)((ULONG_PTR)dll->DllBase + dwRData); - DWORD value = 0xDEADC0DE; - KMemory::Wpm<DWORD>(targetPID, rdata, &value); - value = 0x0; - value = KMemory::Rpm<DWORD>(targetPID, rdata); - std::cout << "Value: " << std::hex << value << std::endl; - - PVOID targetAddr = (PVOID)((UINT64)NULL); - SIZE_T targetSize = 4096; - try { -#if 0 - if (!ki.VAlloc(targetPID, &targetAddr, &targetSize, PAGE_EXECUTE_READWRITE)) { - std::wcout << L"VAlloc failed" << std::endl; - } - if (!ki.VUnlink(targetPID, targetAddr)) { - std::wcout << L"VUnlink failed" << std::endl; - } - if (!ki.VFree(targetPID, targetAddr, targetSize)) { - std::wcout << L"VFree failed" << std::endl; - } -#endif - static bool map_test_dll = true; - if (map_test_dll) { - map_test_dll = false; - SymbolResolver symres; - DLLHelper dll(symres); - if (!dll.Init(targetPID, "./TestDLL.dll")) { - std::wcout << L"DLL Init failed" << std::endl; - } - if (!dll.VerifyHeader()) { - std::wcout << L"DLL VerifyHeader failed" << std::endl; - } - if (!dll.InitTargetMemory()) { - std::wcout << L"DLL InitTargetMemory failed" << std::endl; - } - if (!dll.HasImports()) - { - std::wcout << L"DLL has no ImportTable" << std::endl; - } - else if (!dll.FixImports()) { - std::wcout << L"DLL FixImports failed" << std::endl; - } - if (!dll.HasRelocs()) { - std::wcout << L"DLL has no RelocTable" << std::endl; - } - else if (!dll.FixRelocs()) { - std::wcout << L"DLL FixRelocs failed" << std::endl; - } - if (!dll.CopyHeaderAndSections()) { - std::wcout << L"DLL CopyHeaderAndSections failed" << std::endl; - } - std::wcout << L"DLL mapping succesful" << std::endl; - } - } - catch (std::runtime_error& err) { - std::wcout << err.what() << std::endl; - } - - std::this_thread::sleep_for(std::chrono::microseconds(2500000)); - } - else - - if (ki.RecvWait() == SRR_TIMEOUT) { - std::wcout << L"Ping -> "; - if (!ki.Ping()) { - std::wcout << L"Got no valid PONG, abort!" << std::endl; - running = FALSE; - } - else std::wcout << L"PONG!" << std::endl; - } - - if (!running) - break; - - try { - if (targetPID) { - } - } - catch (std::runtime_error& err) { - std::wcout << err.what() << std::endl; - } - } while (running); - - std::wcout << L"Driver shutdown .." << std::endl; - ki.Exit(); -}
\ No newline at end of file diff --git a/CMD/CMD.vcxproj b/CMD/CMD.vcxproj deleted file mode 100644 index 7ccb18f..0000000 --- a/CMD/CMD.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <VCProjectVersion>15.0</VCProjectVersion> - <ProjectGuid>{231929F8-2FBF-45D9-91B8-AD835ED166A6}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>CMD</RootNamespace> - <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - <SpectreMitigation>false</SpectreMitigation> - <UseOfMfc>false</UseOfMfc> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <SpectreMitigation>false</SpectreMitigation> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="Shared"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <TargetName>$(ProjectName)-kmem</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <TargetName>$(ProjectName)-kmem</TargetName> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> - <AdditionalIncludeDirectories>$(SolutionDir)include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>$(VCToolsInstallDir)lib\x64;$(OutputPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;MemDriverLib.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> - <AdditionalIncludeDirectories>$(SolutionDir)include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="pch.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="CMD.cpp" /> - <ClCompile Include="pch.cpp"> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\MemDriverLib\MemDriverLib.vcxproj"> - <Project>{b6790a97-6995-46b6-ad73-ac5bc4ac76db}</Project> - </ProjectReference> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/CMD/CMD.vcxproj.filters b/CMD/CMD.vcxproj.filters deleted file mode 100644 index 60b713e..0000000 --- a/CMD/CMD.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> - </Filter> - <Filter Include="Header Files"> - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> - <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions> - </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="pch.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="pch.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="CMD.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/CMD/pch.cpp b/CMD/pch.cpp deleted file mode 100644 index 3a3d12b..0000000 --- a/CMD/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed - -#include "pch.h" - -// In general, ignore this file, but keep it around if you are using pre-compiled headers. diff --git a/CMD/pch.h b/CMD/pch.h deleted file mode 100644 index b04e71e..0000000 --- a/CMD/pch.h +++ /dev/null @@ -1,14 +0,0 @@ -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file - -#ifndef PCH_H -#define PCH_H - -// TODO: add headers that you want to pre-compile here - -#endif //PCH_H diff --git a/KMemDriver.sln b/KMemDriver.sln index 87070d3..9f42a79 100644 --- a/KMemDriver.sln +++ b/KMemDriver.sln @@ -16,8 +16,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemDriverWeb", "MemDriverWe EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSGO", "CSGO\CSGO.vcxproj", "{65C081C2-3A90-470C-BF06-AFF2EEB00C25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMD", "CMD\CMD.vcxproj", "{231929F8-2FBF-45D9-91B8-AD835ED166A6}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestDLL", "TestDLL\TestDLL.vcxproj", "{E27E6F2C-154E-46AF-BED4-78D50C751565}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IntegrationTest", "IntegrationTest\IntegrationTest.vcxproj", "{AD4E6887-32BA-4CC9-924C-18F0ECAFB576}" @@ -52,10 +50,6 @@ Global {65C081C2-3A90-470C-BF06-AFF2EEB00C25}.Debug|x64.Build.0 = Debug|x64 {65C081C2-3A90-470C-BF06-AFF2EEB00C25}.Release|x64.ActiveCfg = Release|x64 {65C081C2-3A90-470C-BF06-AFF2EEB00C25}.Release|x64.Build.0 = Release|x64 - {231929F8-2FBF-45D9-91B8-AD835ED166A6}.Debug|x64.ActiveCfg = Debug|x64 - {231929F8-2FBF-45D9-91B8-AD835ED166A6}.Debug|x64.Build.0 = Debug|x64 - {231929F8-2FBF-45D9-91B8-AD835ED166A6}.Release|x64.ActiveCfg = Release|x64 - {231929F8-2FBF-45D9-91B8-AD835ED166A6}.Release|x64.Build.0 = Release|x64 {E27E6F2C-154E-46AF-BED4-78D50C751565}.Debug|x64.ActiveCfg = Release|x64 {E27E6F2C-154E-46AF-BED4-78D50C751565}.Debug|x64.Build.0 = Release|x64 {E27E6F2C-154E-46AF-BED4-78D50C751565}.Release|x64.ActiveCfg = Release|x64 |