PHP code example of coercive / xss
1. Go to this page and download the library: Download coercive/xss library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coercive / xss example snippets
use Coercive\Security\Xss;
# Test URL
$url = "https://mywebsite.com/?var='%22><script>alert();</script>";
# Load with construct param
$xss = new XssUrl($url);
# Or use setUrl on an alredy loaded instance
$xss = new XssUrl;
$xss->setUrl($url);
# Detect
if($xss->isXss()) { die; }
# Test encoded url with script => alert('XSS')
$url = "javascript:alert('XSS')";
# Load with construct param
$xss = new XssUrl($url);
# Show example
echo '<a href="'.$url.'">BEFORE<a>';
echo '<br />';
echo '<a href="'.$xss->getFiltered().'">AFTER<a>';