How barriuso/smbghost_automateexploitation works
Project Type and Purpose
• This is a security tool (Python CLI application) comprised of two main functions:
– Scanner: Detects whether a Windows host is vulnerable to SMBGhost.
– Exploit: Crafts or loads shellcode, triggers the vulnerability, and delivers a reverse shell or custom payload.
• The project also bundles example shellcodes and helper modules under RCE/, Scanner/, and Custom_Shellcodes/.
File Structure
Top-level:
• Smb_Ghost.py — main CLI entry point
• requirements.txt — Python dependencies
• Smb_Ghost.py depends on:
– Scanner/scanner.py & logless_scanner.py
– RCE/exploit.py, kernel_shellcode.asm, smb_win.py, lznt1.py
– Custom_Shellcodes/*.txt
Secondary:
• Scanner/ — vulnerability detection sub-module
• RCE/ — exploit payload generator & helper modules
• Custom_Shellcodes/ — user-provided shellcode examples
• README files — documentation for each sub-module
Key Components
a. CLI Interface
– Input parser (argparse) in Smb_Ghost.py
– Options: --check (scan), -e (exploit), --shellcode/load-shellcode
b. Scanner Module
– scanner.py: crafts benign SMBv3 packets, analyzes responses
– logless_scanner.py: silent mode, batch scanning
c. Exploit Module
– exploit.py: assembles RCE payload, invokes kernel_shellcode.asm via smb_win.py
– kernel_shellcode.asm & lznt1.py: low-level SMB compression/decompression and shellcode stager
d. Custom Shellcode Loader
– Loads .txt from Custom_Shellcodes/, or directly via --load-shellcode
e. Network Target
– Windows SMBv3.1.1 endpoint
– Vulnerable service responds to malformed compression packets
f. Reverse Shell Listener
– Uses LHOST/LPORT to catch the ephemeral TCP connection from the compromised host
Relationships and Data Flows
1) User issues CLI command → Smb_Ghost.py
2a) If --check: invoke Scanner
→ send SMBv3 probe → receive status → report vulnerability
2b) If -e (exploit):
– (Optional) Load or select shellcode
– Assemble exploit packet via the Exploit module
– Send malicious SMB packet → target decompresses → executes shellcode
– Target connects back to attacker on LHOST:LPORT
3) Final output: shell or custom action (e.g., new user creation)
Architectural Patterns / Design Principles
• Modular layering:
– CLI layer → Orchestration layer (Smb_Ghost.py) → Functional sub-modules (Scanner, Exploit) → Helper libraries
• Single Responsibility: each sub-directory handles a distinct aspect (scanning vs. exploitation)
• Extensibility: shellcode loader interface allows plugging in new payloads