Implemented service execution attack technique

This commit is contained in:
VakarisZ 2019-06-28 12:17:39 +03:00
parent a8a355afb2
commit 452724c487
10 changed files with 124 additions and 12 deletions

View File

@ -10,6 +10,8 @@ from infection_monkey.network import SMBFinger
from infection_monkey.network.tools import check_tcp_port from infection_monkey.network.tools import check_tcp_port
from infection_monkey.exploit.tools import build_monkey_commandline from infection_monkey.exploit.tools import build_monkey_commandline
from common.utils.exploit_enum import ExploitType from common.utils.exploit_enum import ExploitType
from infection_monkey.telemetry.attack.t1035_telem import T1035Telem
from common.utils.attack_utils import ScanStatus
LOG = getLogger(__name__) LOG = getLogger(__name__)
@ -129,7 +131,7 @@ class SmbExploiter(HostExploiter):
resp = scmr.hRCreateServiceW(scmr_rpc, sc_handle, self._config.smb_service_name, self._config.smb_service_name, resp = scmr.hRCreateServiceW(scmr_rpc, sc_handle, self._config.smb_service_name, self._config.smb_service_name,
lpBinaryPathName=cmdline) lpBinaryPathName=cmdline)
service = resp['lpServiceHandle'] service = resp['lpServiceHandle']
T1035Telem(ScanStatus.USED, "SMB exploiter ran the monkey by creating a service via MS-SCMR.").send()
try: try:
scmr.hRStartServiceW(scmr_rpc, service) scmr.hRStartServiceW(scmr_rpc, service)
except: except:

View File

@ -0,0 +1,19 @@
from infection_monkey.telemetry.attack.attack_telem import AttackTelem
class T1035Telem(AttackTelem):
def __init__(self, status, usage):
"""
T1035 telemetry.
:param status: ScanStatus of technique
:param usage: Usage string
"""
super(T1035Telem, self).__init__('T1035', status)
self.usage = usage
def get_data(self):
data = super(T1035Telem, self).get_data()
data.update({
'usage': self.usage
})
return data

View File

@ -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 from monkey_island.cc.services.attack.technique_reports import T1145, T1035
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
@ -17,7 +17,8 @@ TECHNIQUES = {'T1210': T1210.T1210,
'T1059': T1059.T1059, 'T1059': T1059.T1059,
'T1086': T1086.T1086, 'T1086': T1086.T1086,
'T1082': T1082.T1082, 'T1082': T1082.T1082,
'T1145': T1145.T1145} 'T1145': T1145.T1145,
'T1035': T1035.T1035}
REPORT_NAME = 'new_report' REPORT_NAME = 'new_report'

View File

@ -98,6 +98,15 @@ SCHEMA = {
"title": "Execution", "title": "Execution",
"type": "object", "type": "object",
"properties": { "properties": {
"T1035": {
"title": "T1035 Service execution",
"type": "bool",
"value": True,
"necessary": False,
"description": "Adversaries may execute a binary, command, or script via a method "
"that interacts with Windows services, such as the Service Control Manager.",
"depends_on": ["T1210"]
},
"T1059": { "T1059": {
"title": "T1059 Command line interface", "title": "T1059 Command line interface",
"type": "bool", "type": "bool",

View File

@ -0,0 +1,31 @@
from monkey_island.cc.database import mongo
from monkey_island.cc.services.attack.technique_reports import AttackTechnique
__author__ = "VakarisZ"
class T1035(AttackTechnique):
tech_id = "T1035"
unscanned_msg = "Monkey didn't try to interact with Windows services."
scanned_msg = "Monkey tried to interact with Windows services, but failed."
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
def get_report_data():
data = T1035.get_tech_base_data()
data.update({'services': list(mongo.db.telemetry.aggregate(T1035.query))})
return data

View File

@ -52,13 +52,13 @@ class AttackTechnique(object):
Gets the status of a certain attack technique. Gets the status of a certain attack technique.
:return: ScanStatus Enum object :return: ScanStatus Enum object
""" """
if mongo.db.attack_results.find_one({'telem_category': 'attack', if mongo.db.telemetry.find_one({'telem_category': 'attack',
'status': ScanStatus.USED.value, 'data.status': ScanStatus.USED.value,
'technique': cls.tech_id}): 'data.technique': cls.tech_id}):
return ScanStatus.USED return ScanStatus.USED
elif mongo.db.attack_results.find_one({'telem_category': 'attack', elif mongo.db.telemetry.find_one({'telem_category': 'attack',
'status': ScanStatus.SCANNED.value, 'data.status': ScanStatus.SCANNED.value,
'technique': cls.tech_id}): 'data.technique': cls.tech_id}):
return ScanStatus.SCANNED return ScanStatus.SCANNED
else: else:
return ScanStatus.UNSCANNED return ScanStatus.UNSCANNED

View File

@ -14,7 +14,7 @@ SCHEMA = {
"SmbExploiter" "SmbExploiter"
], ],
"title": "SMB Exploiter", "title": "SMB Exploiter",
"attack_techniques": ["T1110", "T1075"] "attack_techniques": ["T1110", "T1075", "T1035"]
}, },
{ {
"type": "string", "type": "string",

View File

@ -11,7 +11,11 @@ export function renderMachine(val){
export function renderMachineFromSystemData(data) { export function renderMachineFromSystemData(data) {
let machineStr = data['hostname'] + " ( "; let machineStr = data['hostname'] + " ( ";
data['ips'].forEach(function(ipInfo){ data['ips'].forEach(function(ipInfo){
machineStr += ipInfo['addr'] + " "; if(typeof ipInfo === "object"){
machineStr += ipInfo['addr'] + " ";
} else {
machineStr += ipInfo + " ";
}
}); });
return machineStr + ")" return machineStr + ")"
} }

View File

@ -0,0 +1,44 @@
import React from 'react';
import '../../../styles/Collapse.scss'
import ReactTable from "react-table";
import { renderMachineFromSystemData } from "./Helpers"
class T1035 extends React.Component {
constructor(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() {
return (
<div>
<div>{this.props.data.message}</div>
<br/>
{this.props.data.services.length !== 0 ?
<ReactTable
columns={T1035.getServiceColumns()}
data={this.props.data.services}
showPagination={false}
defaultPageSize={this.props.data.services.length}
/> : ""}
</div>
);
}
}
export default T1035;

View File

@ -14,6 +14,7 @@ import T1059 from "../attack/techniques/T1059";
import T1086 from "../attack/techniques/T1086"; 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";
const tech_components = { const tech_components = {
'T1210': T1210, 'T1210': T1210,
@ -24,7 +25,8 @@ const tech_components = {
'T1059': T1059, 'T1059': T1059,
'T1086': T1086, 'T1086': T1086,
'T1082': T1082, 'T1082': T1082,
'T1145': T1145 'T1145': T1145,
'T1035': T1035
}; };
const classNames = require('classnames'); const classNames = require('classnames');