Skip to content

Linux payload implementing HV exploits to run a custom bootloader

C

Cleanup Makefile and linker.ld.

Andy Nguyen6a95a5ee8247
diff --git a/include/linux.h b/include/linux.h
index 8305187..bc3e37a 100644
--- a/include/linux.h
+++ b/include/linux.h
@@ -1,6 +1,7 @@
#ifndef __LINUX_H__
#define __LINUX_H__
+#include <stdint.h>
#include <unistd.h>
#define X86_SUBARCH_PS5 5
diff --git a/shellcode_hv/Makefile b/shellcode_hv/Makefile
index 5aae236..75dcfff 100644
--- a/shellcode_hv/Makefile
+++ b/shellcode_hv/Makefile
@@ -1,8 +1,3 @@
-ifndef PS5_PAYLOAD_SDK
- PS5_PAYLOAD_SDK = /opt/ps5-payload-sdk/
-endif
-
-# 1. Variables
ifeq ($(shell uname -m),aarch64)
CC = x86_64-linux-gnu-gcc
LD = x86_64-linux-gnu-ld
@@ -12,8 +7,8 @@ CC = gcc
LD = ld
OBJCOPY = objcopy
endif
-CFLAGS = -O2 -fno-stack-protector -ffreestanding -nostdlib -fcf-protection=none -m64 -I$(PS5_PAYLOAD_SDK)/target/include
-LDFLAGS = -T linker.ld
+CFLAGS = -O2 -fno-stack-protector -ffreestanding -nostdlib -fcf-protection=none -m64
+LDFLAGS = -T linker.ld -Wl,--no-warn-rwx-segments
TARGET = shellcode_hv.elf
TEXT_BIN = shellcode_hv.bin
dump = shellcode_hv.h
diff --git a/shellcode_kernel/Makefile b/shellcode_kernel/Makefile
index 042aab6..9d3ec17 100644
--- a/shellcode_kernel/Makefile
+++ b/shellcode_kernel/Makefile
@@ -1,8 +1,3 @@
-ifndef PS5_PAYLOAD_SDK
- PS5_PAYLOAD_SDK = /opt/ps5-payload-sdk/
-endif
-
-
ifeq ($(shell uname -m),aarch64)
CC = x86_64-linux-gnu-gcc
LD = x86_64-linux-gnu-ld
@@ -12,16 +7,15 @@ CC = gcc
LD = ld
OBJCOPY = objcopy
endif
-CFLAGS = -O2 -fno-stack-protector -ffreestanding -nostdlib -m64 -I$(PS5_PAYLOAD_SDK)/target/include
-LDFLAGS = -T linker.ld
+CFLAGS = -O2 -fno-stack-protector -ffreestanding -nostdlib -fcf-protection=none -m64
+LDFLAGS = -T linker.ld -Wl,--no-warn-rwx-segments
TARGET = shellcode_kernel.elf
TEXT_BIN = shellcode_kernel.bin
+dump = shellcode_kernel.h
SRC = main.c utils.c boot_linux.c
OBJ = $(SRC:.c=.o)
-dump = shellcode_kernel.h
-
all: $(dump)
$(TARGET): $(OBJ)
@@ -31,7 +25,7 @@ $(TARGET): $(OBJ)
$(CC) $(CFLAGS) -c $< -o $@
$(TEXT_BIN): $(TARGET)
- $(OBJCOPY) -O binary -j .text $(TARGET) $(TEXT_BIN)
+ $(OBJCOPY) -O binary -j .shell_code $(TARGET) $(TEXT_BIN)
clean:
rm -f $(OBJ) $(TARGET) $(TEXT_BIN) $(dump)
diff --git a/shellcode_kernel/linker.ld b/shellcode_kernel/linker.ld
index 98598d4..611bd59 100644
--- a/shellcode_kernel/linker.ld
+++ b/shellcode_kernel/linker.ld
@@ -4,15 +4,15 @@ ENTRY(main)
SECTIONS
{
. = 0x1000; /* 0x1000 to avoid warnings from linker */
- .text :
+ /* Place our custom header first */
+ .shell_code :
{
*(.entry_point)
*(.text)
*(.text.*)
- *(.data)
- *(.data.*)
+ *(.data*)
*(.rodata*)
*(.bss)
*(.bss.*)
}
-}
\ No newline at end of file
+}