pwnable.kr-blackjack

题目描述:

Hey! check out this C implementation of blackjack game!

I found it online

  • http://cboard.cprogramming.com/c-programming/114023-simple-blackjack-program.html

I like to give my flags to millionares.

how much money you got?

Running at : nc pwnable.kr 9009

看了下源码,就是个blackjack(21点)游戏,本还以为是需要自己写个机器人,过关的要求的是millionaire(100万),结果黑盒就过了,过程很简单,在投注的时候输了一个很大的数,第一次没有通过,要求重新输入,然后再输一次,并赢了这局就可以了。

看下源码,很容易发现有问题的地方:

int betting() //Asks user amount to bet
{
 printf("\n\nEnter Bet: $");
 scanf("%d", &bet);
 
 if (bet > cash) //If player tries to bet more money than player has
 {
        printf("\nYou cannot bet more money than you have.");
        printf("\nEnter Bet: ");
        scanf("%d", &bet);
        return bet;
 }
 else return bet;
} // End Function

这里if应该改成while,如果是if的话,这里只做了一次验证,第二次输入的bet并没有验证:

这样成功获得了flag:

YaY_I_AM_A_MILLIONARE_LOL

Cash: $727380468

——-

S
9
S

——-

Your Total is 9

The Dealer Has a Total of 10

flag是:

YaY_I_AM_A_MILLIONARE_LOL

最近的文章

pwnable.kr-lotto

题目描述: Mommy! I made a lotto program for my homework. do you want to play? ssh [email protected] -p2222 (pw:guest)看下源码,是个简易的lotto系统,输入6个字符,与系统/dev/urandom生成的6个字符进行比较,如果相同的话就中奖了,但是在检查的地方代码出现了问题:int match = 0, j = 0; for(i=0; i<6; i++){ for(j=0...…

lotto pwnable.kr继续阅读
更早的文章

pwnable.kr-coin1

题目描述: Mommy, I wanna play a game! (if your network response time is too slow, try nc 0 9007 inside pwnable.kr server) Running at : nc pwnable.kr 9007运行连接后发现是个小游戏: ————————————————— – Shall we play a game? – ————————————————— You have given ...…

coin payload pwnable.kr socket 二分法继续阅读