extracting-config-from-agent-tesla-rat

从 Agent Tesla RAT 样本中提取嵌入的配置信息,包括 SMTP/FTP/Telegram 数据泄露凭据、键盘记录器设置和 C2 端点,使用 .NET 反编译和内存分析技术。

9 stars

Best use case

extracting-config-from-agent-tesla-rat is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

从 Agent Tesla RAT 样本中提取嵌入的配置信息,包括 SMTP/FTP/Telegram 数据泄露凭据、键盘记录器设置和 C2 端点,使用 .NET 反编译和内存分析技术。

Teams using extracting-config-from-agent-tesla-rat should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/extracting-config-from-agent-tesla-rat/SKILL.md --create-dirs "https://raw.githubusercontent.com/killvxk/cybersecurity-skills-zh/main/skills/extracting-config-from-agent-tesla-rat/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/extracting-config-from-agent-tesla-rat/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How extracting-config-from-agent-tesla-rat Compares

Feature / Agentextracting-config-from-agent-tesla-ratStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

从 Agent Tesla RAT 样本中提取嵌入的配置信息,包括 SMTP/FTP/Telegram 数据泄露凭据、键盘记录器设置和 C2 端点,使用 .NET 反编译和内存分析技术。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 从 Agent Tesla RAT 中提取配置

## 概述

Agent Tesla 是一款基于 .NET 的远程访问木马(RAT)和键盘记录器,在 2024 年跻身十大恶意软件变种之列,影响全球 6.3% 的企业网络。它通过 SMTP 电子邮件、FTP 上传、Telegram Bot API 或 Discord Webhook 窃取凭据。恶意软件配置内嵌于 .NET 程序集中,通常使用字符串加密、资源加密或自定义加载器进行混淆,后者通过 .NET Reflection 在内存中解密并执行 Agent Tesla(无文件方式)。配置提取需要使用 dnSpy 或 ILSpy 反编译 .NET 程序集,识别配置字符串的解密例程,并提取 SMTP 服务器地址、凭据、FTP 端点、Telegram Bot Token 和目标应用程序。

## 前置条件

- dnSpy 或 ILSpy,用于 .NET 反编译
- Python 3.9+,带有 `dnlib` 或 `pythonnet`,用于自动化提取
- de4dot,用于 .NET 去混淆
- 理解 .NET IL 代码和 Reflection
- 沙箱环境,用于动态分析(ANY.RUN、CAPE)

## 操作步骤

### 步骤 1:去混淆并提取配置

```python
#!/usr/bin/env python3
"""从 .NET 程序集中提取 Agent Tesla RAT 配置。"""
import re
import sys
import json
import base64
import hashlib
from pathlib import Path


def extract_strings_from_dotnet(filepath):
    """从 .NET 二进制文件中提取可读字符串用于配置分析。"""
    with open(filepath, 'rb') as f:
        data = f.read()

    # 从 .NET 元数据中提取 US(用户字符串)堆
    strings = []

    # 查找常见的 Agent Tesla 配置模式
    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]

    # 提取 Base64 编码的字符串(常见混淆方式)
    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):
    """解密 Agent Tesla 加密的配置字符串。"""
    key = bytes.fromhex(key_hex)
    # Agent Tesla V1:使用密钥进行简单 XOR
    decrypted_strings = []

    # 查找加密数据块(高熵字节序列)
    blob_pattern = re.compile(rb'[\x80-\xff]{16,256}')
    for match in blob_pattern.finditer(data):
        blob = match.group()
        # 尝试 XOR 解密
        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 的密钥派生,然后 AES 解密
    sha256_key = hashlib.sha256(key).digest()

    return decrypted_strings


def analyze_exfiltration_config(config):
    """分析提取的配置以识别数据泄露方式。"""
    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"用法:{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))
```

## 验证标准

- 已识别数据泄露方式(SMTP/FTP/Telegram/Discord)
- 已从配置中提取服务器地址和凭据
- 已恢复目标应用程序列表
- 已记录键盘记录器和截屏功能设置
- 已识别持久化机制
- 已提取适合网络封锁的 IoC

## 参考资料

- [Splunk - Agent Tesla 检测与分析](https://www.splunk.com/en_us/blog/security/inside-the-mind-of-a-rat-agent-tesla-detection-and-analysis.html)
- [Qualys - 捕获 Agent Tesla RAT](https://blog.qualys.com/vulnerabilities-threat-research/2022/02/02/catching-the-rat-called-agent-tesla)
- [ANY.RUN Agent Tesla 分析](https://any.run/malware-trends/agenttesla/)
- [Trustwave - Agent Tesla 新型加载器](https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/agent-teslas-new-ride-the-rise-of-a-novel-loader/)
- [Malpedia - Agent Tesla](https://malpedia.caad.fkie.fraunhofer.de/details/win.agent_tesla)

Related Skills

testing-cors-misconfiguration

9
from killvxk/cybersecurity-skills-zh

在安全评估期间,识别和利用跨源资源共享(CORS)错误配置,这些配置允许未经授权的跨域数据访问和凭证窃取。

remediating-s3-bucket-misconfiguration

9
from killvxk/cybersecurity-skills-zh

本技能提供识别和修复 Amazon S3 存储桶错误配置(这些错误配置会将敏感数据暴露给未授权访问)的分步操作流程。涵盖在账户和存储桶级别启用 S3 阻止公开访问(Block Public Access)、审计存储桶策略和 ACL、强制加密、配置访问日志记录,以及使用 AWS Config 和 Lambda 部署自动化修复措施。

performing-ssl-tls-inspection-configuration

9
from killvxk/cybersecurity-skills-zh

在网络安全设备上配置 SSL/TLS 检查,对 HTTPS 流量进行解密、检查和重加密以用于威胁检测,同时管理证书、豁免项和隐私合规要求。

implementing-google-workspace-sso-configuration

9
from killvxk/cybersecurity-skills-zh

为 Google Workspace 配置基于 SAML 2.0 的单点登录(SSO),与第三方身份提供商集成,实现集中认证并强制执行全组织范围的访问策略。

implementing-aws-config-rules-for-compliance

9
from killvxk/cybersecurity-skills-zh

实施 AWS Config 规则,对 AWS 资源进行持续合规监控,部署符合 CIS 和 PCI DSS 框架的托管和自定义规则,使用 SSM Automation 配置自动修复,并在多账户之间聚合合规数据。

hardening-docker-daemon-configuration

9
from killvxk/cybersecurity-skills-zh

通过配置 daemon.json 实现用户命名空间重映射、TLS 认证、无根模式(rootless mode)和 CIS Benchmark 控制措施,对 Docker daemon 进行安全加固。

extracting-windows-event-logs-artifacts

9
from killvxk/cybersecurity-skills-zh

使用 Chainsaw、Hayabusa 和 EvtxECmd 提取、解析和分析 Windows 事件日志(EVTX),以检测横向移动、持久化和权限提升。

extracting-memory-artifacts-with-rekall

9
from killvxk/cybersecurity-skills-zh

使用 Rekall 内存取证框架分析内存转储,检测进程空洞化(process hollowing)、通过 VAD 异常注入的代码、隐藏进程和 rootkit。应用 pslist、psscan、vadinfo、malfind 和 dlllist 等插件从 Windows 内存镜像中提取取证工件。适用于应急响应内存分析场景。

extracting-iocs-from-malware-samples

9
from killvxk/cybersecurity-skills-zh

从恶意软件样本中提取攻陷指标(IoC),包括文件哈希、网络指标(IP、域名、URL)、 主机痕迹(文件路径、注册表键、互斥锁)以及行为模式,用于威胁情报共享和检测规则创建。 适用于 IoC 提取、威胁指标采集、恶意软件指标收集或从样本构建检测内容等请求场景。

extracting-credentials-from-memory-dump

9
from killvxk/cybersecurity-skills-zh

使用 Volatility 和 Mimikatz 从内存转储中提取缓存的凭据、密码哈希、Kerberos 票据和身份验证令牌,用于取证调查。

extracting-browser-history-artifacts

9
from killvxk/cybersecurity-skills-zh

从 Chrome、Firefox 和 Edge 中提取并分析浏览器历史记录、Cookie、缓存、下载记录和书签,以获取用户网络活动的取证证据。

exploiting-oauth-misconfiguration

9
from killvxk/cybersecurity-skills-zh

在安全评估期间识别并利用 OAuth 2.0 和 OpenID Connect 错误配置,包括重定向 URI 操纵、令牌泄漏和授权码窃取。