代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.111cn.net/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <body> |
log_demo.php代码
代码如下 | 复制代码 |
<?php if ($_get['a'] == "pin") { if ($_get['a'] == "log") { |
log_aux.php代码
代码如下 | 复制代码 |
<?php function getpincookie($pin_code) function checkpincookie($pin_code_in, $timeout=300) // 5 miniuteswww.111cn.net function getpinimg() function __getpinimg($path) // output pincode image. if (strlen($data) < 200) { echo $data; |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>几种防御php程序被木马攻击配置详解方法</title>
</head>
<body>
防止跳出web目录
首先修改httpd.conf,如果你只允许你的php脚本程序在web目录里操作,还可以修改httpd.conf文件限制php的操作路径。比如你的web目录是/usr/local/apache/htdocs,那么在httpd.conf里加上这么几行:
php_admin_value open_basedir /usr/local/apache
/htdocs
这样,如果脚本要读取/usr/local/apache/htdocs以外的文件将不会被允许,如果错误显示打开的话会提示这样的错误:
warning: open_basedir restriction in effect. file is in wrong directory in
/usr/local/apache/htdocs/open.php on line 4
等等。
2、防止php木马执行webshell
打开safe_mode,
在,php.ini中设置
disable_functions= passthru,exec,shell_exec,system
二者选一即可,也可都选
3、防止php木马读写文件目录
在php.ini中的
disable_functions= passthru,exec,shell_exec,system
后面加上php处理文件的函数
主要有
fopen,mkdir,rmdir,chmod,unlink,dir
fopen,fread,fclose,fwrite,file_exists
closedir,is_dir,readdir.opendir
fileperms.copy,unlink,delfile
即成为
disable_functions= passthru,exec,shell_exec,system,fopen,mkdir,rmdir,chmod,unlink,dir
,fopen,fread,fclose,fwrite,file_exists
,closedir,is_dir,readdir.opendir
,fileperms.copy,unlink,delfile
ok,大功告成,php木马拿我们没辙了,遗憾的是这样的话,利用文本数据库教程的那些东西就都不能用了。
如果是在windos平台下搭建的apache我们还需要注意一点,apache默认运行是system权限,这很恐怖,这让人感觉很不爽.那我们就给apache降降权限吧。
net user apache fuckmicrosoft /add
net localgroup users apache /del
ok.我们建立了一个不属于任何组的用户apche。
我们打开计算机管理器,选服务,点apache服务的属性,我们选择log on,选择this account,我们填入上面所建立的账户和密码,重启apache服务,ok,apache运行在低权限下了。
实际上我们还可以通过设置各个文件夹的权限,来让apache用户只能执行我们想让它能干的事情,给每一个目录建立一个单独能读写的用户。这也是当前很多虚拟主机提供商的流行配置方法哦,不过这种方法用于防止这里就显的有点大材小用了
</body>
</html>
代码如下 | 复制代码 |
function _strips教程lashes($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = _strips教程lashes($val); } } else { $string = stripslashes($string); } return $string; } |
//111cn.net提示你:使用方法
代码如下 | 复制代码 |
$post = _stripslashes( $_post ); $get = _stripslashes( $_get ); $ot = _stripslashes( $_post['cc'] ); |
//这样用户所提交的" ' 增加的了' 或"这样,可以防止一些基本sql注入方法。
php教程获取文件扩展名二种有效方法
$upload_name ='www.111cn.net.rar';
$attach_ext = strtolower(substr(strrchr($upload_name,'.'),1));
echo $attach_ext;
//方法二
$extarray = explode('.',$upload_name);
if( is_array( $extarray ) )
{
$ext = end($extarray);
echo $ext;
}
/*
在文件上传过程中我们经常会需要取得上传文件的扩展名或叫做后缀名,进行
判断以确定文件类型。
本站原创文章转载注明来源www.111cn.net
名称:random_password()
#
#作者:克里斯亨特,杰里米阿什克拉夫特
#
#日期:1999年5月,2000年10月
#
#用途:返回一个作为密码使用随机单词。元音和辅音
#是交替给一个(希望)pronouncable,因此
#难忘的结果。
#
#用法:$ my_new_password = random_password();
#
#(c)1999年克里斯亨特。授予权限是自由包括此脚本
#您的程序。提供这个头是原封不动。
#
#2000年10月 - 茉莉酸 - Perl代码移植到PHP
function random_password() {
$maxlen = 6; # Default to 6
# Build tables of vowels & consonants. Single vowels are repeated so that
# resultant words are not dominated by dipthongs$vowel = array ("a","e", "i", "o", "u", "y", "ai", "au", "ay", "ea", "ee", "eu", "ia", "ie", "io", "oa", "oi", "oo", "oy");
$consonant = array ("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "qu", "r", "s", "t", "v", "w", "x", "z", "th", "st", "sh", "ph", "ng", "nd");
$password = "";srand((double) microtime()*1000000);
$vowelnext = (int)rand(0,1); # Initialise to 0 or 1 (ie true or false)do {
if ($vowelnext) {
$password = $password.$vowel[rand(0,sizeof($vowel))];
} else {
$password = $password.$consonant[rand(0,sizeof($consonant))];
}$vowelnext = !$vowelnext; # Swap letter type for the next one
} while (strlen($password) <$maxlen);
return $password;
}