38 lines
No EOL
612 B
C
38 lines
No EOL
612 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
#include <stdlib.h>
|
|
|
|
int echo_service(){
|
|
char x[4];
|
|
read(0, x, 50);
|
|
printf("%s", x);
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
|
|
void brop() {
|
|
system("/bin/sh");
|
|
printf("brop");
|
|
fflush(stdout);
|
|
}
|
|
|
|
int main(void) {
|
|
printf("%p\n", &main);
|
|
printf("%p\n", &brop);
|
|
printf("%lu\n", (unsigned long)&main - (unsigned long)&brop);
|
|
fflush(stdout);
|
|
while(1) {
|
|
if (fork() == 0) {
|
|
echo_service();
|
|
return 0;
|
|
}
|
|
int status;
|
|
wait(&status);
|
|
if (status != 0) {
|
|
puts("You broke the internet!");
|
|
fflush(stdout);
|
|
}
|
|
}
|
|
return 0;
|
|
} |