├── x64 └── Release │ ├── WifiKeyDecryptor.exe │ ├── WifiKeyDecryptor.iobj │ ├── WifiKeyDecryptor.ipdb │ └── WifiKeyDecryptor.pdb ├── WifiKeyDecryptor ├── x64 │ └── Release │ │ ├── vc140.pdb │ │ ├── WifiKeyDecryptor.obj │ │ ├── WifiKeyDecryptor.tlog │ │ ├── CL.read.1.tlog │ │ ├── CL.write.1.tlog │ │ ├── CL.command.1.tlog │ │ ├── link.read.1.tlog │ │ ├── link.write.1.tlog │ │ ├── link.command.1.tlog │ │ └── WifiKeyDecryptor.lastbuildstate │ │ └── WifiKeyDecryptor.log ├── targetver.h ├── stdafx.h ├── WifiKeyDecryptor.vcxproj.filters ├── ReadMe.txt ├── WifiKeyDecryptor.vcxproj └── WifiKeyDecryptor.cpp ├── WifiKeyDecryptor.sln └── README.md /x64/Release/WifiKeyDecryptor.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/x64/Release/WifiKeyDecryptor.exe -------------------------------------------------------------------------------- /x64/Release/WifiKeyDecryptor.iobj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/x64/Release/WifiKeyDecryptor.iobj -------------------------------------------------------------------------------- /x64/Release/WifiKeyDecryptor.ipdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/x64/Release/WifiKeyDecryptor.ipdb -------------------------------------------------------------------------------- /x64/Release/WifiKeyDecryptor.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/x64/Release/WifiKeyDecryptor.pdb -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/vc140.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/vc140.pdb -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.obj -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/l4tr0d3ctism/WifikeyDecryptor/HEAD/WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.tlog/WifiKeyDecryptor.lastbuildstate: -------------------------------------------------------------------------------- 1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit 2 | Release|x64|c:\users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\| 3 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/WifiKeyDecryptor.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 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Source Files 19 | 20 | 21 | -------------------------------------------------------------------------------- /WifiKeyDecryptor.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WifiKeyDecryptor", "WifiKeyDecryptor\WifiKeyDecryptor.vcxproj", "{729CA8E6-6630-4930-9FED-56BD94A86437}" 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 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Debug|x64.ActiveCfg = Debug|x64 17 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Debug|x64.Build.0 = Debug|x64 18 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Debug|x86.ActiveCfg = Debug|Win32 19 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Debug|x86.Build.0 = Debug|Win32 20 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Release|x64.ActiveCfg = Release|x64 21 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Release|x64.Build.0 = Release|x64 22 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Release|x86.ActiveCfg = Release|Win32 23 | {729CA8E6-6630-4930-9FED-56BD94A86437}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : WifiKeyDecryptor Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this WifiKeyDecryptor application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your WifiKeyDecryptor application. 9 | 10 | 11 | WifiKeyDecryptor.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | WifiKeyDecryptor.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | WifiKeyDecryptor.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named WifiKeyDecryptor.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WifikeyDecryptor 2 | decrypt all of the wifi key interface Profile in Windows 3 | 4 | All the passwords of the wireless networks you are connected, stored in the interfaced folder in X:\ProgramData\Microsoft\Wlansvc\Profiles. 5 | All the information discussed hence forth will apply only to Vista and higher operating systems only. 6 | As we know already, each wireless settings are stored in XML file. Here is the actual contents of one such file, 7 | ``` 8 | 9 | 10 | wifiname 11 | 12 | 13 | 536563757269747958706C6F646564 14 | SecurityXploded 15 | 16 | false 17 | 18 | ESS 19 | auto 20 | false 21 | 22 | 23 | 24 | WPAPSK 25 | AES 26 | false 27 | 28 | 29 | passPhrase 30 | true 31 | password 32 | 33 | 34 | 35 | 36 | ``` 37 | Each Wireless profile mainly stores information about WiFi name, security settings such as authentication, encryption and the encrypted password. Here each wireless device is represented by its interface GUID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and all the wireless settings for this device are stored in XML file with random GUID name. 38 | ``` 39 | C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\{Random-GUID}.xml 40 | ``` 41 | The tools that decrypt the wireless key Only get the values key inside the current interface and perform their operations on it. 42 | But every time you try to remove the interface or use another wireless network card and... A new interface folder is created in the interfaces folder. 43 | 44 | ![alt text](https://filestore.community.support.microsoft.com/api/images/260de800-6f70-447c-8d7c-961a14ec8399) 45 | this tool first obtains the encrypted keys in all interfaces that have been created in the past, and then decrypts them. 46 | 47 | Run Program as administrator for Decrypt Key and show them :) 48 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/x64/Release/WifiKeyDecryptor.log: -------------------------------------------------------------------------------- 1 | Build started 3/11/2020 10:37:55 AM. 2 | 1>Project "c:\Users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\WifiKeyDecryptor\WifiKeyDecryptor.vcxproj" on node 2 (Build target(s)). 3 | 1>ClCompile: 4 | E:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /Zi /nologo /W3 /WX- /sdl /O2 /Oi /GL /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"x64\Release\\" /Fd"x64\Release\vc140.pdb" /Gd /TP /errorReport:prompt WifiKeyDecryptor.cpp 5 | WifiKeyDecryptor.cpp 6 | 1>WifiKeyDecryptor.cpp(154): warning C4244: 'argument': conversion from 'SIZE_T' to 'ULONG', possible loss of data 7 | 1>WifiKeyDecryptor.cpp(170): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'DWORD' 8 | 1>WifiKeyDecryptor.cpp(170): warning C4302: 'type cast': truncation from 'HANDLE' to 'DWORD' 9 | 1>WifiKeyDecryptor.cpp(176): warning C4312: 'type cast': conversion from 'BOOL' to 'PBYTE' of greater size 10 | Link: 11 | E:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:PROMPT /OUT:"c:\users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\x64\Release\WifiKeyDecryptor.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"c:\users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\x64\Release\WifiKeyDecryptor.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG:incremental /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\x64\Release\WifiKeyDecryptor.lib" /MACHINE:X64 x64\Release\WifiKeyDecryptor.obj 12 | Generating code 13 | All 300 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. 14 | Finished generating code 15 | WifiKeyDecryptor.vcxproj -> c:\users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\x64\Release\WifiKeyDecryptor.exe 16 | 1>Done Building Project "c:\Users\l4tr0d3ctism\documents\visual studio 2015\Projects\WifiKeyDecryptor\WifiKeyDecryptor\WifiKeyDecryptor.vcxproj" (Build target(s)). 17 | 18 | Build succeeded. 19 | 20 | Time Elapsed 00:00:01.44 21 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/WifiKeyDecryptor.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 | {729CA8E6-6630-4930-9FED-56BD94A86437} 23 | Win32Proj 24 | WifiKeyDecryptor 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | Use 87 | Level3 88 | Disabled 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | NotUsing 100 | Level3 101 | Disabled 102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 103 | true 104 | 105 | 106 | Console 107 | true 108 | 109 | 110 | 111 | 112 | Level3 113 | Use 114 | MaxSpeed 115 | true 116 | true 117 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | true 124 | true 125 | 126 | 127 | 128 | 129 | Level3 130 | NotUsing 131 | MaxSpeed 132 | true 133 | true 134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | Console 139 | true 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /WifiKeyDecryptor/WifiKeyDecryptor.cpp: -------------------------------------------------------------------------------- 1 | // wifikeyDecryptor.cpp : Defines the entry point for the console application. 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #pragma comment (lib, "Crypt32.lib") 12 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) 13 | #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L) 14 | 15 | 16 | using namespace std; 17 | wstring_convert< codecvt > conv; 18 | 19 | void listDir(const char * dirn); 20 | string xmlfile, keyMaterial; 21 | char filePath[1024]; 22 | wstring Wstr; 23 | 24 | typedef enum _SYSTEM_INFORMATION_CLASS { 25 | SystemProcessInformation = 5 26 | } SYSTEM_INFORMATION_CLASS; 27 | 28 | typedef struct _UNICODE_STRING { 29 | USHORT Length; 30 | USHORT MaximumLength; 31 | PWSTR Buffer; 32 | } UNICODE_STRING; 33 | 34 | typedef LONG KPRIORITY; // Thread priority 35 | 36 | typedef struct _SYSTEM_PROCESS_INFORMATION_DETAILD { 37 | ULONG NextEntryOffset; 38 | ULONG NumberOfThreads; 39 | LARGE_INTEGER SpareLi1; 40 | LARGE_INTEGER SpareLi2; 41 | LARGE_INTEGER SpareLi3; 42 | LARGE_INTEGER CreateTime; 43 | LARGE_INTEGER UserTime; 44 | LARGE_INTEGER KernelTime; 45 | UNICODE_STRING ImageName; 46 | KPRIORITY BasePriority; 47 | HANDLE UniqueProcessId; 48 | ULONG InheritedFromUniqueProcessId; 49 | ULONG HandleCount; 50 | BYTE Reserved4[4]; 51 | PVOID Reserved5[11]; 52 | SIZE_T PeakPagefileUsage; 53 | SIZE_T PrivatePageCount; 54 | LARGE_INTEGER Reserved6[6]; 55 | } SYSTEM_PROCESS_INFORMATION_DETAILD, *PSYSTEM_PROCESS_INFORMATION_DETAILD; 56 | 57 | typedef NTSTATUS(WINAPI *PFN_NT_QUERY_SYSTEM_INFORMATION)( 58 | IN SYSTEM_INFORMATION_CLASS SystemInformationClass, 59 | IN OUT PVOID SystemInformation, 60 | IN ULONG SystemInformationLength, 61 | OUT OPTIONAL PULONG ReturnLength 62 | ); 63 | 64 | // 65 | // The function changes a privilege named pszPrivilege for 66 | // the current process. If bEnablePrivilege is FALSE, the privilege 67 | // will be disabled, otherwise it will be enabled. 68 | // 69 | BOOL SetCurrentPrivilege(LPCTSTR pszPrivilege, // Privilege to enable/disable 70 | BOOL bEnablePrivilege) // to enable or disable privilege 71 | { 72 | HANDLE hToken; 73 | TOKEN_PRIVILEGES tp; 74 | LUID luid; 75 | TOKEN_PRIVILEGES tpPrevious; 76 | DWORD cbPrevious = sizeof(TOKEN_PRIVILEGES); 77 | BOOL bSuccess = FALSE; 78 | 79 | if (!LookupPrivilegeValue(NULL, pszPrivilege, &luid)) return FALSE; 80 | 81 | if (!OpenProcessToken(GetCurrentProcess(), 82 | TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, 83 | &hToken 84 | )) return FALSE; 85 | 86 | // 87 | // first pass. get current privilege setting 88 | // 89 | tp.PrivilegeCount = 1; 90 | tp.Privileges[0].Luid = luid; 91 | tp.Privileges[0].Attributes = 0; 92 | 93 | AdjustTokenPrivileges( 94 | hToken, 95 | FALSE, 96 | &tp, 97 | sizeof(TOKEN_PRIVILEGES), 98 | &tpPrevious, 99 | &cbPrevious); 100 | 101 | if (GetLastError() == ERROR_SUCCESS) { 102 | // 103 | // second pass. set privilege based on previous setting 104 | // 105 | tpPrevious.PrivilegeCount = 1; 106 | tpPrevious.Privileges[0].Luid = luid; 107 | 108 | if (bEnablePrivilege) 109 | tpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED); 110 | else 111 | tpPrevious.Privileges[0].Attributes ^= (SE_PRIVILEGE_ENABLED & 112 | tpPrevious.Privileges[0].Attributes); 113 | 114 | AdjustTokenPrivileges( 115 | hToken, 116 | FALSE, 117 | &tpPrevious, 118 | cbPrevious, 119 | NULL, 120 | NULL); 121 | 122 | if (GetLastError() == ERROR_SUCCESS) bSuccess = TRUE; 123 | 124 | CloseHandle(hToken); 125 | } 126 | else { 127 | DWORD dwErrorCode = GetLastError(); 128 | 129 | CloseHandle(hToken); 130 | SetLastError(dwErrorCode); 131 | } 132 | 133 | return bSuccess; 134 | } 135 | 136 | DWORD GetProcessIdByProcessName(LPCWSTR pszProcessName) 137 | { 138 | SIZE_T bufferSize = 1024 * sizeof(SYSTEM_PROCESS_INFORMATION_DETAILD); 139 | PSYSTEM_PROCESS_INFORMATION_DETAILD pspid = NULL; 140 | HANDLE hHeap = GetProcessHeap(); 141 | PBYTE pBuffer = NULL; 142 | ULONG ReturnLength; 143 | PFN_NT_QUERY_SYSTEM_INFORMATION pfnNtQuerySystemInformation = (PFN_NT_QUERY_SYSTEM_INFORMATION) 144 | GetProcAddress(GetModuleHandle(TEXT("ntdll.dll")), "NtQuerySystemInformation"); 145 | NTSTATUS status; 146 | int uLen = lstrlenW(pszProcessName)*sizeof(WCHAR); 147 | 148 | __try { 149 | pBuffer = (PBYTE)HeapAlloc(hHeap, 0, bufferSize); 150 | #pragma warning(disable: 4127) 151 | while (TRUE) { 152 | #pragma warning(default: 4127) 153 | status = pfnNtQuerySystemInformation(SystemProcessInformation, (PVOID)pBuffer, 154 | bufferSize, &ReturnLength); 155 | if (status == STATUS_SUCCESS) 156 | break; 157 | else if (status != STATUS_INFO_LENGTH_MISMATCH) { // 0xC0000004L 158 | _tprintf(TEXT("ERROR 0x%X\n"), status); 159 | return 1; // error 160 | } 161 | 162 | bufferSize *= 2; 163 | pBuffer = (PBYTE)HeapReAlloc(hHeap, 0, (PVOID)pBuffer, bufferSize); 164 | } 165 | 166 | for (pspid = (PSYSTEM_PROCESS_INFORMATION_DETAILD)pBuffer;; 167 | pspid = (PSYSTEM_PROCESS_INFORMATION_DETAILD)(pspid->NextEntryOffset + (PBYTE)pspid)) { 168 | 169 | if (pspid->ImageName.Length == uLen && lstrcmpiW(pspid->ImageName.Buffer, pszProcessName) == 0) 170 | return (DWORD)pspid->UniqueProcessId; 171 | 172 | if (pspid->NextEntryOffset == 0) break; 173 | } 174 | } 175 | __finally { 176 | pBuffer = (PBYTE)HeapFree(hHeap, 0, pBuffer); 177 | } 178 | return 0; 179 | } 180 | 181 | int convw() { 182 | wstring val = conv.from_bytes(keyMaterial); 183 | Wstr = val; 184 | return 0; 185 | } 186 | 187 | int wifikey() { 188 | BOOL bIsSuccess, bImpersonated = FALSE; 189 | HANDLE hProcess = NULL, hProcessToken = NULL; 190 | DATA_BLOB DataOut, DataVerify; 191 | // !!! in the next line you should copy the string from 192 | WCHAR szKey[800]; 193 | convw(); 194 | 195 | swprintf_s(szKey, (Wstr.length() + 1), L"%s", Wstr.c_str()); 196 | 197 | 198 | 199 | 200 | BYTE byKey[1024]; 201 | DWORD cbBinary, dwFlags, dwSkip; 202 | DWORD dwProcessId = GetProcessIdByProcessName(L"winlogon.exe"); 203 | if (dwProcessId == 0) return 1; 204 | 205 | bIsSuccess = SetCurrentPrivilege(SE_DEBUG_NAME, TRUE); 206 | if (!bIsSuccess) return GetLastError(); 207 | 208 | __try { 209 | hProcess = OpenProcess(MAXIMUM_ALLOWED, FALSE, dwProcessId); 210 | if (!hProcess) __leave; 211 | bIsSuccess = OpenProcessToken(hProcess, MAXIMUM_ALLOWED, &hProcessToken); 212 | if (!bIsSuccess) __leave; 213 | bIsSuccess = ImpersonateLoggedOnUser(hProcessToken); 214 | if (!bIsSuccess) __leave; 215 | bImpersonated = TRUE; 216 | 217 | cbBinary = sizeof(byKey); 218 | bIsSuccess = CryptStringToBinary(szKey, lstrlenW(szKey), CRYPT_STRING_HEX, // CRYPT_STRING_HEX_ANY 219 | byKey, &cbBinary, &dwSkip, &dwFlags); 220 | if (!bIsSuccess) __leave; 221 | DataOut.cbData = cbBinary; 222 | DataOut.pbData = (BYTE*)byKey; 223 | 224 | if (CryptUnprotectData(&DataOut, NULL, NULL, NULL, NULL, 0, &DataVerify)) { 225 | _tprintf(TEXT("The decrypted data is: %hs\n"), DataVerify.pbData); 226 | } 227 | } 228 | __finally { 229 | if (bImpersonated) 230 | RevertToSelf(); 231 | if (hProcess) 232 | CloseHandle(hProcess); 233 | if (hProcessToken) 234 | CloseHandle(hProcessToken); 235 | } 236 | return 0; 237 | } 238 | 239 | void listDir(const char * dirn) 240 | { 241 | char dirnPath[1024]; 242 | string search = " "; 243 | string search2 = " "; 244 | string ssidname, line; 245 | 246 | sprintf_s((dirnPath), "%s\\*", dirn); 247 | WIN32_FIND_DATAA f; 248 | HANDLE h = FindFirstFileA(dirnPath, &f); 249 | if (h == INVALID_HANDLE_VALUE) { return; } 250 | do 251 | { 252 | const char * name = f.cFileName; 253 | if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { continue; } 254 | char filePath[1024]; 255 | sprintf_s(filePath, "%s%s%s", dirn, "\\", name); 256 | 257 | ifstream myfile(filePath); 258 | if (myfile.is_open()) 259 | { 260 | while (getline(myfile, line)) 261 | { 262 | if (line.find(search2, 0) != string::npos) { 263 | ssidname = line; 264 | ssidname = ssidname.replace(0, 9, ""); 265 | ssidname.resize(ssidname.size() - 7); 266 | cout << "SSID = " << ssidname << endl; 267 | } 268 | 269 | 270 | if (line.find(search, 0) != string::npos) { 271 | keyMaterial = line; 272 | keyMaterial = keyMaterial.replace(0, 17, ""); 273 | keyMaterial.resize(keyMaterial.size() - 14); 274 | 275 | wifikey(); 276 | 277 | 278 | } 279 | 280 | } 281 | } 282 | 283 | if (f.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) 284 | { 285 | listDir(filePath); 286 | } 287 | } while (FindNextFileA(h, &f)); 288 | FindClose(h); 289 | } 290 | 291 | int _tmain() 292 | { 293 | listDir("C:/ProgramData/Microsoft/Wlansvc/Profiles/Interfaces/"); 294 | wifikey(); 295 | 296 | system("pause"); 297 | return 0; 298 | } --------------------------------------------------------------------------------