> For the complete documentation index, see [llms.txt](https://dmcxblue.gitbook.io/red-team-notes-2-0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dmcxblue.gitbook.io/red-team-notes-2-0/red-team-techniques/persistence/t1546-event-triggered-execution/trap.md).

# Trap

Adversaries may establish persistence by executing malicious content triggered by an interrupt signal. The trap command allows programs and shell to specify commands that will be executed upon receiving interrupt signals. A common situation is a script allowing for a graceful termination and handling of common keyboard interrupts like CTRL+C and CTR+D.&#x20;

The trap command allows us to change what happens when certain signals are received. A demonstration on how we can call the calculator when a user utilizes the CTRL-C keyboard interruption.

<figure><img src="/files/D17J8JIiyFGP9Lusex8t" alt=""><figcaption></figcaption></figure>

&#x20;
