MITRE ATT&CK Technique
Description
The <code>trap</code> command allows programs and shells to specify commands that will be executed upon receiving interrupt signals. A common situation is a script allowing for graceful termination and handling of common keyboard interrupts like <code>ctrl+c</code> and <code>ctrl+d</code>. Adversaries can use this to register code to be executed when the shell encounters specific interrupts either to gain execution or as a persistence mechanism. Trap commands are of the following format <code>trap 'command list' signals</code> where "command list" will be executed when "signals" are received.(Citation: Trap Manual)(Citation: Cyberciti Trap Statements)
Supported Platforms
Created
April 29, 2026
Last Updated
April 29, 2026
STIX Data
{'created': '2017-12-14T16:46:06.044Z',
'created_by_ref': 'identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5',
'description': 'The <code>trap</code> command allows programs and shells to '
'specify commands that will be executed upon receiving '
'interrupt signals. A common situation is a script allowing '
'for graceful termination and handling of common keyboard '
'interrupts like <code>ctrl+c</code> and <code>ctrl+d</code>. '
'Adversaries can use this to register code to be executed when '
'the shell encounters specific interrupts either to gain '
'execution or as a persistence mechanism. Trap commands are of '
"the following format <code>trap 'command list' signals</code> "
'where "command list" will be executed when "signals" are '
'received.(Citation: Trap Manual)(Citation: Cyberciti Trap '
'Statements)',
'external_references': [{'external_id': 'T1154',
'source_name': 'mitre-attack',
'url': 'https://attack.mitre.org/techniques/T1154'},
{'description': 'ss64. (n.d.). trap. Retrieved May '
'21, 2019.',
'source_name': 'Trap Manual',
'url': 'https://ss64.com/bash/trap.html'},
{'description': 'Cyberciti. (2016, March 29). Trap '
'statement. Retrieved May 21, 2019.',
'source_name': 'Cyberciti Trap Statements',
'url': 'https://bash.cyberciti.biz/guide/Trap_statement'}],
'id': 'attack-pattern--b53dbcc6-147d-48bb-9df4-bcb8bb808ff6',
'kill_chain_phases': [{'kill_chain_name': 'mitre-attack',
'phase_name': 'execution'},
{'kill_chain_name': 'mitre-attack',
'phase_name': 'persistence'}],
'modified': '2025-10-24T17:49:15.696Z',
'name': 'Trap',
'object_marking_refs': ['marking-definition--fa42a846-8d90-4e51-bc29-71d5b4802168'],
'revoked': True,
'spec_version': '2.1',
'type': 'attack-pattern',
'x_mitre_attack_spec_version': '3.2.0',
'x_mitre_deprecated': False,
'x_mitre_detection': '',
'x_mitre_domains': ['enterprise-attack'],
'x_mitre_is_subtechnique': False,
'x_mitre_modified_by_ref': 'identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5',
'x_mitre_platforms': ['Linux', 'macOS'],
'x_mitre_version': '1.2'}