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.
68 lines
1.8 KiB
C
68 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "protocol.h"
|
|
#include "sdk_shim.h"
|
|
#include "net.h"
|
|
|
|
int net_send_all(int fd, const void *buf, int len) {
|
|
const char *p = (const char *)buf;
|
|
int left = len;
|
|
while (left > 0) {
|
|
int chunk = (left > NET_MAX_LENGTH) ? NET_MAX_LENGTH : left;
|
|
ssize_t n = send(fd, p, chunk, 0);
|
|
if (n <= 0) return -1;
|
|
p += n;
|
|
left -= (int)n;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int net_recv_all(int fd, void *buf, int len, int force) {
|
|
char *p = (char *)buf;
|
|
int left = len;
|
|
while (left > 0) {
|
|
int chunk = (left > NET_MAX_LENGTH) ? NET_MAX_LENGTH : left;
|
|
int flags = force ? MSG_WAITALL : 0;
|
|
ssize_t n = recv(fd, p, chunk, flags);
|
|
if (n <= 0) return -1;
|
|
p += n;
|
|
left -= (int)n;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static inline uint32_t bitswap32(uint32_t x) {
|
|
return ((x >> 1) & 0x55555555u) | ((x << 1) & 0xAAAAAAAAu);
|
|
}
|
|
|
|
int net_send_int32(int fd, uint32_t value) {
|
|
uint32_t wire = bitswap32(value);
|
|
return net_send_all(fd, &wire, sizeof(wire));
|
|
}
|
|
|
|
extern long __crt_syscall(long sysno, ...);
|
|
int net_select(int fd, void *readfds, void *writefds, void *exceptfds, void *timeout) {
|
|
return (int)__crt_syscall(93, fd, readfds, writefds, exceptfds, timeout);
|
|
}
|
|
|
|
int net_get_ip_address(char *out) {
|
|
if (sceNetCtlInit() < 0) return -1;
|
|
uint8_t info[0x100];
|
|
int rc = sceNetCtlGetInfo(0xE, info);
|
|
if (rc < 0) return -1;
|
|
memcpy(out, info, 0x10);
|
|
sceNetCtlTerm();
|
|
return rc;
|
|
}
|
|
|
|
void *net_alloc_buffer(uint32_t size) {
|
|
if (size == 0) return NULL;
|
|
void *p = malloc(size);
|
|
if (!p) return NULL;
|
|
|
|
volatile char *cp = (volatile char *)p;
|
|
for (uint32_t i = 0; i < size; i += 0x1000) cp[i] = 0;
|
|
if (size > 0) cp[size - 1] = 0;
|
|
return p;
|
|
}
|