Advertisement
Guest User

EZcheats.

a guest
Dec 12th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. bool spoof_volume_id(char drive)
  2. {
  3. const int max_pbsi = 3;
  4.  
  5. struct partial_boot_sector_info
  6. {
  7. LPCSTR Fs; // file system name
  8. DWORD FsOffs; // offset of file system name in the boot sector
  9. DWORD SerialOffs; // offset of the serialnumber in the boot sector
  10. };
  11.  
  12. partial_boot_sector_info pbsi[max_pbsi] =
  13. {
  14. {"FAT32", 0x52, 0x43},
  15. {"FAT", 0x36, 0x27},
  16. {"NTFS", 0x03, 0x48}
  17. };
  18.  
  19. char buf[64];
  20. sprintf_s(buf, "\\\\.\\%c:", drive);
  21.  
  22. HANDLE hFile = CreateFileA(buf, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  23. if (hFile == INVALID_HANDLE_VALUE)
  24. return false;
  25. BYTE sector[0x200];
  26. DWORD dwBytesRead;
  27. bool result = false;
  28. if (ReadFile(hFile, sector, sizeof(sector), &dwBytesRead, nullptr)) {
  29. int i;
  30. for (i = 0; i < max_pbsi; i++)
  31. {
  32. if (strncmp(pbsi[i].Fs, (const char*)(sector + pbsi[i].FsOffs), strlen(pbsi[i].Fs)) == 0)
  33. {
  34. // we found a valid signature
  35. break;
  36. }
  37. }
  38.  
  39. if (i < max_pbsi) {
  40. printf("drive: %c, Serial: %X\r\n", drive, *(PDWORD)(sector + pbsi[i].SerialOffs));
  41. *(PDWORD)(sector + pbsi[i].SerialOffs) ^= generate_volume_serial_number();
  42. printf("drive: %c, Spoofed Serial: %X\r\n", drive, *(PDWORD)(sector + pbsi[i].SerialOffs));
  43. if (INVALID_SET_FILE_POINTER != SetFilePointer(hFile, NULL, NULL, FILE_BEGIN)) {
  44. DWORD dwBytesWritten;
  45. result = ::WriteFile(hFile, sector, sizeof(sector), &dwBytesWritten, nullptr) == TRUE;
  46. }
  47. }
  48. else
  49. printf("unknown fs\r\n");
  50. }
  51.  
  52. ::CloseHandle(hFile);
  53. return result;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement