mirror of
https://github.com/Pharaoh2k/ps5debug-NG.git
synced 2026-10-21 19:33:05 -05:00
PS5 debugger payload, inspired by Ctn's ps5debug 1.0b5 and wire-compatible with it. Runs the wire-protocol server inside SceShellCore via an umtx-loaded installer that injects the embedded debugger ELF. Features: process scan/RPC/ELF-inject, on-console scan, full debugger (breakpoints, watchpoints, single-step, regs/FP/DR access), kernel R/W, server-side Zydis disassembly, on-console Keystone assembler (0xBDAA0024), foreground-app metadata (0xBDDD0006), server-side RBP stack walk (CMD_PROC_READ_STACK), klog forwarder (TCP 3232), rest-mode survival and a lot more. Supports FW families 3.x / 4.0 / 4.x (incl. 4.51) / 5.x / 6.x / 7.x / 7.5x / 8.x via the kpatch routine in installer/source/main.c. GPL-3.0-only.
73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "sdk_shim.h"
|
|
|
|
int hijack_mode(void)
|
|
{
|
|
return kernel_dynlib_dlsym(-1, 0x2001, "sceKernelDlsym") != 0;
|
|
}
|
|
|
|
int __wrap___patch_init(void)
|
|
{
|
|
if (hijack_mode()) {
|
|
|
|
return 0;
|
|
}
|
|
|
|
int pid = getpid();
|
|
|
|
{
|
|
unsigned char caps[16];
|
|
unsigned long attrs;
|
|
|
|
if (kernel_get_ucred_caps(pid, caps)) {
|
|
klog_puts("kernel_get_ucred_caps failed");
|
|
return -1;
|
|
}
|
|
if (!(attrs = kernel_get_ucred_attrs(pid))) {
|
|
klog_puts("kernel_get_ucred_attrs failed");
|
|
return -1;
|
|
}
|
|
|
|
caps[5] = 0x1c;
|
|
caps[7] = 0x40;
|
|
caps[15] |= 0x40;
|
|
attrs |= 0x80;
|
|
|
|
if (kernel_set_ucred_caps(pid, caps)) {
|
|
klog_puts("kernel_set_ucred_caps failed");
|
|
return -1;
|
|
}
|
|
if (kernel_set_ucred_attrs(pid, attrs)) {
|
|
klog_puts("kernel_set_ucred_attrs failed");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
{
|
|
unsigned long kproc;
|
|
unsigned long kaddr;
|
|
unsigned long uaddr;
|
|
|
|
if (!(kproc = kernel_get_proc(pid))) {
|
|
return -1;
|
|
}
|
|
|
|
if (kernel_copyout(kproc + 0x3e8, &kaddr, sizeof(kaddr)) < 0) {
|
|
return -1;
|
|
}
|
|
|
|
uaddr = 0;
|
|
if (kernel_copyin(&uaddr, kaddr + 0xf0, sizeof(uaddr)) < 0) {
|
|
return -1;
|
|
}
|
|
|
|
uaddr = (unsigned long)-1L;
|
|
if (kernel_copyin(&uaddr, kaddr + 0xf8, sizeof(uaddr)) < 0) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|