Skip to content

Instantly share code, notes, and snippets.

@JayXon
Created March 20, 2015 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayXon/85c023369e4bbea74a68 to your computer and use it in GitHub Desktop.
Save JayXon/85c023369e4bbea74a68 to your computer and use it in GitHub Desktop.
SCTF2014 MISC100
#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