solved 6
This commit is contained in:
27
4/level6/level6.c
Normal file
27
4/level6/level6.c
Normal file
@@ -0,0 +1,27 @@
|
||||
// gcc -o level6 -no-pie -fstack-protector level6.c
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void win(void) {
|
||||
char *argv[2];
|
||||
argv[0] = "/bin/sh";
|
||||
argv[1] = NULL;
|
||||
execve(argv[0], argv, NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Disable output buffering. Not part of the challenge.
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
|
||||
char buffer[64];
|
||||
while (1) {
|
||||
puts("What do you want to talk about?");
|
||||
read(0, buffer, 128);
|
||||
if (buffer[0] == '\0' || buffer[0] == '\n') break;
|
||||
|
||||
printf("I can't talk about %s.\n", buffer);
|
||||
}
|
||||
puts("Bye.");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user