Show HN:Stuxnet——臭名昭著的网络武器重构源代码
Show HN: Stuxnet – A reconstructed source code of the infamous cyber-weapon

原始链接: https://github.com/Sadpainy/Stuxnet

本仓库旨在对 2010 年发现的“震网”(Stuxnet)网络武器进行教育性重建,其内容源于对该病毒二进制样本的逆向工程。本项目严格限定于恶意软件分析、防御性研究及学术探讨,旨在剖析首个已知能对工业控制系统(ICS)造成物理破坏的恶意软件。 代码库重现了震网复杂的架构,包括其传播机制(通过 USB 和网络共享)、权限提升漏洞利用、用于隐蔽的高级 Rootkit 模块,以及核心载荷——即旨在操纵西门子 S7 PLC 模块并损坏离心机转子的逻辑程序。本仓库按模块化组件进行组织,如初始投放程序、S7/Step 7 钩子库及内核模式驱动程序,并附有在受控隔离虚拟环境中进行构建的说明。 **免责声明:** 本资料仅供教育目的使用,并非可部署的恶意软件。用户必须在安全、沙盒化的环境中操作,并遵守所有道德和法律标准。本项目旨在为网络安全专业人员提供研究高级持续性威胁(APT)的资源,以开发用于保护关键基础设施的强健检测特征码。

一位开发者分享了“震网”(Stuxnet)的重构源代码项目。作为2010年臭名昭著的网络武器,“震网”被认为曾针对并破坏了伊朗的核离心机。该代码库包含约1.5万行代码,旨在用于研究和教育目的。 Hacker News 上的讨论强调了“震网”作为关键工业基础设施安全转折点的历史意义,指出该武器的发现揭示了随后被修复的多个漏洞。评论者们参与了此次重构的技术实现讨论,并就改进目录过滤和处理系统稳定性提出了建议。项目开发者表示,在分析和重构代码的繁琐过程中利用了大语言模型(LLM)的辅助,这表明尽管工作复杂,但现代人工智能工具在识别和完善漏洞方面提供了显著帮助。该项目为那些对世界上最复杂的恶意软件架构感兴趣的人提供了一份参考资源。
相关文章

原文

Build Status License: GPL v3 Platform

This repository contains a strictly educational and research-oriented reconstruction of the infamous Stuxnet worm. It is the product of countless hours of reverse engineering work conducted by the global security research community on the original binary samples discovered in 2010.

Disclaimer: This code is provided solely for academic study, malware analysis training, and defensive research. It is not intended to be used for any malicious purposes, nor is it a deployable piece of malware. The authors and contributors do not condone illegal or unethical activities.

Table of Contents

Overview

Core Components

Technical Architecture

Build Instructions

Usage

Legal and License

Acknowledgements

Stuxnet is widely recognized as the first known cyber-weapon designed to cause physical destruction to industrial control systems (ICS). It specifically targeted Siemens Step 7 software and S7-300/400 PLCs, ultimately manipulating frequency converter drives to damage centrifuge rotors.

This repository is a reconstructed source code derived from the decompiled binaries. It preserves the original logic and attack vectors while structuring the codebase for readability and analysis.

Key Characteristics

Target: Siemens SIMATIC WinCC, Step 7, and S7 PLCs.

Propagation: USB drives (LNK exploits), Network shares (Print Spooler), Peer-to-Peer (P2P).

Payload: Modification of PLC block logic (OB1/OB35) to alter motor frequencies.

Stealth: Advanced Rootkit capabilities (MRxCls.sys, MRxNet.sys) for file, process, and registry hiding.

The repository is organized by the primary modules identified during the analysis of the original malware.

Module: Loader/Dropper Filename: winsta.exe, ~WTR4141.tmp Description: Entry point responsible for initial infection, privilege escalation, and deployment of other components.

Module: Privilege Escalation Filename: ~WTR4132.tmp Description: Exploits the Win32k.sys vulnerability to gain system-level privileges.

Module: S7 Hook Library Filename: s7otbxdx.dll Description: Malicious replacement of the original s7otbxsx.dll. Intercepts communication between Step 7 and the PLC.

Module: Step7 Hook Library Filename: s7aaapix.dll Description: Intercepts AUT (Automation Tool) API calls within the Step 7 engineering environment.

Module: Rootkit (File System) Filename: mrxcls.sys Description: Kernel-mode driver used to hide Stuxnet files, processes, and registry keys via SSDT hooking.

Module: Rootkit (Network) Filename: mrxnet.sys Description: Filters file system requests to hide malicious files and enables P2P propagation.

Module: Payload (Attack) Filename: s7plcmain Description: The core logic responsible for the "Frequency Tampering" attack that damages the centrifuges.

The following describes the high-level execution flow of the Stuxnet framework.

Stage 1: Initial Infection Vector (USB/Network) Stage 2: Dropper and Escalation Stage 3: Check Environment Stage 4a: Target Found (Siemens Software) -> Install S7 Hooks Stage 4b: Non-target -> Self-Destruct/Idle Stage 5: Monitor PLC Writes Stage 6: Detect OB1/OB35 Write -> Inject Payload Stage 7: Modify Frequency Output Stage 8: Physical Damage to Centrifuges Stage 9: Install Rootkit (MRxCls) Stage 10: Hide Files and Registry Stage 11: Load Network Module (MRxNet) Stage 12: P2P Propagation

Execution Flow

  1. Environment Reconnaissance: The worm checks for the presence of specific Siemens software (WinCC, Step 7) and specific target PLCs (S7-315, S7-417).

  2. DLL Injection: It intercepts the s7blk_write function call.

  3. Code Injection: When a user downloads a project to the PLC, the malicious code is appended to the OB1/OB35 blocks.

  4. Physical Impact: The PLC executes the manipulated code, causing the connected variable frequency drives (VFDs) to spin at abnormal frequencies (high/low), resulting in mechanical damage.

Build Instructions

Important: This codebase is designed for static analysis and debugging in a controlled virtual environment. It is not intended for live deployment on any critical infrastructure.

Requirements

Build Environment: Microsoft Visual Studio 2019/2022 (Windows) or mingw-w64.

Target OS: Windows XP / Windows 7 (for driver compatibility).

Driver Kit: Windows Driver Kit (WDK) 7600 (if compiling kernel drivers).

Building the User-Mode Modules

Clone the repository

git clone https://github.com/Sadpainy/Stuxnet.git cd stuxnet-analysis

Build the main dropper

cd winsta nmake /f Makefile.win

Build the S7 hook library

cd ../s7otbxdx cl /LD s7otbxdx.c user32.lib ws2_32.lib

This code is intended for:

Malware Analysis: Understanding the specific code logic used in advanced persistent threats (APTs).

Defensive Research: Developing detection signatures for ICS security tools (e.g., YARA rules, Snort signatures).

Academic Study: Examining the intersection of cybersecurity and critical infrastructure protection.

Analysis Setup

  1. Isolate Environment: Use a virtual machine (VMWare/VirtualBox) with Host-Only networking enabled. Disable internet connectivity.

  2. Load Modules: Analyze the .dll and .sys files using tools such as IDA Pro, Ghidra, or x64dbg.

  3. Monitor Activity: Use Process Monitor (ProcMon), Process Hacker, and Wireshark to observe the behavior.

Legal and License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

The code in this repository is a product of reverse engineering for educational purposes only. The original authors of the Stuxnet worm are anonymous, but the reconstruction contained herein is the work of independent security researchers.

The authors do not claim ownership of the original malware.

The code is provided "AS IS" without warranty of any kind.

The authors are not responsible for any misuse or damage caused by this code.

By using this repository, you acknowledge that you are solely responsible for ensuring compliance with all applicable laws and regulations.

This research and reconstruction would not have been possible without the extensive analysis and threat intelligence provided by global cybersecurity vendors.

Symantec (W32.Stuxnet dossier)

Kaspersky Lab (The Stuxnet saga)

ESET (Stuxnet under the microscope)

Amr Thabet and Christian Roggia (research-virus/stuxnet)

This is an academic reconstruction. Use it to build stronger defenses, not to cause harm.

联系我们 contact @ memedata.com