Small partners recently discovered a site of learning pwn: http://www.pwnable.kr/ . Then think of a conduct, did have in mind the
Record it. So began the first!
1. Tap fd picture appears:
Observation ssh [email protected] -p2222 (pw: guest), is a ssh command. ssh secure shell is commonly used to link remote Linux servers.
We try to open a terminal linked server. Where fd is a user name, pwnable.kr is a domain name, this can be replaced by ip or alias. -p 2222 is,
port. guest for the password.
2. Open cmd terminal, enter ssh [email protected] -p 2222, and enter the password, successful landing! If you use the ip login, you can dig pwnable.kr,
The pwnable.kr replaced ip to other unchanged
3. logged in is the root directory (/ home / fd), then ls -alh view all files.
Analyze the last three file permissions:
File permissions owner group
-r-sr-x--- 1 fd_pwn fd 7.2K Jun 11 2014 fd
-rw-r--r-- 1 root root 418 Jun 11 2014 fd.c
-r--r----- 1 fd_pwn root 50 Jun 11 2014 flag
-r-sr-x--- 其中第一个-表示文件,r-s r-x ---分别为用户fp_pwn,组fd,以及其他用户对该文件的权限。分析可知,fd即我们登陆的用户只是对fd.c拥有可读权限。我们对flag文件无任何权限,只能从fd.c下手。
这里要特别提一下权限s,s权限是指在执行该文件是,获取该文件拥有者(在这即为fd_pwn)的所有权限。后边要用到哦!
4.上边分析了只能从fd.c下手,我们先查看下fd.c 输入cat fd.c:
5.分析下代码:
atio()函数是将字符串转换为数字,即将我们输入的数字处理为一下。
read(fp,buff,num)函数是将fp所指向的文件,读取num个字符,写到buf中。返回值为实际读取的字符数。如果fp为零,则在命令行读取。
strcmp(a,b),比较ab大小。如果a=b,返回值为0.
下面重点来了:
system("/bin/cat flag") 这个C文件会帮我们执行查看flag的命令。这里最关键的是当程序运行的时候,fd用户是可以获得fd_pwn的所有权限的,而fd_pwn 拥有对flag的r权限,这不正是我们需要的吗?
总结一下:
我们要让运行fd,使得可以查看flag文件。 分析代码可知,当我们输入的参数使 fd == 0 ,然后输入字符串LETMEWIN\n 即可。
6.终端输入:./fd 4660 然后输入LETMEWIN,回车:
7.然后将上边的mommy。。。输入到 flag框内,完成!!
补充:
我们可以将fd.c文件拷到我们本地,使用命令scp -P2222 [email protected]:fd.c .