I have a static compiled program called (example 'busybox'). Busybox (or a another file) doesn't need any library file. So that means in theory I can run busybox everywhere with a linux kernel (without glibc files or another library files at runtime).
Now is my plan to run busybox in jail (chroot) on a directory doesn't have libraries or any resource and that is possible because 'busybox' is static compiled. (I'm root, or have root access) My idea is too make a gate (like a memory I/O address to access the executable, or that executable loaded in the memory). First I create the gate (a memory address) where the program begins (a shared memory address that a child process can use). Loaded from the busybox executable. I use mprotect
too make the file executable and then I run fork()
in C
, That subprocess runs chroot
too change the root directory and jails himself. Then for security he changes the user to a non-root user without sudo access and has access to the directorys with setuid
and setgid
. And then the program runs the loaded program in memory with arguments provided from the parent. (the jailer that jails the busybox is also static compiled)
Yes, it is possible to run executable from memory:
How can i execute an executable from memory?
Only the problem is, how to run that memory executable with command line arguments?