AGENT SKILL

malware-reversing-ghidrare

Malware Reversing Ghidrare.

License 许可
MIT
最近更新
2026-09-01
Stars
★ 0
Forks
0

01 前言 Front Matter

name
malware-reversing-ghidrare
domain
cybersecurity
description
Malware Reversing Ghidrare.

02 资源文件 1

03 SKILL.md 正文

| | Disassembly | Converting machine code bytes into human-readable assembly language instructions; Ghidra's Listing view shows disassembled code | | Decompilation | Lifting assembly code to pseudo-C representation for easier analysis; Ghidra's Decompile window provides this view | | Cross-Reference (XREF) | Reference showing where a function or data address is called from or used; essential for tracing code execution flow | | Control Flow Graph (CFG) | Visual representation of all possible execution paths through a function; reveals branching logic and loops | | Original Entry Point (OEP) | The actual start address of the malware code after unpacking; packers redirect execution through an unpacking stub first | | Function Signature | The return type, name, and parameter types of a function; applying correct signatures improves decompiler output quality | | Ghidra Script | Python or Java automation script executed within Ghidra to perform batch analysis, pattern searching, or data extraction |

Tools & Systems

  • Ghidra: NSA's open-source software reverse engineering suite with disassembler, decompiler, and scripting support for multiple architectures
  • IDA Pro/Free: Industry-standard interactive disassembler; IDA Free provides x86/x64 cloud-based decompilation
  • Binary Ninja: Commercial reverse engineering platform with modern UI and extensive API for plugin development
  • x64dbg: Open-source x64/x32 debugger for Windows used alongside Ghidra for dynamic debugging of malware
  • FindCrypt (Ghidra Plugin): Plugin that identifies cryptographic constants and algorithms in binary code

Common Scenarios

Scenario: Reversing Custom C2 Protocol

Context: Behavioral analysis shows encrypted traffic to an external IP on a non-standard port. Network signatures cannot detect variants because the protocol is proprietary. Deep reverse engineering is needed to understand the protocol structure.

Approach:

  1. Import the unpacked sample into Ghidra and run full auto-analysis
  2. Locate socket/WinHTTP API calls and trace backwards to the calling function
  3. Identify the encryption routine called before data is sent (follow data flow from send/HttpSendRequest)
  4. Reverse the encryption (XOR key extraction, RC4 key derivation, AES key location)
  5. Map the command structure by analyzing the response parsing function (switch/case on command IDs)
  6. Document the protocol format (header structure, command bytes, encryption method)
  7. Create a protocol decoder script for network monitoring tools

Pitfalls:

  • Not running the full auto-analysis before starting manual analysis (missing function boundaries and type propagation)
  • Ignoring indirect calls through function pointers or vtables (use cross-references to data holding function addresses)
  • Spending time on library code that Ghidra's Function ID (FID) or FLIRT signatures should have identified
  • Not saving Ghidra project progress frequently (analysis state can be lost on crashes)

Output Format

REVERSE ENGINEERING ANALYSIS REPORT
=====================================
Sample:           unpacked_payload.exe
SHA-256:          abc123def456...
Architecture:     x86 (32-bit PE)
Ghidra Project:   MalwareX_Analysis

FUNCTION MAP
0x00401000  main()              - Entry point, initializes config
0x00401200  decrypt_config()    - XOR decryption with 16-byte key
0x00401400  init_c2()           - WinHTTP initialization, URL construction
0x00401800  c2_beacon()         - HTTP POST beacon with system info
0x00401C00  cmd_dispatcher()    - Switch on 12 command codes
0x00402000  inject_process()    - Process hollowing into svchost.exe
0x00402400  persist_registry()  - HKCU Run key persistence
0x00402800  exfil_data()        - File collection and encrypted upload

C2 PROTOCOL
Method:           HTTPS POST to /gate.php
Encryption:       RC4 with derived key (MD5 of bot_id + campaign_key)
Bot ID Format:    MD5(hostname + username + volume_serial)
Beacon Interval:  60 seconds with 10% jitter
Command Set:
  0x01 - Download and execute file
  0x02 - Execute shell command
  0x03 - Upload file to C2
  0x04 - Update configuration
  0x05 - Uninstall and remove traces

ENCRYPTION DETAILS
Algorithm:        RC4
Key Derivation:   MD5(bot_id + "campaign_2025_q3")
Hardcoded Seed:   "campaign_2025_q3" at offset 0x00405A00

EXTRACTED IOCs
C2 URLs:          hxxps://update.malicious[.]com/gate.php
                  hxxps://backup.evil[.]net/gate.php (failover)
Campaign ID:      campaign_2025_q3
RC4 Key Material: [see encryption details above]

04 同仓库更多 Skills