forked from p34709852/monkey
Implemented execution trough module load attack technique
This commit is contained in:
parent
452724c487
commit
d1f8e52266
|
@ -5,7 +5,8 @@ import socket
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import infection_monkey.config
|
import infection_monkey.config
|
||||||
|
from common.utils.attack_utils import ScanStatus
|
||||||
|
from infection_monkey.telemetry.attack.t1129_telem import T1129Telem
|
||||||
from infection_monkey.pyinstaller_utils import get_binary_file_path, get_binaries_dir_path
|
from infection_monkey.pyinstaller_utils import get_binary_file_path, get_binaries_dir_path
|
||||||
|
|
||||||
__author__ = 'itay.mizeretz'
|
__author__ = 'itay.mizeretz'
|
||||||
|
@ -49,8 +50,10 @@ class MimikatzCollector(object):
|
||||||
self._get = get_proto(("get", self._dll))
|
self._get = get_proto(("get", self._dll))
|
||||||
self._get_text_output_proto = get_text_output_proto(("getTextOutput", self._dll))
|
self._get_text_output_proto = get_text_output_proto(("getTextOutput", self._dll))
|
||||||
self._isInit = True
|
self._isInit = True
|
||||||
|
T1129Telem(ScanStatus.USED, "Windows module loader was used to load Mimikatz DLL.").send()
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("Error initializing mimikatz collector")
|
LOG.exception("Error initializing mimikatz collector")
|
||||||
|
T1129Telem(ScanStatus.SCANNED, "Monkey tried to load Mimikatz DLL, but failed.").send()
|
||||||
|
|
||||||
def get_logon_info(self):
|
def get_logon_info(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
from infection_monkey.telemetry.attack.attack_telem import AttackTelem
|
from infection_monkey.telemetry.attack.usage_telem import UsageTelem
|
||||||
|
|
||||||
|
|
||||||
class T1035Telem(AttackTelem):
|
class T1035Telem(UsageTelem):
|
||||||
def __init__(self, status, usage):
|
def __init__(self, status, usage):
|
||||||
"""
|
"""
|
||||||
T1035 telemetry.
|
T1035 telemetry.
|
||||||
:param status: ScanStatus of technique
|
:param status: ScanStatus of technique
|
||||||
:param usage: Usage string
|
:param usage: Usage string
|
||||||
"""
|
"""
|
||||||
super(T1035Telem, self).__init__('T1035', status)
|
super(T1035Telem, self).__init__('T1035', status, usage)
|
||||||
self.usage = usage
|
|
||||||
|
|
||||||
def get_data(self):
|
|
||||||
data = super(T1035Telem, self).get_data()
|
|
||||||
data.update({
|
|
||||||
'usage': self.usage
|
|
||||||
})
|
|
||||||
return data
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
from infection_monkey.telemetry.attack.usage_telem import UsageTelem
|
||||||
|
|
||||||
|
|
||||||
|
class T1129Telem(UsageTelem):
|
||||||
|
def __init__(self, status, usage):
|
||||||
|
"""
|
||||||
|
T1129 telemetry.
|
||||||
|
:param status: ScanStatus of technique
|
||||||
|
:param usage: Usage string
|
||||||
|
"""
|
||||||
|
super(T1129Telem, self).__init__("T1129", status, usage)
|
|
@ -0,0 +1,20 @@
|
||||||
|
from infection_monkey.telemetry.attack.attack_telem import AttackTelem
|
||||||
|
|
||||||
|
|
||||||
|
class UsageTelem(AttackTelem):
|
||||||
|
|
||||||
|
def __init__(self, technique, status, usage):
|
||||||
|
"""
|
||||||
|
T1035 telemetry.
|
||||||
|
:param status: ScanStatus of technique
|
||||||
|
:param usage: Usage string
|
||||||
|
"""
|
||||||
|
super(UsageTelem, self).__init__(technique, status)
|
||||||
|
self.usage = usage
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
data = super(UsageTelem, self).get_data()
|
||||||
|
data.update({
|
||||||
|
'usage': self.usage
|
||||||
|
})
|
||||||
|
return data
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from monkey_island.cc.services.attack.technique_reports import T1210, T1197, T1110, T1075, T1003, T1059, T1086, T1082
|
from monkey_island.cc.services.attack.technique_reports import T1210, T1197, T1110, T1075, T1003, T1059, T1086, T1082
|
||||||
from monkey_island.cc.services.attack.technique_reports import T1145, T1035
|
from monkey_island.cc.services.attack.technique_reports import T1145, T1035, T1129
|
||||||
from monkey_island.cc.services.attack.attack_config import AttackConfig
|
from monkey_island.cc.services.attack.attack_config import AttackConfig
|
||||||
from monkey_island.cc.database import mongo
|
from monkey_island.cc.database import mongo
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ TECHNIQUES = {'T1210': T1210.T1210,
|
||||||
'T1086': T1086.T1086,
|
'T1086': T1086.T1086,
|
||||||
'T1082': T1082.T1082,
|
'T1082': T1082.T1082,
|
||||||
'T1145': T1145.T1145,
|
'T1145': T1145.T1145,
|
||||||
'T1035': T1035.T1035}
|
'T1035': T1035.T1035,
|
||||||
|
'T1129': T1129.T1129}
|
||||||
|
|
||||||
REPORT_NAME = 'new_report'
|
REPORT_NAME = 'new_report'
|
||||||
|
|
||||||
|
@ -58,12 +59,12 @@ class AttackReportService:
|
||||||
Gets latest report (by retrieving it from db or generating a new one).
|
Gets latest report (by retrieving it from db or generating a new one).
|
||||||
:return: report dict.
|
:return: report dict.
|
||||||
"""
|
"""
|
||||||
|
return AttackReportService.generate_new_report()
|
||||||
if AttackReportService.is_report_generated():
|
if AttackReportService.is_report_generated():
|
||||||
telem_time = AttackReportService.get_latest_attack_telem_time()
|
telem_time = AttackReportService.get_latest_attack_telem_time()
|
||||||
latest_report = mongo.db.attack_report.find_one({'name': REPORT_NAME})
|
latest_report = mongo.db.attack_report.find_one({'name': REPORT_NAME})
|
||||||
if telem_time and latest_report['latest_telem_time'] and telem_time == latest_report['latest_telem_time']:
|
if telem_time and latest_report['latest_telem_time'] and telem_time == latest_report['latest_telem_time']:
|
||||||
return latest_report
|
return latest_report
|
||||||
return AttackReportService.generate_new_report()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_report_generated():
|
def is_report_generated():
|
||||||
|
|
|
@ -107,6 +107,15 @@ SCHEMA = {
|
||||||
"that interacts with Windows services, such as the Service Control Manager.",
|
"that interacts with Windows services, such as the Service Control Manager.",
|
||||||
"depends_on": ["T1210"]
|
"depends_on": ["T1210"]
|
||||||
},
|
},
|
||||||
|
"T1129": {
|
||||||
|
"title": "T1129 Execution through module load",
|
||||||
|
"type": "bool",
|
||||||
|
"value": True,
|
||||||
|
"necessary": False,
|
||||||
|
"description": "The Windows module loader can be instructed to load DLLs from arbitrary "
|
||||||
|
"local paths and arbitrary Universal Naming Convention (UNC) network paths.",
|
||||||
|
"depends_on": ["T1078", "T1003"]
|
||||||
|
},
|
||||||
"T1059": {
|
"T1059": {
|
||||||
"title": "T1059 Command line interface",
|
"title": "T1059 Command line interface",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
|
|
@ -10,22 +10,8 @@ class T1035(AttackTechnique):
|
||||||
scanned_msg = "Monkey tried to interact with Windows services, but failed."
|
scanned_msg = "Monkey tried to interact with Windows services, but failed."
|
||||||
used_msg = "Monkey successfully interacted with Windows services."
|
used_msg = "Monkey successfully interacted with Windows services."
|
||||||
|
|
||||||
query = [{'$match': {'telem_category': 'attack',
|
|
||||||
'data.technique': tech_id}},
|
|
||||||
{'$lookup': {'from': 'monkey',
|
|
||||||
'localField': 'monkey_guid',
|
|
||||||
'foreignField': 'guid',
|
|
||||||
'as': 'monkey'}},
|
|
||||||
{'$project': {'monkey': {'$arrayElemAt': ['$monkey', 0]},
|
|
||||||
'status': '$data.status',
|
|
||||||
'usage': '$data.usage'}},
|
|
||||||
{'$addFields': {'_id': 0,
|
|
||||||
'machine': {'hostname': '$monkey.hostname', 'ips': '$monkey.ip_addresses'},
|
|
||||||
'monkey': 0}},
|
|
||||||
{'$group': {'_id': {'machine': '$machine', 'status': '$status', 'usage': '$usage'}}}]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_report_data():
|
def get_report_data():
|
||||||
data = T1035.get_tech_base_data()
|
data = T1035.get_tech_base_data()
|
||||||
data.update({'services': list(mongo.db.telemetry.aggregate(T1035.query))})
|
data.update({'services': list(mongo.db.telemetry.aggregate(T1035.get_usage_query()))})
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
from monkey_island.cc.database import mongo
|
||||||
|
from monkey_island.cc.services.attack.technique_reports import AttackTechnique
|
||||||
|
|
||||||
|
__author__ = "VakarisZ"
|
||||||
|
|
||||||
|
|
||||||
|
class T1129(AttackTechnique):
|
||||||
|
tech_id = "T1129"
|
||||||
|
unscanned_msg = "Monkey didn't try to load any DLL's."
|
||||||
|
scanned_msg = "Monkey tried to load DLL's, but failed."
|
||||||
|
used_msg = "Monkey successfully loaded DLL's using Windows module loader."
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_report_data():
|
||||||
|
data = T1129.get_tech_base_data()
|
||||||
|
data.update({'dlls': list(mongo.db.telemetry.aggregate(T1129.get_usage_query()))})
|
||||||
|
return data
|
|
@ -112,3 +112,23 @@ class AttackTechnique(object):
|
||||||
data = cls.get_message_and_status(status)
|
data = cls.get_message_and_status(status)
|
||||||
data.update({'title': cls.technique_title()})
|
data.update({'title': cls.technique_title()})
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_usage_query(cls):
|
||||||
|
"""
|
||||||
|
:return: Query that parses attack telems for simple report component
|
||||||
|
(gets machines and attack technique usage).
|
||||||
|
"""
|
||||||
|
return [{'$match': {'telem_category': 'attack',
|
||||||
|
'data.technique': cls.tech_id}},
|
||||||
|
{'$lookup': {'from': 'monkey',
|
||||||
|
'localField': 'monkey_guid',
|
||||||
|
'foreignField': 'guid',
|
||||||
|
'as': 'monkey'}},
|
||||||
|
{'$project': {'monkey': {'$arrayElemAt': ['$monkey', 0]},
|
||||||
|
'status': '$data.status',
|
||||||
|
'usage': '$data.usage'}},
|
||||||
|
{'$addFields': {'_id': 0,
|
||||||
|
'machine': {'hostname': '$monkey.hostname', 'ips': '$monkey.ip_addresses'},
|
||||||
|
'monkey': 0}},
|
||||||
|
{'$group': {'_id': {'machine': '$machine', 'status': '$status', 'usage': '$usage'}}}]
|
||||||
|
|
|
@ -19,3 +19,19 @@ export function renderMachineFromSystemData(data) {
|
||||||
});
|
});
|
||||||
return machineStr + ")"
|
return machineStr + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Formats telemetry data that contains _id.machine and _id.usage fields into columns
|
||||||
|
for react table. */
|
||||||
|
export function getUsageColumns() {
|
||||||
|
return ([{
|
||||||
|
columns: [
|
||||||
|
{Header: 'Machine',
|
||||||
|
id: 'machine',
|
||||||
|
accessor: x => renderMachineFromSystemData(x._id.machine),
|
||||||
|
style: { 'whiteSpace': 'unset' },
|
||||||
|
width: 300},
|
||||||
|
{Header: 'Usage',
|
||||||
|
id: 'usage',
|
||||||
|
accessor: x => x._id.usage,
|
||||||
|
style: { 'whiteSpace': 'unset' }}]
|
||||||
|
}])}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import '../../../styles/Collapse.scss'
|
import '../../../styles/Collapse.scss'
|
||||||
import ReactTable from "react-table";
|
import ReactTable from "react-table";
|
||||||
import { renderMachineFromSystemData } from "./Helpers"
|
import { getUsageColumns } from "./Helpers"
|
||||||
|
|
||||||
|
|
||||||
class T1035 extends React.Component {
|
class T1035 extends React.Component {
|
||||||
|
@ -10,20 +10,6 @@ class T1035 extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getServiceColumns() {
|
|
||||||
return ([{
|
|
||||||
columns: [
|
|
||||||
{Header: 'Machine',
|
|
||||||
id: 'machine',
|
|
||||||
accessor: x => renderMachineFromSystemData(x._id.machine),
|
|
||||||
style: { 'whiteSpace': 'unset' },
|
|
||||||
width: 300},
|
|
||||||
{Header: 'Usage',
|
|
||||||
id: 'usage',
|
|
||||||
accessor: x => x._id.usage,
|
|
||||||
style: { 'whiteSpace': 'unset' }}]
|
|
||||||
}])};
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -31,7 +17,7 @@ class T1035 extends React.Component {
|
||||||
<br/>
|
<br/>
|
||||||
{this.props.data.services.length !== 0 ?
|
{this.props.data.services.length !== 0 ?
|
||||||
<ReactTable
|
<ReactTable
|
||||||
columns={T1035.getServiceColumns()}
|
columns={getUsageColumns()}
|
||||||
data={this.props.data.services}
|
data={this.props.data.services}
|
||||||
showPagination={false}
|
showPagination={false}
|
||||||
defaultPageSize={this.props.data.services.length}
|
defaultPageSize={this.props.data.services.length}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import React from 'react';
|
||||||
|
import '../../../styles/Collapse.scss'
|
||||||
|
import ReactTable from "react-table";
|
||||||
|
import {getUsageColumns} from "./Helpers";
|
||||||
|
|
||||||
|
class T1129 extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div>{this.props.data.message}</div>
|
||||||
|
<br/>
|
||||||
|
{this.props.data.dlls.length !== 0 ?
|
||||||
|
<ReactTable
|
||||||
|
columns={getUsageColumns()}
|
||||||
|
data={this.props.data.dlls}
|
||||||
|
showPagination={false}
|
||||||
|
defaultPageSize={this.props.data.dlls.length}
|
||||||
|
/> : ""}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default T1129;
|
|
@ -15,6 +15,7 @@ import T1086 from "../attack/techniques/T1086";
|
||||||
import T1082 from "../attack/techniques/T1082";
|
import T1082 from "../attack/techniques/T1082";
|
||||||
import T1145 from "../attack/techniques/T1145";
|
import T1145 from "../attack/techniques/T1145";
|
||||||
import T1035 from "../attack/techniques/T1035";
|
import T1035 from "../attack/techniques/T1035";
|
||||||
|
import T1129 from "../attack/techniques/T1129";
|
||||||
|
|
||||||
const tech_components = {
|
const tech_components = {
|
||||||
'T1210': T1210,
|
'T1210': T1210,
|
||||||
|
@ -26,7 +27,8 @@ const tech_components = {
|
||||||
'T1086': T1086,
|
'T1086': T1086,
|
||||||
'T1082': T1082,
|
'T1082': T1082,
|
||||||
'T1145': T1145,
|
'T1145': T1145,
|
||||||
'T1035': T1035
|
'T1035': T1035,
|
||||||
|
'T1129': T1129
|
||||||
};
|
};
|
||||||
|
|
||||||
const classNames = require('classnames');
|
const classNames = require('classnames');
|
||||||
|
|
Loading…
Reference in New Issue