Skip to content

Instantly share code, notes, and snippets.

@dmknght
Last active April 26, 2025 02:24
Show Gist options
  • Save dmknght/46f5e105c4675e945fa38658109e8c46 to your computer and use it in GitHub Desktop.
Save dmknght/46f5e105c4675e945fa38658109e8c46 to your computer and use it in GitHub Desktop.
[WIP] A for-fun *Nix malware development syllabus

Hand-on Malware Development on Linux Syllabus

Course Overview

This course provides an in-depth exploration of advanced malware development techniques on Linux, focusing on sophisticated methods such as binary injection, process injection, and file hijacking. Designed for learners with a foundational understanding of Linux and programming, the course emphasizes practical application in a safe, controlled environment (virtual machines) and underscores ethical and legal considerations for academic or authorized security testing purposes.

Malin 101

Day 0: Introduction to Malware and Linux System Programming

Week 1: Remote Shell via TCP connection

  • Objectives:
    • Understand TCP/IP and how to programming with it.
    • Linux file description (?) with Socket. TODO verify this content
    • Understand pipeline and redirection via bash.
    • Remote shell via TCP connection: Reverse Shell, Bind Shell.
    • Execute malicious code remotely.
  • Activities:
    • File description, pipeline and redirection.
    • Learn TCP/IP, basic Socket development. Socket connection with Bash and Pipeline.
    • Non-interactive reverse shell with Python and Nim. Interactive reverse shell with Bash. Introduce bind shell.
    • Introduce concept of malware loader:
      • Remote Python code execution with eval and / or exec.
      • Remote Python object execution (de-serialization) with pickle
  • Resources:

Week 2: C&C Development

Week 3: Data collection & Credential Access

  • Objectives:
    • Location of Linux's valuable data.
    • Collect data on Linux Desktop and Linux Server. (maybe in memory too)
    • Writing keylogger with X-11 /dev/input/
  • Activities:
    • Introduce Linux's Filesystem Hierarchy Standard, examine valuable spots.
    • Introduce Linux Desktop and X-11 Server
    • Write module to enumerate system's info
    • Write module to search and collect valuable data.
    • Examine X-11 keylogger X-spy, a C lang keylogger. Introduction Nim's Binding and write an X-11 keylogger in Nim.
    • Keylogger with /dev/input/.
  • Resouces:

Week 4: System persistence

  • Objectives:
    • Understand Linux's core places: cron, system unit, script hooking
    • Understand Linux Desktop's startup mechanism.
  • Activities:
    • Logon execution:
      • System daemon start
      • Autostart on X-11
    • Event trigger execution:
      • System's hooking script introduction
      • Unix shell config modification
      • Udev rules
    • Schedule task / job execution:
      • Systemd timer
      • Cron

Week 5: Basic system evasion Defense evasion

  • Objectives:
    • Learn basic concept of signature-based detection and how to evade
    • Traces in system logs
    • Traffic obfuscate.
    • Code obfuscation and encryption.
  • Activities:
    • Introduce Yara and signature matching
    • Write encoder and decoder to encode malicious traffic.
    • Encode / encrypt source code and decrypt them.
    • Hide / delete activities from system logs
  • Resources:
    • TODO write here

Malin 102 (TODO list)

Week 6: Linux shellcode

Week 7: Code Injection (and process injection) Techniques

Week 7: Discovery and Lateral movement (?). In memory data collection maybe?

TODO dbus

Week 7: Kernel-Level Malware and Rootkits

  • Objectives:
    • Develop kernel modules and basic rootkits.
    • Learn to hide processes and files using kernel hooks.
    • Understand risks and detection challenges of kernel-level malware.
  • Activities:
    • Create a kernel module that hides a process, tested in a VM.
  • Resources:
    • Linux kernel documentation
    • Detecting Linux Binary File Poisoning

Week 8: Advanced Evasion Techniques

  • Objectives:
    • Implement encryption and code obfuscation to conceal malware functionality.
    • Apply anti-debugging techniques (e.g., detecting GDB attachment).
    • Use anti-sandbox methods (e.g., checking for VM indicators like VMware tools).
    • Explore persistence via init scripts and cron jobs.
    • Tunneling
  • Activities:
    • Develop a malware sample with an encrypted payload, tested for evasion in a VM.
  • Resources:
    • Learning to Write Fully Undetected Malware

Week 9: Persistence Mechanisms and File Hijacking

  • Objectives:
    • Maintain malware presence using cron jobs, init scripts, and startup services.
    • File Hijacking:
      • Perform binary poisoning (e.g., replacing /bin/ls with a malicious version).
      • Use symbolic links to redirect file operations (e.g., linking /tmp/malware to /bin/ls).
      • Explore library hijacking, including Python library hijacking (e.g., modifying /usr/lib/python3.7/base64.py) and LD_PRELOAD manipulation.
      • Manipulate PYTHONPATH for Python library redirection.
  • Activities:
    • Replace a system file in a VM with a malicious version.
    • Demonstrate Python library hijacking.
  • Resources:
    • Python Library Hijacking on Linux
    • Hackers hijack Linux devices using PRoot isolated filesystems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment