Skip to content

Instantly share code, notes, and snippets.

@blaquee
Last active December 18, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaquee/5788708 to your computer and use it in GitHub Desktop.
Save blaquee/5788708 to your computer and use it in GitHub Desktop.
ctfdefcon
#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