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; j<6; j++){
			if(lotto[i] == submit[j]){
				match++;
			}
		}
	}

我们可以看到这里把输入的submit的每个字节都与生成的lotto的每个字节进行了比较,这里如果我们submit提交的都是同一个字节,只要lotto里面出现一次,match的值就为6,会成功返回flag,所以这里我们尝试每次都输入#######,也就是6个35:

Submit your 6 lotto bytes : ######

Lotto Start!

bad luck…

– Select Menu –

  1. Play Lotto
  1. Help
  1. Exit

1

Submit your 6 lotto bytes : ######

Lotto Start!

bad luck…

– Select Menu –

  1. Play Lotto
  1. Help
  1. Exit

1

Submit your 6 lotto bytes : ######

Lotto Start!

sorry mom… I FORGOT to check duplicate numbers… 🙁

– Select Menu –

  1. Play Lotto
  1. Help
  1. Exit

大概尝试了三次之后成功获得了flag:

sorry mom… I FORGOT to check duplicate numbers… 🙁

最近的文章

pwnable.kr-cmd1

题目描述: Mommy! what is PATH environment in Linux? ssh [email protected] -p2222 (pw:guest)cmd1.c的源码为:#include <stdio.h>#include <string.h>int filter(char* cmd){ int r=0; r += strstr(cmd, "flag")!=0; r += strstr(cmd, "sh")!=0; r += strstr(...…

cmd pwnable.kr shell拼接继续阅读
更早的文章

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 a...…

21点 blackjack bypass pwnable.kr继续阅读