forked from p15670423/monkey
Add T1053 (windows PBA)
This commit is contained in:
parent
73c4070f54
commit
7588cd8eea
|
@ -1,7 +1,7 @@
|
|||
from common.data.post_breach_consts import POST_BREACH_JOB_SCHEDULING
|
||||
from infection_monkey.post_breach.pba import PBA
|
||||
from infection_monkey.post_breach.job_scheduling.job_scheduling import\
|
||||
get_commands_to_schedule_jobs
|
||||
get_commands_to_schedule_jobs, remove_scheduled_jobs
|
||||
|
||||
|
||||
class ScheduleJobs(PBA):
|
||||
|
@ -11,6 +11,9 @@ class ScheduleJobs(PBA):
|
|||
|
||||
def __init__(self):
|
||||
linux_cmds, windows_cmds = get_commands_to_schedule_jobs()
|
||||
|
||||
super(ScheduleJobs, self).__init__(name=POST_BREACH_JOB_SCHEDULING,
|
||||
linux_cmd=' '.join(linux_cmds),
|
||||
windows_cmd=windows_cmds)
|
||||
|
||||
remove_scheduled_jobs()
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
import subprocess
|
||||
from infection_monkey.post_breach.job_scheduling.linux.job_scheduling import\
|
||||
get_linux_commands_to_schedule_jobs
|
||||
from infection_monkey.post_breach.job_scheduling.windows.job_scheduling import\
|
||||
get_windows_commands_to_schedule_jobs
|
||||
get_windows_commands_to_schedule_jobs,\
|
||||
get_windows_commands_to_remove_scheduled_jobs
|
||||
from infection_monkey.utils.environment import is_windows_os
|
||||
|
||||
|
||||
def get_commands_to_schedule_jobs():
|
||||
linux_cmds = get_linux_commands_to_schedule_jobs()
|
||||
windows_cmds = get_windows_commands_to_schedule_jobs()
|
||||
return linux_cmds, windows_cmds
|
||||
|
||||
|
||||
def remove_scheduled_jobs():
|
||||
subprocess.run(get_windows_commands_to_remove_scheduled_jobs() if is_windows_os() # noqa: DUO116
|
||||
else '',
|
||||
shell=True)
|
||||
|
|
|
@ -1,2 +1,28 @@
|
|||
SCHEDULED_TASK_NAME = 'monkey-spawn-cmd'
|
||||
SCHEDULED_TASK_COMMAND = 'C:\windows\system32\cmd.exe'
|
||||
|
||||
|
||||
def get_windows_commands_to_schedule_jobs():
|
||||
return ''
|
||||
return [
|
||||
'schtasks',
|
||||
'/Create',
|
||||
'/SC',
|
||||
'monthly',
|
||||
'/TN',
|
||||
SCHEDULED_TASK_NAME,
|
||||
'/TR',
|
||||
SCHEDULED_TASK_COMMAND
|
||||
]
|
||||
|
||||
|
||||
def get_windows_commands_to_remove_scheduled_jobs():
|
||||
return [
|
||||
'schtasks',
|
||||
'/Delete',
|
||||
'/TN',
|
||||
SCHEDULED_TASK_NAME,
|
||||
'/F',
|
||||
'>',
|
||||
'nul',
|
||||
'2>&1'
|
||||
]
|
||||
|
|
|
@ -4,7 +4,7 @@ from monkey_island.cc.models import Monkey
|
|||
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, T1105, T1065, T1035, T1129, T1106, T1107, T1188
|
||||
from monkey_island.cc.services.attack.technique_reports import T1090, T1041, T1222, T1005, T1018, T1016, T1021, T1064
|
||||
from monkey_island.cc.services.attack.technique_reports import T1136, T1156, T1504, T1158, T1154, T1166, T1168
|
||||
from monkey_island.cc.services.attack.technique_reports import T1136, T1156, T1504, T1158, T1154, T1166, T1168, T1053
|
||||
from monkey_island.cc.services.attack.attack_config import AttackConfig
|
||||
from monkey_island.cc.database import mongo
|
||||
from monkey_island.cc.services.reporting.report_generation_synchronisation import safe_generate_attack_report
|
||||
|
@ -43,7 +43,8 @@ TECHNIQUES = {'T1210': T1210.T1210,
|
|||
'T1158': T1158.T1158,
|
||||
'T1154': T1154.T1154,
|
||||
'T1166': T1166.T1166,
|
||||
'T1168': T1168.T1168
|
||||
'T1168': T1168.T1168,
|
||||
'T1053': T1053.T1053
|
||||
}
|
||||
|
||||
REPORT_NAME = 'new_report'
|
||||
|
|
|
@ -129,7 +129,6 @@ SCHEMA = {
|
|||
"in certain situations by abusing PowerShell profiles which "
|
||||
"are scripts that run when PowerShell starts."
|
||||
},
|
||||
<<<<<<< HEAD
|
||||
"T1053": {
|
||||
"title": "Scheduled task",
|
||||
"type": "bool",
|
||||
|
@ -149,18 +148,6 @@ SCHEMA = {
|
|||
"description": "Adversaries can set the setuid or setgid bits to get code running in "
|
||||
"a different user’s context."
|
||||
}
|
||||
=======
|
||||
# "T1053": {
|
||||
# "title": "Scheduled task",
|
||||
# "type": "bool",
|
||||
# "value": True,
|
||||
# "necessary": False,
|
||||
# "link": "https://attack.mitre.org/techniques/T1053",
|
||||
# "description": "Windows utilities can be used to schedule programs or scripts to "
|
||||
# "be executed at a date and time. An adversary may use task scheduling to "
|
||||
# "execute programs at system startup or on a scheduled basis for persistence."
|
||||
# },
|
||||
>>>>>>> Add T1168 (linux PBA)
|
||||
}
|
||||
},
|
||||
"defence_evasion": {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
from monkey_island.cc.services.attack.technique_reports import AttackTechnique
|
||||
from monkey_island.cc.database import mongo
|
||||
from common.utils.attack_utils import ScanStatus
|
||||
from common.data.post_breach_consts import POST_BREACH_JOB_SCHEDULING
|
||||
|
||||
|
||||
__author__ = "shreyamalviya"
|
||||
|
||||
|
||||
class T1053(AttackTechnique):
|
||||
tech_id = "T1053"
|
||||
unscanned_msg = "Monkey did not try scheduling a job."
|
||||
scanned_msg = "Monkey tried scheduling a job on the system but failed."
|
||||
used_msg = "Monkey scheduled a job on the system."
|
||||
|
||||
query = [{'$match': {'telem_category': 'post_breach',
|
||||
'data.name': POST_BREACH_JOB_SCHEDULING}},
|
||||
{'$project': {'_id': 0,
|
||||
'machine': {'hostname': '$data.hostname',
|
||||
'ips': ['$data.ip']},
|
||||
'result': '$data.result'}}]
|
||||
|
||||
@staticmethod
|
||||
def get_report_data():
|
||||
data = {'title': T1053.technique_title()}
|
||||
|
||||
job_scheduling_info = list(mongo.db.telemetry.aggregate(T1053.query))
|
||||
|
||||
status = (ScanStatus.USED.value if job_scheduling_info[0]['result'][1]
|
||||
else ScanStatus.SCANNED.value) if job_scheduling_info else ScanStatus.UNSCANNED.value
|
||||
|
||||
data.update(T1053.get_base_data_by_status(status))
|
||||
data.update({'info': job_scheduling_info})
|
||||
return data
|
|
@ -198,7 +198,7 @@ SCHEMA = {
|
|||
"ScheduleJobs"
|
||||
],
|
||||
"title": "Job scheduling",
|
||||
"attack_techniques": ["T1168"]
|
||||
"attack_techniques": ["T1168", "T1053"]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
import React from 'react';
|
||||
import ReactTable from 'react-table';
|
||||
import {renderMachineFromSystemData, ScanStatus} from './Helpers';
|
||||
import MitigationsComponent from './MitigationsComponent';
|
||||
|
||||
class T1053 extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
static getColumns() {
|
||||
return ([{
|
||||
columns: [
|
||||
{ Header: 'Machine',
|
||||
id: 'machine',
|
||||
accessor: x => renderMachineFromSystemData(x.machine),
|
||||
style: {'whiteSpace': 'unset'}},
|
||||
{ Header: 'Result',
|
||||
id: 'result',
|
||||
accessor: x => x.result,
|
||||
style: {'whiteSpace': 'unset'}}
|
||||
]
|
||||
}])
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div>{this.props.data.message}</div>
|
||||
<br/>
|
||||
{this.props.data.status === ScanStatus.USED ?
|
||||
<ReactTable
|
||||
columns={T1053.getColumns()}
|
||||
data={this.props.data.info}
|
||||
showPagination={false}
|
||||
defaultPageSize={this.props.data.info.length}
|
||||
/> : ''}
|
||||
<MitigationsComponent mitigations={this.props.data.mitigations}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default T1053;
|
Loading…
Reference in New Issue