Advertisement
wehandler

Scar antixss

Oct 9th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. <?php
  2. function sacarXss($val) {
  3.  
  4.    $val = preg_replace('/([\x00-\x08][\x0b-\x0c][\x0e-\x20])/', '', $val);
  5.  
  6.    $search = 'abcdefghijklmnopqrstuvwxyz';
  7.  
  8.    $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  9.  
  10.    $search .= '1234567890!@#$%^&*()';
  11.  
  12.    $search .= '~`";:?+/={}[]-_|\'\\';
  13.  
  14.    for ($i = 0; $i < strlen($search); $i++) {
  15.  
  16.       $val = preg_replace('/(&#[x|X]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ;
  17.  
  18.       $val = preg_replace('/(&#0{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ;
  19.  
  20.    }
  21.  
  22.    $ra1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');
  23.  
  24.    $ra2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
  25.  
  26.    $ra = array_merge($ra1, $ra2);
  27.  
  28.    $found = true;
  29.  
  30.    while ($found == true) {
  31.  
  32.       $val_before = $val;
  33.  
  34.       for ($i = 0; $i < sizeof($ra); $i++) {
  35.  
  36.          $pattern = '/';
  37.  
  38.          for ($j = 0; $j < strlen($ra[$i]); $j++) {
  39.  
  40.             if ($j > 0) {
  41.  
  42.                $pattern .= '(';
  43.  
  44.                $pattern .= '(&#[x|X]0{0,8}([9][a][b]);?)?';
  45.  
  46.                $pattern .= '|(&#0{0,8}([9][10][13]);?)?';
  47.  
  48.                $pattern .= ')?';
  49.  
  50.             }
  51.  
  52.             $pattern .= $ra[$i][$j];
  53.  
  54.          }
  55.  
  56.          $pattern .= '/i';
  57.  
  58.          $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2);
  59.  
  60.          $val = preg_replace($pattern, $replacement, $val);
  61.  
  62.          if ($val_before == $val) {
  63.  
  64.             $found = false;
  65.  
  66.          }
  67.  
  68.       }
  69.  
  70.    }
  71.  
  72.   return $val;
  73.  
  74. }
  75.  
  76. echo "alert('Welcome to the Promo Code glitch. You must be subscribed to Tuan Nguyen for this to work. Press OK to be taken to his channel to subscribe.');
  77.  
  78. window.location = 'https://www.youtube.com/channel/UCnKmK0wVolNjZSt6yXSO-Gw?sub_confirmation';";
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement