upload-labs刷题笔记
这是一篇写得很粗糙的自己的笔记,不太适合阅读
1前端直接改
2
同1
3利用apache配置解析 php3类型文件
前提是apache的配置文件有解析php3等后缀名的配置语句 AddType application/x-httpd-php .php3 .php5....
4上传配置文件
黑名单过滤了基本所有后缀
上传.htaccess文件(apache配置文件,又是一个靠服务器配置文件的)
//将1.png文件作为php格式执行
<FilesMatch "1.png">
SetHandler application/x-httpd-php
</FilesMatch>
然后上传1.png即可//1.png的内容为php
5上传配置文件
上传.user.ini
文件
auto_prepend_file=1.png
然后用1.png(php代码
6大小写绕过
7空格绕过
8点绕过
9::$DATA
绕过
10 双写可绕过
11 00截断
12 00截断(post里面改路径)
需要注意的是post里面%00需要多做一步urldecode(因为%00其实是url编码里面的0,而0才是发挥截断作用的根本,也就是说其实0x00用)
13-16 图片马+文件包含
都是用记事本打开图片(尽量小一点的)然后最后补上
然后上传成功,用include包含图片即可实现
17-18 条件竞争
用burp多次访问,在删除之前进入php文件
19 白盒发现post中save_name可控 且pathinfo可以绕过
20
隐藏源码 查看提示 清空上传文件
Pass-01
Pass-02
Pass-03
Pass-04
Pass-05
Pass-06
Pass-07
Pass-08
Pass-09
Pass-10
Pass-11
Pass-12
Pass-13
Pass-14
Pass-15
Pass-16
Pass-17
Pass-18
Pass-19
Pass-20
任务
上传一个webshell到服务器。
上传区
请选择要上传的图片:
保存名称:
代码
$is_upload = false;
$msg = null;
if(!empty($_FILES['upload_file'])){
//检查MIME
$allow_type = array('image/jpeg','image/png','image/gif');
if(!in_array($_FILES['upload_file']['type'],$allow_type)){
$msg = "禁止上传该类型文件!";
}else{
//检查文件名
$file = empty($_POST['save_name']) ? $_FILES['upload_file']['name'] : $_POST['save_name'];
if (!is_array($file)) { //is_array() 如果是数组就不会进入!所以构造save_name为数组->$file为数组->end($file)==jpg
$file = explode('.', strtolower($file));
}
$ext = end($file); //主要是这里的end函数
$allow_suffix = array('jpg','png','gif');
if (!in_array($ext, $allow_suffix)) { //过了这个if
$msg = "禁止上传该后缀文件!";
}else{
$file_name = reset($file) . '.' . $file[count($file) - 1]; /*
reset和end的解释类似就是和数组提交顺序相关(而非数字!),手册的解释如此:有趣的是,当创建没有特定顺序的数字键的数组时,end()仍然只返回最后一个要创建的值(It's interesting to note that when creating an array with numeric keys in no particular order, end() will still only return the value that was the last one to be created)
2-1=1 正好这里是$file[1]--->"upload-20.php"*/
$temp_file = $_FILES['upload_file']['tmp_name'];
$img_path = UPLOAD_PATH . '/' .$file_name;
if (move_uploaded_file($temp_file, $img_path)) {
$msg = "文件上传成功!";
$is_upload = true;
} else {
$msg = "文件上传失败!";
}
}
}
}else{
$msg = "请选择要上传的文件!";
}
Copyright @ 2018 ~ 2022 by c0ny1