Malware Analysis

Objectives: By the end of this topic, you will be able to…

  • Differentiate between static and dynamic analysis
  • Observe and document suspicious behaviors of a binary
  • Recognize indicators of compromise
  • Perform basic analysis in a safe and controlled manner

What is malware?

Malware (malicious software) is any program designed to damage, disrupt, steal, or exploit computer systems, networks, or data.

Common types

TypeDescription
TrojanDisguises as legitimate software to execute malicious actions
WormReplicates automatically through networks without user intervention
RansomwareEncrypts files and demands payment for their release
SpywareMonitors user activity without consent (e.g., keyloggers)
RootkitGains privileged access while hiding its presence
BotnetNetwork of infected computers remotely controlled for distributed attacks

Malware life cycle

Understanding the life cycle helps detect and mitigate attacks at different stages:

  1. Delivery: How malware reaches the system (email attachments, malicious links, USB, exploits)
  2. Execution: The malicious code runs on the victim system
  3. Persistence: Attempts to maintain presence after reboots or cleanup
  4. Command and Control (C2): Communication with the attacker for instructions
  5. Action: Data theft, file encryption, espionage
  6. Evasion: Techniques to avoid detection (obfuscation, encryption, sandbox detection)

Static analysis (without executing the binary)

Focuses on examining the malicious file without running it, making it safer in initial stages.

Common techniques:

  • Review metadata (creation date, author, hashes)
  • Identify file type with file, strings, binwalk, readelf
  • Basic disassembly using Ghidra, IDA Free, or Radare2
  • Extract readable strings with strings to identify URLs, commands, filenames
  • Analyze headers: check imports/exports, sections, architecture
  • Compare hashes with known malware databases (VirusTotal, Hybrid Analysis)

Advantages: low risk of infection, useful for gathering initial indicators. Limitations: does not reveal dynamic behavior, can be bypassed by obfuscated or packed malware.


Dynamic analysis (controlled execution)

Involves executing the malware in a safe environment to observe its behavior.

Typical environment: isolated virtual machines with snapshots and no direct internet connection.

Aspects observed:

  • File, registry, or process modifications
  • Outbound communications (IP, domain, port, protocol)
  • Persistence mechanisms (scheduled tasks, startup modifications)
  • Process behavior and resource usage

Precautions:

  • Never run real samples on production or daily-use systems
  • Ensure network isolation
  • Use snapshots to easily revert the environment

Indicators of Compromise (IoC)

IoCs are traces or signals that indicate a system has been compromised:

  • Hashes of malicious files (MD5, SHA256)
  • Suspicious filenames or paths
  • IP addresses or domains the malware connects to
  • Modified registry keys
  • Characteristic strings inside binaries or processes

These indicators are shared among security professionals to facilitate detection and incident response (via STIX, MISP, threat intelligence feeds).


Recommendations for safe analysis

  • Always use controlled environments (virtual machines, sandboxes)
  • Disable unnecessary features such as shared folders or open ports
  • Take snapshots before any execution
  • Avoid direct internet connection
  • Have forensic and monitoring tools ready
  • Maintain a logbook of all actions taken
  • Store samples with neutral names and safe extensions (.txt, .bin) to avoid accidental execution

Hands-on lab

Requirements: Kali Linux (isolated VM), provided sim_malware binary, Wireshark

Part 1: Static analysis

  1. Run initial analysis:
file sim_malware
md5sum sim_malware
sha256sum sim_malware
  1. Extract readable strings:
strings sim_malware | less

Look for commands like bash, curl, nc, /bin/sh, wget.

  1. Inspect assembly:
objdump -d sim_malware | less

Look for call, syscall, functions such as connect, open, write.

Part 2: Dynamic analysis

  1. Observe system calls:
strace -o output_strace.txt ./sim_malware
ltrace -o output_ltrace.txt ./sim_malware
  1. Monitor connections and processes:
netstat -anp
lsof -p $(pgrep sim_malware)
ps aux | grep sim_malware
  1. Open Wireshark and capture traffic during execution: DNS lookups? Outbound TCP/IP? HTTP?
  2. Check for file creation or modification:
find /tmp -newerct "10 minutes ago"

Part 3: IOC — Indicators of Compromise

Document observed elements in a table:

TypeIndicatorObservation
Hashd41d8cd98f00b204...SHA256 of the sample
File/tmp/payload.shCreated by the binary
Processnc -e /bin/sh ...Simulated reverse shell
Network192.168.1.10:4444Outbound connection detected
String"pwned!"Message found in strings output

Submission

Compressed folder with:

  • output_strace.txt, output_ltrace.txt, captures from strings, objdump
  • Screenshots of netstat, ps, and Wireshark traffic
  • IOC table in .md, .csv, or .pdf
  • Brief written reflection (less than 1 page)

Key concepts

TermDefinition
MalwareMalicious software designed to damage or compromise systems
RansomwareMalware that encrypts files and demands payment to release them
TrojanMalware disguised as legitimate software
IoCObservable evidence that a system has been compromised
Static analysisExamination of binaries without executing them
Dynamic analysisObservation of behavior during execution

Test yourself

  1. Classification: You receive a suspicious file. Describe your analysis process step by step, starting with static techniques before moving to dynamic ones. Why this order?

  2. IoC: What indicators of compromise would you look for in a system you suspect was infected with ransomware?

  3. Safety: Why is it critical to use an isolated virtual machine for dynamic analysis? What could happen if you analyze malware on your main system?


Navigation:Previous | Home | Next