Name Date Size #Lines LOC

..--

module/H--191167

README.mdH A D18-Oct-20221.1 KiB3317

extract.cppH A D17-Oct-20226.8 KiB228208

inject.cppH A D17-Oct-20229.7 KiB307265

kernel-mremap-pid-patch-6.0.0.diffH A D17-Oct-20227 KiB199184

napp.cppH A D17-Oct-2022935 4036

README.md

1# A silly experiment to add kernel interface for changing virtual memory layout for any pid.
2
3> Linux kernel only support changing mmaps for `current` process, for good reason, I think.
4> This silly attempt is to add kernel function for mremap any process, thus the `spirit` of one simple memory program could be injected into another program by a `muggle`.
5
6## Kernel change
7
8> The change is only experimental, only necessary parts involving `current` is changed, and a new interface is added for other module to exporse to user space.
9
10## Driver module
11
12> Supply `ioctl` interface to connect user space request with kernel mremap.
13
14## extract
15
16> Collect program's memory layout/content and registers, and save it.
17
18* /proc/[pid]/maps ---- mem layout
19* /proc/[pid]/mem ---- mem content
20* ptrace PTRACE_PEEKUSER PTRACE_GETREGSET  ---- register collect
21
22
23
24## inject
25
26> convert a existing program, inject the `spirit` from other program
27
28* /dev/ptracexx ---- change memlayout
29* ptrace PTRACE_POKEDATA  ---- write back memory content
30* ptrace PTRACE_POKEUSER PTRACE_SETREGSET ---- restore registry
31
32
33