Skip to content

Instantly share code, notes, and snippets.

@MrPickles
Last active Sep 20, 2016
Embed
What would you like to do?
This is a short program written for HACS408E that will generate a victory message for the sharedverbose binary.
#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