Created
January 16, 2021 04:20
-
-
Save xfgusta/d322b5a62d3411e6d57dcddcacbc394e to your computer and use it in GitHub Desktop.
Based on sentsui by xrsec (https://gist.github.com/xrsec/da6c11a49ba883c11ba68e50f0a809de)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/ioctl.h> | |
#include <fcntl.h> | |
int main(int argc, char **argv) { | |
if(argc != 3 || getuid()) { | |
fprintf(stderr, "Run '%s <fd> <cmd>' as root\n", argv[0]); | |
return 1; | |
} | |
int fd = open(argv[1], O_RDWR); | |
if(!fd) { | |
fprintf(stderr, "Can't open %s\n", argv[1]); | |
return 1; | |
} | |
for(char *c = argv[2]; *c; c++) | |
if(ioctl(fd, TIOCSTI, c)) | |
return 1; | |
return ioctl(fd, TIOCSTI, "\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment