Source:BF2Password/bf2pass.cpp

From Codemotion
Jump to: navigation, search

Source:BF2Password/bf2pass.cpp

Description

Source.

Code

Parent Directory: Source:BF2Password
Plain Code: edit

  1. #include <windows.h>
  2. #include <iostream>
  3. #include <Tlhelp32.h>
  4. #include "colors.cpp"
  5.  
  6. using namespace std;
  7.  
  8. DWORD GetPID (char* proc);
  9. void EnableDebugPriv();
  10. DWORD GetDLL (char* DllName, DWORD tPid);
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14. SetColor(-1,1);
  15. ClearConsole();
  16.  
  17. SetColor(7);
  18. cout <<" |||||||||||||||||||||||||||||||||||||||||||||||||| ||\n";
  19. SetColor(-21);
  20. cout << " ~ TyranO's Battlefield 2 Pass Recover for BF2 1.41 ~\n";
  21. SetColor(7);
  22. cout <<" |||||||||||||||||||||||||||||||||||||||||||||||||| ||\n" << endl;
  23. SetColor(11);
  24.  
  25. char str[24];
  26. char buf[24];
  27. int key = 10000;
  28.  
  29. strcpy(str, "Dibq~_7c0RV\"0`qcc0Bus_fub0");
  30.  
  31. for(int i=0;i < strlen(str);i++) {
  32. char enc = (char)((int)str[i] ^ key);
  33. //char dec = (char)((int)enc ^ key);
  34. //printf("char: %c (enc: %c)\n", str[i], enc);
  35. buf[i] = enc;
  36. }
  37. buf[strlen(str)] = 0;
  38.  
  39. SetConsoleTitle(buf);
  40.  
  41.  
  42. if(GetPID("BF2.exe") == 0)
  43. {
  44. SetColor(-4);
  45. cout << "BF2 was not found." << endl << endl;
  46. SetColor(-1);
  47. system("Pause");
  48. exit(0);
  49. }
  50. else
  51. {
  52. SetColor(-1);
  53. cout << "Select or log in the account from which you want to recover the password." << endl << endl;
  54. DWORD Address = 36977564;
  55. DWORD Buffer = 0;
  56. SIZE_T BytesRead = 0;
  57. HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPID("BF2.exe"));
  58. EnableDebugPriv();
  59. for(;;)
  60.  
  61. {
  62. char Name[20];
  63. Name[19] = 0;
  64.  
  65. for( unsigned int i = 0; i < 19; i++ )
  66. {
  67. ReadProcessMemory( hProc, (LPVOID)( Address + i ), &Buffer, 1, &BytesRead );
  68. Name[i] = Buffer;
  69. }
  70. SetColor(10);
  71. cout << "Your current password is: ";
  72. SetColor(-20);
  73. cout << Name << endl << endl;
  74. SetColor(-1);
  75. system("Pause");
  76. cout << endl;
  77.  
  78. }
  79. }
  80. }
  81.  
  82. // Get PID for process (proc).
  83. DWORD GetPID (char* proc)
  84. {
  85. BOOL working=0;
  86. PROCESSENTRY32 lppe= {0};
  87. DWORD targetPid=0;
  88. HANDLE hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROC ESS ,0);
  89.  
  90. if (hSnapshot)
  91. {
  92. lppe.dwSize=sizeof(lppe);
  93. working=Process32First(hSnapshot,&lppe);
  94. while (working)
  95. {
  96. if (_stricmp(lppe.szExeFile,proc)==0)
  97. {
  98. targetPid=lppe.th32ProcessID;
  99. break;
  100. }
  101. working=Process32Next(hSnapshot,&lppe);
  102. }
  103. }
  104.  
  105. CloseHandle( hSnapshot );
  106. return targetPid;
  107. }
  108.  
  109. // Debug Priviledges.
  110. void EnableDebugPriv()
  111. {
  112. HANDLE hToken;
  113. LUID sedebugnameValue;
  114. TOKEN_PRIVILEGES tkp;
  115. OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
  116. LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
  117. tkp.PrivilegeCount = 1;
  118. tkp.Privileges[0].Luid = sedebugnameValue;
  119. tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  120. AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
  121. CloseHandle( hToken );
  122. }
  123.  
  124. // DLL Base (6F).
  125. DWORD GetDLL(char* DllName, DWORD tPid)
  126. {
  127. HANDLE snapMod;
  128. MODULEENTRY32 me32;
  129.  
  130. if (tPid == 0) return 0;
  131. snapMod = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, tPid);
  132. me32.dwSize = sizeof(MODULEENTRY32);
  133.  
  134. if (Module32First(snapMod, &me32)){
  135. do{
  136. if (strcmp(DllName,me32.szModule) == 0){
  137. CloseHandle(snapMod);
  138. return (DWORD) me32.modBaseAddr;
  139. }
  140. }while(Module32Next(snapMod,&me32));
  141. }
  142.  
  143. CloseHandle(snapMod);
  144. return 0;
  145.  
  146. }
Personal tools