From 10c42774f1be3ae20e5a287a01fa94be5494f634 Mon Sep 17 00:00:00 2001 From: Pharaoh2k <5753365+Pharaoh2k@users.noreply.github.com> Date: Tue, 28 Jul 2026 12:32:02 +0000 Subject: [PATCH] Bump to v1.3.2 with capability 1.1 and embed a build fingerprint Branding advertises capability level 1.1 (content-verified writes) and now carries a 16-hex build fingerprint injected by build.sh and the debugger/installer Makefiles, so a staged ELF is identifiable from CMD_BRANDING. --- build.sh | 88 ++++++++++++++++++++++++++++++++++------ common/include/version.h | 11 ++++- debugger/Makefile | 7 ++++ debugger/source/meta.c | 8 +--- installer/Makefile | 7 ++++ 5 files changed, 100 insertions(+), 21 deletions(-) diff --git a/build.sh b/build.sh index 7f9dd12..327e64a 100644 --- a/build.sh +++ b/build.sh @@ -9,6 +9,53 @@ cd "$SCRIPT_DIR" SDK_SRC="$SCRIPT_DIR/ps5-payload-sdk" SDK_INSTALL="$SDK_SRC/install" ARTIFACT="$SCRIPT_DIR/ps5debug-NG.elf" +WRITE_DIAG_MODE="${WRITE_DIAG:-0}" +WRITE_PATH_MODE="${WRITE_PATH:-0}" + +compute_build_fingerprint() { + local manifest source_fingerprint + manifest="$(mktemp)" + if git -C "$SCRIPT_DIR" rev-parse --is-inside-work-tree \ + >/dev/null 2>&1; then + ( + cd "$SCRIPT_DIR" + git ls-files -co --exclude-standard -z -- \ + build.sh common debugger installer | + LC_ALL=C sort -z + ) > "$manifest" + else + ( + cd "$SCRIPT_DIR" + find build.sh common debugger installer -type f \ + ! -path '*/build/*' -print0 | + LC_ALL=C sort -z + ) > "$manifest" + fi + if [ ! -s "$manifest" ]; then + rm -f "$manifest" + echo "ERROR: no payload sources found for build fingerprint." >&2 + return 1 + fi + source_fingerprint="$( + (cd "$SCRIPT_DIR"; xargs -0 sha256sum < "$manifest") | + sha256sum | cut -c1-64 + )" + rm -f "$manifest" + printf '%s diag=%s path=%s\n' \ + "$source_fingerprint" "$WRITE_DIAG_MODE" "$WRITE_PATH_MODE" | + sha256sum | cut -c1-16 +} + +validate_write_build_mode() { + case "$WRITE_DIAG_MODE" in + 0|1) ;; + *) echo "ERROR: WRITE_DIAG must be 0 or 1." >&2; exit 1 ;; + esac + case "$WRITE_PATH_MODE" in + 0|1|2) ;; + *) echo "ERROR: WRITE_PATH must be 0 (auto), 1 (DMAP), or 2 (mdbg)." >&2; exit 1 ;; + esac +} require_build_host() { # This payload's release bytes are toolchain-sensitive. Keep the supported @@ -26,6 +73,19 @@ verify_sdk_links() { # with core.symlinks=false turns them into one-line regular files that the C # compiler then parses as source text. local rel target + if ! git -C "$SCRIPT_DIR" rev-parse --is-inside-work-tree \ + >/dev/null 2>&1; then + while IFS= read -r -d '' rel; do + if [ ! -e "$SCRIPT_DIR/$rel" ]; then + echo "ERROR: required SDK symlink is broken: $rel" >&2 + exit 1 + fi + done < <( + cd "$SCRIPT_DIR" + find ps5-payload-sdk/include/freebsd -type l -print0 + ) + return + fi while IFS= read -r rel; do [ -z "$rel" ] && continue if [ ! -L "$SCRIPT_DIR/$rel" ]; then @@ -53,14 +113,6 @@ verify_toolchain() { fi } -clean_build() { - echo "==> cleaning" - (cd debugger && make clean) || true - (cd installer && make clean) || true - (cd "$SDK_SRC" && make clean) || true - rm -rf "$SDK_INSTALL" "$ARTIFACT" -} - build_sdk() { if [ ! -f "$SDK_INSTALL/toolchain/prospero.mk" ]; then echo "==> building SDK (one-time, ~30s)" @@ -72,13 +124,21 @@ build_sdk() { } build_debugger() { - echo "==> building debugger" - make -C debugger + local fingerprint="$1" + echo "==> building debugger (fingerprint $fingerprint)" + make -B -C debugger \ + BUILD_FINGERPRINT="$fingerprint" \ + WRITE_DIAG="$WRITE_DIAG_MODE" \ + WRITE_PATH="$WRITE_PATH_MODE" } build_installer() { + local fingerprint="$1" echo "==> building installer (embeds debugger)" - make -C installer + make -B -C installer \ + BUILD_FINGERPRINT="$fingerprint" \ + WRITE_DIAG=0 \ + WRITE_PATH="$WRITE_PATH_MODE" } publish_artifact() { @@ -93,9 +153,11 @@ if [ "${1:-}" = "clean" ]; then fi require_build_host +validate_write_build_mode verify_sdk_links build_sdk verify_toolchain -build_debugger -build_installer +BUILD_FINGERPRINT="$(compute_build_fingerprint)" +build_debugger "$BUILD_FINGERPRINT" +build_installer "$BUILD_FINGERPRINT" publish_artifact diff --git a/common/include/version.h b/common/include/version.h index d2f9062..de6863f 100644 --- a/common/include/version.h +++ b/common/include/version.h @@ -2,5 +2,12 @@ #pragma once -#define PS5DEBUG_NG_VERSION_STR "1.3.1" -#define PS5DEBUG_NG_BRAND_STR "ps5debug-NG by OSR v" PS5DEBUG_NG_VERSION_STR +#define PS5DEBUG_NG_VERSION_STR "1.3.2" + +#ifndef PS5DEBUG_NG_BUILD_FINGERPRINT_STR +#define PS5DEBUG_NG_BUILD_FINGERPRINT_STR "unfingerprinted" +#endif + +#define PS5DEBUG_NG_BRAND_STR \ + "ps5debug-NG by OSR v" PS5DEBUG_NG_VERSION_STR \ + " [" PS5DEBUG_NG_BUILD_FINGERPRINT_STR "]" diff --git a/debugger/Makefile b/debugger/Makefile index 7f5ecd7..f51aef2 100644 --- a/debugger/Makefile +++ b/debugger/Makefile @@ -21,6 +21,13 @@ CFLAGS := -Wall -O2 -I../common/include -Iinclude -I$(ZYDIR) -I$(KSDIR)/include LDFLAGS := -Wl,--wrap=__patch_init LDLIBS := -lSceLibcInternal -lkernel_sys -lSceNet -lSceNetCtl -lSceSysCore +WRITE_DIAG ?= 0 +WRITE_PATH ?= 0 +BUILD_FINGERPRINT ?= unfingerprinted +CFLAGS += -DPS5DEBUG_WRITE_DIAGNOSTICS=$(WRITE_DIAG) +CFLAGS += -DPS5DEBUG_FORCE_WRITE_PATH=$(WRITE_PATH) +CFLAGS += -DPS5DEBUG_NG_BUILD_FINGERPRINT_STR=\"$(BUILD_FINGERPRINT)\" + ZYDIS_CFLAGS := -O3 -DNDEBUG -DZYAN_NO_LIBC -w -I../common/include -Iinclude -I$(ZYDIR) CXXFILES := $(wildcard source/*.cpp) diff --git a/debugger/source/meta.c b/debugger/source/meta.c index 089b316..b96ca28 100644 --- a/debugger/source/meta.c +++ b/debugger/source/meta.c @@ -25,12 +25,8 @@ int handle_version(int fd, struct cmd_packet *packet) { int handle_branding(int fd, struct cmd_packet *packet) { (void)packet; - /* Human brand, a NUL, then the capability LEVEL. C-string clients stop at the - NUL so the displayed brand is unchanged; capability-aware clients read the - level past it. NOTE: the literals are split ("\0" "1.0") on purpose - "\01.0" - would be parsed as the octal escape \01, not a NUL followed by "1.0". Bump the - level (and add the feature on the client) as new capabilities are added. */ - static const char brand[] = PS5DEBUG_NG_BRAND_STR "\0" "1.0"; + /* Capability 1.1 adds content-verified process writes. */ + static const char brand[] = PS5DEBUG_NG_BRAND_STR "\0" "1.1"; uint32_t len = (uint32_t)(sizeof(brand) - 1); net_send_all(fd, &len, sizeof(uint32_t)); net_send_all(fd, brand, (int)len); diff --git a/installer/Makefile b/installer/Makefile index 6ae0f9a..129a5c4 100644 --- a/installer/Makefile +++ b/installer/Makefile @@ -20,6 +20,13 @@ CFLAGS := -Wall -O2 -I../common/include -ffunction-sections -fdata-sections LDFLAGS := -Wl,--gc-sections LDLIBS := -lSceLibcInternal -lkernel_sys -lSceNet -lSceNetCtl -lSceSysCore +WRITE_DIAG ?= 0 +WRITE_PATH ?= 0 +BUILD_FINGERPRINT ?= unfingerprinted +CFLAGS += -DPS5DEBUG_WRITE_DIAGNOSTICS=$(WRITE_DIAG) +CFLAGS += -DPS5DEBUG_FORCE_WRITE_PATH=$(WRITE_PATH) +CFLAGS += -DPS5DEBUG_NG_BUILD_FINGERPRINT_STR=\"$(BUILD_FINGERPRINT)\" + CFILES := $(wildcard ../common/source/*.c) $(wildcard source/*.c) all: $(ELF)