CTF web题总结--上传文件绕过
来源:互联网 发布:地图开疆 知乎 编辑:程序博客网 时间:2024/06/05 13:49
代码:
<?phpif (empty($_FILES['inputFile'])) { echo json_encode(['error'=>'No files found for upload.']); return;}$allowedExts = array('php', 'php3', 'php4', 'php5', 'php7', 'phtml', 'cgi');$success = false;$output = '';$file = $_FILES['inputFile'];$filename = $file['name'];$parts = explode('.', basename($filename));$ext = end($parts);$type = $file['type'];$size = $file['size'];if (in_array($ext, $allowedExts) || count($parts) > 2) { $output = ['error'=>'How dare you do so???'];} else { if ($file['error'] > 0) { $success = false; $output = ['error' => $file['error']]; } else { $target = 'uploads' . DIRECTORY_SEPARATOR . sha1(uniqid()) . '.' . $ext; if ($fp = fopen($file["tmp_name"], 'r')) { $table_change = array('<?'=>''); $table_change += array('php' => ''); $table_change += array('script' => ''); $contents = fread($fp, filesize($file['tmp_name'])); fclose($fp); $contents = strtr($contents, $table_change); $fpw = fopen($target, 'w'); fwrite($fpw, $contents); fclose($fpw); } $output = ['uploaded' => $target]; }}echo json_encode($output);
可以上传Php、phtm
等类型,过滤了<?php
等,但是可以使用<?Script language="Php">
来绕过过滤,然后就一句话木马即可
阅读全文
0 0
- CTF web题总结--上传文件绕过
- CTF web题总结--绕过正则表达式
- CTF web题总结--任意文件下载
- CTF web题总结--SSRF
- CTF web题总结--unserizable
- CTF web题总结--LFI
- 文件上传验证绕过技术总结
- 文件上传验证绕过技术总结
- ctf 文件上传测试
- 上传验证绕过总结
- CTF web题总结--php函数漏洞
- CTF web题总结--爆破用户名密码
- CTF web总结
- CTF web总结
- CTF实验吧-上传绕过【0x00截断】
- CTF web总结(入门)
- CTF web总结--sql注入
- java web文件上传总结
- 单步调试 step into/step out/step over 区别
- DbUtils
- es6常用方法
- 跟我学分布式事务之2PC和3PC
- 软件开发过程,mvc
- CTF web题总结--上传文件绕过
- 数据挖掘中常见的数据处理技巧
- FreeMarker系列--FreeMarker入门
- String使用 == 和 equal
- centos磁盘扩展
- 使用STL:vector创建二维数组
- 最长公共字符串
- jq 动态增加、删除表tr行
- 分布式事务中2PC与3PC的区别