Created
March 20, 2015 05:13
-
-
Save JayXon/85c023369e4bbea74a68 to your computer and use it in GitHub Desktop.
SCTF2014 MISC100
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 <sys/types.h> | |
#include <signal.h> | |
#include <stdlib.h> | |
#include <err.h> | |
#include <termios.h> | |
int main(int argc, char *argv[]) | |
{ | |
struct termios info; | |
tcgetattr(0, &info); /* get current terminal attirbutes; 0 is the file descriptor for stdin */ | |
info.c_lflag &= ~ICANON; /* disable canonical mode */ | |
info.c_cc[VMIN] = 1; /* wait until at least one keystroke available */ | |
info.c_cc[VTIME] = 0; /* no timeout */ | |
tcsetattr(0, TCSANOW, &info); /* set immediately */ | |
int pid = atoi(argv[1]); | |
printf("pid: %d\n", pid); | |
int c; | |
while ((c = getchar()) != -1) | |
if (kill(pid, c) == -1) | |
warn("kill"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment