KONDORDEVSECURITYCORP/c2Telegram
GitHub: KONDORDEVSECURITYCORP/c2Telegram
基于Palo Alto Unit42威胁情报报告的LLM驱动Telegram C2概念验证项目,演示了通过自然语言指挥受感染主机的无代码攻击模式。
Stars: 0 | Forks: 0
# 🔴 c2Telegram — 基于 Telegram 的 LLM 驱动 C2 PoC
**概念验证 · 威胁情报研究 · Unit42 2026**
[](https://python.org)
[](LICENSE)
[](SECURITY.md)
[](https://github.com/KONDORDEVSECURITYCORP)
## 目录
- [西班牙语](#español)
- [这是什么?](#qué-es-esto)
- [架构](#arquitectura)
- [安装](#instalación)
- [配置](#configuración)
- [用法](#uso)
- [PoC 功能](#capacidades-del-poc)
- [英语](#english)
- [这是什么?](#what-is-this)
- [架构](#architecture)
- [安装](#installation)
- [配置](#configuration)
- [用法](#usage)
- [PoC 功能](#poc-capabilities)
- [参考](#referencias--references)
# 西班牙语
## 这是什么?
本仓库实现了一个**概念验证**,基于 **Palo Alto Networks Unit42** 于 2026 年 6 月 17 日发布的威胁情报报告。该报告记录了如何将 Telegram 机器人与大型语言模型(LLM)结合使用,从而构建命令与控制(C2)基础设施,而无需攻击者具备专门的技术。
### 威胁背景
记录在案的攻击载体结合了三种可访问的技术:
| 组件 | 功能 | 工具 |
|---|---|---|
| **Telegram Bot API** | 加密且匿名的 C2 通道 | Telegram Bot |
| **LLM (Groq/Llama)** | 将自然语言翻译为 shell 命令 | Groq API |
| **Python 植入物** | 在受感染的主机上执行 | Python 脚本 |
### 为什么这很重要?
- 消除了技术门槛:操作员只需用自然语言输入(例如,“列出桌面文件”)
- LLM 会将指令翻译为具体的操作系统命令
- 使用合法的 Telegram 基础设施作为 C2 通道,增加了拦截难度
- 该植入物是跨平台的(Linux, Windows, macOS)
## 架构
```
┌─────────────────────────────────────────────────────────────────┐
│ OPERADOR (Atacante) │
│ Telegram Chat → Lenguaje natural │
└────────────────────────┬────────────────────────────────────────┘
│ Mensaje de texto
▼
┌─────────────────────────────────────────────────────────────────┐
│ TELEGRAM BOT API │
│ Canal cifrado · Infraestructura legítima │
└────────────────────────┬────────────────────────────────────────┘
│ Long-polling (HTTPS)
▼
┌─────────────────────────────────────────────────────────────────┐
│ IMPLANTE EN EL HOST │
│ │
│ ┌─────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Fase 1 │ │ Fase 3 │ │ Fase 4 │ │
│ │ Beacon │ │ LLM Translator │ │ Executor │ │
│ │ Fingerprint│──▶│ Groq API │──▶│ Shell/File/Net │ │
│ └─────────────┘ │ llama-3.1-8b │ └──────────────────┘ │
│ └──────────────────┘ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Fase 2 — TelegramClient │ │
│ │ • Polling de mensajes • Envío de resultados │ │
│ │ • Exfiltración de archivos (hasta 50 MB) │ │
│ └──────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
```
### 执行阶段
```
Fase 1: Host Fingerprinting & Beacon
└─ Recopila: IP pública, hostname, usuario, OS, procesador
└─ Envía beacon inicial al operador vía Telegram
Fase 2: C2 Infrastructure (Telegram)
└─ TelegramClient: polling cada 5 seg, filtra mensajes por operator_id
└─ Solo procesa mensajes del operador autorizado
Fase 3: LLM Command Translation
└─ Envía el mensaje al LLM (Groq/Llama)
└─ El LLM devuelve un action token estructurado:
EXECUTE_COMMAND:
| GET_FILE: | SCAN_NETWORK: | ...
Fase 4: Command Execution & Exfiltration
└─ Ejecuta el action token en el host
└─ Devuelve resultado al operador via Telegram
└─ Archivos grandes → exfiltración directa como documento
```
## 安装
### 前提条件
- Python 3.9 或更高版本
- Pip
- [console.groq.com](https://console.groq.com) 账号(免费)
- 使用 [@BotFather](https://t.me/BotFather) 创建的 Telegram Bot
### 步骤
```
# 克隆仓库
git clone https://github.com/KONDORDEVSECURITYCORP/c2Telegram.git
cd c2Telegram
# 创建虚拟环境(推荐)
python3 -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
# 安装依赖
pip install -r requirements.txt
# 直接在脚本中编辑凭据
nano llm_telegram_poc.py
# 找到 CONFIG 块并替换占位符(参见 Configuration 章节)
```
## 配置
打开 `llm_telegram_poc.py` 并找到 `CONFIG` 块。用你的实际值替换这三个占位符:
```
CONFIG = {
'telegram_bot_token': 'TELEGRAM_BOT_TOKEN', # <-- pega tu token aquí
'telegram_operator_id': 0, # <-- pon tu ID numérico aquí
'groq_api_key': 'GROQ_API_KEY', # <-- pega tu API key aquí
...
}
```
### 待编辑字段
| CONFIG 中的字段 | 获取位置 | 格式示例 |
|---|---|---|
| `telegram_bot_token` | @BotFather → `/newbot` | `123456789:ABCdefGHIjklMNOpqrsTUVwxyz` |
| `telegram_operator_id` | @userinfobot (整数) | `987654321` |
| `groq_api_key` | console.groq.com → API Keys | `gsk_xxxxxxxxxxxxxxxxxxxx` |
| `llm_model` | 可选,请参阅 [Groq 模型](https://console.groq.com/docs/models) | `llama-3.1-8b-instant` |
| `poll_interval` | 可选 — 轮询之间的秒数 | `5` |
| `poll_timeout` | 可选 — long-poll 超时时间 | `30` |
### 如何获取你的 Telegram ID
向机器人 [@userinfobot](https://t.me/userinfobot) 发送任何消息 — 它会回复你的数字 `id`。
## 用法
```
# 激活虚拟环境(如果尚未激活)
source .venv/bin/activate
# 运行 PoC
python3 llm_telegram_poc.py
```
一旦启动,植入物将发送一个带有主机信息的 **beacon**,并开始监听来自 Telegram 聊天的命令。
### 示例命令(自然语言)
| 你在 Telegram 中输入的内容 | 植入物执行的操作 |
|---|---|
| `list files in /tmp` | `ls /tmp` |
| `show me running processes` | `ps aux` |
| `what's my ip` | 调用 ipify + whoami |
| `read the file /etc/hostname` | `cat /etc/hostname` |
| `check open ports on 192.168.1.1` | 端口扫描 |
## PoC 功能
| 模块 | 能力 | 备注 |
|---|---|---|
| `HostIntelligence` | 主机指纹识别 | 公共 IP,OS,用户,主机名 |
| `TelegramClient` | 通过 Telegram 进行 C2 | 轮询 + 发送 + 文件窃取 |
| `LLMCommandTranslator` | 将自然语言翻译为 shell | Groq Llama 3.1 8B |
| `CommandExecutor` | 执行命令 | Shell,文件读取,网络扫描 |
| `LLMTelegramC2` | 主编排器 | 完整的 C2 生命周期 |
# 英语
## 这是什么?
本仓库实现了一个**概念验证**,基于 **Palo Alto Networks Unit42** 于 2026 年 6 月 17 日发布的威胁情报报告。该报告记录了如何将 Telegram 机器人与大型语言模型(LLM)结合使用,从而构建命令与控制(C2)基础设施,而无需攻击者具备技术技能。
### 威胁背景
记录在案的攻击载体结合了三种可访问的技术:
| 组件 | 功能 | 工具 |
|---|---|---|
| **Telegram Bot API** | 加密且匿名的 C2 通道 | Telegram Bot |
| **LLM (Groq/Llama)** | 将自然语言翻译为 shell 命令 | Groq API |
| **Python 植入物** | 在受感染的主机上执行 | Python 脚本 |
### 为什么这很重要?
- 消除了技术门槛:操作员只需用自然语言输入(例如,“列出桌面文件”)
- LLM 会将指令翻译为具体的 OS 命令
- 使用合法的 Telegram 基础设施作为 C2 通道,增加了拦截难度
- 该植入物是跨平台的(Linux, Windows, macOS)
## 架构
```
┌─────────────────────────────────────────────────────────────────┐
│ OPERATOR (Attacker) │
│ Telegram Chat → Natural Language Input │
└────────────────────────┬────────────────────────────────────────┘
│ Text message
▼
┌─────────────────────────────────────────────────────────────────┐
│ TELEGRAM BOT API │
│ Encrypted channel · Legitimate infrastructure │
└────────────────────────┬────────────────────────────────────────┘
│ Long-polling (HTTPS)
▼
┌─────────────────────────────────────────────────────────────────┐
│ IMPLANT ON HOST │
│ │
│ ┌─────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Phase 1 │ │ Phase 3 │ │ Phase 4 │ │
│ │ Beacon │ │ LLM Translator │ │ Executor │ │
│ │ Fingerprint│──▶│ Groq API │──▶│ Shell/File/Net │ │
│ └─────────────┘ │ llama-3.1-8b │ └──────────────────┘ │
│ └──────────────────┘ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Phase 2 — TelegramClient │ │
│ │ • Message polling • Result delivery │ │
│ │ • File exfiltration (up to 50 MB) │ │
│ └──────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
```
### 执行阶段
```
Phase 1: Host Fingerprinting & Beacon
└─ Collects: public IP, hostname, username, OS, processor
└─ Sends initial beacon to operator via Telegram
Phase 2: C2 Infrastructure (Telegram)
└─ TelegramClient: polls every 5 sec, filters by operator_id
└─ Only processes messages from the authorized operator
Phase 3: LLM Command Translation
└─ Sends message to LLM (Groq/Llama)
└─ LLM returns a structured action token:
EXECUTE_COMMAND: | GET_FILE: | SCAN_NETWORK: | ...
Phase 4: Command Execution & Exfiltration
└─ Executes the action token on the host
└─ Returns result to operator via Telegram
└─ Large outputs → direct file exfiltration as Telegram document
```
## 安装
### 前提条件
- Python 3.9 或更高版本
- Pip
- [console.groq.com](https://console.groq.com) 账号(提供免费层)
- 使用 [@BotFather](https://t.me/BotFather) 创建的 Telegram Bot
### 步骤
```
# 克隆仓库
git clone https://github.com/KONDORDEVSECURITYCORP/c2Telegram.git
cd c2Telegram
# 创建虚拟环境(推荐)
python3 -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
# 安装依赖
pip install -r requirements.txt
# 直接在脚本中编辑凭据
nano llm_telegram_poc.py
# 找到 CONFIG 块并替换占位符(参见 Configuration 章节)
```
## 配置
打开 `llm_telegram_poc.py` 并找到 `CONFIG` 块。用你的实际值替换这三个占位符:
```
CONFIG = {
'telegram_bot_token': 'TELEGRAM_BOT_TOKEN', # <-- paste your token here
'telegram_operator_id': 0, # <-- put your numeric ID here
'groq_api_key': 'GROQ_API_KEY', # <-- paste your API key here
...
}
```
### 待编辑字段
| CONFIG 字段 | 获取位置 | 格式示例 |
|---|---|---|
| `telegram_bot_token` | @BotFather → `/newbot` | `123456789:ABCdefGHIjklMNOpqrsTUVwxyz` |
| `telegram_operator_id` | @userinfobot (整数) | `987654321` |
| `groq_api_key` | console.groq.com → API Keys | `gsk_xxxxxxxxxxxxxxxxxxxx` |
| `llm_model` | 可选,请参阅 [Groq 模型](https://console.groq.com/docs/models) | `llama-3.1-8b-instant` |
| `poll_interval` | 可选 — 轮询之间的秒数 | `5` |
| `poll_timeout` | 可选 — long-poll 超时时间 | `30` |
### 如何获取你的 Telegram ID
向机器人 [@userinfobot](https://t.me/userinfobot) 发送任何消息 — 它会回复你的数字 `id`。
## 用法
```
# 激活虚拟环境(如果尚未激活)
source .venv/bin/activate
# 运行 PoC
python3 llm_telegram_poc.py
```
一旦启动,植入物将发送一个带有主机信息的初始 **beacon**,并开始监听来自 Telegram 聊天的命令。
### 示例命令(自然语言)
| 你在 Telegram 中输入的内容 | 植入物执行的操作 |
|---|---|
| `list files in /tmp` | `ls /tmp` |
| `show me running processes` | `ps aux` |
| `what's my ip` | 调用 ipify + whoami |
| `read the file /etc/hostname` | `cat /etc/hostname` |
| `check open ports on 192.168.1.1` | 端口扫描 |
## PoC 功能
| 模块 | 能力 | 备注 |
|---|---|---|
| `HostIntelligence` | 主机指纹识别 | 公共 IP,OS,用户,主机名 |
| `TelegramClient` | 通过 Telegram 进行 C2 | 轮询 + 传递 + 文件窃取 |
| `LLMCommandTranslator` | 将自然语言翻译为 shell | Groq Llama 3.1 8B |
| `CommandExecutor` | 执行命令 | Shell,文件读取,网络扫描 |
| `LLMTelegramC2` | 主编排器 | 完整的 C2 生命周期 |
## 参考
- [Palo Alto Networks Unit42 — 基于 Telegram 的 LLM 驱动恶意软件 (2026-06-17)](https://unit42.paloaltonetworks.com/)
- [Groq API 文档](https://console.groq.com/docs)
- [Telegram Bot API](https://core.telegram.org/bots/api)
- [python-dotenv](https://pypi.org/project/python-dotenv/)
## 项目结构
```
c2Telegram/
├── llm_telegram_poc.py # Main PoC implant — edit CONFIG block here
├── .gitignore # Git exclusions
├── requirements.txt # Python dependencies
├── README.md # This file
└── SECURITY.md # Responsible use policy
```
**KONDOR DEV SECURITY CORP**
*攻击安全 · 红队 · 威胁情报*
标签:PoC, Python, Sysdig, 命令与控制(C2), 威胁情报, 开发者工具, 无后门, 暴力破解, 逆向工具