suchen
Heimphp教程php手册php通用防注入与注入详细说明

php通用防注入与注入详细说明

Jun 13, 2016 am 10:11 AM
getphppostsqlUnd命令Injektion详细veranschaulichen过滤通用

php通用防注入主要是过滤一些sql命令与php post get传过来的参考我们/要过滤一些非法字符,这样可以防止基本的注入了,那关第于apache 服务器安装设置方法也是必须的。管理员用户名和密码都采取md5加密,这样就能有效地防止了php的注入。

php教程通用防注入主要是过滤一些sql命令与php post get传过来的参考我们/要过滤一些非法字符,这样可以防止基本的注入了,那关第于apache 服务器安装设置方法也是必须的。管理员用户名和密码都采取md5加密,这样就能有效地防止了php的注入。
还有服务器和mysql教程也要加强一些安全防范。
对于linux服务器的安全设置:
加密口令,使用“/usr/sbin/authconfig”工具打开密码的shadow功能,对password进行加密。
禁止访问重要文件,进入linux命令界面,在提示符下输入:
#chmod 600 /etc/inetd.conf    //改变文件属性为600
#chattr +i  /etc/inetd.conf     //保证文件属主为root
#chattr –i  /etc/inetd.conf     // 对该文件的改变做限制  
禁止任何用户通过su命令改变为root用户
在su配置文件即/etc/pam.d/目录下的开头添加下面两行:
auth  sufficient  /lib/security/pam_rootok.so debug
auth  required  /lib/security/pam_whell.so group=wheel
删除所有的特殊帐户
#userdel  lp等等    删除用户
#groupdel lp等等    删除组
禁止不使用的suid/sgid程序
#find / -type f (-perm -04000  - o –perm -02000 ) -execls –lg {} ;

$arrfiltrate=array("'",";","union","select","insert","update","delete","load_file","outfile");

 //出错后要跳转的url

$strgourl="";  

function funstringexist($strfiltrate,$arrfiltrate)
{
  foreach ($arrfiltrate as $key=>$value)
  {
    if (eregi($value,$strfiltrate))
    {
      return true;
    }
  }
  return false;
}

//合并$_post 、 $_get和$_cookie

if(function_exists(array_merge))   
{
  $arrpostgetcookiesession=array_merge($http_post_vars,$http_get_vars,$http_cookie_vars); 
  $string = implode("",$arrpostgetcookiesession);
}

//验证

if(funstringexist($string,$arrfiltrate))
{
  echo "";
}
else
{
  echo "";
}

第二款防注入实例

php通用防注入安全代码
说明:
判断传递的变量中是否含有非法字符
如$_post、$_get
功能:
防注入
**************************/
//要过滤的非法字符
$arrfiltrate=array("'",";","union");
//出错后要跳转的url,不填则默认前一页
$strgourl="";
//是否存在数组中的值
function funstringexist($strfiltrate,$arrfiltrate){
foreach ($arrfiltrate as $key=>$value){
if (eregi($value,$strfiltrate)){
return true;
}
}
return false;
}
//合并$_post 和 $_get
if(function_exists(array_merge)){
$arrpostandget=array_merge($http_post_vars,$http_get_vars);
}else{
foreach($http_post_vars as $key=>$value){
$arrpostandget[]=$value;
}
foreach($http_get_vars as $key=>$value){
$arrpostandget[]=$value;
}
}
//验证开始
foreach($arrpostandget as $key=>$value){
if (funstringexist($value,$arrfiltrate)){
echo "alert(/"neeao提示,非法字符/");";
if (empty($strgourl)){
echo "history.go(-1);";
}else{
echo "window.location=/"".$strgourl."/";";
}
exit;
}
}


看一下关于注入细节

转化成ascii后是char(97,108,112,104,97)
转化成16进制是0x616c706861
(我们将在光盘中提供16进制和ascii转换工具)
好了直接在浏览器里输入:

http://localhost/site/admin/login.php?
username=char(97,108,112,104,97)%23


sql语句变成:

select * from alphaaut

hor where username=char(97,108,112,104,97)# and password=


如图21


  正如我们期望的那样,他顺利执行了,我们得到我们想要的。
  当然咯,我们也可以这样构造

http://www.bKjia.c0m/site/admin/login.php?username=0x616c706861%23


sql语句变成:

select * from alphaauthor where username
=0x616c706861%23# and password=


我们再一次是成功者了。很有成就感吧,

或许你会问我们是否可以把#也放在char()里
实际上char(97,108,112,104,97)相当于 alpha
注意是alpha上加引号,表示alpha字符串。
我们知道在mysql中如果执行

mysql> select * from dl_users where username=alpha;
error 1054 (42s22): unknown column alpha in where clause


看返回错误了。因为他会认为alpha是一个变量。所以我们得在alpha上加引号。
如下

mysql> select * from dl_users where username= alpha ;

 

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. So reparieren Sie Audio, wenn Sie niemanden hören können
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Wie man alles in Myrise freischaltet
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

EditPlus chinesische Crack-Version

EditPlus chinesische Crack-Version

Geringe Größe, Syntaxhervorhebung, unterstützt keine Code-Eingabeaufforderungsfunktion

SublimeText3 Linux neue Version

SublimeText3 Linux neue Version

SublimeText3 Linux neueste Version

WebStorm-Mac-Version

WebStorm-Mac-Version

Nützliche JavaScript-Entwicklungstools

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Herunterladen der Mac-Version des Atom-Editors

Herunterladen der Mac-Version des Atom-Editors

Der beliebteste Open-Source-Editor