On day 8 of our journey into malware development in C, we’re going to cover one of my favorite techniques, a critical aspect of malware behavior: persistence. Malware persistence techniques are used to ensure that a malicious program continues to execute even after the system reboots, allowing it to maintain control or surveillance over a long period of time. Let's explore how to achieve persistence in both Windows and Unix environments by leveraging common startup mechanisms.
Day 8 – Malware Persistence and Survivability
Objective
Today’s goal is to understand how malware can be kept on a system to ensure it executes automatically every time the system starts. We’ll explore various techniques for persistence, such as adding entries to startup mechanisms in both Windows and Unix systems. At the end, we’ll modify our keylogger to make it run automatically at system startup.
Persistence Mechanisms
Persistence is the ability of malware to survive system reboots. There are many ways to achieve persistence, depending on the operating system and security context. Malware developers use persistence techniques to maintain their presence on a system over time, ensuring their code continues to run even after the target reboots or logs off.
Persistence Techniques in Windows and Unix
Windows Persistence Techniques
In Windows, there are several common ways to make a program run on startup:
Registry Run Keys:
- Registry is a database used by Windows to store system and application settings. The Run keys are popular targets for malware seeking persistence because anything added to these keys will run when the user logs in.
- The keys can be found in:
- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
- HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Startup Folder:
- Windows also has a Startup Folder that contains shortcuts to programs that should be executed when a user logs in. This is a simpler method and can be used by copying a shortcut to your program into:
- %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
- Tasks: Achieving malware persistence can be done by using hidden scheduled tasks (e.g., Windows Task Scheduler or Linux cron jobs) to execute malicious scripts periodically or by embedding automated startup entries within the registry or system services to ensure persistence across reboots.
No comments:
Post a Comment