├── .gitignore ├── LICENSE ├── README.md ├── enablerdp.cpp ├── enablerdp.sln ├── enablerdp.vcxproj ├── enablerdp.vcxproj.filters ├── enablerdp.vcxproj.user └── images ├── check.png ├── enable.png └── howtouse.png /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore 2 | .vs/* 3 | Release/* 4 | Release.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## fast-enable-rdp 2 | This tool Enable RDP and set firewall by Windows API. 3 | 4 | ## How to use? 5 | 6 | ``` python 7 | enablerdp.exe 8 | -- this help 9 | enablerdp.exe any 10 | -- Output system version, registry value, service status and firewall status 11 | enablerdp.exe port 1 12 | -- Only set fDenyTSConnections=0 And fEnableWinStation=1(Ignore port set) 13 | enablerdp.exe port 2 14 | -- Modify the registry, start services, and set up firewalls 15 | enablerdp.exe port 3 16 | -- Set firewall on the specified port(Allow In,It will be remove same rule) 17 | enablerdp.exe port 4 18 | -- Try to start service(Ignore port input) 19 | enablerdp.exe port 5 20 | -- Try to Modify the registry for enable RDP on a lower version system(Ignore port input) 21 | ``` 22 | 23 | ```enablerdp.exe any (get system information)``` 24 | 25 | ![](https://cdn.jsdelivr.net/gh/yanghaoi/enable-rdp/images/howtouse.png) 26 | 27 | ```TermService is stop and Firewall is ON``` 28 | 29 | ![](https://cdn.jsdelivr.net/gh/yanghaoi/enable-rdp/images/check.png) 30 | 31 | ```Use enablerdp.exe 3389 2 (start TermService and add rule-in in Firewall )``` 32 | 33 | ![](https://cdn.jsdelivr.net/gh/yanghaoi/enable-rdp/images/enable.png) 34 | 35 | 36 | ## reference 37 | 38 | https://blog.csdn.net/PeterZ1997/article/details/79953992 39 | 40 | https://docs.microsoft.com/en-us/windows/win32/api/netfw/nn-netfw-inetfwrule 41 | 42 | https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoa 43 | 44 | https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-gettcptable 45 | 46 | https://docs.microsoft.com/en-us/windows/win32/api/netfw/nf-netfw-inetfwpolicy2-get_rules 47 | 48 | https://docs.microsoft.com/zh-cn/windows/win32/termserv/detecting-the-terminal-services-environment 49 | 50 | 51 | -------------------------------------------------------------------------------- /enablerdp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | // #include 8 | #pragma comment(lib, "Iphlpapi.lib") // IPHlpApi.h 9 | 10 | #define NET_FW_IP_PROTOCOL_TCP_NAME L"TCP" 11 | #define NET_FW_IP_PROTOCOL_UDP_NAME L"UDP" 12 | 13 | #define NET_FW_RULE_DIR_IN_NAME L"In" 14 | #define NET_FW_RULE_DIR_OUT_NAME L"Out" 15 | 16 | #define NET_FW_RULE_ACTION_BLOCK_NAME L"Block" 17 | #define NET_FW_RULE_ACTION_ALLOW_NAME L"Allow" 18 | 19 | #define NET_FW_RULE_ENABLE_IN_NAME L"TRUE" 20 | #define NET_FW_RULE_DISABLE_IN_NAME L"FALSE" 21 | 22 | #define TERMINAL_SERVER_KEY _T("SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\") 23 | #define GLASS_SESSION_ID _T("GlassSessionId") 24 | 25 | // Forward declarations 26 | HRESULT WFCOMInitialize(INetFwPolicy2** ppNetFwPolicy2); 27 | 28 | // 对于当前活动的防火墙配置文件,显示防火墙是打开还是关闭 29 | HRESULT GetCurrentFirewallState(__in INetFwPolicy2* pNetFwPolicy2) 30 | { 31 | HRESULT hr = S_FALSE; 32 | long CurrentProfilesBitMask = 0; 33 | VARIANT_BOOL bActualFirewallEnabled = VARIANT_FALSE; 34 | struct ProfileMapElement 35 | { 36 | NET_FW_PROFILE_TYPE2 Id; 37 | LPCWSTR Name; 38 | }; 39 | ProfileMapElement ProfileMap[3]; 40 | ProfileMap[0].Id = NET_FW_PROFILE2_DOMAIN; 41 | ProfileMap[0].Name = L"Domain"; 42 | ProfileMap[1].Id = NET_FW_PROFILE2_PRIVATE; 43 | ProfileMap[1].Name = L"Private"; 44 | ProfileMap[2].Id = NET_FW_PROFILE2_PUBLIC; 45 | ProfileMap[2].Name = L"Public"; 46 | 47 | hr = pNetFwPolicy2->get_CurrentProfileTypes(&CurrentProfilesBitMask); 48 | if (FAILED(hr)) 49 | { 50 | wprintf(L"[-] Failed to get CurrentProfileTypes. Error: %x.\n", hr); 51 | goto CLEANUP; 52 | } 53 | for (int i = 0; i < 3; i++) 54 | { 55 | if (CurrentProfilesBitMask & ProfileMap[i].Id) 56 | { 57 | hr = pNetFwPolicy2->get_FirewallEnabled(ProfileMap[i].Id, &bActualFirewallEnabled); 58 | if (FAILED(hr)) 59 | { 60 | wprintf(L"[-] Failed to get FirewallEnabled settings for %s profile. Error: %x.\n", ProfileMap[i].Name, hr); 61 | goto CLEANUP; 62 | } 63 | 64 | if (bActualFirewallEnabled) { 65 | wprintf(L"[*] On %s profile (Current) : Firewall state is %s\n", ProfileMap[i].Name, (bActualFirewallEnabled ? L"ON" : L"OFF")); 66 | return 4; 67 | } 68 | else { 69 | wprintf(L"[*] On %s profile (Current) : Firewall state is %s\n", ProfileMap[i].Name, (bActualFirewallEnabled ? L"ON" : L"OFF")); 70 | return 3; 71 | } 72 | } 73 | } 74 | CLEANUP: 75 | return hr; 76 | } 77 | 78 | /// 79 | /// 检查防火墙规则组是否启用 80 | /// 81 | /// 82 | /// 83 | /// 84 | HRESULT IsRuleGroupEnabled(__in INetFwPolicy2* pNetFwPolicy2, wchar_t* RuleGroup) 85 | { 86 | 87 | HRESULT hr = S_OK; 88 | VARIANT_BOOL bActualEnabled = VARIANT_FALSE; 89 | 90 | BSTR GroupName = SysAllocString(RuleGroup); 91 | if (NULL == GroupName) 92 | { 93 | wprintf(L"[-] ERROR: Insufficient memory\n"); 94 | goto Cleanup; 95 | } 96 | 97 | // 检测规则组是否在专用配置和公用配置中启用 98 | hr = pNetFwPolicy2->IsRuleGroupEnabled(NET_FW_PROFILE2_PRIVATE | NET_FW_PROFILE2_PUBLIC, GroupName, &bActualEnabled); 99 | 100 | if (SUCCEEDED(hr)) 101 | { 102 | if (VARIANT_TRUE == bActualEnabled && S_OK == hr) 103 | { 104 | wprintf(L"[+] Rule Group currently enabled on both public and private profiles\n"); 105 | } 106 | else if (VARIANT_TRUE == bActualEnabled && S_FALSE == hr) 107 | { 108 | wprintf(L"[+] Rule Group currently enabled on either public or private profile but not both\n"); 109 | } 110 | else if (VARIANT_FALSE == bActualEnabled) 111 | { 112 | wprintf(L"[-] Rule Group currently disabled on both public and private profiles\n"); 113 | } 114 | } 115 | else 116 | { 117 | wprintf(L"[-] Failed calling API IsRuleGroupCurrentlyEnabled. Error: 0x %x.\n", hr); 118 | goto Cleanup; 119 | } 120 | Cleanup: 121 | SysFreeString(GroupName); 122 | return hr; 123 | } 124 | 125 | /// 126 | /// 检查防火墙状态 127 | /// 128 | /// TRUE:开启,FLASE:关闭 129 | BOOL CheckFireWallState() { 130 | int res = 0; 131 | HRESULT hr = S_OK; 132 | HRESULT hrComInit = S_OK; 133 | INetFwPolicy2* pNetFwPolicy2 = NULL; 134 | // Initialize COM. 135 | hrComInit = CoInitializeEx( 136 | 0, 137 | COINIT_APARTMENTTHREADED 138 | ); 139 | 140 | // Ignore RPC_E_CHANGED_MODE; this just means that COM has already been 141 | // initialized with a different mode. Since we don't care what the mode is, 142 | // we'll just use the existing mode. 143 | if (hrComInit != RPC_E_CHANGED_MODE) 144 | { 145 | if (FAILED(hrComInit)) 146 | { 147 | printf("CoInitializeEx failed: 0x%08lx\n", hrComInit); 148 | goto Cleanup; 149 | } 150 | } 151 | 152 | // Retrieve INetFwPolicy2 153 | hr = WFCOMInitialize(&pNetFwPolicy2); 154 | if (FAILED(hr)) 155 | { 156 | goto Cleanup; 157 | } 158 | // 检查是否开启了防火墙 159 | res = GetCurrentFirewallState(pNetFwPolicy2); 160 | if (res == 3) { 161 | // 防火墙关闭 162 | goto Cleanup; 163 | } 164 | if (pNetFwPolicy2 != NULL) 165 | { 166 | pNetFwPolicy2->Release(); 167 | } 168 | return TRUE; 169 | Cleanup: 170 | // Release the INetFwPolicy2 object 171 | if (pNetFwPolicy2 != NULL) 172 | { 173 | pNetFwPolicy2->Release(); 174 | } 175 | return FALSE; 176 | } 177 | 178 | /// 179 | /// 设置防火墙规则 180 | /// 181 | /// 182 | /// 183 | BOOL __cdecl SetFireWall(int P = NULL) 184 | { 185 | HRESULT hrComInit = S_OK; 186 | HRESULT hr = S_OK; 187 | int port = 0; 188 | int res = 0; 189 | long index = 0; 190 | SAFEARRAY* pSa = NULL; 191 | INetFwPolicy2* pNetFwPolicy2 = NULL; 192 | INetFwRules* pFwRules = NULL; 193 | INetFwRule* pFwRule = NULL; 194 | if (P != NULL) { 195 | port = P; 196 | } 197 | else { 198 | return FALSE; 199 | } 200 | 201 | // 规则名称 202 | wchar_t RuleName[200] = L""; 203 | // 规则描述 204 | wchar_t RuleDescription[200] = L""; 205 | // 规则组名 206 | wchar_t RuleGroup[100] = L""; 207 | // 规则端口 208 | wchar_t RuleLPorts[11] = L""; 209 | 210 | swprintf(RuleName, 200, L"远程桌面 - RemoteFX (TCP-In) -Remote"); 211 | swprintf(RuleDescription, 200, L"用于远程桌面服务的入站规则,以允许 RDP 通信。[TCP %d]", port); 212 | swprintf(RuleGroup, 100, L"远程桌面"); 213 | swprintf(RuleLPorts, 11, L"%d", port); 214 | 215 | BSTR bstrRuleName = SysAllocString(RuleName); 216 | BSTR bstrRuleDescription = SysAllocString(RuleDescription); 217 | BSTR bstrRuleGroup = SysAllocString(RuleGroup); 218 | BSTR bstrRuleLPorts = SysAllocString(RuleLPorts); 219 | 220 | // Error checking for BSTR allocations 221 | if (NULL == bstrRuleName) { printf("Failed to allocate bstrRuleName\n"); goto Cleanup; } 222 | if (NULL == bstrRuleDescription) { printf("Failed to allocate bstrRuleDescription\n"); goto Cleanup; } 223 | if (NULL == bstrRuleGroup) { printf("Failed to allocate bstrRuleGroup\n"); goto Cleanup; } 224 | if (NULL == bstrRuleLPorts) { printf("Failed to allocate bstrRuleLPorts\n"); goto Cleanup; } 225 | 226 | // Initialize COM. 227 | hrComInit = CoInitializeEx( 228 | 0, 229 | COINIT_APARTMENTTHREADED 230 | ); 231 | 232 | // Ignore RPC_E_CHANGED_MODE; this just means that COM has already been 233 | // initialized with a different mode. Since we don't care what the mode is, 234 | // we'll just use the existing mode. 235 | if (hrComInit != RPC_E_CHANGED_MODE) 236 | { 237 | if (FAILED(hrComInit)) 238 | { 239 | printf("CoInitializeEx failed: 0x%08lx\n", hrComInit); 240 | goto Cleanup; 241 | } 242 | } 243 | 244 | // Retrieve INetFwPolicy2 245 | hr = WFCOMInitialize(&pNetFwPolicy2); 246 | if (FAILED(hr)) 247 | { 248 | goto Cleanup; 249 | } 250 | 251 | // 检查是否开启了防火墙 252 | res = GetCurrentFirewallState(pNetFwPolicy2); 253 | if (3 == res) { 254 | goto Cleanup; 255 | } 256 | else if (4 == res) { 257 | printf("[*] Add Firewall Exception Rule For Port %d.\n", P); 258 | } 259 | 260 | // Retrieve INetFwRules - https://docs.microsoft.com/en-us/windows/win32/api/netfw/nf-netfw-inetfwpolicy2-get_rules 261 | hr = pNetFwPolicy2->get_Rules(&pFwRules); 262 | if (FAILED(hr)) 263 | { 264 | printf("get_Rules failed: 0x%08lx\n", hr); 265 | goto Cleanup; 266 | } 267 | 268 | // 先清理掉之前开放的规则 269 | hr = pFwRules->Remove(bstrRuleName); 270 | if (FAILED(hr)) 271 | { 272 | printf("[-] Firewall Rule Remove failed: 0x%08lx\n", hr); 273 | goto Cleanup; 274 | } 275 | else { 276 | printf("[+] Firewall Rule Remove succeeded.\n"); 277 | } 278 | 279 | // Create a new Firewall Rule object. 280 | hr = CoCreateInstance( 281 | __uuidof(NetFwRule), 282 | NULL, 283 | CLSCTX_INPROC_SERVER, 284 | __uuidof(INetFwRule), 285 | (void**)&pFwRule); 286 | if (FAILED(hr)) 287 | { 288 | printf("CoCreateInstance for Firewall Rule failed: 0x%08lx\n", hr); 289 | goto Cleanup; 290 | } 291 | 292 | // INetFwRule接口 293 | // Populate the Firewall Rule object https://docs.microsoft.com/en-us/windows/win32/api/netfw/nn-netfw-inetfwrule 294 | hr = pFwRule->put_Name(bstrRuleName); 295 | if (FAILED(hr)) 296 | { 297 | printf("put_Name failed: 0x%08lx\n", hr); 298 | goto Cleanup; 299 | } 300 | 301 | // Populate the Firewall Rule Description 302 | hr = pFwRule->put_Description(bstrRuleDescription); 303 | if (FAILED(hr)) 304 | { 305 | printf("put_Description failed: 0x%08lx\n", hr); 306 | goto Cleanup; 307 | } 308 | 309 | // Populate the Firewall Rule Protocol 310 | hr = pFwRule->put_Protocol(NET_FW_IP_PROTOCOL_TCP); 311 | if (FAILED(hr)) 312 | { 313 | printf("put_Protocol failed: 0x%08lx\n", hr); 314 | goto Cleanup; 315 | } 316 | 317 | hr = pFwRule->put_Enabled(VARIANT_TRUE); 318 | if (FAILED(hr)) 319 | { 320 | printf("put_Enabled failed: 0x%08lx\n", hr); 321 | goto Cleanup; 322 | } 323 | 324 | // pFwRule->put_Profiles(CurrentProfilesBitMask); 325 | hr = pFwRule->put_Profiles(NET_FW_PROFILE2_ALL); // 对所有配置文件生效 326 | if (FAILED(hr)) 327 | { 328 | printf("put_Profiles failed: 0x%08lx\n", hr); 329 | goto Cleanup; 330 | } 331 | 332 | // Populate the Firewall Rule Group 333 | hr = pFwRule->put_Grouping(bstrRuleGroup); // 指定单个规则所属的组。 334 | if (FAILED(hr)) 335 | { 336 | printf("put_Grouping failed: 0x%08lx\n", hr); 337 | goto Cleanup; 338 | } 339 | 340 | hr = pFwRule->put_Protocol(NET_FW_IP_PROTOCOL_TCP); 341 | if (FAILED(hr)) 342 | { 343 | printf("put_Protocol failed: 0x%08lx\n", hr); 344 | goto Cleanup; 345 | } 346 | 347 | // Populate the Firewall Rule Local Ports 348 | hr = pFwRule->put_LocalPorts(bstrRuleLPorts); // 指定此规则的本地端口列表。 349 | if (FAILED(hr)) 350 | { 351 | printf("put_LocalPorts failed: 0x%08lx\n", hr); 352 | goto Cleanup; 353 | } 354 | 355 | hr = pFwRule->put_Action(NET_FW_ACTION_ALLOW); 356 | if (FAILED(hr)) 357 | { 358 | printf("put_Action failed: 0x%08lx\n", hr); 359 | goto Cleanup; 360 | } 361 | 362 | // Add the Firewall Rule 363 | hr = pFwRules->Add(pFwRule); 364 | if (FAILED(hr)) 365 | { 366 | printf("[-] Firewall Rule Add failed: 0x%08lx\n", hr); 367 | goto Cleanup; 368 | } 369 | else { 370 | printf("[+] Firewall Rule Add succeeded.\n"); 371 | } 372 | Sleep(1000); 373 | // 检查我们的组是否启用成功 374 | IsRuleGroupEnabled(pNetFwPolicy2, RuleGroup); 375 | return TRUE; 376 | 377 | Cleanup: 378 | 379 | // Free BSTR's 380 | SysFreeString(bstrRuleName); 381 | SysFreeString(bstrRuleDescription); 382 | SysFreeString(bstrRuleGroup); 383 | SysFreeString(bstrRuleLPorts); 384 | 385 | // Release the INetFwRule object 386 | if (pFwRule != NULL) 387 | { 388 | pFwRule->Release(); 389 | } 390 | 391 | // Release the INetFwRules object 392 | if (pFwRules != NULL) 393 | { 394 | pFwRules->Release(); 395 | } 396 | 397 | // Release the INetFwPolicy2 object 398 | if (pNetFwPolicy2 != NULL) 399 | { 400 | pNetFwPolicy2->Release(); 401 | } 402 | 403 | // Uninitialize COM. 404 | if (SUCCEEDED(hrComInit)) 405 | { 406 | CoUninitialize(); 407 | } 408 | 409 | return FALSE; 410 | } 411 | 412 | // Instantiate INetFwPolicy2 413 | HRESULT WFCOMInitialize(INetFwPolicy2** ppNetFwPolicy2) 414 | { 415 | HRESULT hr = S_OK; 416 | 417 | hr = CoCreateInstance( 418 | __uuidof(NetFwPolicy2), 419 | NULL, 420 | CLSCTX_INPROC_SERVER, 421 | __uuidof(INetFwPolicy2), 422 | (void**)ppNetFwPolicy2); 423 | 424 | if (FAILED(hr)) 425 | { 426 | printf("CoCreateInstance for INetFwPolicy2 failed: 0x%08lx\n", hr); 427 | goto Cleanup; 428 | } 429 | 430 | Cleanup: 431 | return hr; 432 | } 433 | 434 | // https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-gettcptable 435 | // 获取Tcp端口状态 436 | BOOL GetTcpPortState(ULONG nPort) 437 | { 438 | MIB_TCPTABLE TcpTable[200]; 439 | DWORD nSize = sizeof(TcpTable); 440 | if (NO_ERROR == GetTcpTable(&TcpTable[0], &nSize, TRUE)) 441 | { 442 | DWORD nCount = TcpTable[0].dwNumEntries; 443 | if (nCount > 0) 444 | { 445 | for (DWORD i = 0; i < nCount; i++) 446 | { 447 | MIB_TCPROW TcpRow = TcpTable[0].table[i]; 448 | DWORD temp1 = TcpRow.dwLocalPort; 449 | int temp2 = temp1 / 256 + (temp1 % 256) * 256; 450 | if (temp2 == nPort) 451 | { 452 | return TRUE; 453 | } 454 | } 455 | } 456 | return FALSE; 457 | } 458 | else { 459 | printf("[-] GetTcpTable\n"); 460 | } 461 | return FALSE; 462 | } 463 | 464 | //获取Udp端口状态 465 | BOOL GetUdpPortState(ULONG nPort) 466 | { 467 | MIB_UDPTABLE UdpTable[100]; 468 | DWORD nSize = sizeof(UdpTable); 469 | if (NO_ERROR == GetUdpTable(&UdpTable[0], &nSize, TRUE)) 470 | { 471 | DWORD nCount = UdpTable[0].dwNumEntries; 472 | if (nCount > 0) 473 | { 474 | for (DWORD i = 0; i < nCount; i++) 475 | { 476 | MIB_UDPROW TcpRow = UdpTable[0].table[i]; 477 | DWORD temp1 = TcpRow.dwLocalPort; 478 | int temp2 = temp1 / 256 + (temp1 % 256) * 256; 479 | if (temp2 == nPort) 480 | { 481 | return TRUE; 482 | } 483 | } 484 | } 485 | return FALSE; 486 | } 487 | return FALSE; 488 | } 489 | 490 | 491 | //封装字符型注册表操作 492 | BOOL setStringValueToReg(HKEY hRoot, const char* szSubKey, const char* szValueName, const char* szValue) 493 | { 494 | HKEY hKey; 495 | long lRet; 496 | if (lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL)) return false; 497 | if (lRet = RegSetValueEx(hKey, szValueName, 0, REG_SZ, (BYTE*)szValue, strlen(szValue))) return false; 498 | RegCloseKey(hKey); 499 | RegCloseKey(hRoot); 500 | return true; 501 | } 502 | 503 | //封装数值型(DWORD)注册表操作 504 | BOOL setDWORDValueToReg(HKEY hRoot, const char* szSubKey, const char* szValueName, DWORD szValue) 505 | { 506 | HKEY hKey; 507 | long lRet; 508 | if (lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL)) return false; 509 | if (lRet = RegSetValueEx(hKey, szValueName, 0, REG_DWORD, (BYTE*)&szValue, sizeof(DWORD))) return false; 510 | RegCloseKey(hKey); 511 | RegCloseKey(hRoot); 512 | return true; 513 | } 514 | 515 | //封装数值型(DWORD)注册表查询 516 | DWORD getDWORDValueToReg(HKEY hRoot, const char* szSubKey, const char* szValueName) 517 | { 518 | DWORD GetValue = 0; 519 | DWORD dataSize = sizeof(GetValue); 520 | HKEY hKey = NULL; 521 | DWORD lResult = 0; 522 | lResult = RegOpenKeyExA(hRoot, szSubKey, 0, KEY_ALL_ACCESS, &hKey); 523 | if (ERROR_SUCCESS != lResult) { 524 | if (lResult == ERROR_FILE_NOT_FOUND) { 525 | printf("[-] Key %s not found.\n", szSubKey); 526 | } 527 | else { 528 | printf("[-] RegOpenKeyExA failed (%d)\n", lResult); 529 | } 530 | return FALSE; 531 | } 532 | 533 | lResult = RegGetValueA(hKey, NULL, szValueName, RRF_RT_REG_DWORD, NULL, &GetValue, &dataSize); 534 | switch (lResult) { 535 | case ERROR_SUCCESS: { 536 | printf("[*] RegGet %s is %d\n", szValueName, GetValue); 537 | break; 538 | } 539 | case ERROR_MORE_DATA: { 540 | printf("[-] %s 缓冲区太小\n", szValueName); 541 | break; 542 | } 543 | case ERROR_FILE_NOT_FOUND: { 544 | printf("[-] %s 注册表值不存在\n", szValueName); 545 | break; 546 | } 547 | default: 548 | { 549 | printf("[-] RegQueryValueEx failed (%d)\n", lResult); 550 | break; 551 | } 552 | } 553 | RegCloseKey(hKey); 554 | return GetValue; 555 | } 556 | 557 | /// 558 | /// 启用RDP 559 | /// 560 | /// 561 | /// 562 | /// 563 | /// 564 | /// 565 | BOOL SetReg(DWORD PORT, BOOL EnableSta = FALSE, BOOL ChangeBind = FALSE, BOOL WIN2000 = FALSE) 566 | { 567 | DWORD GetPort = 0; 568 | DWORD dataSize = sizeof(GetPort); 569 | 570 | // 查询端口 571 | GetPort = getDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "PortNumber"); 572 | 573 | if (GetPort == PORT) { 574 | printf("[!] New Port is equal to Old Port\n"); 575 | } 576 | 577 | //是否改变端口 578 | if (ChangeBind) { 579 | // 修改RDP监听端口,先关闭RDP功能 - WIN7 - WIN 2008 - WIN10 580 | // 指定启用远程桌面连接。 581 | // true 指定拒绝远程桌面连接。 这是默认值。 582 | // false 指定启用远程桌面连接。 583 | // set fDenyTSConnections = 1 拒绝连接 584 | if (setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", "fDenyTSConnections", 0x00000001)) { 585 | printf("[*] Set fDenyTSConnections = 1\n"); 586 | } 587 | if (setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "fEnableWinStation", 0x00000000)) { 588 | printf("[*] Set fEnableWinStation = 0\n"); 589 | } 590 | 591 | int count = 0; 592 | printf("[*] Wait for port %d release...\n", GetPort); 593 | do { 594 | Sleep(500); 595 | count += 1; 596 | if (count > 40) { 597 | printf("[-] Port release faied.\n"); 598 | break; 599 | } 600 | } while (GetTcpPortState(GetPort)); 601 | if (count > 40) { 602 | return FALSE; 603 | } 604 | printf("[+] RDP Port %d Release succeeded!\n\n", GetPort); 605 | 606 | //设置端口 WIN7 - WIN 2008 - WIN10 607 | if (setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "PortNumber", PORT)) { 608 | printf("[+] Set PortNumber = %d\n", PORT); 609 | } 610 | 611 | // 端口设置完成后 启用远程桌面连接 612 | if (setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", "fDenyTSConnections", 0x00000000)) { 613 | printf("[*] Set fDenyTSConnections = 0\n"); 614 | } 615 | if (setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "fEnableWinStation", 0x00000001)) { 616 | printf("[*] Set fEnableWinStation = 1\n"); 617 | } 618 | count = 0; 619 | printf("[*] Wait for port %d Bind...\n", PORT); 620 | do { 621 | Sleep(500); 622 | count += 1; 623 | if (count > 60) { 624 | printf("[-] Port Bind faied.\n"); 625 | break; 626 | } 627 | } while (!GetTcpPortState(PORT)); 628 | if (count > 60) { 629 | return FALSE; 630 | } 631 | else { 632 | printf("[+] RDP Change Port succeeded!\n"); 633 | } 634 | } 635 | // 仅设置注册表启用RDP 636 | else if (EnableSta) { 637 | if (!setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", "fDenyTSConnections", 0x00000000) || !setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "fEnableWinStation", 0x00000001)) { 638 | printf("[-] Set fDenyTSConnections Or fEnableWinStation faied.\n"); 639 | return FALSE; 640 | } 641 | else { 642 | printf("[+] Set fDenyTSConnections And fEnableWinStation succeeded!\n"); 643 | } 644 | } 645 | else if (WIN2000) { 646 | // 低版本、非主流版本等 647 | // 修改端口- WIN2008-NOT-没用到的注册表项,功能待测试。 648 | // setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\Wds\\rdpwd\\Tds\\tcp", "PortNumber", PORT); 649 | 650 | // Set PortNumber 651 | // 修改端口- 这个配置没找到对应的主机版本 652 | // setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\RDPTcp", "PortNumber", PORT); 653 | 654 | /*win2000*/ 655 | //重新初始化脱机文件缓存和数据库 656 | if (!setStringValueToReg(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\netcache", "Enabled", "0")) { 657 | printf("[-] Set Enabled faied \n "); 658 | } 659 | 660 | //ShutdownWithoutLogon,1:用户可无需登录关闭系统,0 登录界面不显示关闭按钮 661 | if (!setStringValueToReg(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "ShutdownWithoutLogon", "0")) { 662 | printf("[-] Set ShutdownWithoutLogon faied \n "); 663 | } 664 | 665 | //启用管理员连接 666 | if (!setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SOFTWARE\\Policies\\Microsoft\\Windows\\Installer", "EnableAdminTSRemote", 0x00000001)) { 667 | printf("[-] Set EnableAdminTSRemote faied \n "); 668 | } 669 | 670 | //启用服务 ,在启动模式下设置终端服务 671 | if (!setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", "TSEnabled", 0x00000001)) { 672 | printf("[-] Set TSEnabled faied \n "); 673 | }; 674 | 675 | if (!setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\TermDD", "Start", 0x00000002)) { 676 | printf("[-] Set Start faied \n "); 677 | } 678 | 679 | if (!setDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\TermService", "Start", 0x00000002)) { 680 | printf("[-] Set TermService-Start faied\n "); 681 | } 682 | if (!setStringValueToReg(HKEY_USERS, ".DEFAULT\\Keyboard Layout\\Toggle", "Hotkey", "2")) { 683 | printf("[-] Set Toggle-Hotkey faied\n "); 684 | } 685 | printf("[*] All Reg Value Set Done.\n"); 686 | } 687 | return TRUE; 688 | } 689 | 690 | BOOL GetWinVersion() { 691 | // NTSTATUS 也是Long类型。 WINAPI* , __stdcall* 都是来声明函数指针的,指向后面这个结构体指针 692 | // static NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW); 693 | 694 | // 声明一个__stdcall函数指针, LP - OSVERSIONINFOEXW 长整型指针 // Nt**、Zw**和Rtl** 开头表示未公开 695 | typedef LONG(__stdcall* lpRtlGetVersion)(LPOSVERSIONINFOEXW); 696 | 697 | BOOL Sup = FALSE; 698 | 699 | lpRtlGetVersion RtlGetVersion = NULL; 700 | OSVERSIONINFOEXW OSInfo = { sizeof(OSVERSIONINFOEXW), 0, 0, 0, 0,{ 0 } }; 701 | LPCTSTR lpszMajorName = NULL; 702 | DWORD dwPlatformId = 0; 703 | DWORD dwMajorVersion = 0; 704 | DWORD dwMinorVersion = 0; 705 | DWORD dwBuildNumber = 0; 706 | 707 | BYTE wProductType = NULL; 708 | WCHAR* szCSDVersion = NULL; 709 | WORD wServicePackMajor = NULL; 710 | WORD wServicePackMinor = NULL; 711 | 712 | // Get ntdll.dll 713 | HMODULE ntdll = GetModuleHandle("ntdll.dll"); 714 | if (!ntdll) 715 | { 716 | return FALSE; 717 | } 718 | // *(FARPROC*)&RtlGetVersion = GetProcAddress(hNtDll, "RtlGetVersion"); 719 | 720 | RtlGetVersion = (lpRtlGetVersion)GetProcAddress(ntdll, "RtlGetVersion"); 721 | if (RtlGetVersion == NULL) { 722 | return FALSE; 723 | } 724 | 725 | NTSTATUS ntStatus = RtlGetVersion(&OSInfo); 726 | if (ntStatus != 0) { 727 | return FALSE; 728 | } 729 | 730 | dwPlatformId = OSInfo.dwPlatformId; // 系统支持的平台 731 | dwMajorVersion = OSInfo.dwMajorVersion; // 主要版本 732 | dwMinorVersion = OSInfo.dwMinorVersion; // 次要版本 733 | dwBuildNumber = OSInfo.dwBuildNumber; // 构建版本号 734 | 735 | // 标识系统类型 https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoa 736 | wProductType = OSInfo.wProductType; 737 | 738 | szCSDVersion = OSInfo.szCSDVersion; // 系统补丁包的名称 739 | wServicePackMajor = OSInfo.wServicePackMajor; // 系统补丁包的主版本 740 | wServicePackMinor = OSInfo.wServicePackMinor; // 系统补丁包的主版本 741 | 742 | switch (dwPlatformId) 743 | { 744 | case VER_PLATFORM_WIN32_NT: 745 | switch (dwMajorVersion) 746 | { 747 | 748 | case 5: 749 | if (dwMinorVersion == 0) { 750 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "2000" : "2000 Server"; 751 | } 752 | else { 753 | if (dwMinorVersion == 1) { 754 | lpszMajorName = "XP"; 755 | } 756 | else { 757 | if (dwMinorVersion == 2) { 758 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "XP x64" : "Server 2003"; 759 | } 760 | } 761 | } 762 | break; 763 | case 6: 764 | if (dwMinorVersion == 0) { 765 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "Vista" : "Server 2008"; 766 | } 767 | else 768 | if (dwMinorVersion == 1) { 769 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "7" : "Server 2008 R2"; 770 | } 771 | else 772 | if (dwMinorVersion == 2) { 773 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "8" : "Server 2012"; 774 | } 775 | else 776 | if (dwMinorVersion == 3) 777 | { 778 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "8.1" : "Server 2012 R2"; 779 | } 780 | break; 781 | case 10: 782 | if (dwMinorVersion == 0) { 783 | lpszMajorName = (VER_NT_WORKSTATION == wProductType) ? "10" : "Server 2016"; \ 784 | } 785 | break; 786 | default: 787 | break; 788 | } 789 | printf("[+] Version:"); 790 | if (!lpszMajorName) 791 | { 792 | if (wServicePackMajor) 793 | printf("Windows %u.%u.%u, SP %u", dwMajorVersion, dwMinorVersion, dwBuildNumber, wServicePackMajor); 794 | else 795 | printf("Windows %u.%u.%u", dwMajorVersion, dwMinorVersion, dwBuildNumber); 796 | } 797 | else 798 | { 799 | if (wServicePackMajor) 800 | printf("Windows %s [%u.%u.%u] - SP %u", lpszMajorName, dwMajorVersion, dwMinorVersion, dwBuildNumber, wServicePackMajor); 801 | else 802 | printf("Windows %s [%u.%u.%u]", lpszMajorName, dwMajorVersion, dwMinorVersion, dwBuildNumber); 803 | } 804 | if (szCSDVersion[0]) 805 | { 806 | printf("(%ls)", szCSDVersion); 807 | } 808 | break; 809 | 810 | default: 811 | { 812 | printf("", dwPlatformId); 813 | } 814 | break; 815 | } 816 | printf("\n"); 817 | 818 | // 检查版本类型,然后排除不支持的系统 :) 819 | const char* edition = ""; 820 | DWORD ed; 821 | if (GetProductInfo(dwMajorVersion, dwMinorVersion, wServicePackMajor, wServicePackMinor, &ed)) 822 | { 823 | printf("[*] PRODUCT_PROFESSIONAL: %d \n", ed); 824 | switch (ed) 825 | { 826 | case PRODUCT_ULTIMATE: 827 | { 828 | Sup = TRUE; 829 | edition = "Ultimate"; //旗舰版 830 | break; 831 | } 832 | case PRODUCT_BUSINESS: 833 | { 834 | Sup = TRUE; 835 | edition = "Business"; 836 | break; 837 | } 838 | case PRODUCT_BUSINESS_N: 839 | { 840 | Sup = TRUE; 841 | edition = "Business N"; 842 | break; 843 | } 844 | case PRODUCT_PROFESSIONAL: 845 | { 846 | Sup = TRUE; 847 | edition = "Windows 10 Pro"; 848 | break; 849 | } 850 | case PRODUCT_PRO_WORKSTATION: 851 | { 852 | Sup = TRUE; 853 | edition = "Pro for Workstations"; 854 | break; 855 | } 856 | case PRODUCT_PRO_WORKSTATION_N: 857 | { 858 | Sup = TRUE; 859 | edition = "Windows 10 Pro for Workstations N"; 860 | break; 861 | } 862 | 863 | case PRODUCT_PROFESSIONAL_E: 864 | { 865 | edition = "Not supported"; 866 | break; 867 | } 868 | case PRODUCT_PROFESSIONAL_N: 869 | { 870 | Sup = TRUE; 871 | edition = "Windows 10 Pro N"; 872 | break; 873 | } 874 | case PRODUCT_UNDEFINED: 875 | { 876 | edition = "An unknown product"; 877 | break; 878 | } 879 | case PRODUCT_EDUCATION: 880 | { 881 | Sup = TRUE; 882 | edition = "Windows 10 Education"; 883 | break; 884 | } 885 | 886 | case PRODUCT_EDUCATION_N: { 887 | Sup = TRUE; 888 | edition = "Windows 10 Education N"; 889 | break; 890 | } 891 | case PRODUCT_ENTERPRISE: 892 | { 893 | Sup = TRUE; 894 | edition = "Windows 10 Enterprise"; 895 | break; 896 | } 897 | case PRODUCT_ENTERPRISE_E: 898 | { 899 | Sup = TRUE; 900 | edition = "Windows 10 Enterprise E"; 901 | break; 902 | } 903 | case PRODUCT_ENTERPRISE_EVALUATION: 904 | { 905 | Sup = TRUE; 906 | edition = "Windows 10 Enterprise Evaluation"; 907 | break; 908 | } 909 | case PRODUCT_ENTERPRISE_N: 910 | { 911 | Sup = TRUE; 912 | edition = "Windows 10 Enterprise N"; 913 | break; 914 | } 915 | case PRODUCT_ENTERPRISE_N_EVALUATION: 916 | { 917 | Sup = TRUE; 918 | edition = "Windows 10 Enterprise N Evaluation"; 919 | break; 920 | } 921 | case PRODUCT_ENTERPRISE_S: 922 | { 923 | Sup = TRUE; 924 | edition = "Windows 10 Enterprise 2015 LTSB"; 925 | break; 926 | } 927 | case PRODUCT_ENTERPRISE_S_EVALUATION: 928 | { 929 | Sup = TRUE; 930 | edition = "Windows 10 Enterprise 2015 LTSB Evaluation"; 931 | break; 932 | } 933 | case PRODUCT_ENTERPRISE_S_N: 934 | { 935 | Sup = TRUE; 936 | edition = "Windows 10 Enterprise 2015 LTSB N"; 937 | break; 938 | } 939 | case PRODUCT_ENTERPRISE_S_N_EVALUATION: 940 | { 941 | Sup = TRUE; 942 | edition = "Windows 10 Enterprise 2015 LTSB N Evaluation"; 943 | break; 944 | } 945 | case PRODUCT_HOME_BASIC: 946 | { 947 | edition = "Home Basic"; 948 | break; 949 | } 950 | case PRODUCT_HOME_BASIC_E: 951 | { 952 | edition = "Not supported"; 953 | break; 954 | } 955 | case PRODUCT_HOME_BASIC_N: 956 | { 957 | edition = "Home Basic N"; 958 | break; 959 | } 960 | case PRODUCT_HOME_PREMIUM: 961 | { 962 | edition = "Home Premium"; 963 | break; 964 | } 965 | case PRODUCT_HOME_PREMIUM_E: 966 | { 967 | edition = "Not supported"; 968 | break; 969 | } 970 | 971 | case PRODUCT_CORE: 972 | { 973 | edition = "Windows 10 Home"; 974 | break; 975 | } 976 | case PRODUCT_CORE_COUNTRYSPECIFIC: 977 | { 978 | edition = "Windows 10 Home China"; 979 | break; 980 | } 981 | case PRODUCT_CORE_N: 982 | { 983 | edition = "Windows 10 Home N"; 984 | break; 985 | } 986 | case PRODUCT_CORE_SINGLELANGUAGE: 987 | { 988 | edition = "Windows 10 Home Single Language"; 989 | break; 990 | } 991 | default: 992 | edition = "Unknown"; 993 | break; 994 | } 995 | printf("[+] Found edition: %s\n", edition); 996 | } 997 | return Sup; 998 | } 999 | 1000 | /// 1001 | /// 检查服务状态 1002 | /// 1003 | /// 1004 | BOOL CheckService() { 1005 | SC_HANDLE shSCManager = NULL, shService = NULL; 1006 | SERVICE_STATUS_PROCESS stat; 1007 | DWORD dwSize = 0; 1008 | DWORD dwLpqscSize = 0; 1009 | LPQUERY_SERVICE_CONFIGA lpServiceConfig = NULL; 1010 | DWORD needed = 0; 1011 | BOOL ret = TRUE; 1012 | shSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 1013 | shService = OpenService(shSCManager, "TermService", SERVICE_ALL_ACCESS); 1014 | if (!shService) 1015 | { 1016 | printf("[-] OpenService Failed \n"); 1017 | goto clean; 1018 | } 1019 | 1020 | ret = QueryServiceStatusEx(shService, SC_STATUS_PROCESS_INFO, 1021 | (BYTE*)&stat, sizeof stat, &needed); 1022 | if (ret == 0) { 1023 | printf("[-] QueryServiceStatusEx failed\n"); 1024 | goto clean; 1025 | } 1026 | 1027 | if (stat.dwCurrentState == SERVICE_RUNNING) { 1028 | printf("[+] TermService is running\n"); 1029 | } 1030 | else { 1031 | // 服务停止失败等情况 1032 | if (stat.dwCurrentState != SERVICE_STOPPED) { 1033 | printf("[-] TermService failed,CurrentState: %d \n ", stat.dwCurrentState); 1034 | } 1035 | else { printf("[-] TermService is NOT running\n"); } 1036 | return FALSE; 1037 | } 1038 | return TRUE; 1039 | 1040 | clean: 1041 | if (NULL != shSCManager) 1042 | CloseServiceHandle(shSCManager); 1043 | if (NULL != shService) 1044 | CloseServiceHandle(shService); 1045 | return FALSE; 1046 | } 1047 | 1048 | /// 1049 | /// 启动服务 1050 | /// 1051 | /// 1052 | BOOL NetStartServices() { 1053 | SC_HANDLE shSCManager = NULL, shService = NULL; 1054 | SERVICE_STATUS_PROCESS stat; 1055 | DWORD dwSize = 0; 1056 | DWORD dwLpqscSize = 0; 1057 | LPQUERY_SERVICE_CONFIGA lpServiceConfig = NULL; 1058 | DWORD needed = 0; 1059 | BOOL ret = TRUE; 1060 | shSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 1061 | shService = OpenService(shSCManager, "TermService", SERVICE_ALL_ACCESS); 1062 | if (!shService) 1063 | { 1064 | printf("[-] OpenService Failed \n"); 1065 | goto clean; 1066 | } 1067 | 1068 | ret = QueryServiceStatusEx(shService, SC_STATUS_PROCESS_INFO, 1069 | (BYTE*)&stat, sizeof stat, &needed); 1070 | if (ret == 0) { 1071 | printf("QueryServiceStatusEx failed\n"); 1072 | goto clean; 1073 | } 1074 | if (stat.dwCurrentState == SERVICE_RUNNING) { 1075 | printf("[+] TermService is running\n"); 1076 | } 1077 | else { 1078 | // 服务停止失败等情况 1079 | if (stat.dwCurrentState != SERVICE_STOPPED) { 1080 | printf("[-] TermService failed,CurrentState: %d \n ", stat.dwCurrentState); 1081 | return FALSE; 1082 | } 1083 | printf("[-] TermService is NOT running\n"); 1084 | 1085 | // 查询服务启动类型 1086 | if (!QueryServiceConfigA(shService, NULL, 0, &dwSize)) { 1087 | if (dwSize) { 1088 | // This part is not critical error will not stop the program 1089 | dwLpqscSize = dwSize; 1090 | printf("[*] LPQUERY_SERVICE_CONFIGA need 0x%08x bytes\n", dwLpqscSize); 1091 | lpServiceConfig = (LPQUERY_SERVICE_CONFIGA)GlobalAlloc(GPTR, dwSize); 1092 | if (lpServiceConfig == NULL) { 1093 | printf("[-] Out of memory"); 1094 | return FALSE; 1095 | } 1096 | if (QueryServiceConfigA(shService, lpServiceConfig, dwLpqscSize, &dwSize)) { 1097 | printf("[*] Start type: %d \n", lpServiceConfig->dwStartType); 1098 | if (lpServiceConfig->dwStartType == SERVICE_DISABLED) { 1099 | //设置服务为自启动 1100 | printf("[*] Try to ChangeServiceConfig\n"); 1101 | if (ChangeServiceConfig(shService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) { 1102 | printf("[+] ChangeServiceConfig succeeded\n"); 1103 | // Waiting for configuration to take effect 1104 | Sleep(500); 1105 | if (StartService(shService, 0, NULL)) { 1106 | printf("[+] Start TermService succeeded\n"); 1107 | } 1108 | else { 1109 | printf("[-] Start TermService failed (%d) \n", GetLastError()); 1110 | goto clean; 1111 | } 1112 | } 1113 | else { 1114 | printf("[-] ChangeServiceConfig failed (%d) \n", GetLastError()); 1115 | goto clean; 1116 | } 1117 | } 1118 | else { 1119 | //启动服务 1120 | printf("[*] Try to Start TermService\n"); 1121 | if (StartService(shService, 0, NULL)) { 1122 | printf("[+] Start TermService succeeded\n"); 1123 | } 1124 | else 1125 | { 1126 | printf("[-] Start TermService failed (%d) \n", GetLastError()); 1127 | goto clean; 1128 | } 1129 | } 1130 | } 1131 | else { printf("[-] QueryServiceConfigA failed\n"); goto clean; } 1132 | } 1133 | } 1134 | } 1135 | 1136 | if (NULL != shSCManager) 1137 | CloseServiceHandle(shSCManager); 1138 | if (NULL != shService) 1139 | CloseServiceHandle(shService); 1140 | return TRUE; 1141 | clean: 1142 | if (NULL != shSCManager) 1143 | CloseServiceHandle(shSCManager); 1144 | if (NULL != shService) 1145 | CloseServiceHandle(shService); 1146 | return FALSE; 1147 | } 1148 | 1149 | 1150 | /// 1151 | /// 检查一下注册表里有没有 TermService 服务 1152 | /// 1153 | /// 1154 | BOOL CheckTermServiceReg() { 1155 | HKEY hKey = NULL; 1156 | if (ERROR_SUCCESS != RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\TermService", 0, KEY_ALL_ACCESS, &hKey)) { 1157 | printf("[-] RegOpenKeyExA failed\n"); 1158 | return FALSE; 1159 | } 1160 | return TRUE; 1161 | } 1162 | 1163 | 1164 | /// 1165 | /// 检查当前会话是否已经在远程会话中 1166 | /// https://docs.microsoft.com/zh-cn/windows/win32/termserv/detecting-the-terminal-services-environment 1167 | /// 1168 | /// 1169 | BOOL IsCurrentSessionRemoteable() 1170 | { 1171 | BOOL fIsRemoteable = FALSE; 1172 | 1173 | if (GetSystemMetrics(SM_REMOTESESSION)) 1174 | { 1175 | fIsRemoteable = TRUE; 1176 | } 1177 | else 1178 | { 1179 | HKEY hRegKey = NULL; 1180 | LONG lResult; 1181 | 1182 | lResult = RegOpenKeyEx( 1183 | HKEY_LOCAL_MACHINE, 1184 | TERMINAL_SERVER_KEY, 1185 | 0, // ulOptions 1186 | KEY_READ, 1187 | &hRegKey 1188 | ); 1189 | 1190 | if (lResult == ERROR_SUCCESS) 1191 | { 1192 | DWORD dwGlassSessionId; 1193 | DWORD cbGlassSessionId = sizeof(dwGlassSessionId); 1194 | DWORD dwType; 1195 | 1196 | lResult = RegQueryValueEx( 1197 | hRegKey, 1198 | GLASS_SESSION_ID, 1199 | NULL, // lpReserved 1200 | &dwType, 1201 | (BYTE*)&dwGlassSessionId, 1202 | &cbGlassSessionId 1203 | ); 1204 | 1205 | if (lResult == ERROR_SUCCESS) 1206 | { 1207 | DWORD dwCurrentSessionId; 1208 | 1209 | if (ProcessIdToSessionId(GetCurrentProcessId(), &dwCurrentSessionId)) 1210 | { 1211 | fIsRemoteable = (dwCurrentSessionId != dwGlassSessionId); 1212 | } 1213 | } 1214 | } 1215 | 1216 | if (hRegKey) 1217 | { 1218 | RegCloseKey(hRegKey); 1219 | } 1220 | } 1221 | 1222 | return fIsRemoteable; 1223 | } 1224 | 1225 | 1226 | /// 1227 | /// 检查系统版本信息和RDP的注册表、服务设置、防火墙 情况 1228 | /// 1229 | /// 1230 | BOOL RdpInfoScan(BOOL IsOk = FALSE) { 1231 | printf("[*] System information Scan...\n"); 1232 | if (IsCurrentSessionRemoteable()) { 1233 | printf("[!] Your are in RDP Session!\n"); 1234 | } 1235 | 1236 | //检查是不是服务器版, 该函数支持 >= win2008 ; 1237 | if (IsWindowsServer()) { 1238 | printf("[*] Is Windows Server\n"); 1239 | } 1240 | else { 1241 | // 不是服务器就检查是否是支持RDP的版本 1242 | if (GetWinVersion()) { 1243 | printf("[+] Your OS edition support RDP.\n"); 1244 | } 1245 | else { 1246 | // 不支持 1247 | printf("[-] Your OS edition does not support RDP.\n"); 1248 | return FALSE; 1249 | } 1250 | } 1251 | 1252 | // 检查是否具有管理员权限,因为操作注册表需要管理员权限 1253 | if (IsUserAnAdmin()) { 1254 | printf("[+] Success: Administrative permissions confirmed\n\n"); 1255 | } 1256 | else { 1257 | printf("[-] Failure: Current permissions inadequate\n"); 1258 | return FALSE; 1259 | } 1260 | 1261 | //检查注册表中是否存在 TermService 服务 1262 | if (!CheckTermServiceReg()) { 1263 | printf("[-] Your system not install TermService\n"); 1264 | return FALSE; 1265 | } 1266 | else { 1267 | printf("[+] Find TermService in registry\n"); 1268 | } 1269 | 1270 | if (!IsOk) { 1271 | //检查设置的端口 1272 | DWORD DCheckPort = getDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "PortNumber"); 1273 | } 1274 | 1275 | if (!IsOk) { 1276 | //检查注册表中fDenyTSConnections的状态 1277 | DWORD DCheckfDenyTSConnections = getDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", "fDenyTSConnections"); 1278 | if (0 == DCheckfDenyTSConnections) { 1279 | printf("[+] TermService Connections is enable in key fDenyTSConnections \n"); 1280 | } 1281 | else { 1282 | printf("[-] TermService Connections is disable in key fDenyTSConnections\n"); 1283 | } 1284 | } 1285 | 1286 | if (!IsOk) { 1287 | //检查注册表中fEnableWinStation的状态 1288 | DWORD DCheckfEnableWinStation = getDWORDValueToReg(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", "fEnableWinStation"); 1289 | if (1 == DCheckfEnableWinStation) { 1290 | printf("[+] TermService Connections is enable in key fEnableWinStation \n"); 1291 | } 1292 | else { 1293 | printf("[-] TermService Connections is disable in key fEnableWinStation\n"); 1294 | } 1295 | } 1296 | //检查防火墙开放情况 1297 | if (!IsOk) { 1298 | CheckFireWallState(); 1299 | } 1300 | 1301 | //检查服务是否正在运行 1302 | if (!CheckService()) { 1303 | if (IsOk) { 1304 | printf("[-] The Service is NOT running\n"); 1305 | } 1306 | else { 1307 | printf("[-] The Service is NOT running. You can try to start it later\n"); 1308 | return FALSE; 1309 | } 1310 | } 1311 | printf("[+] Your system support for rdp\n\n"); 1312 | return TRUE; 1313 | } 1314 | 1315 | 1316 | int main(int argc, char* argv[]) 1317 | { 1318 | clock_t start, end; 1319 | start = clock(); 1320 | if (argc == 1) { 1321 | printf("[*] ===========================================================\n"); 1322 | printf(" %s\n", argv[0]); 1323 | printf(" \t -- this help\n"); 1324 | printf(" %s any\n", argv[0]); 1325 | printf(" \t -- Output system version, registry value, service status and firewall status\n"); 1326 | printf(" %s port 1\n", argv[0]); 1327 | printf(" \t -- Only set fDenyTSConnections=0 And fEnableWinStation=1(Ignore port set) \n"); 1328 | printf(" %s port 2\n", argv[0]); 1329 | printf(" \t -- Modify the registry, start services, and set up firewalls\n"); 1330 | printf(" %s port 3\n", argv[0]); 1331 | printf(" \t -- Set firewall on the specified port(Allow In,It will be remove same rule)\n"); 1332 | printf(" %s port 4\n", argv[0]); 1333 | printf(" \t -- Try to start service(Ignore port input)\n"); 1334 | printf(" %s port 5\n", argv[0]); 1335 | printf(" \t -- Try to Modify the registry for enable RDP on a lower version system(Ignore port input)\n"); 1336 | printf("[*] ===========================================================\n\n"); 1337 | } 1338 | else if (argc == 2) { 1339 | RdpInfoScan(); 1340 | } 1341 | else if (argc == 3) { 1342 | DWORD PORT = 3389; 1343 | 1344 | //1: 启用注册表,2:修改端口并启用RDP、开放防火墙 3.仅设置防火墙 4.仅尝试启动服务 5. 尝试在WIN2000中设置注册表启用RDP. 1345 | DWORD Action = 1; 1346 | // 获取输入的端口,并转为int型 1347 | PORT = atoi(argv[1]); 1348 | Action = atoi(argv[2]); 1349 | 1350 | // 如果转换失败 1351 | if (PORT == 0 || Action == 0) { 1352 | printf("[-] atoi error, Please check your input( enrdp.exe 3389 action(int) ).\n"); 1353 | } 1354 | else { 1355 | //如果输入的端口不在端口范围内 1356 | if (PORT < 1 || PORT > 65535) { 1357 | printf("[-] Please check your input( 1-65535 ).\n"); 1358 | } 1359 | else { 1360 | //1.仅启用注册表设置 :) 1361 | if (Action == 1) { 1362 | printf("[*] Only Set Reg To Enable RDP,Ignore port set\n"); 1363 | SetReg(PORT, TRUE); 1364 | } 1365 | else if (Action == 2) { 1366 | // 配置检查 1367 | if (RdpInfoScan(TRUE)) { 1368 | //修改端口、启用RDP、开放防火墙 1369 | // 检查端口是否被占用 (通过获取本机端口状态判断) 1370 | if (GetTcpPortState(PORT) || GetUdpPortState(PORT)) { 1371 | printf("[-] The port is occupied, please replace the port.\n"); 1372 | } 1373 | else { 1374 | printf("[*] The port is not occupied\n"); 1375 | printf("[*] Make sure TermService runing...\n"); 1376 | if (NetStartServices()) { 1377 | printf("[*] Change Port...\n"); 1378 | if (SetReg(PORT, FALSE, TRUE)) { 1379 | printf("[*] SetFireWall...\n"); 1380 | if (SetFireWall(PORT)) 1381 | { 1382 | printf("[+] Successful\n"); 1383 | } 1384 | } 1385 | } 1386 | } 1387 | } 1388 | else { 1389 | printf("[-] Configuration check failed\n"); 1390 | } 1391 | } 1392 | else if (Action == 3) { 1393 | if (SetFireWall(PORT)) 1394 | { 1395 | printf("[+] Successful\n"); 1396 | } 1397 | } 1398 | else if (Action == 4) { 1399 | if (NetStartServices()) { 1400 | printf("[+] Successful\n"); 1401 | } 1402 | } 1403 | else if (Action == 5) { 1404 | if (SetReg(PORT, FALSE, FALSE, TRUE)) { 1405 | printf("[+] Successful\n"); 1406 | } 1407 | } 1408 | else { 1409 | return TRUE; 1410 | } 1411 | } 1412 | } 1413 | } 1414 | else { 1415 | return TRUE; 1416 | } 1417 | end = clock(); 1418 | printf("\n[*] Done. Time used: %lf seconds.\n", (double)((double)end - (double)start) / CLOCKS_PER_SEC); 1419 | return TRUE; 1420 | } -------------------------------------------------------------------------------- /enablerdp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enablerdp", "enablerdp.vcxproj", "{9FFE67B5-3D56-4842-A41D-AD29A6D82332}" 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 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Debug|x64.ActiveCfg = Debug|x64 17 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Debug|x64.Build.0 = Debug|x64 18 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Debug|x86.ActiveCfg = Debug|Win32 19 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Debug|x86.Build.0 = Debug|Win32 20 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Release|x64.ActiveCfg = Release|x64 21 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Release|x64.Build.0 = Release|x64 22 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Release|x86.ActiveCfg = Release|Win32 23 | {9FFE67B5-3D56-4842-A41D-AD29A6D82332}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0E9B1A5-A3BA-4D58-ACC1-DED95436FBC2} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /enablerdp.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 | {9ffe67b5-3d56-4842-a41d-ad29a6d82332} 25 | enablerdp 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 | MultiByte 41 | 42 | 43 | Application 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v142 52 | true 53 | MultiByte 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 | false 79 | $(SolutionDir)$(Configuration)\$(Platform)\ 80 | $(Configuration)\$(Platform)\ 81 | 82 | 83 | true 84 | 85 | 86 | false 87 | false 88 | $(SolutionDir)$(Configuration)\$(Platform)\ 89 | $(Configuration)\$(Platform)\ 90 | 91 | 92 | 93 | Level3 94 | true 95 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 96 | true 97 | 98 | 99 | Console 100 | true 101 | 102 | 103 | 104 | 105 | Level3 106 | true 107 | true 108 | true 109 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 110 | true 111 | MultiThreaded 112 | 113 | 114 | Console 115 | true 116 | true 117 | false 118 | 119 | 120 | 121 | 122 | Level3 123 | true 124 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 125 | true 126 | 127 | 128 | Console 129 | true 130 | 131 | 132 | 133 | 134 | Level3 135 | true 136 | true 137 | true 138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 139 | true 140 | MultiThreaded 141 | 142 | 143 | Console 144 | true 145 | true 146 | false 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /enablerdp.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 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /enablerdp.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /images/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaoi/enable-rdp/aaf4a3066f83f94679cfcc9022097d42816be320/images/check.png -------------------------------------------------------------------------------- /images/enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaoi/enable-rdp/aaf4a3066f83f94679cfcc9022097d42816be320/images/enable.png -------------------------------------------------------------------------------- /images/howtouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanghaoi/enable-rdp/aaf4a3066f83f94679cfcc9022097d42816be320/images/howtouse.png --------------------------------------------------------------------------------