├── BlockOpenHandle ├── BlockOpenHandle.cpp ├── BlockOpenHandle.sln ├── BlockOpenHandle.vcxproj ├── BlockOpenHandle.vcxproj.filters └── BlockOpenHandle.vcxproj.user └── README.md /BlockOpenHandle/BlockOpenHandle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void SetProcessSecurityDescriptor() { 6 | // Define a security descriptor string in SDDL format 7 | // The following SDDL string denies all access to the process, except for the SYSTEM account and the process owner 8 | LPCWSTR sddl = L"D:P" 9 | L"(D;OICI;GA;;;WD)" // Deny all access to the "World" (Everyone) 10 | L"(A;OICI;GA;;;SY)" // Allow all access to the "System" 11 | L"(A;OICI;GA;;;OW)"; // Allow all access to the process "Owner" 12 | 13 | PSECURITY_DESCRIPTOR securityDescriptor = nullptr; 14 | 15 | // Convert the SDDL string to a security descriptor 16 | if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(sddl, SDDL_REVISION_1, &securityDescriptor, nullptr)) { 17 | // Handle the error 18 | return; 19 | } 20 | 21 | // Set the security descriptor for the process 22 | if (!SetKernelObjectSecurity(GetCurrentProcess(), DACL_SECURITY_INFORMATION, securityDescriptor)) { 23 | // Handle the error 24 | } 25 | 26 | // Free the security descriptor 27 | LocalFree(securityDescriptor); 28 | } 29 | 30 | 31 | int main() { 32 | printf("[PID] : %d\n", GetCurrentProcessId()); 33 | SetProcessSecurityDescriptor(); 34 | 35 | getchar(); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /BlockOpenHandle/BlockOpenHandle.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32106.194 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlockOpenHandle", "BlockOpenHandle.vcxproj", "{55F0368B-63DA-40E7-A8A5-289F70DF9C7F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Debug|x64.ActiveCfg = Debug|x64 17 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Debug|x64.Build.0 = Debug|x64 18 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Debug|x86.Build.0 = Debug|Win32 20 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Release|x64.ActiveCfg = Release|x64 21 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Release|x64.Build.0 = Release|x64 22 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Release|x86.ActiveCfg = Release|Win32 23 | {55F0368B-63DA-40E7-A8A5-289F70DF9C7F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {FD320948-2C2E-4EAB-95E2-AF6348D1FE08} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /BlockOpenHandle/BlockOpenHandle.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {55f0368b-63da-40e7-a8a5-289f70df9c7f} 25 | BlockOpenHandle 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v142 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v142 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /BlockOpenHandle/BlockOpenHandle.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /BlockOpenHandle/BlockOpenHandle.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BlockOpenHandle 2 | Block any Process to open HANDLE to your process , only SYTEM is allowed to open handle to your process ,with that you can avoid remote memory scanners 3 | 4 | ## POC 5 | ![Block](https://user-images.githubusercontent.com/123980007/234769688-c72a0496-286e-49a2-8fe4-b55e109aa9ce.png) 6 | --------------------------------------------------------------------------------