añadan a los 3 arrays $xss1, $xss2 y php indistintamentes si quieren mas expresiones relacionadas con XSS y webshells
Caracteristicas:
- no se podrá sobreescribir un mismo archivo ( evita duplicación )
- tamaño máximo de archivos a subir de 100kb
- no sirve de nada el http live headers ' no lo pasa '
- lleva un Filtro muy bueno tanto de XSS y ahora también de php
- permitios: serán el tipo de archivo que se podrá subir, ahora mismo solo se permite la subida a archivos:
- denegados: todos los demás no puestos en permitidos
Código PHP:
<?php
echo base64_decode('PGh0bWw+CjxoZWFkPgo8c3R5bGU+Ym9keXtiYWNrZ3JvdW5kLWNvbG9yOmJsYWNrO2NvbG9yOnJl
ZDt9Cjwvc3R5bGU+CjwvaGVhZD4KPGNlbnRlcj4KPGZvcm0gYWN0aW9uPSIiIG1ldGhvZD0icG9z
dCIgZW5jdHlwZT0ibXVsdGlwYXJ0L2Zvcm0tZGF0YSI+CjxpbWcgc3JjPSJodHRwOi8vaW1nMjA0
LmltYWdlc2hhY2sudXMvaW1nMjA0LzM1NDUvc2l0ZWxvZ293LnBuZyIgYm9yZGVyPSIwIj4KIAo8
cD48Zm9udCBjb2xvcj0iZ3JlZW4iPjxoMT5bU2VjdXJlIFVwbG9hZGVyXSB2MyBieSBNaWNoQnVr
YW5hPC9oMT48L2ZvbnQ+PC9wPjxiciAvPjxiciAvPgogCiAKPGlucHV0IG5hbWU9InVzZXJmaWxl
IiB0eXBlPSJmaWxlIj4KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2FkZW5hdGV4dG8iIHZh
bHVlPSIxIj4KPGlucHV0IHR5cGU9InN1Ym1pdCIgdmFsdWU9IkVudmlhciI+CiAKPC9mb3JtPg==
');
error_reporting (E_ALL ^ E_NOTICE);
$saltolinea = base64_decode('PGJyIC8+');
if ($_POST['cadenatexto']!="")
{
$permitidos = array('jpg', 'png', 'gif', 'jpeg', 'txt', 'pdf');
$archivo = $_FILES['userfile']['name'];
$tio = $_FILES['userfile']['tmp_name'];
$prefijo = substr(md5(uniqid(rand())),0,6);
$destino = "./subidos/".$prefijo."_".$archivo;
$tamano_archivo = $_FILES['userfile']['size'];
$val=file_get_contents($tio);
if(!file_get_contents($tio))
{
echo "fallo";
exit(0);
}
$xss1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script',
'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');
$xss2 = 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');
$php = Array('php', '<', '?', 'g', 'gzdeflate', 'gzinflate', 'gzuncompress', 'gzdecode', '>');
$ra = array_merge($xss1, $xss2, $php);
$num = count($ra);
echo "Cantidad de expresiones XSS cargadas actualmente: ".$num.$saltolinea;
if((($tamano_archivo < 100000) && (in_array(end(explode('.', $archivo)), $permitidos)))){
echo "Cantidad de deteccion XSS: ";
for ($i = 1; $i <= $num; $i++)
{
$lol = @substr_count($val, $ra[$i]);
echo $lol;
if ($lol > 0)
{
print_r(@substr_count($val, $ra)>0);
echo ''.$saltolinea;
exit(0);
}
}
if (copy($_FILES['userfile']['tmp_name'],$destino))
{
echo $saltolinea.$saltolinea.$saltolinea;
echo ''.$saltolinea;
exit(0);
}
}else{
echo ''.$saltolinea;
exit(0);
}
};
?>



No hay comentarios:
Publicar un comentario