mirror of
https://github.com/Pharaoh2k/ps5debug-NG.git
synced 2026-10-22 11:53:13 -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.
61 lines
1.7 KiB
C
61 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "protocol.h"
|
|
#include "sdk_shim.h"
|
|
#include "net.h"
|
|
#include "kern_rw_fast.h"
|
|
|
|
int kern_base_handle(int fd, struct cmd_packet *packet) {
|
|
(void)packet;
|
|
uint64_t kbase = KERNEL_ADDRESS_DATA_BASE;
|
|
net_send_int32(fd, CMD_SUCCESS);
|
|
net_send_all(fd, &kbase, 8);
|
|
return 0;
|
|
}
|
|
|
|
int kern_read_handle(int fd, struct cmd_packet *packet) {
|
|
struct cmd_kern_read_packet *p = (struct cmd_kern_read_packet *)packet->data;
|
|
if (!p) {
|
|
net_send_int32(fd, CMD_DATA_NULL);
|
|
return 0;
|
|
}
|
|
void *buf = net_alloc_buffer(p->length);
|
|
if (!buf) {
|
|
net_send_int32(fd, CMD_DATA_NULL);
|
|
return 1;
|
|
}
|
|
kernel_copyout_fast(p->address, buf, p->length);
|
|
net_send_int32(fd, CMD_SUCCESS);
|
|
net_send_all(fd, buf, p->length);
|
|
free(buf);
|
|
return 0;
|
|
}
|
|
|
|
int kern_write_handle(int fd, struct cmd_packet *packet) {
|
|
struct cmd_kern_write_packet *p = (struct cmd_kern_write_packet *)packet->data;
|
|
if (!p) {
|
|
net_send_int32(fd, CMD_DATA_NULL);
|
|
return 0;
|
|
}
|
|
void *buf = net_alloc_buffer(p->length);
|
|
if (!buf) {
|
|
net_send_int32(fd, CMD_DATA_NULL);
|
|
return 1;
|
|
}
|
|
net_send_int32(fd, CMD_SUCCESS);
|
|
net_recv_all(fd, buf, p->length, 1);
|
|
kernel_copyin_fast(buf, p->address, p->length);
|
|
net_send_int32(fd, CMD_SUCCESS);
|
|
free(buf);
|
|
return 0;
|
|
}
|
|
|
|
int kern_handle(int fd, struct cmd_packet *packet) {
|
|
switch (packet->cmd) {
|
|
case 0xBDCC0001u: return kern_base_handle(fd, packet);
|
|
case 0xBDCC0002u: return kern_read_handle(fd, packet);
|
|
case 0xBDCC0003u: return kern_write_handle(fd, packet);
|
|
default: return 1;
|
|
}
|
|
}
|