Know where to look in user space
Hilko Bengen
2026-09-14
ps(1), ls(1),
etc.ls(1) or find(1)/proc/$PID/ directory entriesgetdents64 (1)getdents = "get
directory entries"readdir syscall: Writes multiple directory
entries into user-provided bufferssize_t getdents64(int fd, void dirp[.count], size_t count);
struct linux_dirent64 {
ino64_t d_ino; /* 64-bit inode number */
off64_t d_off; /* Not an offset; see getdents() */
unsigned short d_reclen; /* Size of this dirent */
unsigned char d_type; /* File type */
char d_name[]; /* Filename (null-terminated) */
};
getdents64 (2)Read a directory containing foo bar baz quux HIDEME:
getdents64 (3)libc hook or syscall hook copies remaining data over HIDEME, reduces buffer size:
Goal: hide suspicious configuration or scripts
Technique: Hook read call, recognize start, end markers
For example, parts of a patched init script
/proc/$PIDkill pidfd_open getpgid getpriority getsid ioprio_get prlimit64 rt_sigqueueinfo rt_tgsigqueueinfo sched_getaffinity sched_getattr sched_getparam sched_getscheduler sched_rr_get_interval
init
and kthreadd (pid 1, 2)/proc/$PID/task/$TID/children/sys/fs/cgroup/*/cgroup.threadsgetdents64
with mininal buffer sizes that will hold at most 1 entryrk-exposerk-exposeFinding hidden processes:
# rk-expose ps-diff
Differences between: [children, getdents, readdir]
- Extra processes found using 'children':
- 3273 boopkit /usr/bin/boopkit
- 3274 boopkit /usr/bin/boopkit
- Extra processes found using 'getdents':
- 3273 boopkit /usr/bin/boopkit
- 3274 boopkit /usr/bin/boopkit
- No anomalies found using 'readdir'
Finding hidden files:
$ rk-expose ls-diff .
Differences between: [getdents, readdir]
- Extra paths found using 'getdents':
- - ./diamorphine_secret_file
- No anomalies found using 'readdir'
Attack/defense may have an arms race component
cf. Issue #36 "Singularity is not getting detected"
/proc/$PIDgetdents64 is runningSlides will be published at https://hillu.codeberg.page/conference-materials/balccon-2k26/slides.reveal.html
Contact me at
Hilko Bengen <bengen@hilluzination.de> @hillu@infosec.exchange @hillu_.matrix.org