puts("What would you like to do?\n"); printf("%u. Add new rifle\n", 1); printf("%u. Show added rifles\n", 2); printf("%u. Order selected rifles\n", 3); printf("%u. Leave a Message with your Order\n", 4); printf("%u. Show current stats\n", 5); printf("%u. Exit!\n", 6);
v0 = __readgsdword(0x14u); printf("Enter any notice you'd like to submit with your order: "); fgets(message, 0x80, stdin); deln(message); return __readgsdword(0x14u) ^ v0; }
经过逆向分析发现明显的堆溢出,这里chunk也不大属于fastbins,而且free的参数可控,那么首先考虑典型的house of spirit攻击,首先覆盖pre_add,改为指向got附近的指针,使name或者descript指向已经解析过的got项且pre_add位置指向空,那么就可以泄露出libc的地址;另一方面,将pre_add的值改为指向newtimes,将newtimes改为0x41,下一个chunk在msg中也可以改成正确的大小,就可以将其释放,再次分配可以更改这片区域,其中message是指针,它本来指向msg,若将其改为某个got项,就可对其进行修改。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
.bss:0804A288 ; rifle *rifleList .bss:0804A288 rifleList dd ? ; DATA XREF: add+11↑r .bss:0804A288 ; add+25↑w ... .bss:0804A28C align 20h .bss:0804A2A0 ordertimes dd ? ; DATA XREF: order+5A↑r .bss:0804A2A0 ; order+62↑w ... .bss:0804A2A4 newtimes dd ? ; DATA XREF: add+C5↑r .bss:0804A2A4 ; add+CD↑w ... .bss:0804A2A8 ; char *message .bss:0804A2A8 message dd ? ; DATA XREF: editMsg+23↑r .bss:0804A2A8 ; editMsg+3C↑r ... .bss:0804A2AC align 20h .bss:0804A2C0 msg db ? ; ; DATA XREF: main+29↑o .bss:0804A2C1 db ? ; .bss:0804A2C2 db ? ; .bss:0804A2C3 db ? ;