宝哥软件园

str_replace导致的注入问题摘要

编辑:宝哥软件园 来源:互联网 时间:2021-08-21

研究了置换注射的安全性。

sql注入的过滤方式一般是引用addslashes函数进行过滤。

他将把注入的单引号转换成 ',双引号转换成 ',反斜杠转换成 等等

写一个php代码:

!DOCTYPE html html head title/title meta http-equiv=' Content-Type ' Content=' text/html;charset=utf-8 '/head body?PHP $ x=$ _ GET[' x '];$ id=str _ replace(addslashes($ _ GET[' y ']),'',addslashes($ x));回声'过滤: '。addslashes($x)。br/';Echo 'replace替换旁路:$id。br/';$conn=mysql_connect('127.0.0.1 ',' root ',' root ');//连接到mysql数据库mysql_select_db('test ',$ conn);//在$conn连接请求下选择测试数据库名称$ SQL=' select * from user 1,其中id=' $ id//定义sql语句,组合变量id $ result=MySQL _ query($ SQL);//执行sql语句并返回变量result while($ row=MySQL _ fetch _ array($ result)){//遍历数组数据并显示echo 'ID '。$row['id']。/br ';回应“用户名”。$row['name']。/br ';} MySQL _ close($ conn);//关闭数据库连接回显“HR”;Echo' current语句:“”;echo $ sql?/body/html discovery是一个引用addslashes函数的:

单引号或双引号直接转义,这里注入的字符串基本是gg。结束了。

添加斜线问题:

Addslashes将把

更多资讯
游戏推荐
更多+