php:文件系统③

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>VIEW</title>
    <link rel="stylesheet" href="???" type="text/css" />
</head>

<body>
<div class="register">
    <!--文件编码类型enctype;--->
    <form enctype="multipart/form-data" method="post" action="uploadprocess.php" name="myform">
        <table>
            <tr><td align="center" colspan="2"><font style="font-size: 40px;font-family:华文彩云;">
                        文件上传
                    </font></td></tr>
            <tr><td>请输入用户名:</td><td><input type="text" name="username" /> </td></tr>
            <tr><td>请简单介绍该文件</td><td><textarea rows="10" cols="40" name="fileintro" >
                </textarea></td></tr>
            <tr><td>请选择上传的文件:</td><td><input type="file" name="myfile" /> </td></tr>
            <tr><td><input type="submit" value="上传"></td><td> </td></tr>
        </table>
    </form>
</div>

</body>
</html>

<?php
$username=$_POST['username'];
$fileintro=$_POST['fileintro'];
echo $username.$fileintro;
echo "<pre>";
print_r($_FILES);
echo "</pre>";
//上传大文件时,需在php.ini中修改post_max_sizeupload_max_filesize参数;
$user_path=$_SERVER['DOCUMENT_ROOT']."/Hanshunping/UP/".$username;
$user_path=iconv("utf-8","gb2312",$user_path);
if(!file_exists($user_path)){
    mkdir($user_path);

}
$fileName=$_FILES['myfile']['name'];
$fileName=iconv("utf-8","gb2312",$fileName);

if(is_uploaded_file($_FILES['myfile']['tmp_name'])){
    $uploaded_file=$_FILES['myfile']['tmp_name'];
    //避免同一用户上传的同一名字文件被覆盖;
    $move_to_file=$user_path."/".time().rand(1,1000).
        substr($fileName,strrpos($fileName,"."));

    if(move_uploaded_file($uploaded_file,$move_to_file)){
        echo $_FILES['myfile']['name']."上传OK";
    }else{
        echo "上传失败";
    }
}else{
    echo "FAILED";
}


<?php $filename = $_GET['file']; 1、使用php://filter协议,读取index.php文件的源码,提交过程和截图。 参考代码 <?php $filename = $_GET['file']; include($filename); ?> ① 创建index.php,将上述参考代码写入,打开页面: ② 将Url修改为:http://127.0.0.1:8080/?file=php://filter/read=convert.base64-encode/resource=index.php 可以实现对index.php的以base64形式的源码查看: ③ 使用在线解码工具(https://www.toolhelper.cn/EncodeDecode/Base64)进行解码: 2、使用php://input协议执行一段php代码,提交过程和截图。 ① 输入http://127.0.0.1:8080/?file=php://input访问: ② 并使用burpsuit进行拦截,将包送至Repeater中修改为Post,并将php语句插到最后 ③ SEND发送, ④ 输入http://127.0.0.1:8080/shell.php访问刚刚写的php文件: 1、使用php://filter协议,读取index.php文件的源码,提交过程和截图。 参考代码 <?php $filename = $_GET['file']; include($filename); ?> ① 创建index.php,将上述参考代码写入,打开页面: ② 将Url修改为:http://127.0.0.1:8080/?file=php://filter/read=convert.base64-encode/resource=index.php 可以实现对index.php的以base64形式的源码查看: ③ 使用在线解码工具(https://www.toolhelper.cn/EncodeDecode/Base64)进行解码: 2、使用php://input协议执行一段php代码,提交过程和截图。 ① 输入http://127.0.0.1:8080/?file=php://input访问: ② 并使用burpsuit进行拦截,将包送至Repeater中修改为Post,并将php语句插到最后 ③ SEND发送, ④ 输入http://127.0.0.1:8080/shell.php访问刚刚写的php文件:
11-12
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值