毛坯的人生和精裝的朋友圈
pwn17
while ( 1 ){menu();v4 = 0;puts("\nEnter the command you want choose:(1.2.3.4 or 5)\n");__isoc99_scanf("%d", &v4);switch ( v4 ){case 1:system("id");break;case 2:puts("Which directory?('/','./' or the directiry you want?)");read(0, buf, 0xAuLL);strcat(dest, buf);system(dest);puts("Execution succeeded!");break;case 3:sleep(1u);puts("$cat /ctfshow_flag");sleep(1u);puts("ctfshow{");sleep(2u);puts("... ...");sleep(3u);puts("Your flag is ...");sleep(5u);puts("ctfshow{flag is not here!}");sleep(0x14u);puts("wtf?You haven't left yet?\nOk~ give you flag:\nflag is loading......");sleep(0x1BF52u);system("cat /ctfshow_flag");break;case 4:sleep(2u);puts("su: Authentication failure");break;case 5:puts("See you!");exit(-1);default:puts("command not found!");break;}}
當我們看到case3中的system("cat /ctfshow_flag");覺得穩了
但是前面的sleep(0x1BF52u)意思要等31個小時才能執行到這一步啊
所以我們看到了case2
? ?case 2:
? ? ? ? puts("Which directory?('/','./' or the directiry you want?)");
? ? ? ? read(0, buf, 0xAuLL);// 通過read()函數從標準輸入(stdin)中讀取用戶輸入,并將其存儲在名為“buf”的緩沖區中,并且限制了長度最多為0xA,即9? ? ? ? strcat(dest, buf);//將用戶輸入的目錄追加到名為“dest”的已有字符串后面
? ? ? ? system(dest);
? ? ? ? puts("Execution succeeded!");
? ? ? ? break;
我們可以直接輸入/bin/sh來取得shell,因為//bin/sh可以執行sh命令
也可以直接;cat c*??
pwn18?
main
puts("Which is the real flag?");__isoc99_scanf("%d", &v4);if ( v4 == 9 )fake();elsereal();system("cat /ctfshow_flag");return 0;
}
fack()
int fake()
{return system("echo 'flag is here'>>/ctfshow_flag");
real()
int real()
{return system("echo 'flag is here'>/ctfshow_flag");
}
>>的意思是在/ctfshow_flag后追加flag is here
>是直接覆蓋掉/ctfshow_flag的內容了
所以我們只需填9就可以了