[网络安全]upload-labs Pass-20 解题详析

[网络安全]upload-labs Pass-20 解题详析(1) } ?>上传一个到服务器。请选择要上传的图片: 保存名称: 阅读详情

读者可参考、订阅专栏:Upload-Labs靶场攻防实战


Antsword蚁剑

蚁剑工具的使用可参考:

[网络安全]AntSword(蚁剑)实战解题详析(入门)

[网络安全]DVWA之File Upload—AntSword(蚁剑)攻击姿势及解题详析合集


姿势

后端逻辑代码:

<?php
include '../config.php';
include '../common.php';
include '../head.php';
include '../menu.php';

$is_upload = false;
$msg = null;
if (isset($_POST['submit'])) {
    if (file_exists(UPLOAD_PATH)) {
        $deny_ext = array("php","php5","php4","php3","php2","html","htm","phtml","pht","jsp","jspa","jspx","jsw","jsv","jspf","jtml","asp","aspx","asa","asax","ascx","ashx","asmx","cer","swf","htaccess");

        /*
        $file_name = trim($_POST['save_name']);
        $file_name = deldot($file_name);//删除文件名末尾的点
        $file_ext = pathinfo($file_name,PATHINFO_EXTENSION);
        $file_ext = strtolower($file_ext); //转换为小写
        $file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA
        $file_ext = trim($file_ext); //首尾去空
        */

        $file_name = $_POST['save_name'];
        $file_ext = pathinfo($file_name,PATHINFO_EXTENSION);

        if(!in_array($file_ext,$deny_ext)) {
            $temp_file = $_FILES['upload_file']['tmp_name'];
            $img_path = UPLOAD_PATH . '/' .$file_name;
            if (move_uploaded_file($temp_file, $img_path)) { 
                $is_upload = true;
            }else{
                $msg = '上传出错!';
            }
        }else{
            $msg = '禁止保存为该类型文件!';
        }

    } else {
        $msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';
    }
}
?>

<div id="upload_panel">
    <ol>
        <li>
            <h3>任务</h3>
            <p>上传一个<code>webshell</code>到服务器。</p>
        </li>
        <li>
            <h3>上传区</h3>
            <form enctype="multipart/form-data" method="post">
                <p>请选择要上传的图片:<p>
                <input class="input_file" type="file" name="upload_file"/>
                <p>保存名称:<p>
                <input class="input_text" type="text" name="save_name" value="upload-19.jpg" /><br/>
                <input class="button" type="submit" name="submit" value="上传"/>
            </form>
            <div id="msg">
                <?php 
                    if($msg != null){
                        echo "提示:".$msg;
                    }
                ?>
            </div>
            <div id="img">
                <?php
                    if($is_upload){
                        echo '<img src="'.$img_path.'" width="250px" />';
                    }
                ?>
            </div>
        </li>
        <?php 
            if($_GET['action'] == "show_code"){
                include 'show_code.php';
            }
        ?>
    </ol>
</div>

<?php
include '../footer.php';
?>

简单来说,定义了一个黑名单,接着使用move_uploaded_file函数将临时上传文件移动到指定的目标路径

由于move_uploaded_file函数会忽略掉文件末尾的 /.

因此当我们上传shell.php/.时,既能绕过黑名单,又能在移动路径时变为shell.php,达到命令执行的目的。

在这里插入图片描述

接着上传:

在这里插入图片描述

抓包:

在这里插入图片描述

改包:

在这里插入图片描述

放包:

在这里插入图片描述

利用靶场提供的文件包含漏洞:

在这里插入图片描述

成功实现命令执行:

在这里插入图片描述

(实战)[re:Invent 2018]-001:赛道分析-(致敬1024) 打印log 阅读详情

相关推荐

[华为ensp]双核心的园区网

(给部分只会emm......借鉴的朋友提个醒,在group-member e0/0/2 to e0/0/20是所选,所以到了p l t那会给2-20端口都配置上trunk,别紧张,不是你问题)完成上述配置后,PC1可以ping通HTTP2服务器,Client1可以访问HTTP2服务器的HTTP站点,如果不能就要检查上述是否正确。本次实验主要目的是采用双核心的冗余网络,采用MSTP和VRRP技术,在核心层交换机上配置SC1上配置OSPF协议。SC1交换机上配置VRRP。在SC1上配置DHCP。

2301_78859499的博客 1416

【网络安全】upload-labs Pass-04 解题详析

htaccess(Hypertext Access)是一个用于配置Apache服务器行为的配置文件。它通常位于网站的根目录或特定目录中,并用来控制目录下的文件访问权限、重定向、错误处理、认证等方面的设置。当服务器收到对"asdfg.jpg"文件的请求时,根据该指令,服务器会将其当作PHP脚本来处理,而不是直接将其作为静态图片返回给用户。这段代码是使用.htaccess文件的FilesMatch指令来对特定的文件进行处理。因此我们可以上传.htaccess文件,实现能够访问脚本文件、执行脚本即可。

等风来 6079

4D毫米波雷达

详解4D成像毫米波雷达

sangba2019的博客 2393

[网络安全]upload-labs Pass-07 解题详析

接着放包、复制文件上传路径、连接蚁剑即可。

等风来 5937

【文献阅读:信道估计】Deep Residual Learning Meets OFDM Channel Estimation

基于深度学习的信道估计技术

weixin_43178683的博客 1754

第 4 课 树莓派5的换源与中文输入法

树莓派换源、中文输入法的安装

嵌入式老牛的博客 2288

【网络安全】upload-labs Pass-19 解题详析

本文介绍了如何通过修改myupload.php文件中的代码,利用图片码绕过文件上传限制,上传含有eval代码的GIF文件,并通过文件包含功能点实现命令执行。文章详细描述了上传过程、获取图片路径、利用文件包含功能点执行命令的步骤,并提供了POC示例。此外,文章还提到可以通过条件竞争的方式完成该任务,并提供了相关参考链接。读者可参考相关专栏和文章,进一步学习网络安全攻防实战技巧。

等风来 6171

扩增子分析|基于零模型的群落确定性和随机性构建过程——R实战

周集中教授团队多年在群落确定性和随机性过程深耕,于2017年总结出来下述图表中的计算路径,广受生态领域研究者的推崇。本文基于该计算路径,梳理了整理了邓晔老师组的代码,通过一个实例演示了计算过程和结果。

weixin_46814750的博客 4673

【网络安全】upload-labs Pass-18 解题详析

作用为:fopen(“info.php”, “w”) 使用写入模式(w)打开了一个名为 info.php 的文件,然后,fputs() 函数将 <?> 写入到打开的文件中。的原理类似,我们可以在上传文件的一瞬间访问该文件,这样文件就无法被过滤及二次渲染。但利用条件竞争时,需要快速进行访问,而手工较慢,因此需要写特定的脚本进行访问或上传。可以知道,后端逻辑代码先上传文件,再进行过滤及二次渲染。说明info.php成功生成,同时该文件包含一句话木马。在点击开始攻击的一瞬间,访问目标文件路径。

等风来 6220

【NLG】(六)文本生成评价指标—— ROUGE原理及代码示例

前奏: 【NLG】(一)文本生成评价指标——BLEU原理及代码示例 【NLG】(二)文本生成评价指标—— METEOR原理及代码示例 【NLG】(三)文本生成评价指标—— ENTROPY原理及代码示例 【NLG】(四)文本生成评价指标—— diversity原理及代码示例 【NLG】(五)文本生成评价指标—— kl_divergence原理及代码示例 1.ROUGE原理 2.优缺点 3.如何算ROUGE ...

凝眸伏笔的博客 1万+

单片机应用案例:ESP32 搭配 BH1750 光强传感器和 Web 服务器

在该应用案例中,我们将使用 ESP32 开发板作为主控制器,BH1750 光强传感器用于采集环境光强度数据,并通过 Web 服务器展示采集到的数据。步骤一:购买材料步骤二:连接硬件步骤三:编写代码我们将使用 Arduino IDE 编写代码,以下是主要代码:// WiFi 设置const char* ssid = “你的 WiFi 名称”;const char* password = “密码”;// Web 服务器实例// BH1750 实例// 获取当前光强度数据。

RlDart的博客 813

【网络安全】upload-labs Pass-12 解题详析

00截断是操作系统层的漏洞,由于操作系统是C语言或汇编语言编写的,这两种语言在定义字符串时,都是以\0(即0x00)作为字符串的结尾。操作系统在识别字符串时,当读取到\0字符时,就认为读取到了一个字符串的结束符号。:定义允许上传的文件扩展名数组,只允许上传 jpg、png 和 gif 文件。因此,我们可以通过修改数据包,插入\0字符的方式,达到字符串截断的目的。函数从最后一个点(.)之后截取字符串,即获取文件扩展名。:检查文件扩展名是否在允许上传的扩展名数组中。:从上传的文件名中提取文件扩展名。

等风来 5965

【网络安全】upload-labs Pass-17 解题详析

由于二次渲染后图片中的部分数据会被修改,即(A,B,C)可能会被修改为(A,D,E),那么对于此限制,我们可以找到不被修改的。imagecreatefrompng是PHP中的一个函数,用于创建一个新的图像资源对象,并从PNG格式的图像文件中读取数据。,因为它不被过滤,因此我们将A修改为注入语句,此时语句不会被过滤,从而达到命令执行的目的。可以看到自00000190后,数据被二次渲染,也就是说在该行之前的数据是不会被渲染的。

等风来 6937

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

【网络安全】upload-labs Pass-16 解题详析

本文介绍了如何利用Antsword蚁剑工具进行文件上传漏洞的攻防实战。文章首先提供了相关的参考链接,详细讲解了蚁剑的使用方法和实战案例。接着,文章分析了后端逻辑代码,重点介绍了exif_imagetype()函数的使用,该函数通过读取图像的第一个字节来验证文件类型。文章提示需要通过开启php_exif模块来支持该函数,并建议使用图片码绕过文件类型验证。最后,文章引用了详细的解题分析链接,供读者进一步学习参考。

等风来 6010

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

[网络安全]upload-labs Pass-05 解题详析

由代码审计可知,对于上传的文件名,先删除文件名末尾的点,然后首位去空,因此我们可构造。可知,不能使用Pass-04的解题方法进行.htaccess文件绕过。

等风来 5897

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【网络安全】upload-labs Pass-13 解题详析

该题同Pass-12考察00截断,但为POST传参型。该题同Pass-12考察00截断,但为POST传参型。之后即可进行shell操作,本文不再赘述。接着将%00进行URL编码。

等风来 6008

【网络安全】upload-labs Pass-15 解题详析

使用getimagesize()函数获取图像文件的大小并返回图像的尺寸以及文件类型及图片高度与宽度,并将其取出的文件类型信息$info[2]与文件后缀白名单进行对比,判断上传的文件是否合法,并将info[2]作为上传后的文件的后缀名。其它操作同Pass-14,本文不再赘述。于是我们仍可以使用图片码上传。

等风来 5886

[网络安全]upload-labs Pass-08 解题详析

接着放包、复制文件上传路径、连接蚁剑即可。本文不再赘述。

等风来 5850

[网络安全]upload-labs Pass-02 解题详析

可使用Pass-01的方法。

等风来 5822

【网络安全】upload-labs Pass-03 解题详析

故可使用其它后缀名绕过,如php3、php4、phtml。代码审计可知普通的文件名被加入黑名单。

等风来 5984

[网络安全]upload-labs Pass-06 解题详析

由于PHPStudy中apache 2.4.39连接报错,可切换为nginx 1.15.11。本关并未使用strtolower函数对文件名进行大小写过滤,故可抓包进行大小写绕过。接着打开图片链接可得到文件上传URL。将.php改为.Php。

等风来 5947

【网络安全】upload-labs Pass-14 解题详析

可知其检测了文件头信息,此时仅抓包修改文件后缀名不可绕过。将1.php与1.png合并为shell.php即可。需写出文件所在路径及期望得到的文件路径。故文件包含、传参执行命令成功。成功得到shell.png。

等风来 6277

[网络安全]upload-labs Pass-10 解题详析

函数将文件扩展名中的字符串"::$DATA"替换为空,即去除该字符串。函数获取文件名中最后一个点(.)及其后面的部分,即文件的扩展名。这段代码是用于处理上传文件的文件名和文件扩展名。函数去除文件扩展名字符串首尾可能存在的空格。:从上传的文件中获取文件名,并使用。函数,将文件名末尾的点(.)删除。函数去除首尾可能存在的空格。函数将文件扩展名转换为小写。故上传的文件后缀名为。

等风来 5803

【网络安全】upload-labs Pass-21 解题详析

将文件名按照点号进行拆分。拆分后的结果是一个包含文件名和文件后缀的数组。如果不是数组类型,则使用。函数将文件后缀转换为小写字母。

等风来 6053

[网络安全]upload-labs Pass-01 解题详析

明显的是,我们可以访问该文件,故文件上传成功。

等风来 5962
上一篇: 【网络安全】upload-labs Pass-18 解题详析
下一篇: 【网络安全】upload-labs Pass-19 解题详析
秋说
秋说 优质创作者: 编程框架、信息安全技术领域 优质创作者: 编程框架、信息安全技术领域
博客等级 码龄4年 3万+粉丝 1906原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋说

感谢打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值