├── README.md ├── bin └── checksec.exe ├── checksec.sln ├── checksec.vcxproj ├── checksec.vcxproj.filters └── main.cpp /README.md: -------------------------------------------------------------------------------- 1 | # checksec-win 2 | 3 | checksec tool for win10 RS1 4 | 5 | SDK ver 10.0.14393 6 | 7 | ![Usage](http://i.imgur.com/7gZQIpm.png) 8 | -------------------------------------------------------------------------------- /bin/checksec.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wmliang/checksec-win/1fec5a80121298a7687ba9ce6d837b3429500077/bin/checksec.exe -------------------------------------------------------------------------------- /checksec.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checksec", "checksec.vcxproj", "{BBAD7340-D1BB-4473-BB4A-435A53D33C39}" 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 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Debug|x64.ActiveCfg = Debug|x64 17 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Debug|x64.Build.0 = Debug|x64 18 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Debug|x86.ActiveCfg = Release|Win32 19 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Debug|x86.Build.0 = Release|Win32 20 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Release|x64.ActiveCfg = Release|x64 21 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Release|x64.Build.0 = Release|x64 22 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Release|x86.ActiveCfg = Release|Win32 23 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /checksec.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 | {BBAD7340-D1BB-4473-BB4A-435A53D33C39} 23 | checksec 24 | 10.0.14393.0 25 | 26 | 27 | 28 | Application 29 | true 30 | v140 31 | MultiByte 32 | 33 | 34 | Application 35 | false 36 | v140 37 | true 38 | MultiByte 39 | 40 | 41 | Application 42 | true 43 | v140 44 | MultiByte 45 | 46 | 47 | Application 48 | false 49 | v140 50 | true 51 | MultiByte 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | Level3 75 | Disabled 76 | true 77 | MultiThreadedDLL 78 | 79 | 80 | 81 | 82 | Level3 83 | Disabled 84 | true 85 | 86 | 87 | 88 | 89 | Level3 90 | MaxSpeed 91 | true 92 | true 93 | true 94 | MultiThreaded 95 | 96 | 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | MaxSpeed 105 | true 106 | true 107 | true 108 | 109 | 110 | true 111 | true 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /checksec.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;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 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // stringification 6 | #define str(s) #s 7 | 8 | void print_error(const char *desc, DWORD errcode) { 9 | LPSTR errorText = NULL; 10 | 11 | FormatMessageA( 12 | // use system message tables to retrieve error text 13 | FORMAT_MESSAGE_FROM_SYSTEM 14 | // allocate buffer on local heap for error text 15 | | FORMAT_MESSAGE_ALLOCATE_BUFFER 16 | // Important! will fail otherwise, since we're not 17 | // (and CANNOT) pass insertion parameters 18 | | FORMAT_MESSAGE_IGNORE_INSERTS, 19 | NULL, // unused with FORMAT_MESSAGE_FROM_SYSTEM 20 | errcode, 21 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 22 | errorText, // output 23 | 0, // minimum size for output buffer 24 | NULL); // arguments - see note 25 | 26 | if (errorText != NULL) { 27 | if (desc == NULL) desc = "Error"; 28 | if (errorText[strlen(errorText) - 1] == '\n') errorText[strlen(errorText) - 1] = '\0'; 29 | if (errorText[strlen(errorText) - 1] == '\r') errorText[strlen(errorText) - 1] = '\0'; 30 | fprintf(stderr, "%s: %08X: %s\n", desc, errcode, errorText); 31 | // release memory allocated by FormatMessage() 32 | LocalFree(errorText); 33 | } 34 | } 35 | 36 | #define GET_MITIGATION(proc, p, b, s) \ 37 | if (!GetProcessMitigationPolicy((proc), (p), (b), (s))) { \ 38 | if (0) { print_error(str(p), GetLastError()); } \ 39 | } else 40 | 41 | void print_mitigations(HANDLE hProc) { 42 | 43 | PROCESS_MITIGATION_DEP_POLICY dep = { 0 }; 44 | PROCESS_MITIGATION_ASLR_POLICY aslr = { 0 }; 45 | PROCESS_MITIGATION_DYNAMIC_CODE_POLICY dynamic_code = { 0 }; 46 | PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY strict_handle_check = { 0 }; 47 | PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY system_call_disable = { 0 }; 48 | PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY extension_point_disable = { 0 }; 49 | PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY cfg = { 0 }; 50 | PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY signature = { 0 }; 51 | PROCESS_MITIGATION_FONT_DISABLE_POLICY font = { 0 }; 52 | PROCESS_MITIGATION_IMAGE_LOAD_POLICY image_load = { 0 }; 53 | ULONG64 mitigation_options = { 0 }; 54 | 55 | GET_MITIGATION(hProc, ProcessDEPPolicy, &dep, sizeof(dep)) { 56 | printf("ProcessDEPPolicy\n"); 57 | printf(" Enable %u\n", dep.Enable); 58 | printf(" DisableAtlThunkEmulation %u\n", dep.DisableAtlThunkEmulation); 59 | printf(" Permanent %u\n", dep.Permanent); 60 | } 61 | 62 | GET_MITIGATION(hProc, ProcessASLRPolicy, &aslr, sizeof(aslr)) { 63 | printf("ProcessASLRPolicy\n"); 64 | printf(" EnableBottomUpRandomization %u\n", aslr.EnableBottomUpRandomization); 65 | printf(" EnableForceRelocateImages %u\n", aslr.EnableForceRelocateImages); 66 | printf(" EnableHighEntropy %u\n", aslr.EnableHighEntropy); 67 | printf(" DisallowStrippedImages %u\n", aslr.DisallowStrippedImages); 68 | } 69 | 70 | GET_MITIGATION(hProc, ProcessDynamicCodePolicy, &dynamic_code, sizeof(dynamic_code)) { 71 | printf("ProcessDynamicCodePolicy\n"); 72 | printf(" ProhibitDynamicCode %u\n", dynamic_code.ProhibitDynamicCode); 73 | printf(" AllowThreadOptOut %u\n", dynamic_code.AllowThreadOptOut); 74 | // printf(" AllowRemoteDowngrade %u\n", dynamic_code.AllowRemoteDowngrade); 75 | } 76 | 77 | GET_MITIGATION(hProc, ProcessStrictHandleCheckPolicy, &strict_handle_check, sizeof(strict_handle_check)) { 78 | printf("ProcessStrictHandleCheckPolicy\n"); 79 | printf(" RaiseExceptionOnInvalidHandleReference %u\n", strict_handle_check.RaiseExceptionOnInvalidHandleReference); 80 | printf(" HandleExceptionsPermanentlyEnabled %u\n", strict_handle_check.HandleExceptionsPermanentlyEnabled); 81 | } 82 | 83 | GET_MITIGATION(hProc, ProcessSystemCallDisablePolicy, &system_call_disable, sizeof(system_call_disable)) { 84 | printf("ProcessSystemCallDisablePolicy\n"); 85 | printf(" DisallowWin32kSystemCalls %u\n", system_call_disable.DisallowWin32kSystemCalls); 86 | } 87 | 88 | GET_MITIGATION(hProc, ProcessExtensionPointDisablePolicy, &extension_point_disable, sizeof(extension_point_disable)) { 89 | printf("ProcessExtensionPointDisablePolicy\n"); 90 | printf(" DisableExtensionPoints %u\n", extension_point_disable.DisableExtensionPoints); 91 | } 92 | 93 | GET_MITIGATION(hProc, ProcessControlFlowGuardPolicy, &cfg, sizeof(cfg)) { 94 | printf("ProcessControlFlowGuardPolicy\n"); 95 | printf(" EnableControlFlowGuard %u\n", cfg.EnableControlFlowGuard); 96 | // printf(" EnableExportSuppression %u\n", cfg.EnableExportSuppression); 97 | // printf(" StrictMode %u\n", cfg.StrictMode); 98 | } 99 | 100 | GET_MITIGATION(hProc, ProcessSignaturePolicy, &signature, sizeof(signature)) { 101 | printf("ProcessSignaturePolicy\n"); 102 | printf(" MicrosoftSignedOnly %u\n", signature.MicrosoftSignedOnly); 103 | printf(" StoreSignedOnly %u\n", signature.StoreSignedOnly); 104 | printf(" MitigationOptIn %u\n", signature.MitigationOptIn); 105 | } 106 | 107 | GET_MITIGATION(hProc, ProcessFontDisablePolicy, &font, sizeof(font)) { 108 | printf("ProcessFontPolicy\n"); 109 | printf(" DisableNonSystemFonts %u\n", font.DisableNonSystemFonts); 110 | printf(" AuditNonSystemFontLoading %u\n", font.AuditNonSystemFontLoading); 111 | } 112 | 113 | GET_MITIGATION(hProc, ProcessImageLoadPolicy, &image_load, sizeof(image_load)) { 114 | printf("ProcessImageLoadPolicy\n"); 115 | printf(" NoRemoteImages %u\n", image_load.NoRemoteImages); 116 | printf(" NoLowMandatoryLabelImages %u\n", image_load.NoLowMandatoryLabelImages); 117 | printf(" PreferSystem32Images %u\n", image_load.PreferSystem32Images); 118 | } 119 | 120 | GET_MITIGATION(hProc, ProcessMitigationOptionsMask, &mitigation_options, sizeof(mitigation_options)) { 121 | printf("ProcessMitigationOptionsMask\n"); 122 | printf(" MitigationOptions %llx\n", mitigation_options); 123 | 124 | if (mitigation_options & PROCESS_CREATION_MITIGATION_POLICY_SEHOP_ENABLE) { 125 | printf(" PROCESS_CREATION_MITIGATION_POLICY_SEHOP_ENABLE\n"); 126 | } 127 | 128 | if (mitigation_options & PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_ON) { 129 | printf(" PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_ON\n"); 130 | } 131 | else if (mitigation_options & PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_OFF) { 132 | printf(" PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_OFF\n"); 133 | } 134 | 135 | if (mitigation_options & PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON) { 136 | printf(" PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON\n"); 137 | } 138 | else if (mitigation_options & PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_OFF) { 139 | printf(" PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_OFF\n"); 140 | } 141 | 142 | } 143 | } 144 | 145 | void usage(const char *p) { 146 | printf("Usage: %s \n", p); 147 | } 148 | 149 | int main(int argc, char* argv[]) { 150 | DWORD pid = 0; 151 | HANDLE hProc; 152 | 153 | if (argc != 2) { 154 | usage(argv[0]); 155 | return EXIT_FAILURE; 156 | } 157 | 158 | pid = strtoul(argv[1], NULL, 0); 159 | if (pid == 0) { 160 | usage(argv[0]); 161 | return EXIT_FAILURE; 162 | } 163 | 164 | hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, (DWORD)pid); 165 | if (hProc == NULL) { 166 | print_error("OpenProcess", GetLastError()); 167 | return EXIT_FAILURE; 168 | } 169 | 170 | print_mitigations(hProc); 171 | 172 | CloseHandle(hProc); 173 | return EXIT_SUCCESS; 174 | } --------------------------------------------------------------------------------