1.只需要nc一下~
这题由于靶机问题,暂时无法复现
本题nc
链接上靶机以后,是个docker
镜像题,可惜它并没有考到这个,我们只需env
查看环境变量或者echo $FLAG
即可
2.口算题卡
连上靶机后发现真的就是小学数学题,只要算对100次即可获得flag,本体考察的是pwntools
工具的使用,这里使用到了eval
函数
3.狠狠的溢出捏~
本体是标准的ret2libc
但似乎又有些不同,比赛的时候卡了一会
检查文件
> file pwn4 && checksec --file=pwn4
pwn4: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped
RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE
Partial RELRO No canary found NX enabled No PIE No RPATH No RUNPATH 67 Symbols No 0 1pwn4
64位,NX保护
用radare2
分析一下文件
> r2 pwn4
[0x004005c0]> aaa
INFO: Analyze all flags starting with sym. and entry0 (aa)
INFO: Analyze all functions arguments/locals (afva@@@F)
INFO: Analyze function calls (aac)
INFO: Analyze len bytes of instructions for references (aar)
INFO: Finding and parsing C++ vtables (avrr)
INFO: Type matching analysis for all functions (aaft)
INFO: Propagate noreturn information (aanr)
INFO: Use -AA or aaaa to perform additional experimental analysis
afl
查看程序中的所有函数
> afl
0x004005c0 1 42 entry0
0x00400600 4 37 sym.deregister_tm_clones
0x00400630 4 55 sym.register_tm_clones
0x00400670 3 29 sym.__do_global_dtors_aux
0x004006a0 1 7 sym.frame_dummy
0x004007e0 1 2 sym.__libc_csu_fini
0x004007e4 1 9 sym._fini
0x00400770 4 101 sym.__libc_csu_init
0x004005f0 1 2 sym._dl_relocate_static_pie
0x004006b0 3 185 main
0x00400590 1 6 sym.imp.setbuf
0x00400570 1 6 sym.imp.puts
0x004005a0 1 6 sym.imp.read
0x00400580 1 6 sym.imp.strlen
0x004005b0 1 6 sym.imp.exit
0x00400540 3 23 sym._init
没有什么显眼的函数,直接反汇编main
函数
> pdg @ main
// WARNING: Variable defined which should be unmapped: var_4h
// WARNING: Could not reconcile some variable overlaps
ulong main(void)
{
ulong var_70h;
ulong buf;
uint8_t var_5h;
ulong var_4h;
var_4h._0_4_ = 0;
sym.imp.setbuf(_reloc.stdin, 0);
sym.imp.setbuf(_reloc.stdout, 0);
sym.imp.setbuf(_reloc.stderr, 0);
sym.imp.puts("Leave your message:");
sym.imp.read(0, &buf, 0x200);
var_5h = sym.imp.strlen(&buf);
if (0x50 < var_5h) {
sym.imp.puts("hacker");
sym.imp.exit(0);
}
sym.imp.puts("Ok,Message Received");
return 0;
}
buf
数组0x60
,read
函数处有溢出,而且溢出的地址足够大。strlen
函数检查buf
长度,这里我们要做的第一步就是绕过if
函数,因为是strlen
所以我使用\0
来绕过
没有system
函数,我们来手动找一下/bin/sh
题目也没有给,到这我们所能使用的办法只有puts
函数泄漏libc
64位程序需要寄存器传惨
> ROPgadget --binary pwn4 --only 'pop|ret'
Gadgets information
============================================================
0x00000000004007cc : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret
0x00000000004007ce : pop r13 ; pop r14 ; pop r15 ; ret
0x00000000004007d0 : pop r14 ; pop r15 ; ret
0x00000000004007d2 : pop r15 ; ret
0x00000000004007cb : pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret
0x00000000004007cf : pop rbp ; pop r14 ; pop r15 ; ret
0x0000000000400628 : pop rbp ; ret
0x00000000004007d3 : pop rdi ; ret
0x00000000004007d1 : pop rsi ; pop r15 ; ret
0x00000000004007cd : pop rsp ; pop r13 ; pop r14 ; pop r15 ; ret
0x0000000000400556 : ret
EXP:
第二次构造rop
链的时候要注意栈平衡