Jashwanth33/RAT

GitHub: Jashwanth33/RAT

一个基于 Python 的教育用途远程访问工具,用于学习网络安全中客户端-服务端架构、通信协议和加密机制。

Stars: 0 | Forks: 1

# 远程访问工具(教育用途) [![Python](https://img.shields.io/badge/Python-3.8+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org) [![安全](https://img.shields.io/badge/Educational-Tool-FF4444?style=for-the-badge)](LICENSE) [![许可证](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](LICENSE) ## 架构概述 `mermaid graph TB subgraph "Server (Controller)" ServerMain[Server Main] CommandCenter[Command Center] ConnectionMgr[Connection Manager] DataProcessor[Data Processor] end ``` subgraph "Client (Target)" ClientMain[Client Main] SystemInfo[System Info Module] Screenshot[Screenshot Module] KeyLogger[Keylogger Module] FileMgr[File Manager] end subgraph "Communication" Socket[TCP Socket] Encryption[Encryption Layer] Protocol[Custom Protocol] end ServerMain --> CommandCenter ServerMain --> ConnectionMgr ConnectionMgr --> Socket Socket --> Encryption Encryption --> Protocol Protocol --> Socket Socket --> ClientMain ClientMain --> SystemInfo ClientMain --> Screenshot ClientMain --> KeyLogger ClientMain --> FileMgr SystemInfo --> DataProcessor Screenshot --> DataProcessor ``` ` ## 客户端-服务端通信流程 `mermaid sequenceDiagram participant C as Client participant S as Server ``` S->>C: Connection Request C-->>S: Connection Established S->>C: Get System Info C-->>S: System Information S->>C: Take Screenshot C-->>S: Screenshot Data S->>C: Start Keylogger C-->>S: Keylogger Started S->>C: Get Keystrokes C-->>S: Keystroke Data S->>C: Upload File C-->>S: File Received S->>C: Execute Command C-->>S: Command Output S->>C: Disconnect C-->>S: Connection Closed ``` ` ## 命令流程 `mermaid flowchart TD A[User Command] --> B{Command Type} ``` B -->|System Info| C[Gather System Data] B -->|Screenshot| D[Capture Screen] B -->|Keylogger| E[Start/Stop Logger] B -->|File Ops| F[File Operations] B -->|Shell| G[Execute Shell Commands] C --> H[Serialize Data] D --> H E --> H F --> H G --> H H --> I[Encrypt Data] I --> J[Send to Server] J --> K[Server Receives] K --> L[Decrypt Data] L --> M[Display Results] ``` ` ## 项目结构 ` RAT/ │ ├── server/ │ ├── server.py # 服务端主应用 │ ├── client_handler.py # 处理客户端连接 │ ├── command_center.py # 命令接口 │ ├── connection_manager.py # 管理活动连接 │ ├── data_processor.py # 处理接收的数据 │ ├── encryption.py # 加密工具 │ ├── logger.py # 服务端日志 │ └── config.py # 服务端配置 │ ├── client/ │ ├── client.py # 客户端主应用 │ ├── system_info.py # 收集系统信息 │ ├── screenshot.py # 截屏捕获 │ ├── keylogger.py # 键盘记录模块 │ ├── file_manager.py # 文件操作 │ ├── shell.py # Shell 命令执行 │ ├── persistence.py # 持久化机制 │ ├── encryption.py # 客户端加密 │ ├── connection.py # 服务端连接 │ └── config.py # 客户端配置 │ ├── shared/ │ ├── protocol.py # 通信协议 │ ├── encryption_utils.py # 共享加密 │ ├── data_structures.py # 数据结构 │ └── constants.py # 共享常量 │ ├── utils/ │ ├── logger.py # 日志工具 │ ├── helpers.py # 辅助函数 │ └── validators.py # 输入验证 │ ├── docs/ │ ├── ARCHITECTURE.md # 架构文档 │ ├── PROTOCOL.md # 协议规范 │ ├── INSTALLATION.md # 安装指南 │ └── EDUCATIONAL_NOTES.md # 教育笔记 │ ├── tests/ │ ├── test_server.py │ ├── test_client.py │ ├── test_protocol.py │ └── test_encryption.py │ ├── configs/ │ ├── server_config.yaml │ └── client_config.yaml │ ├── requirements.txt └── README.md ` ## 功能 | 模块 | 函数 | 描述 | |--------|----------|-------------| | 系统信息 | get_system_info() | OS、CPU、RAM、IP 信息 | | 屏幕截图 | capture_screen() | 进行屏幕截图 | | 键盘记录 | start_keylogger() | 记录键盘敲击 | | 文件管理 | upload/download() | 文件传输 | | Shell | execute_command() | 运行 shell 命令 | | 持久化 | install_persistence() | 维持访问 | ## 通信协议 ` 消息格式: ┌─────────┬─────────┬─────────┬─────────┐ │ Header │ Command │ Length │ Payload │ │ (4 bytes)│ (1 byte)│ (4 bytes)│ (N bytes)│ └─────────┴─────────┴─────────┴─────────┘ 命令: 0x01 - GET_SYSTEM_INFO 0x02 - TAKE_SCREENSHOT 0x03 - START_KEYLOGGER 0x04 - STOP_KEYLOGGER 0x05 - GET_KEYSTROKES 0x06 - UPLOAD_FILE 0x07 - DOWNLOAD_FILE 0x08 - EXECUTE_COMMAND 0x09 - DISCONNECT ` ## 安装说明 `ash # 克隆仓库 git clone https://github.com/Jashwanth33/RAT.git cd RAT # 安装依赖 pip install -r requirements.txt # 启动服务端 python server/server.py # 启动客户端(在目标机器上) python client/client.py --server ` ## 免责声明 **本工具仅供教育用途。** - 这是用于学习网络安全的简化版本 - 未经授权访问计算机系统是非法的 - 在测试前务必获得明确许可 - 作者不对滥用行为负责 - 仅在受控的实验环境中使用 ## 学习目标 1. 理解客户端-服务端架构 2. 网络 socket 编程 3. 数据序列化和加密 4. 系统信息收集 5. 进程和线程管理 ## 许可证 MIT 许可证 - 仅限教育用途 ## 作者 **Jashwanth** - [GitHub](https://github.com/Jashwanth33)
标签:HTTP工具, IP 地址批量处理, Python, 客户端/服务端架构, 文件管理, 无后门, 无线安全, 远程访问木马, 逆向工具, 键盘记录