pwnable.kr-random

题目描述:

Daddy, teach me how to use random value in programming!

ssh [email protected] -p2222 (pw:guest)

其中random.c的代码为:

#include <stdio.h>

int main(){
 unsigned int random;
 random = rand(); // random value!

 unsigned int key=0;
 scanf("%d", &key);

 if( (key ^ random) == 0xdeadbeef ){
 printf("Good!\n");
 system("/bin/cat flag");
 return 0;
 }

 printf("Wrong, maybe you should try 2^32 cases.\n");
 return 0;
}

代码很简单,一开始以为是需要通过key溢出覆盖random的值,结果经过调试发现每次random()生成的数值是固定的,因为在本题的代码中并没有制定随机数种子(seed),导致每次生成的第一个数都是固定的。

第一个数为:0x6b8b456,最后的结果要求是(key ^ random) == 0xdeadbeef,

所以key的值应该为:0xdeadbeef^0x6b8b4567=3039230856

输入之后,获得flag:

random@ubuntu:~$ ./random

3039230856

Good!

Mommy, I thought libc random is unpredictable…

所以flag为:

Mommy, I thought libc random is unpredictable…

最近的文章

pwnable.kr-input

题目描述: Mom? how can I pass my input to a computer program? ssh [email protected] -p2222 (pw:guest)连接上ssh后,input.c的源码如下:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/socket.h>#include <arpa/inet.h&...…

exploit fd fork pipe pwn pwnable.kr read() shellcode socket 管道传输 重定向继续阅读
更早的文章

pwnable.kr-passcode

依然是题目描述: Mommy told me to make a passcode based login system. My initial C code was compiled without any error! Well, there was some compiler warning, but who cares about that? ssh [email protected] -p2222 (pw:guest)连上后,目录下有c源码和可执行文件,首先查看下程序...…

canary exploit gdb GOT覆盖 peda pwn pwnable.kr shellcode 溢出继续阅读