Kali
/var/www/html/upload.php
创建目录、修改上传文件大小、运行服务
sudo mkdir /var/www/uploads
sudo chown www-data: /var/www/uploads
sudo vim /etc/php/7.4/apache2/php.ini
upload_max_filesize = 6M
sudo systemctl start apache2.server
========================================================================
Windows客户端
powershell
# 本地文件路径
$FilePath = 'c:\Users\Administrator\Desktop\import.doc';
# 服务器保存的文件名
$FieldName = 'import.doc' ;
$URL = 'http://192.168.164.141/upload.php';
# 换行符
$LF = "`r`n";
# boundary标记,用于区分多个文件
$boundary = [System.Guid]::NewGuid().ToString();
$ContentType = 'multipart/form-data; charset=utf-8; boundary='+$boundary;
# 读取本地文件
$File =[System.IO.File]::ReadAllBytes($FilePath);
# 编码器,用于将boundary等信息转为字节
$enc=[System.Text.Encoding]::GetEncoding('UTF-8');
# 拼接boundary与文件字节
[byte[]]$Body = $enc.GetBytes("--$boundary"+$LF+"Content-Disposition: form-data; name='file'; filename="+$FieldName+$LF+"Content-Type: application/octet-stream"+$LF+$LF);
[byte[]]$Body +=$File
[byte[]]$Body += $enc.GetBytes($LF+"--"+$boundary+"--"+$LF);
# $Body为字节数组时,即为发送数据流
Invoke-WebRequest -Uri $URL -Method Post -ContentType $ContentType -Body $Body ;
========================================================================
md5校验
windows
C:\Users\Administrator> certutil -hashfile C:\Users\Administrator\Desktop\import.doc md5
MD5 的 C:\Users\Administrator\Desktop\import.doc 哈希:
801586a3e0afe7f92aa766e9fcac126e
CertUtil: -hashfile 命令成功完成。
kali
┌──(rootkali)-[/var/www/uploads]
└─# md5sum import.doc
801586a3e0afe7f92aa766e9fcac126e import.doc