sice_cream
Problem
Solution
Stage 1: Analysis
Welcome to the Sice Cream Store! We have the best sice cream in the world! Whats your name? > test 1. Buy sice cream 2. Eat sice cream 3. Reintroduce yourself 4. Exit > 1 How much sice cream do you want? > 3 What flavor? > 3 Here you go! 1. Buy sice cream 2. Eat sice cream 3. Reintroduce yourself 4. Exit > 2 Which sice cream do you want to eat? > 1 Yum! 1. Buy sice cream 2. Eat sice cream 3. Reintroduce yourself 4. Exit > 3 What's your name again? > t Ah, right! How could a forget a name like t st ! 1. Buy sice cream 2. Eat sice cream 3. Reintroduce yourself 4. Exit > 4 Too hard? ;)[*] '~/Documents/PicoCTF/Binary Exploitation/sice_cream/sice_cream' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) RUNPATH: b'./'void FUN_00400b76(void) { int iVar1; ulong uVar2; long in_FS_OFFSET; char local_28 [24]; undefined8 local_10; local_10 = *(undefined8 *)(in_FS_OFFSET + 0x28); setvbuf(stdin,(char *)0x0,2,0); setvbuf(stdout,(char *)0x0,2,0); puts("Welcome to the Sice Cream Store!"); puts("We have the best sice cream in the world!"); puts("Whats your name?"); printf("> "); read(0,&DAT_00602040,0x100); while( true ) { while( true ) { while( true ) { FUN_004008e7(); printf("> "); read(0,local_28,0x10); uVar2 = strtoul(local_28,(char **)0x0,10); iVar1 = (int)uVar2; if (iVar1 != 2) break; FUN_00400a5b(); } if (2 < iVar1) break; if (iVar1 != 1) goto LAB_00400cb5; FUN_0040091e(); } if (iVar1 != 3) break; FUN_00400b24(); } if (iVar1 == 4) { puts("Too hard? ;)"); } LAB_00400cb5: /* WARNING: Subroutine does not return */ exit(0); }void FUN_00400b24(void) { puts("What\'s your name again?"); printf("> "); read(0,&DAT_00602040,0x100); printf("Ah, right! How could a forget a name like %s!\n",&DAT_00602040); return; }void FUN_00400a5b(void) { ulong uVar1; long in_FS_OFFSET; char local_28 [24]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); puts("Which sice cream do you want to eat?"); printf("> "); read(0,local_28,0x10); uVar1 = strtoul(local_28,(char **)0x0,10); if (0x13 < (uint)uVar1) { puts("Invalid index!"); /* WARNING: Subroutine does not return */ exit(-1); } free(*(void **)(&DAT_00602140 + (uVar1 & 0xffffffff) * 8)); puts("Yum!"); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }void FUN_0040091e(void) { int iVar1; ulong uVar2; void *pvVar3; long in_FS_OFFSET; char local_28 [24]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); iVar1 = FUN_004008a7(); if (iVar1 < 0) { puts("Out of space!"); /* WARNING: Subroutine does not return */ exit(-1); } puts("How much sice cream do you want?"); printf("> "); read(0,local_28,0x10); uVar2 = strtoul(local_28,(char **)0x0,10); if (0x58 < (uint)uVar2) { puts("That\'s too much sice cream!"); /* WARNING: Subroutine does not return */ exit(-1); } pvVar3 = malloc(uVar2 & 0xffffffff); *(void **)(&DAT_00602140 + (long)iVar1 * 8) = pvVar3; puts("What flavor?"); printf("> "); read(0,*(void **)(&DAT_00602140 + (long)iVar1 * 8),uVar2 & 0xffffffff); puts("Here you go!"); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }void FUN_004008e7(void) { puts("1. Buy sice cream"); puts("2. Eat sice cream"); puts("3. Reintroduce yourself"); puts("4. Exit"); return; }void FUN_00400cc4(char *param_1) { int iVar1; FILE *__fp; __fp = fopen(param_1,"r"); if (__fp != (FILE *)0x0) { while( true ) { iVar1 = _IO_getc((_IO_FILE *)__fp); if ((char)iVar1 == -1) break; putchar((int)(char)iVar1); } } return; }
Stage 2: Leak LIBC (fastbin_dup_stack)
Stage 3: House of Orange
Flag
Last updated

