Repository: Karneades/malware-persistence Branch: master Commit: e1c74d337740 Files: 3 Total size: 55.5 KB Directory structure: gitextract_lo2k9osv/ ├── .gitignore ├── LICENSE └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.swp ================================================ FILE: LICENSE ================================================ Attribution-ShareAlike 4.0 International ======================================================================= Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. Using Creative Commons Public Licenses Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC- licensed material, or material used under an exception or limitation to copyright. More considerations for licensors: wiki.creativecommons.org/Considerations_for_licensors Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason--for example, because of any applicable exception or limitation to copyright--then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More_considerations for the public: wiki.creativecommons.org/Considerations_for_licensees ======================================================================= Creative Commons Attribution-ShareAlike 4.0 International Public License By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. Section 1 -- Definitions. a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. Section 2 -- Scope. a. License grant. 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: a. reproduce and Share the Licensed Material, in whole or in part; and b. produce, reproduce, and Share Adapted Material. 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 3. Term. The term of this Public License is specified in Section 6(a). 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) (4) never produces Adapted Material. 5. Downstream recipients. a. Offer from the Licensor -- Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. b. Additional offer from the Licensor -- Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter's License You apply. c. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). b. Other rights. 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 2. Patent and trademark rights are not licensed under this Public License. 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. Section 3 -- License Conditions. Your exercise of the Licensed Rights is expressly made subject to the following conditions. a. Attribution. 1. If You Share the Licensed Material (including in modified form), You must: a. retain the following if it is supplied by the Licensor with the Licensed Material: i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); ii. a copyright notice; iii. a notice that refers to this Public License; iv. a notice that refers to the disclaimer of warranties; v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. b. ShareAlike. In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. 1. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. Section 4 -- Sui Generis Database Rights. Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. Section 5 -- Disclaimer of Warranties and Limitation of Liability. a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. Section 6 -- Term and Termination. a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 2. upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. Section 7 -- Other Terms and Conditions. a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. Section 8 -- Interpretation. a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. ======================================================================= Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. Creative Commons may be contacted at creativecommons.org. ================================================ FILE: README.md ================================================ **An awesome list with only the links is found on [awesome-malware-persistence](https://github.com/Karneades/awesome-malware-persistence).** --- # Collection of malware persistence information This repository collects various currently scattered information regarding the detection, the response and the log collection of malware persistence mechanisms. In short, we look for one of the things which is so common between different malware families: the ability to persist on a target host. Also malware associated with the misleading term "fileless" often persists on the target too, though not through regular files on the file system but through changes in configuration files like Windows Registry or cron jobs. Unfortunately, many malware blog posts include all the various IP and hash information but only a few highlight the persistence mechanism from an attack, despite that it's one of the more static and more difficult to change information from an attacker's perspective. Using the persistence mechanism to hunt for malware is more robust than the more frequently changed IP addresses or hashes. If you're only looking for an overview about persistence techniques and some links to useful resources then see [Overview of commonly used persistence mechanisms](#overview-of-commonly-used-persistence-mechanisms) and [links and resources for detection](#links-and-resources-for-detection). See section [tools](#tools) for some well-known persistence collection tools. This repository is regularly updated with new detection resources and tools. If you have inputs then [pull requests](https://github.com/Karneades/malware-persistence/pulls) are more then welcome! * [Why bothering with malware persistence?](#why-bothering-with-malware-persistence) * [Detection](#detection) * [Approach](#approach) * [Overview of commonly used persistence mechanisms](#overview-of-commonly-used-persistence-mechanisms) * [Linux](#linux) * [MacOS](#macos) * [Windows](#windows) * [Cloud](#cloud) * [All OSes and developer specific changes](#all-oses-and-developer-specific-changes) * [Overview of difficult to detect persistence mechanisms](#overview-of-difficult-to-detect-persistence-mechanisms) * [Persistence through UEFI malware and bootkits](#persistence-through-uefi-malware-and-bootkits) * [Links and resources for detection](#links-and-resources-for-detection) * [Examples](#examples) * [Detection Evasion](#detection-evasion) * [Testing](#testing) * [Response](#response) * [Prevention](#prevention) * [Tools](#tools) * [Linux](#linux-1) * [MacOS](#macos-1) * [Windows](#windows-1) * [Acknowledgement](#acknowledgement) ## Why bothering with malware persistence? If you are an incident responder and have to analyze compromised hosts, do a generic compromise assessment or if you do threat hunting activities in your infrastructure, then you should get into the topic of persistence mechanisms as one way to detect known or unknown malware. It's one of the pieces for looking for during IR activities. Let's start with the [persistence technique](https://attack.mitre.org/tactics/TA0003/) description used by [MITRE](https://attack.mitre.org/): > The adversary is trying to maintain their foothold. > > Persistence consists of techniques that adversaries use to keep > access to systems across restarts, changed credentials, and other > interruptions that could cut off their access. Techniques used for > persistence include any access, action, or configuration changes that > let them maintain their foothold on systems, such as replacing or > hijacking legitimate code or adding startup code. One thing in common between different malware families is that they (mostly) try to persist on the target host. Malware associated with the misleading term "fileless" often persists on the target too, though not through regular files on the file system but through changes in configuration files like Windows Registry or cron jobs. Why use the word _mostly_ above? Because there is rare malware which omit setting persistence mechanism on the victim's host itself but reinfect the host after reboot from another system (e.g. DC, where the system is running longtime on which no persistence is needed at all). This gold mine of malware persistence information is a fraction of what other log sources produce. Tens to hundreds of events depending of what you looking for versus thousand to ten thousands of entries for process information. Therefore, the analysis of these events reduce the time and the effort compared to other log sources considerably. The signal to noise ratio is also much lower. So, by becoming and being a persistent persistence hunter, you can make use of this treasury. Though not that kind of persistence hunting described in [Wikipedia](https://en.wikipedia.org/wiki/Persistence_hunting)... > Persistence hunting (sometimes called endurance hunting) is a hunting > technique in which hunters, who may be slower than their prey over short > distances, use a combination of running, walking, and tracking to pursue prey > until it is exhausted. A persistence hunter must be able to run a long > distance over an extended period of time. ## Detection While there are many ways how malware can persist on a host, malware authors rely mostly on a handful of techniques. Beside these often used techniques some malware families and more targeted attacks use more advanced mechanisms to stay hidden on the system. Keep in mind that for some persistence techniques escalated privileges are required and therefore malware running under normal users (and privilege escalation left out of consideration) can only set "user mode" persistence. So if the user on the infected host only use a normal user account then first focus on the user level persistence and secondly look for system level techniques. ### Approach The analysis process could involve these steps, as with other incident response and threat hunting procedures: 1. Collect the persistence mechanisms using single commands for specific techniques (see [links and resources for detection](#links-and-resources-for-detection)) or use tools for collection of a bunch of them at the same time, see [tools](#tools). 2. Analyse the command, file hash, file signer and file path information and enrich the information with more information from external services (AV detection rate, correlation with other files, reputation, signer information, known-bad hash check). 3. If the output doesn't help, check the information against other clients in your infrastructure: Is this entry found on other hosts too? 4. Look for anomalies, e.g. an exe file in startup folder where normally only .lnk files should be placed is suspicious or look for IP addresses or web request in cronjobs. See the links below for detection ideas. 5. In the process of the analysis it is important to note too what is NOT found (evidence of absence) and not only what is found, e.g. no cron jobs were found at all. ### Overview of commonly used persistence mechanisms The used techniques varies from user land persistence mechanisms, to system level persistence, from hiding behind common binary names, to putting malware at unusual but lesser known places. Sometimes only a proxy or other network configuration (i.a. DNS settings) changes were found after infection. Retefe used the latter. Use the information from section [links and resources for detection](#links-and-resources-for-detection) for specific information for these techniques. #### Linux * Often used techniques: startup, rc and init scripts, cron jobs, shell scripts, shell profiles. * In-depth analysis should further include less frequently used techniques: malicious libraries, loadable kernal modules (LKM), binary replacements or network scripts. #### MacOS * Often used techniques: launch daemons and agents, startup items, shell scripts, shell profiles. * In-depth analysis should further include less frequently used techniques: Dylib hijacking. #### Windows * Often used techniques: registry run keys, scheduled tasks, services, startup folder. * In-depth analysis should further include less frequently used techniques: e.g. file handler hijacking (check both HKLM and HKCU), WMI implants, DLL side loading, malicious drivers, LNK files, sneaky way to get persistence through RDP connections on Windows is the use of image hijacks, sometimes known as "sticky keys hijacking" or known as technique "Accessibility Features" in the ATT&CK Matrix, COM Hijacking (check both HKLM and HKCU). #### Cloud * [Shadow Linking: The Persistence Vector of SaaS Identity Threat](https://www.obsidiansecurity.com/blog/shadow-linking-the-persistence-vector-of-saas-identity-threat/) * [Persisting on Entra ID applications and User Managed Identities with Federated Credentials](https://dirkjanm.io/persisting-with-federated-credentials-entra-apps-managed-identities/) * Mapping storage volumes to external storage providers. * [AWSDoor: Persistence on AWS](https://github.com/OtterHacker/AWSDoor) - Access persistence tool for AWS. The [corresponding article](https://www.riskinsight-wavestone.com/en/2025/09/awsdoor-persistence-on-aws/) describes the techniques adversaries can use to hide themselves within a cloud environment and its AWSDoor implementation to simplify and automate the deployment of persistence techniques in AWS environments. #### All OSes and developer specific changes * Proxy and other network configuration changes, backdoor accounts and shortcut modifications. * Developer workstations: e.g. modified IDE software and git hook scripts. ### Overview of difficult to detect persistence mechanisms * Malware which omit setting persistence at all on the victim's host but reinfect the host after reboot from another system, e.g. from a DC (a system which is running long time and no persistence is needed at all). * Persistence, e.g. through registry run keys, is only set shortly before the shutdown command (shutdown command is hooked). Used in Dridex malware in the past. Cool thing, if you knew that, you could cold boot the computer and "deactivate" Dridex. * Abuse of hooked file handler. * DLL side loading (file can be anywhere on the system). * Legitimate binary replacement. * Firmware changes preventing getting rid of malware by normal patching. [Example](https://krebsonsecurity.com/2023/06/barracuda-urges-replacing-not-patching-its-email-security-gateways/). * Database triggers preventing getting rid of malicious access by restoring a backup: [The Attack Vector: Database Triggers as Persistence Mechanisms](https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/the-attack-vector-database-triggers-as-persistence-mechanisms/). ### Persistence through UEFI malware and bootkits * (UEFI) firmware malware, bootkits or modified kernel images. These can be detected by checking the signed binaries from the client (Secure Boot). See [MoonBounce: the dark side of UEFI firmware](https://securelist.com/moonbounce-the-dark-side-of-uefi-firmware/105468) for a in depth write up about one particular UEFI bootkit. * _Analysis has shown that a single component within the inspected firmware’s image was modified by attackers in a way that allowed them to intercept the original execution flow of the machine’s boot sequence and introduce a sophisticated infection chain._ * See section "Revisiting the current state of the art in persistent attacks" for a brief history of UEFI malware. From this section: _In the last year, there have been several public accounts on the ongoing trend of UEFI threats. Notable examples include the UEFI bootkit used as part of the FinSpy surveillance toolset that we reported on, the work of our colleagues from ESET on the ESPectre bootkit, and a little-known threat activity that was discovered within government organisations in the Middle East, using a UEFI bootkit of its own [...] MoonBounce is notable for being the third publicly revealed case of an implant from the latter class of firmware-based rootkits. Previous cases included LoJax and MosaicRegressor, which we reported on during October 2020._ ### Links and resources for detection The following resources cover a lot of persistence techniques and more information on how to detect these specific mechanisms. #### MITRE ATT&CK tactic "TA0003 - Persistence" One of the most comprehensive lists of persistence techniques is the list found in [MITRE ATT&CK tactic "TA0003 - Persistence"](https://attack.mitre.org/tactics/TA0003/). Besides a description, different mitigations and a detection section is provided. Furthermore, the involved actors using these techniques are listed on the page. URL: https://attack.mitre.org/tactics/TA0003/ #### Hexacorn's blog persistence category A second gold mine for persistence information is found on [Hexacorn's blog](http://www.hexacorn.com/blog/category/autostart-persistence/) where regularly and since long time new techniques and blog posts about persistence mechanisms are published, crazy stuff. You'll also find there the legendary series "Beyond good ol’ Run key". URL: http://www.hexacorn.com/blog/category/autostart-persistence/ #### theevilbit's series "Beyond the good ol' LaunchAgents" Series about persistence on macOS beyond just the LaunchDaemons or LaunchAgents directories. In the [introduction](https://theevilbit.github.io/beyond/beyond_intro/) it's also refered to Pasquale Stirparo's posts ([here](https://isc.sans.edu/forums/diary/Beyond+good+ol+LaunchAgent+part+0/24230/) and [here](https://isc.sans.edu/forums/diary/Beyond+good+ol+LaunchAgent+part+1/24274/)) with the name *Beyond the good ol' LaunchAgent* from 2018. URL: https://theevilbit.github.io/tags/beyond/ #### Forensic artifact repository The [forensic artifact repository](https://github.com/ForensicArtifacts/artifacts) covers different artifacts regarding persistence for different OSes. See yaml files for MacOS, Linux and Windows in the [data](https://github.com/ForensicArtifacts/artifacts/tree/master/data) directory. URL: https://github.com/ForensicArtifacts/artifacts #### Sigma rules [Sigma rules](https://github.com/Neo23x0/sigma/tree/master/rules) also include various rules regarding persistence. [Search for persistence rules in Sigma repository](https://github.com/Neo23x0/sigma/search?q=persistence&unscoped_q=persistence) or use the filter options of Sigma for either MITRE ATT&CK persistence category itself or for one specific technique: ``` sigmac --recurse --filter tag=attack.persistence --target splunk --config config/splunk-windows.yml rules sigmac --recurse --filter tag=attack.t1084 --target splunk --config config/splunk-windows.yml rules ``` URL: https://github.com/Neo23x0/sigma/search?q=persistence&unscoped_q=persistence #### Autoruns You can learn which Windows persistence mechanisms are possible by looking at the output of Autoruns on your own client (see also [tools](#tools)). In the output you see the categories and the different locations where things were found. To see which entries Autoruns scans at all, you can start a disassembler and look at the strings found in the binary, this covers only a subset. URL: http://technet.microsoft.com/en-us/sysinternals/bb963902 Another way to find Windows persistence information is to look at the [PowerShell implementation of Autoruns, where the locations are found in the source code]( https://github.com/p0w3rsh3ll/AutoRuns/blob/master/AutoRuns.psm1). Bonus: A [history of the covered persistence locations for each version](https://github.com/p0w3rsh3ll/AutoRuns/blob/master/AutoRuns.psm1#L2824) is found there too, which is awesome! URL: https://github.com/p0w3rsh3ll/AutoRuns/blob/master/AutoRuns.psm1 #### KnockKnock For macOS there's the KnockKnock persistence tool to look for persistence mechanisms: https://github.com/objective-see/KnockKnock. Specific persistence locations are found in the [plugins](https://github.com/objective-see/KnockKnock/tree/main/Plugins) folder, e.g. [LaunchItems](https://github.com/objective-see/KnockKnock/blob/main/Plugins/LaunchItems.m#L21) or [StartupScripts](https://github.com/objective-see/KnockKnock/blob/main/Plugins/StartupScripts.m#L22). #### PoisonApple [PoisonApple](https://github.com/CyborgSecurity/PoisonApple/) is a command-line tool to perform various persistence mechanism techniques on macOS. This tool was designed to be used by threat hunters for cyber threat emulation purposes. Learn about various macOS persistence techniques by looking at the [source code of PoisonApple](https://github.com/CyborgSecurity/PoisonApple/blob/master/poisonapple/techniques.py). #### PANIX [Panix- Persistence Against *NIX - Features](https://github.com/Aegrah/PANIX?tab=readme-ov-file#features) is a highly customizable Linux persistence tool and includes various persistence techniques. #### Various blog posts Various blog posts write about persistence mechanisms, some specific for one technique, others for a broader set of techniques. Here are some for the past years as an inspiration what to look for. See [How malware persists on macOS](https://www.sentinelone.com/blog/how-malware-persists-on-macos/) for macOS persistence locations, General persistence mechanisms: [Common malware persistence mechanisms](https://resources.infosecinstitute.com/common-malware-persistence-mechanisms/), [Malware persistence techniques](https://www.andreafortuna.org/2017/07/06/malware-persistence-techniques/), WMI: [Detecting & Removing an Attacker’s WMI Persistence](https://medium.com/threatpunter/detecting-removing-wmi-persistence-60ccbb7dff96), Winlogon: [Windows Persistence using WinLogon](https://www.hackingarticles.in/windows-persistence-using-winlogon/), Kovter: [Untangling Kovter’s persistence methods](https://blog.malwarebytes.com/threat-analysis/2016/07/untangling-kovter/), [Threat Spotlight: Kovter Malware Fileless Persistence Mechanism](https://threatvector.cylance.com/en_us/home/threat-spotlight-kovter-malware-fileless-persistence-mechanism.html), GlobalFlags in Image File Execution Hijacks: [Persistence using GlobalFlags in Image File Execution Options – Hidden from Autoruns.exe](https://oddvar.moe/2018/04/10/persistence-using-globalflags-in-image-file-execution-options-hidden-from-autoruns-exe/), Bootloader persistence: [Uncovering a MyKings Variant With Bootloader Persistence via Managed Detection and Response](https://blog.trendmicro.com/trendlabs-security-intelligence/uncovering-a-mykings-variant-with-bootloader-persistence-via-managed-detection-and-response/), COM hijacking / CLSID hijacking: [gdatasoftware writeup from 2014](https://www.gdatasoftware.com/blog/2014/10/23941-com-object-hijacking-the-discreet-way-of-persistence) or [pentestlab writeup from 2020](https://pentestlab.blog/2020/05/20/persistence-com-hijacking/) or [Enigma0x3 / Matt Nelson's writeup from 2016 abusing com hijacking in combination with scheduled tasks](https://enigma0x3.net/2016/05/25/userland-persistence-with-scheduled-tasks-and-com-handler-hijacking/), Linux cron: [Linux Malware Persistence with Cron](https://www.sandflysecurity.com/blog/linux-malware-persistence-with-cron/), Microsoft Exchange and Outlook: [Hunting for persistence via Microsoft Exchange Server or Outlook](https://speakerdeck.com/heirhabarov/hunting-for-persistence-via-microsoft-exchange-server-or-outlook), [Shadow Linking: The Persistence Vector of SaaS Identity Threat](https://www.obsidiansecurity.com/blog/shadow-linking-the-persistence-vector-of-saas-identity-threat/), [Linux Detection Engineering - A primer on persistence mechanisms](https://www.elastic.co/security-labs/primer-on-persistence-mechanisms), [Linux LKM Persistence - Rootkit leveraging Linux loadable kernel module (LKM)](https://righteousit.com/2024/11/18/linux-lkm-persistence/), [AWSDoor: Persistence on AWS](https://github.com/OtterHacker/AWSDoor), [Access persistence for AWS](https://www.riskinsight-wavestone.com/en/2025/09/awsdoor-persistence-on-aws/). ### Examples #### MITRE ATT&CK persistence technique called Local Job Scheduling In the list from the [tactic's page](https://attack.mitre.org/tactics/TA0003/), we can navigate to the technique itself, namely [T1168 - local job scheduling](https://attack.mitre.org/techniques/T1168/) and get the description and the needed information about the involved tools and files: > On Linux and macOS systems, multiple methods are supported for creating pre-scheduled and periodic background jobs: cron, at, and launchd. > > [...] > > System-wide cron jobs are installed by modifying /etc/crontab file, /etc/cron.d/ directory or other locations supported by the Cron daemon, while per-user cron jobs are installed using crontab with specifically formatted crontab files. Further below the detection ideas are provided. Besides the process monitoring we can spot malicious jobs by comparing the cron files and commands against other hosts or just search for unusual commands. ``` % grep -r http /etc/cron.daily/* ``` A writeup on bleepingcomputer regarding a [cryptominer on Linux](https://www.bleepingcomputer.com/news/security/cryptominer-uses-cron-to-reinfect-linux-host-after-removal/) shows an example of such a cron entry. IP changes but the persistence technique using the crontab and a web request stays. So hunt them down! #### (Ab)use of Rundll32 A second example is the (ab)use of rundll32.exe to load a library through registery keys or other means ([T1085 - Rundll32](https://attack.mitre.org/techniques/T1085/)). Ursnif is one of the malware families which use a specific rundll32 command line since long time. Therefore, searching for registry keys containing "rundll32" and "DllRegisterServer" in the command line would catch it or just use "rundll32" as a more generic search pattern. Example taken from Trendmicro's [URSNIF threat encyclopedia](https://www.trendmicro.com/vinfo/us/threat-encyclopedia/malware/trojanspy.win32.ursnif.tiaboecq) ``` In HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run dminsenh = "rundll32 "%Application Data%\Microsoft\Appislad\devrusic.dll",DllRegisterServer" ``` #### File handler manipulation Sneaky persistence through manipulation of exefile file handler. [MITRE ATT&CK T1546.001 - Event Triggered Execution: Change Default File Association](https://attack.mitre.org/techniques/T1546/001/). [Lokibot sample from Nov 2021](https://tria.ge/211119-gs7rtshcfr/behavioral2). Check both HKLM and HKCU. ``` \REGISTRY\MACHINE\SOFTWARE\Classes\exefile\shell\open\command\ = "C:\\Windows\\svchost.com \"%1\" %*" ``` and malware was dropped to `C:\Windows\svchost.com`. ## Detection Evasion Malware authors abuse different techniques to hide their malware persistence or make the detection more difficult: * Rootkits hide files or hook registry queries * Use similar or typosquatted names to OS default binary names * Hidding entries by abusing program bugs, like the one with the null byte in registry keys which results in error while collection or just missing entries in the output of tools * [Abusing ADS (alternate data streams) in windows](https://argonsys.com/microsoft-cloud/library/latest-astaroth-living-off-the-land-attacks-are-even-more-invisible-but-not-less-observable/) * Using DLL side-loading for well-known binaries * Using signed binaries which then gets filtered out (depending on the analysis) * Hidden services when special permissions were set at service creation. Seen in section _Installation stealth and persistence_ in Talos' blog post [Threat hunting in large datasets by clustering security events](https://blog.talosintelligence.com/2021/10/threat-hunting-in-large-datasets-by.html). This blog post references another one from SANS, [Red Team Tactics: Hiding Windows Services](https://www.sans.org/blog/red-team-tactics-hiding-windows-services/). * _In the following steps, the script deletes PowerShell logs and registers the final payload as a Windows service using a long command line with some strange permission settings. A quick Google search reveals that these are used to make the service hidden and unremovable using the regular Windows administration tools, without some additional actions. [Talos]_ * _A little known feature of Windows allows the red team or an attacker to hide services from view, creating an opportunity to evade detection from common host-based threat hunting techniques. [SANS]_ ## Testing Use the descriptions and information from the resources in section [detection](#detection) to simulate the persistence. Furthermore, different tools provide checks to verify if detections work. [Atomic Red Team](https://github.com/redcanaryco/atomic-red-team) test suite allows checking for specific MITRE ATT&CK persistence techniques, see e.g. [T1044 "File System Permissions Weakness"](https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1044/T1044.yaml). [hasherezade published demos](https://github.com/hasherezade/persistence_demos) of various (also non standard) persistence methods used by malware, like COM hijacking. Use [PoisonApple](https://github.com/CyborgSecurity/PoisonApple) to perform various persistence techniques on macOS. Use [PANIX](https://github.com/Aegrah/PANIX) to perform various persistence techniques against Linux systems, among others Debian and RHEL. Use [Diamorphine](https://github.com/m0nad/Diamorphine), a loadable kernel module (LKM) rootkit for Linux Kernels (x86/x86_64 and ARM64), to test the detection of LKMs. Use [AWSDoor: Persistence on AWS](https://github.com/OtterHacker/AWSDoor) for adding access persistence on AWS. The [corresponding article](https://www.riskinsight-wavestone.com/en/2025/09/awsdoor-persistence-on-aws/) describes the techniques adversaries can use to hide themselves within a cloud environment and its AWSDoor implementation to simplify and automate the deployment of persistence techniques in AWS environments. ### Example As an example we use the technique [T1183 - "Image File Execution Options Injection"](https://attack.mitre.org/techniques/T1183/) and abuse the "sticky keys" feature for executing a command shell. This would also be triggered before a login. To test your collection tools, the prevention mechanisms in place and your awesome detections, execute the following for adding a debugger value for the corresponding registry key: ``` REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "cmd /c tasklist" ``` Now you can click multiple times on the shift-key on your keyboard to trigger the execution of cmd. ## Response If you respond to an incident and need to clean up malware persistence as a temporary countermeasure, you just have to remove the given information. For files and configuration changes it's mostly done using standard OS commands. Use your EDR or some other frameworks (e.g. for Windows, see [PowerSponse](https://github.com/swisscom/PowerSponse)). In special cases like WMI the cleanup is not as straightforward as with other mechanisms, see blog post [Removing Backdoors – Powershell Empire Edition](https://www.n00py.io/2017/01/removing-backdoors-powershell-empire-edition/): 1. remove the binding using `Get-WmiObject __FilterToConsumerBinding -Namespace root\subscription | Where-Object { $_.filter -match 'evil'} | Remove-WmiObject;` 1. remove the event consumer using `Get-WmiObject CommandLineEventConsumer -Namespace root\subscription -Filter "name='evil'" | Remove-WmiObject` 1. remove the event filter using `Get-WMIObject -Namespace root\Subscription -Class __EventFilter -Filter "Name='evil'" | Remove-WmiObject -Verbose` Then there were issues with null byte values in the Windows registry and attackers abused that to hide entries in e.g. run keys. Custom tools or the [RegDelNull](https://docs.microsoft.com/en-us/sysinternals/downloads/regdelnull) can be used to remove these entries. ## Prevention This list is in no way comprehensive and just lists some possibilities to prevent malware persistence. The most important thing would be of course to prevent the execution of unknown programs. * Block file writes to unusual places if possible, e.g. public user profile in Windows. * Block file types on specific folders where only limited file types are used (e.g. .exe in startup folder where only .lnk files should be placed). * Use file integrity checking on important config files (e.g. cronjobs). * Reduce privileges so more advanced persistence techniques would fail due to missing privileges. * File system permissions should be checked regularly and be as restricted as possible. * Lock down configuration files (read-only) and on Windows put ACLs on specific registry keys (like for the accessibility features keys). * Prevent the abuse of third party identity providers, see [Shadow Linking: The Persistence Vector of SaaS Identity Threat](https://www.obsidiansecurity.com/blog/shadow-linking-the-persistence-vector-of-saas-identity-threat/). For macOS there's the BlockBlock tool by Patrick Wardle which provides protection by monitoring persistence locations: https://github.com/objective-see/BlockBlock. ## Tools You can either collect the needed information once on a (remote) host in case of an incident or collect the information on a regular basis for baselining and threat hunting. One thing as a reminder and thanks to Harlan Carvey over at windowsir for pointing out similar points too in various blog posts, see [Deep Knowledge, and the Pursuit Thereof ](https://windowsir.blogspot.com/2019/05/deep-knowledge-and-pursuit-thereof.html) and [Troubleshooting and Deep Knowledge](https://windowsir.blogspot.com/2019/05/troubleshooting-and-deep-knowledge.html): Be cautious of the results of tools and try to cross check with different tools or check things by hand. Tools only provide you the information in their way and sometimes miss the malicious entry or some options were turned off etc. Autoruns for example can hide Microsoft signed entries, but than some LOLbin (living-of-the-land, abusing system tools so to say) commands were missing. Use it to reduce the amount of entries, but know the limits. There was a null byte issue with the registry and the entries were missing too in the collection. New version fixed the issue. One more: [Persistence using GlobalFlags in Image File Execution Options – Hidden from Autoruns.exe](https://oddvar.moe/2018/04/10/persistence-using-globalflags-in-image-file-execution-options-hidden-from-autoruns-exe/). For collection of specific techniques see [links and resources for detection](#links-and-resources-for-detection) which cover detailed information about the location of different persistence mechanisms. ### Linux * I'm not aware of a public available tool to get a bunch of persistence mechanisms. But there are different commands which can be put into a script for easier usage. Depending on the distribution use the corresponding commands for `crontab`, `cat`, `grep`, `md5sum`, `sha1sum`, `sha256sum`, `somethingsum` and directory listings for most of the techniques. * [Linux Security and Monitoring Scripts](https://github.com/sqall01/LSMS) - Security and monitoring scripts you can use to monitor your Linux installation for security-related events or for an investigation. Among other finding systemd unit files used for malware persistence. * For regular collection of persistence mechanisms you can look into [osquery](https://osquery.readthedocs.io) or [OSSEC](https://github.com/ossec/ossec-hids). ### MacOS * [KnockKnock](https://www.objective-see.com/products/knockknock.html) uncovers persistently installed software in order to generically reveal such malware. See [Github repository too for the source code](https://github.com/objective-see/KnockKnock). * [BlockBlock](https://github.com/objective-see/BlockBlock) provides continual protection by monitoring persistence locations. * [Dylib Hijack Scanner or DHS](https://www.objective-see.com/products/dhs.html), is a simple utility that will scan your computer for applications that are either susceptible to dylib hijacking or have been hijacked. See [Github repository too for the source code](https://github.com/objective-see/DylibHijackScanner). * Besides the UI tool KnockKnock, I'm not aware of a public available command line tool to get a bunch of persistence mechanisms. But there are different commands which can be put into a script for easier usage. Use the corresponding commands for `crontab`, `cat`, `grep`, `md5sum`, `sha1sum`, `sha256sum`, `somethingsum` and directory listings for most of the techniques. * For regular collection of persistence mechanisms you can look into [osquery](https://osquery.readthedocs.io) or [OSSEC](https://github.com/ossec/ossec-hids). ### Windows * A powerful persistence collection tool on Windows is [Autoruns](http://technet.microsoft.com/en-us/sysinternals/bb963902). It collects different categories and persistence information from a live system and [in limited ways from offline images](https://www.sans.org/blog/offline-autoruns-revisited-auditing-malware-persistence/). There is a UI and a command line program and the output format can be set to CSV which can then be imported into your log collection system of choice. * Instead of using CSV output and copy these file to the server, you can use the script [AutorunsToWinEventLog.ps1](https://github.com/palantir/windows-event-forwarding/blob/master/AutorunsToWinEventLog/AutorunsToWinEventLog.ps1) to convert the Autoruns output to Windows event logs and rely on standard Windows event log forwarding. * PowerShell version of [Autoruns](https://github.com/p0w3rsh3ll/AutoRuns). * [PersistenceSniper](https://github.com/last-byte/PersistenceSniper) is a Powershell module to hunt for persistence implanted in Windows machines. * [RegRipper](https://github.com/keydet89/RegRipper2.8) does also extracts various persistence mechanisms from the registry files directly. * [RECmd](https://github.com/EricZimmerman/RECmd) using the config file [UserClassesASEPs](https://github.com/EricZimmerman/RECmd/blob/master/BatchExamples/UserClassesASEPs.reb) extracts user's CLSID information. * [KAPE](https://www.kroll.com/en/insights/publications/cyber/kroll-artifact-parser-extractor-kape) has different targets and modules, see [KapeFiles](https://github.com/EricZimmerman/KapeFiles) which include persistence mechanisms, among others there's a collection of [LNK files](https://github.com/EricZimmerman/KapeFiles/blob/master/Targets/Windows/LNKFilesAndJumpLists.tkape), [scheduled task files](https://github.com/EricZimmerman/KapeFiles/blob/master/Targets/Windows/ScheduledTasks.tkape) and [scheduled task listing](https://github.com/EricZimmerman/KapeFiles/blob/master/Modules/LiveResponse/schtasks.mkape) or a [WMI repository auditing](https://github.com/EricZimmerman/KapeFiles/blob/master/Modules/LiveResponse/WMI-Repository-Auditing.mkape) module. * [PyrsistenceSniper](https://github.com/Hexastrike/PyrsistenceSniper) is a Python-based offline Windows persistence detection tool. Point it at a KAPE dump, a Velociraptor collection, or a mounted disk image and get offline Windows persistence detection. Runs on Windows, Linux, and macOS. * Different AVs and EDR tools also include the detection and prevention of persistence mechanisms. ### Cloud * [AWSDoor: Persistence on AWS](https://github.com/OtterHacker/AWSDoor) for adding access persistence on AWS. The [corresponding article](https://www.riskinsight-wavestone.com/en/2025/09/awsdoor-persistence-on-aws/) describes the techniques adversaries can use to hide themselves within a cloud environment and its AWSDoor implementation to simplify and automate the deployment of persistence techniques in AWS environments. ### Github topic search for persistence Currently not many things are found with these topics, but if you search for #malware and #persistence the matched repositories are listed: https://github.com/search?q=%23malware+%23persistence&type= ## Acknowledgement Thanks to my previous employer [Swisscom](https://www.swisscom.ch) ([Github](https://github.com/swisscom)) for allowing me to publish the information which was inspired by my work in the past few years at the [@swisscom_csirt](https://twitter.com/swisscom_csirt).