New to Claude Skills? Learn how to install them →

mukul975 on GitHub

Extracting Config from Agent Tesla RAT

Free

Automate extraction of Agent Tesla RAT configurations for analysis.

Get this skill

Free · Opens the source repo

What Extracting Config from Agent Tesla RAT does

Extracting Config from Agent Tesla RAT is a specialized tool designed for cybersecurity professionals tasked with analyzing malware samples, specifically the Agent Tesla Remote Access Trojan (RAT). This skill automates the process of extracting embedded configurations from Agent Tesla samples, which include critical information such as exfiltration credentials for SMTP, FTP, and Telegram, as well as keylogger settings and command-and-control (C2) endpoints. By leveraging .NET decompilation and memory analysis techniques, users can efficiently recover vital threat intelligence from suspected malware samples.

The skill operates by utilizing Python scripts that interface with .NET decompilation tools like dnSpy or ILSpy. It identifies and extracts configuration strings that are often obfuscated within the .NET assembly. This includes not only straightforward string extraction but also the decryption of encrypted blobs that may contain sensitive information. The results provide a comprehensive overview of the malware's capabilities, including the methods it uses for data exfiltration and the targeted applications.

This tool is particularly useful for security analysts, incident responders, and red team members who need to understand the operational methods of Agent Tesla. It aids in building detection capabilities and enhances understanding of offensive techniques, making it a valuable resource for improving organizational security postures. The skill is designed to be used in controlled environments, ensuring that analysts can safely analyze malware without risking further spread or damage.

While the skill is powerful, it requires a solid understanding of .NET internals and malware analysis techniques. Users should be familiar with tools like dnSpy or ILSpy, and be prepared to work in a sandboxed environment for dynamic analysis. This ensures that the analysis is both effective and secure, allowing for a thorough investigation of the malware's behavior and configuration.

When to use it

Use this skill when performing authorized security testing or analyzing suspected Agent Tesla malware samples in a controlled environment.

When not to use it

This skill is not suitable for environments where malware analysis is prohibited or where users lack the necessary understanding of .NET and malware analysis techniques.

What you can build with it

Malware Sample Analysis

Use this skill to extract configurations from suspected Agent Tesla samples during malware analysis.

Red Team Engagements

Incorporate this tool in red team exercises to understand and document the exfiltration methods used by Agent Tesla.

Building Detection Capabilities

Leverage the extracted configurations to enhance detection capabilities and improve incident response strategies.

How to install Extracting Config from Agent Tesla RAT

View source

1. Install with the skills CLI

npx skills add mukul975/anthropic-cybersecurity-skills/extracting-config-from-agent-tesla-rat --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mukul975

Extracting Config from Agent Tesla RAT

Overview

Agent Tesla is a .NET-based Remote Access Trojan (RAT) and keylogger that ranked among the top 10 malware variants in 2024, impacting 6.3% of corporate networks globally. It exfiltrates stolen credentials via SMTP email, FTP upload, Telegram bot API, or Discord webhooks. The malware configuration is embedded in the .NET assembly, typically obfuscated using string encryption, resource encryption, or custom loaders that decrypt and execute Agent Tesla in memory via .NET Reflection (fileless). Configuration extraction involves decompiling the .NET assembly with dnSpy or ILSpy, identifying the decryption routine for configuration strings, and extracting SMTP server addresses, credentials, FTP endpoints, Telegram bot tokens, and targeted applications.

When to Use

  • When performing authorized security testing that involves extracting config from agent tesla rat
  • When analyzing malware samples or attack artifacts in a controlled environment
  • When conducting red team exercises or penetration testing engagements
  • When building detection capabilities based on offensive technique understanding

Prerequisites

  • dnSpy or ILSpy for .NET decompilation
  • Python 3.9+ with dnlib or pythonnet for automated extraction
  • de4dot for .NET deobfuscation
  • Understanding of .NET IL code and Reflection
  • Sandbox for dynamic analysis (ANY.RUN, CAPE)

Workflow

Step 1: Deobfuscate and Extract Configuration

#!/usr/bin/env python3
"""Extract Agent Tesla RAT configuration from .NET assemblies."""
import re
import sys
import json
import base64
import hashlib
from pathlib import Path


def extract_strings_from_dotnet(filepath):
    """Extract readable strings from .NET binary for config analysis."""
    with open(filepath, 'rb') as f:
        data = f.read()

    # Extract US (User Strings) heap from .NET metadata
    strings = []

    # Look for common Agent Tesla config patterns
    patterns = {
        "smtp_server": re.compile(rb'smtp[\.\-][\w\.\-]+\.\w{2,}', re.I),
        "email": re.compile(rb'[\w\.\-]+@[\w\.\-]+\.\w{2,}'),
        "ftp_url": re.compile(rb'ftp://[\w\.\-:/]+', re.I),
        "telegram_token": re.compile(rb'\d{8,10}:[A-Za-z0-9_-]{35}'),
        "telegram_chat": re.compile(rb'(?:chat_id=|chatid[=:])[\-]?\d{5,15}', re.I),
        "discord_webhook": re.compile(rb'https://discord\.com/api/webhooks/\d+/[\w-]+'),
        "password": re.compile(rb'(?:pass(?:word)?|pwd)[=:]\s*[\w!@#$%^&*]{4,}', re.I),
        "port": re.compile(rb'(?:port|smtp_port)[=:]\s*\d{2,5}', re.I),
    }

    results = {}
    for name, pattern in patterns.items():
        matches = pattern.findall(data)
        if matches:
            results[name] = [m.decode('utf-8', errors='replace') for m in matches]

    # Extract Base64-encoded strings (common obfuscation)
    b64_pattern = re.compile(rb'[A-Za-z0-9+/]{20,}={0,2}')
    b64_decoded = []
    for match in b64_pattern.finditer(data):
        try:
            decoded = base64.b64decode(match.group())
            text = decoded.decode('utf-8', errors='strict')
            if text.isprintable() and len(text) > 5:
                b64_decoded.append(text)
        except Exception:
            pass

    if b64_decoded:
        results["base64_decoded_strings"] = b64_decoded[:30]

    return results


def decrypt_agenttesla_strings(data, key_hex):
    """Decrypt Agent Tesla encrypted configuration strings."""
    key = bytes.fromhex(key_hex)
    # Agent Tesla V1: Simple XOR with key
    decrypted_strings = []

    # Find encrypted blobs (high-entropy byte sequences)
    blob_pattern = re.compile(rb'[\x80-\xff]{16,256}')
    for match in blob_pattern.finditer(data):
        blob = match.group()
        # Try XOR decryption
        decrypted = bytes(b ^ key[i % len(key)] for i, b in enumerate(blob))
        try:
            text = decrypted.decode('utf-8', errors='strict')
            if text.isprintable() and len(text.strip()) > 3:
                decrypted_strings.append(text.strip())
        except UnicodeDecodeError:
            pass

    # V2: SHA256-based key derivation then AES
    sha256_key = hashlib.sha256(key).digest()

    return decrypted_strings


def analyze_exfiltration_config(config):
    """Analyze extracted configuration for exfiltration methods."""
    methods = []

    if config.get("smtp_server"):
        methods.append({
            "type": "SMTP",
            "servers": config["smtp_server"],
            "emails": config.get("email", []),
        })

    if config.get("ftp_url"):
        methods.append({
            "type": "FTP",
            "urls": config["ftp_url"],
        })

    if config.get("telegram_token"):
        methods.append({
            "type": "Telegram",
            "tokens": config["telegram_token"],
            "chat_ids": config.get("telegram_chat", []),
        })

    if config.get("discord_webhook"):
        methods.append({
            "type": "Discord",
            "webhooks": config["discord_webhook"],
        })

    return methods


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print(f"Usage: {sys.argv[0]} <agent_tesla_sample>")
        sys.exit(1)

    config = extract_strings_from_dotnet(sys.argv[1])
    methods = analyze_exfiltration_config(config)

    report = {"raw_config": config, "exfiltration_methods": methods}
    print(json.dumps(report, indent=2))

Validation Criteria

  • Exfiltration method identified (SMTP/FTP/Telegram/Discord)
  • Server addresses and credentials extracted from config
  • Targeted applications list recovered
  • Keylogger and screenshot capture settings documented
  • Persistence mechanism identified
  • IOCs suitable for network blocking extracted

References

Frequently asked questions about Extracting Config from Agent Tesla RAT

Similar skills