Last active
September 20, 2016 15:23
-
-
Save MrPickles/59707ea5bb34584ff579ff26dd9b1868 to your computer and use it in GitHub Desktop.
This is a short program written for HACS408E that will generate a victory message for the sharedverbose binary.
This file contains 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 <fcntl.h> | |
#include <string.h> | |
#include <sys/mman.h> | |
#include <unistd.h> | |
/* | |
* This causes sharedverbose to print "bingo \o/" by modifying the shared | |
* memory portion to give conditions in which the program will terminate | |
* and give a victory message. | |
* | |
* gcc bingo.c -o bingo -lrt | |
* ./bingo | |
*/ | |
int main() { | |
int fd = shm_open("/sharedverbose", 66, S_IRWXU); | |
char payload[22] = {0}; | |
// Copy the winning payload in. | |
strcpy(payload, "REVEN for 1337s"); | |
// Activate the 21st byte to terminate the infinite loop. | |
payload[21] = 1; | |
write(fd, payload, sizeof(payload)); | |
close(fd); | |
// We wait for the second infinite loop to start... | |
usleep(1000); | |
// ...reopen the shared memory... | |
fd = shm_open("/sharedverbose", 66, S_IRWXU); | |
// ...and flip the 21st byte again to end the program. | |
write(fd, payload, sizeof(payload)); | |
close(fd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment