Last active
December 18, 2015 13:19
-
-
Save blaquee/5788708 to your computer and use it in GitHub Desktop.
ctfdefcon
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 <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
typedef struct _llist { | |
struct _llist *next; | |
uint32_t tag; | |
char data[100]; | |
}llist; | |
char *answer; | |
//function pointer | |
char *(*func)(); | |
llist *head; | |
char* userBuf(llist* p) | |
{ | |
//holds address to p | |
llist* nextp = p; | |
char* d; | |
//traverse llist p | |
while(1){ | |
if(nextp->tag == 0x41414100){ | |
//tag matches magic tag | |
//not sure if necessary but lets replace address of p with nextp, holding current tag/data | |
p = nextp; | |
//return the data at this index | |
d = nextp->data; | |
}else{ | |
//incrmement to next item in list | |
nextp = nextp->next; | |
} | |
} | |
return d; | |
} | |
void send_string(answer){ | |
printf("The answer is: %s", answer); | |
} | |
int main(int argc, char* argv[]) | |
{ | |
func = (char *(*)(llist *))userBuf; | |
answer = (char *)(*func)(head); | |
send_string(answer); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment