Unit 4: Malware Persistence, Injection and Hooking - Subjective Questions
INT251 — Malware Analysis And Cyber Defence • Practice Questions with Detailed Answers
20 questions
Define malware functionality and explain five common capabilities that may be present in modern malware.
Malware functionality refers to the actions and capabilities implemented by malicious software to achieve an attacker's objectives.
Common capabilities include:
- System reconnaissance: Collects operating-system, hardware, user-account, process, network, and security-product information.
- Credential theft: Obtains passwords, browser data, tokens, cookies, or authentication material.
- Command and control: Communicates with remote infrastructure to receive commands and return collected data.
- Persistence: Maintains access by arranging for malicious code to execute after logon, reboot, or another system event.
- Defense evasion: Uses obfuscation, packing, process injection, or security-tool interference to reduce detection.
- Data exfiltration: Transfers selected files or captured information to an attacker-controlled destination.
- Payload execution: Encrypts data, downloads additional components, spies on users, or disrupts system operation.
A malware sample may combine several of these capabilities and activate them conditionally according to its environment.
Explain the concept of malware persistence. Why is persistence important to an attacker, and what evidence can it leave for an analyst?
Malware persistence is the ability of malicious code to regain execution after an interruption such as a reboot, user logoff, process termination, or temporary loss of access.
Persistence is important because it can:
- Preserve access across system restarts.
- Reduce the need to exploit the victim repeatedly.
- Allow long-term surveillance or data collection.
- Support later delivery of additional payloads.
- Re-establish command-and-control communication.
Persistence commonly leaves observable evidence, including:
- New or modified startup configuration entries.
- Unexpected scheduled tasks, services, drivers, or logon scripts.
- Altered application settings or system configuration files.
- Suspicious files in startup-related directories.
- Event-log entries showing service, task, or account changes.
- Network activity shortly after boot or logon.
Analysts correlate these artifacts with file timestamps, process ancestry, digital signatures, and configuration history before deciding whether an entry is malicious.
Describe registry-based persistence on Windows and outline a safe analytical procedure for investigating suspected registry persistence.
Registry-based persistence abuses Windows configuration locations that cause programs or components to execute during startup, logon, or specific application events.
A safe investigation procedure includes:
- Acquire evidence: Export relevant registry hives or collect them through approved forensic tooling.
- Establish a baseline: Compare entries against a known-good image, enterprise inventory, or previous snapshot.
- Inspect execution references: Look for unusual executable paths, scripts, command interpreters, encoded arguments, or user-writable locations.
- Validate referenced files: Calculate hashes, check signatures, record timestamps, and examine file metadata.
- Correlate activity: Compare registry modification times with process, authentication, endpoint, and event-log data.
- Assess scope: Determine whether the entry exists per user or system-wide and whether it appears on other hosts.
- Preserve before remediation: Record the original value and associated evidence before disabling or removing it.
An unfamiliar startup entry is not automatically malicious; software installers and legitimate administration tools also create such entries.
Compare scheduled-task persistence and service-based persistence in terms of activation, privileges, artifacts, and detection opportunities.
| Aspect | Scheduled-task persistence | Service-based persistence |
|---|---|---|
| Activation | Triggered by time, logon, startup, idle state, or an event | Usually activated during boot or by the service manager |
| Privileges | Runs using the account configured for the task | May run under a highly privileged service account |
| Execution style | Can be periodic or event-driven | Commonly long-running, but may also launch and exit |
| Artifacts | Task definitions, task history, event logs, and referenced files | Service configuration, registry data, service-control events, and binaries |
| Detection | Search for unusual triggers, hidden tasks, suspicious commands, or uncommon accounts | Search for unsigned binaries, user-writable paths, abnormal service names, and unexpected privilege levels |
| Operational impact | May generate activity only when its trigger occurs | Can start early and maintain continuous access |
Both mechanisms have legitimate administrative uses. Detection should therefore consider context, provenance, executable reputation, configuration changes, and behavior rather than relying only on the mechanism's existence.
Describe four persistence methods other than registry startup entries, and state one useful detection clue for each.
Four common persistence methods and associated clues are:
- Scheduled tasks: Malware creates an event-based or periodic task. A useful clue is a new task that launches an unsigned file from a temporary or user-writable directory.
- Services or drivers: A malicious component is registered with the operating system. Analysts may observe an unexpected service installation event or an unusual binary path.
- Startup folders or logon scripts: A shortcut, script, or executable is placed where it runs at user logon. A useful clue is a recently created file with an uncommon extension or hidden attributes.
- Application or document add-ins: Malware is loaded when a particular application starts. Detection may reveal an unapproved add-in, template, extension, or configuration change.
- Boot-level modification: Malicious code alters components involved early in startup. Clues include integrity-check failures, unrecognized boot components, or changes outside normal patch activity.
The strongest conclusions come from combining configuration evidence with process execution and file analysis.
Explain virtual memory and discuss why knowledge of virtual address spaces is important during malware analysis.
Virtual memory is an abstraction that gives each process its own logical address space. The operating system and processor translate virtual addresses into physical memory locations through page tables.
Conceptually, an address can be divided into a virtual page number and an offset. If the page size is bytes, the lower bits represent the offset:
Virtual memory is important in malware analysis because:
- Processes normally cannot directly access one another's address spaces.
- Memory pages have permissions such as read, write, and execute.
- Loaded modules and mapped files appear in identifiable memory regions.
- Injected or unpacked code may exist only in memory.
- Address-space layout randomization changes module locations between executions.
- Shared libraries can be mapped into multiple processes while remaining logically separated.
Memory maps, page permissions, allocation history, and module lists can therefore reveal anomalous executable regions or hidden payloads.
Describe the major regions commonly found in a process virtual address space and explain their relevance to malware analysis.
A process virtual address space commonly contains:
- Executable image region: Holds the program's mapped code and static data. Analysts compare it with the on-disk image to detect unexpected modifications.
- Loaded-module regions: Contain shared libraries and runtime components. Unlinked, unsigned, or unexpectedly located modules may require investigation.
- Heap: Stores dynamically allocated data. Decrypted configurations, unpacked payloads, and command data may appear here.
- Stack: Holds function frames, local variables, saved registers, and return addresses. It is useful for reconstructing execution flow.
- Memory-mapped files: Provide file-backed regions for efficient access or interprocess sharing. Their paths and protections can identify suspicious mappings.
- Private anonymous regions: Are not directly backed by ordinary files. Executable anonymous memory can indicate runtime code generation, unpacking, or injection.
No single region proves malicious activity. Analysts evaluate memory protection, contents, ownership, allocation history, and relationships to active threads.
Explain page-level memory protections and discuss why transitions such as writable memory becoming executable are relevant to malware detection.
Operating systems assign page-level protections that control whether a process can read, write, or execute a memory region. These controls support isolation and make accidental or malicious code execution more difficult.
A region that is writable and executable at the same time can allow generated or copied bytes to run as code. Similarly, a transition from writable to executable memory may occur when software constructs code dynamically.
These patterns are relevant because malware may:
- Decrypt or unpack a payload into memory.
- Copy code into another process.
- Replace legitimate instructions with a detour.
- Execute code without storing a conventional executable on disk.
However, such transitions are not conclusive evidence. Just-in-time compilers, browsers, emulators, and some security products also generate code dynamically. Reliable detection combines protection changes with factors such as unusual process ancestry, unsigned modules, remote memory operations, suspicious thread starts, and network activity.
Distinguish between user mode and kernel mode with respect to privileges, memory access, failure impact, and malware behavior.
| Property | User mode | Kernel mode |
|---|---|---|
| Privileges | Restricted; privileged operations require system calls | Highly privileged access to operating-system resources |
| Memory access | Normally limited to the process's permitted address space | Can access kernel memory and, subject to controls, user-process memory |
| Hardware access | Indirect and mediated by the operating system | Drivers and kernel components can interact more directly with hardware |
| Failure impact | Usually terminates or damages an individual process | May crash, corrupt, or compromise the entire system |
| Malware examples | Information stealers, downloaders, user-mode injectors, and API hookers | Malicious drivers, kernel rootkits, and low-level monitoring components |
| Analysis | Generally easier to isolate and observe | Requires specialized tooling and stronger containment precautions |
Kernel-mode malware can obtain broader control and hide user-mode artifacts, but modern systems apply driver signing, secure boot, kernel integrity protections, and access controls to make kernel compromise more difficult.
Describe how a system call transfers execution from user mode to kernel mode and returns a result to the calling process.
A system call is a controlled interface through which a user-mode process requests a privileged operating-system service.
The general sequence is:
- The application prepares a system-call identifier and required arguments.
- A library wrapper or runtime invokes the processor's designated system-call mechanism.
- The processor changes privilege level and transfers control to a validated kernel entry point.
- The kernel verifies parameters, permissions, object references, and memory boundaries.
- The requested kernel service performs the permitted operation.
- The kernel places a return value or status code in the expected location.
- The processor restores the user-mode execution context and resumes the caller.
This boundary is security-critical. Malware may monitor, bypass, or tamper with parts of the path, while analysts examine anomalous calls and return values. Kernel validation remains essential because user-mode input cannot be trusted.
Define code injection and explain why malware injects code into another process.
Code injection is the placement or redirection of executable logic into a process so that the target process runs code that was not part of its expected execution path.
Malware may use injection to:
- Blend with trusted processes: Malicious actions appear to originate from a legitimate application.
- Access process data: Injected code may observe information available inside the target.
- Reuse privileges: Code may operate with the target process's effective permissions, subject to operating-system controls.
- Evade simple detection: The original launcher can terminate while the payload remains active elsewhere.
- Intercept APIs: Execution can be redirected to monitor or alter function calls.
- Maintain operational continuity: A payload may survive the termination of an initial process.
Injection itself is not exclusively malicious; debuggers, accessibility tools, profilers, and endpoint security products may use related mechanisms. Context and behavior are therefore essential for classification.
Describe the conceptual stages of remote-process memory injection and identify the forensic indicators associated with each stage.
At a conceptual level, remote-process injection commonly involves the following stages:
- Target selection: A process is chosen based on trust, privilege, lifetime, or network access. Indicators include unusual process relationships or access attempts.
- Process access: The source obtains rights over the target. Endpoint telemetry may record access requests with memory-modification permissions.
- Memory preparation: Memory is allocated, mapped, or repurposed in the target. Indicators include new private regions or unexpected mapped sections.
- Content transfer: Code or supporting data appears in the target. Memory scans may find executable content not associated with a normal module.
- Execution redirection: A new or existing execution context is made to enter the injected region. Indicators include threads starting outside known modules or abnormal call stacks.
- Cleanup or concealment: Handles, files, or metadata may be removed. Analysts may notice missing backing files, unlinked modules, or short-lived launcher processes.
Detection is strongest when telemetry connects several stages rather than treating one memory event as definitive.
Compare dynamic-library injection, process hollowing, and reflective loading at a conceptual level.
| Technique | Core idea | Typical memory characteristic | Useful detection focus |
|---|---|---|---|
| Dynamic-library injection | Causes a target process to load an additional library | A module may appear in loader records and have a file-backed image | Unexpected libraries, unusual paths, signatures, and cross-process activity |
| Process hollowing | Starts or uses a legitimate process and replaces or redirects its expected image content | Executing memory may differ from the original mapped executable | Image-memory mismatch, abnormal entry point, suspicious parentage, and early memory changes |
| Reflective loading | Loads a module directly from memory using custom loader logic | The module may not be registered like a normally loaded library | Executable private memory, reconstructed headers, imports, and threads outside known modules |
All three techniques attempt to execute code within another process context, but their loading paths and artifacts differ. Memory analysis should be combined with process creation, file, signature, and access telemetry.
Explain process hollowing and describe how an analyst can distinguish a hollowed process from a normally started process.
Process hollowing is an injection technique in which a process created from a legitimate executable has its expected execution image replaced, altered, or bypassed so that different code runs within that process identity.
An analyst may look for:
- A mismatch between the executable on disk and executable pages in memory.
- An entry point that resolves outside the expected image code.
- Memory regions with unusual allocation types or protection histories.
- A main thread whose call stack does not correspond to the declared image.
- Suspicious parent-child relationships or command-line inconsistencies.
- A process created in a paused state followed by immediate memory manipulation.
- Missing, damaged, or inconsistent executable headers and module metadata.
- Network behavior that is atypical for the apparent application.
A robust investigation reconstructs the in-memory image, calculates hashes where practical, compares sections with the original file, and correlates the result with process-creation telemetry.
What is thread execution hijacking? Explain its general principle and the artifacts it may produce.
Thread execution hijacking redirects an existing thread so that it executes unexpected code before possibly returning to its normal path.
Its general principle is:
- A target thread is identified.
- Its execution state is temporarily controlled or observed.
- The instruction pointer or related execution context is redirected toward another memory region.
- The thread resumes and executes the redirected logic.
Potential artifacts include:
- Cross-process access with thread-control permissions.
- Sudden changes to a thread's execution context.
- An instruction pointer located in private or unrecognized executable memory.
- Call stacks that begin outside loaded modules or contain broken transitions.
- Memory allocations or protection changes shortly before thread resumption.
- A mismatch between the thread's expected role and its network or file activity.
Because debuggers and diagnostic tools also manipulate thread contexts, analysts should validate the initiating process, authorization, timing, and destination memory.
Define API hooking and explain how hooking can be used by both legitimate software and malware.
API hooking is the interception or redirection of a function call so that another routine can inspect, modify, block, or supplement the original operation.
Legitimate uses include:
- Debugging and performance profiling.
- Accessibility and compatibility support.
- Security monitoring and policy enforcement.
- Application instrumentation and testing.
Malicious uses include:
- Hiding files, processes, registry entries, or network connections.
- Capturing credentials or sensitive input.
- Modifying security-relevant results returned to applications.
- Monitoring communications and altering data.
- Redirecting execution to an injected payload.
A hook may modify code, function pointers, import tables, or other dispatch structures. Since hooking has valid uses, analysts must consider the hook owner, code signature, installation method, target function, destination address, and resulting behavior.
Compare inline hooking and import-table hooking with respect to operation, scope, artifacts, and detection.
| Aspect | Inline hooking | Import-table hooking |
|---|---|---|
| Operation | Modifies instructions near a function so execution branches to another routine | Replaces an imported function pointer with a different destination |
| Scope | Can affect callers that reach the altered function body | Usually affects calls made through the modified table in a particular module |
| Artifacts | Changed code bytes, branch instructions, altered page protections, or trampoline regions | Import pointers resolving outside the expected exporting module |
| Complexity | Must preserve overwritten instructions and execution flow | Relies on the module's imported-function dispatch structure |
| Detection | Compare memory bytes with trusted code and inspect branch destinations | Validate import entries against expected symbol addresses and loaded modules |
Both techniques redirect control flow. Analysts should account for legitimate instrumentation and for sophisticated hooks that restore bytes temporarily, chain multiple handlers, or conceal their destination.
Explain the concept of a trampoline in inline hooking and state why instruction boundaries and relative addresses matter.
A trampoline is a small executable sequence used to preserve access to the original function when its initial instructions have been replaced by a hook.
Conceptually, it:
- Stores the complete original instructions displaced by the redirection.
- Executes those instructions when original behavior is required.
- Transfers control back to the original function after the modified region.
Instruction boundaries matter because machine instructions have variable lengths on common architectures. Copying only part of an instruction produces invalid or unintended execution. Relative addresses also matter because a copied branch or data reference may calculate its destination from the instruction's current address. Moving that instruction can therefore change its meaning unless the reference is adjusted.
For analysts, trampoline indicators include executable private memory, copied function prologues, branches back into known modules, and code pages that differ from their trusted on-disk versions.
Describe kernel-mode hooking and explain why it presents greater analytical and defensive challenges than user-mode hooking.
Kernel-mode hooking redirects or modifies execution within privileged operating-system code paths, driver callbacks, dispatch routines, or other kernel-controlled mechanisms.
It is more challenging because:
- Privilege is broad: Kernel code can access critical memory and system objects.
- Visibility may be manipulated: A malicious driver may alter information returned to user-mode tools.
- Failure impact is high: Incorrect analysis or removal can crash the operating system.
- Artifacts are specialized: Investigation may require kernel debugging, trusted memory acquisition, and driver analysis.
- Security controls intervene: Driver signing, secure boot, kernel integrity checks, and virtualization-based protections affect what modifications are possible.
- Version dependence is significant: Internal structures and protections differ across operating-system releases.
Defenders use trusted boot measurements, driver inventories, code-integrity events, kernel telemetry, memory forensics, and comparisons across independent data sources to identify hidden or redirected behavior.
Design a defensive investigation workflow for a host suspected of malware persistence, process injection, and API hooking.
A defensible workflow should preserve evidence while progressively validating the suspected behaviors:
- Contain the host: Isolate it according to incident-response policy while preserving necessary management access.
- Record volatile state: Capture active processes, threads, network connections, logged-on users, handles, loaded modules, and memory where authorized.
- Build a process timeline: Correlate parent-child relationships, command lines, account context, process access, and network events.
- Inspect persistence: Review startup configuration, tasks, services, drivers, logon mechanisms, and application extensions against a baseline.
- Examine memory: Identify executable private regions, image-memory mismatches, suspicious protection changes, and threads executing outside recognized modules.
- Check for hooks: Compare code bytes and function pointers with trusted references; inspect redirection destinations and ownership.
- Validate files: Hash relevant files, verify signatures, preserve samples, and examine metadata in an isolated environment.
- Correlate evidence: Connect persistence changes to the process responsible, then connect that process to injection or hook artifacts.
- Determine scope: Search other endpoints for the same hashes, paths, configuration patterns, certificates, and behaviors.
- Remediate and verify: Remove or reimage according to risk, rotate exposed credentials, close the initial access path, and confirm that indicators do not return after reboot.
Every action should be documented with timestamps, tool versions, evidence sources, and chain-of-custody information.
Define malware functionality and explain five common capabilities that may be present in modern malware.
Malware functionality refers to the actions and capabilities implemented by malicious software to achieve an attacker's objectives.
Common capabilities include:
- System reconnaissance: Collects operating-system, hardware, user-account, process, network, and security-product information.
- Credential theft: Obtains passwords, browser data, tokens, cookies, or authentication material.
- Command and control: Communicates with remote infrastructure to receive commands and return collected data.
- Persistence: Maintains access by arranging for malicious code to execute after logon, reboot, or another system event.
- Defense evasion: Uses obfuscation, packing, process injection, or security-tool interference to reduce detection.
- Data exfiltration: Transfers selected files or captured information to an attacker-controlled destination.
- Payload execution: Encrypts data, downloads additional components, spies on users, or disrupts system operation.
A malware sample may combine several of these capabilities and activate them conditionally according to its environment.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →