关于 extracting-config-from-agent-tesla-rat
用于从 Agent Tesla RAT 的 .NET 程序集中提取配置的恶意软件分析技能。内容包括反混淆,以及恢复数据外传端点、凭据、目标应用和相关设置,供授权分析使用。
主要功能
- 01反编译 .NET 程序集
- 02解密配置字符串
- 03提取数据外传端点
- 04恢复目标应用列表
- 05分析持久化机制与指标
适用场景
- 01在沙箱中分析 Agent Tesla 样本
- 02提取用于网络拦截的指标
- 03记录恶意软件的数据外传方式
- 04支持授权红队分析
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill extracting-config-from-agent-tesla-rat安装后在 Claude Code 中输入/extracting-config-from-agent-tesla-rat确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEassets/template.mdreferences/api-reference.mdstandards.mdworkflows.mdscripts/agent.py详细介绍
从 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 和目标应用程序。
何时使用
- 在执行涉及从 agent tesla rat 提取配置的授权安全测试时
- 在受控环境中分析恶意软件样本或攻击产物时
- 在开展红队演练或渗透测试项目时
- 在基于攻击技术理解构建检测能力时
先决条件
- 用于 .NET 反编译的 dnSpy 或 ILSpy
- Python 3.9+ 搭配
dnlib或pythonnet用于自动化提取 - 用于 .NET 反混淆的 de4dot
- 了解 .NET IL 代码和 Reflection
- 用于动态分析的沙箱(ANY.RUN、CAPE)
工作流
步骤 1:反混淆并提取配置
#!/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))
验证标准
- 已识别窃取方法(SMTP/FTP/Telegram/Discord)
- 已从配置中提取服务器地址和凭据
- 已恢复目标应用程序列表
- 已记录键盘记录器和屏幕截图捕获设置
- 已识别持久化机制
- 已提取适用于网络阻断的 IOC
参考资料
评论
支持 Markdown