I had an ideea to secure the upload via php code. Can you try to broke my test site (no httacces protection): Upload Here Shells:>, to let me know if this protectection actually works.
Protection Class Source Code:
And a demo in attachment.
Protection Class Source Code:
PHP Code:
<?php
//@package Simple safe-upload
//@author: Ionutxp
//@email: ionut_gerrard@yahoo.com
class SafeUpload
{
const upload_to = 'safe';
private $disalowed_tags = array('<html>', '<head>', 'href', '<td>', '<table>',
'<div', '<b>', 'function');
public $curent_location = null;
public function __construct($location)
{
$this->curent_location = $location;
if (count($_FILES) > 0)
{
foreach ($_FILES as & $file)
{
$goto = self::upload_to . '/' . mt_rand(1000000, 9999999) . '.php';
if (copy($file['tmp_name'], $goto))
{
self::check_file($goto);
}
}
return;
}
}
private function call_curl($goto)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $goto);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$webrep = curl_exec($curl);
curl_close($curl);
return $webrep;
}
private function check_file($url)
{
$content = $this->call_curl($this->curent_location . '/' . $url);
foreach ($this->disalowed_tags as $val)
{
if (substr_count($content, $val) > 0 && substr_count($content, 'syntax error') ==
0)
{
echo 'This site is protected.';
unset($_FILES);
break;
}
}
unlink($url);
}
}
$safe = new SafeUpload('http://mytester.host.org/'); // path to your uploader
?>
Comment