Skip to content

Instantly share code, notes, and snippets.

@johnkhbaek
Created May 18, 2021 21:46
Show Gist options
  • Save johnkhbaek/38e1127d3e6a780cf66a9c5a667c313f to your computer and use it in GitHub Desktop.
Save johnkhbaek/38e1127d3e6a780cf66a9c5a667c313f to your computer and use it in GitHub Desktop.
// gcc keys.c
// ./a.out
#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 = "\ncurl https://wtfismyip.com/text\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