D-Link Firmware
D-Link Firmware:DIR-2640_REVA_FIRMWARE_1.11B02
After extracting the firmware using binwalk, drag prog.cgi into IDA for analysis:
In the sub_481FC8 function, we can see a variable count controlling the number of iterations of a for loop. Within the loop, the strcpy function is used to copy haystack into ptr. However, since count is not validated, if count is sufficiently large, it can cause a heap overflow.
Checksec Analysis:
It turns out that no protections are enabled. First, let’s test it und ...
Dlink固件
Dlink固件:DIR-2640_REVA_FIRMWARE_1.11B02
binwalk提取固件后将prog.cgi拖入ida分析:在函数sub_481FC8中,可以看到一个变量count,来控制for循环的次数,循环中,使用strcpy函数把haystack复制到ptr中,而count并没有经过验证,所以当count足够大时,可以造成堆溢出。
checksec查看保护:发现啥保护都没开,先在qemu用户态下测试一下,运行prog.cgi大概是有些设备没挂载,所以我们先启动一个chroot容器,运行一下rcS
12chroot . ./qemu-mipsel-static ./bin/ashcd /etc/init.d && ./rcS
虽然有些问题,但还是挂载了一些盘上去,再运行prog.cgi试试
报错,经过调试,发现程序在函数sub_42D2DC退出,该函数是一个注册表函数,其在调用函数trace时,会触发ioctl的报错,所以我们把它patch掉,成功进入主循环
后来发现这个程序并不是通过网络来通信,而是利用getenv函数,通过环境变量来与web ...
hgame_week3_pwn题解
溢出来了offset_by_null利用的是堆合并时的漏洞,glibc 2.27的unsorted bin chunk在合并时,会根据当前chunk的prev in use位来判断是否向前/向后合并,然后通过prev size取到unsortedbin chunk的地址,这个时候会做一次检查,但中间合并的chunk他是不会做检查的,也就是说,即便中间的chunk是 in use的状态,也会被合并进去。也就是说我们可以构造一个这样的结构,假设有三个地址连续的chunk,我们把第一个chunk放进unsorted bin中,chunk2和chunk3 malloc出来,通过chunk2的offset by null改到chunk3的prev in use位,然后再把chunk3放入unsorted bin,触发合并,那么,正在in use状态的chunk2就会被合并进去,此时我们仍能访问到chunk2,uaf就达成了。这里可以泄露一次libc.
fastbins_double_free任意地址写可是这里充其量只能泄露,chunk中的内容已经不能修改了,我们得换种思路实现任意地址写 ...
hgame_week2_pwn题解
EldenRing 2简单的uaf,因为寒假才刚开始入门堆,所以写得稍微详细点。先看看伪c,
123456789101112131415161718192021222324252627282930313233// local variable allocation has failed, the output may be wrong!int __cdecl main(int argc, const char **argv, const char **envp){ int v4; // [rsp+1Ch] [rbp-4h] BYREF init(argc, argv, envp); while ( 1 ) { menu(*(_QWORD *)&argc); *(_QWORD *)&argc = "%d"; __isoc99_scanf("%d", &v4); switch ( v4 ) { case 1: add_note(); ...
hgame_week1_pwn题解
ezsignIn手速够快直接拿下一血
elden ring黑屏加载难绷,思路大概这样,栈迁移到bss段,mprotect改bss段权限,然后bss段注入shellcode执行orw.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061from pwn import *context(arch="amd64",log_level="debug")#p=process("./vuln")p=remote("47.100.137.175",32546)one=0xe3afelibc=ELF("./libc.so.6")elf=context.binary=ELF("./vuln")sleep(8)#gdb.attach(p)pop_rdi=0x00000000004013e3main=0x401297 ...
强网杯ez_fmt复现
ez_fmt本来想着用格式化字符串低位爆破,不过看了别的师傅的文章,似乎有更为巧妙的思路。先给大家看看题目
1234567891011121314151617nt __cdecl main(int argc, const char **argv, const char **envp){ char buf[88]; // [rsp+0h] [rbp-60h] BYREF unsigned __int64 v5; // [rsp+58h] [rbp-8h] v5 = __readfsqword(0x28u); setvbuf(stdout, 0LL, 2, 0LL); setvbuf(stdin, 0LL, 2, 0LL); printf("There is a gift for you %p\n", buf); read(0, buf, 0x30uLL); if ( w == 0xFFFF ) { printf(buf); w = 0; } return 0;}
题目逻辑很简单,给了一个栈上的地 ...
HackNote
Hacknote对于入门堆的师傅来说,这是个不错的入门题,但pwnabletw上扣了符号表,gdb调试起来比较麻烦,建议先做攻防世界上的,我们先看看ida反编译出来的代码
123456789101112131415161718192021222324252627282930313233343536373839404142void __cdecl __noreturn main(){ int v0; // eax char buf[4]; // [esp+8h] [ebp-10h] BYREF unsigned int v2; // [esp+Ch] [ebp-Ch] v2 = __readgsdword(0x14u); setvbuf(stdout, 0, 2, 0); setvbuf(stdin, 0, 2, 0); while ( 1 ) { while ( 1 ) { all_choice(); read(0, buf, 4u); v0 = atoi(buf); ...