2020.3.28 xctf(warmup)②

这篇博客主要探讨了PHP中的三个关键函数:in_array(), mb_substr(), mb_strpos(),并结合了一个CTF(warmup)挑战中的例子进行分析。作者指出,理解这些函数对于解决特定的编程问题至关重要。文章详细解释了每个函数的工作原理,并且通过代码示例展示了如何使用它们。最后,作者揭示了如何利用这些函数解决CTF挑战,从而获取flag。" 118484739,10535438,理解计算机视觉:特征描述符与图像匹配,"['计算机视觉', '图像处理', '特征检测', '图像匹配', 'OpenCV']

由于不熟悉PHP的几个函数,我查了几个小时才弄明白后面讲的什么!!
我们首先要弄懂的几个php函数:in_array(), mb_substr(), mb_strpos(),
在这里插入图片描述在这里插入图片描述可以看到有注释source.php,访问后可以看到其源码
在这里插入图片描述发现一个hint.php文件,先访问一下
在这里插入图片描述我猜测flag就在这个ffffllllaaaagggg里面
现在我们就开始看看代码中讲的啥!!
在这里插入图片描述
这里的整个逻辑就是这里的三个判断,其中最后一个判断是利用函数,前面两个判断是很容易绕过的。
我们这里分析一下,这个函数里讲的啥!!!
在这里插入图片描述这里就相当于创建一个python中的字典(当然这里是php)
然后第一个if条件就是判断这个变量是不是存在以及是不是字符串。
第二个if条件是判断我们传进来的这个参数是不是存在于前面创建的字典中

在这里插入图片描述首先mb_strpos()返回的是?在 p a g e 中 的 位 置 ( 也 就 是 一 个 数 ) , m b s u b s t r ( ) 函 数 是 在 page中的位置(也就是一个数), mb_substr()函数是在 pagembsubstrpage字符串中截取从第二参数到第三个参数之间的字符串。
下面就接着判断这个$page是不是开始创建的字典中的值。
在这里插入图片描述这里的代码和上面的代码差不多,唯一就是多了一个urldecode(),

urlencode()函数原理就是首先把中文字符转换为十六进制,然后在每个字符前面加一个标识符%。
urldecode()函数与urlencode()函数原理相反,用于解码已编码的 URL 字符串,其原理就是把十六进制字符串转换为中文字符

当我们这里传进去的是hint.php或者 source.php时,经过urldecode()是不会发生任何变化的。
在这里插入图片描述http://111.198.29.45:58041/?file=hint.php?/././././ffffllllaaaagggg
或者

http://111.198.29.45:58041/?file=hint.php%253f/../../../../ffffllllaaaagggg

***%253f是 ? 的二次编码***因为这里的?第一次会在url中自动解码一次,函数中还有一次。
由此得到flag
至于这里为什么include()会执行成功!!
include函数:以字符‘/’分隔(而且不计个数),如果在前面的字符串所代表的文件无法被PHP找到,则PHP会自动包含‘/’后面的文件——注意是最后一个‘/’。
…/和./以及/的含义
不知道目标文件在几级目录,有几个“…/”,就向上多跳几级。

在这里插入图片描述

### XCTF Challenge Web-6b6b154857 Details and Solution XCTF (eXtreme CTF) is a well-known platform for hosting Capture The Flag competitions, where participants solve challenges related to cybersecurity. For the specific challenge `web-6b6b154857`, detailed information may not be publicly available unless it was part of an official event with documented solutions or walkthroughs. #### Understanding the Problem Context Web-based challenges typically involve identifying vulnerabilities such as SQL injection, cross-site scripting (XSS), command injection, broken authentication mechanisms, etc., within a provided application environment[^2]. In this case, solving the challenge would require analyzing its structure and exploiting any weaknesses present in the system. #### General Approach to Solving Web Challenges To tackle web-related problems like `web-6b6b154857` from XCTF: 1. **Reconnaissance**: Begin by gathering all possible metadata about the target website using tools like `curl`, `wget`, or even manual inspection through browsers. ```bash curl http://challenge-url/ ``` 2. **Source Code Analysis**: If source code snippets are accessible via browser developer tools or other means, review them thoroughly for clues regarding hidden endpoints, comments indicating potential issues, or misconfigurations that could lead to exploitation opportunities[^3]. 3. **Vulnerability Exploitation**: Based on identified flaws during reconnaissance phase, attempt various attack vectors depending upon what seems plausible given context-specific constraints imposed by organizers when designing these puzzles[^4]: - Try injecting payloads into input fields looking out especially sensitive areas prone errors leading unauthorized access credentials leakage database manipulation actions beyond intended scope functionality offered users interacting normally without malicious intent whatsoever; Example payload testing against suspected XSS vulnerability might look something along lines below: ```html <script>alert(&#39;test&#39;);</script> ``` 4. **Flag Retrieval**: Once successful penetration achieved either directly retrieving flag stored somewhere inside filesystem memory process space network traffic captured packets sent received between client server communications over HTTP(S). #### Important Considerations While Participating Competitions Such As XCTF Always adhere strictly ethical guidelines set forth competition rules ensuring fair play among competitors while respecting legal boundaries protecting systems outside controlled environments specifically prepared contest purposes only never targeting real-world assets under any circumstances whatsoever[^5].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值