How samratashok/nishang works
Project Type & Purpose
• This is an offensive-security framework implemented as a PowerShell module plus a directory of standalone scripts.
• It’s not a traditional client-server or web app, but a plugin-style library of payloads, backdoors, enumeration and exploitation scripts, and “clients” that generate malicious docs or webshells.
File-Structure Analysis
• Top‐level “nishang.psm1” (PowerShell module) exports all functions.
• Folders represent functional categories:
• ActiveDirectory – AD-focused backdoors and privilege modifications
• Antak-WebShell – a .NET webshell for in-memory PS execution
• Backdoors – multiple C2 techniques (HTTP, DNS TXT, screen-saver, etc.)
• Bypass – anti-AMSI evasion
• Client – payload generators (CHM, Word, Excel, JS, HTA, etc.)
• Escalation, Execution, Gather, MITM, Pivot, Scan – each group of PS scripts for a phase of a red-team engagement
• Shells – reverse shells over HTTP, HTTPS, ICMP, TCP, UDP, WMI
• Utility – common helpers (encode/decode, persistence, exfiltration, download, DNS TXT generator, key parser, etc.)
• powerpreter – monolithic version of many functions in one module
Key Insights from README
• The “module” (nishang.psm1) is the central loader.
• Scripts are meant to be dot-sourced or loaded in memory via WebClient or -EncodedCommand.
• Many scripts interact with external C2 channels (HTTP(S) servers, DNS servers, Gmail, Pastebin, SMB shares).
• Persistence points (registry, scheduled tasks, ADS, etc.) and evasion (AMSI bypass).
Diagramming the Architecture
a. Main Components
1. Target Host (Windows PowerShell v3+)
2. Nishang Module Loader (nishang.psm1)
3. Functional Script Groups (represented as sub-systems/packages):
– AD Module
– Backdoors Module
– Bypass Module
– Client Payload Generator Module
– Escalation Module
– Execution Module
– Gathering Module
– MITM Module
– Pivoting Module
– Scanning Module
– Shells Module
– Utility Module
4. powerpreter Monolith (optional single-module alternative)
5. External Services/C2 Channels:
– HTTP/HTTPS Server, DNS TXT Server, Email (Gmail), Pastebin, SMB/NTLM Collector, DCOM/WMI Remoting, Domain Controller, MSSQL Server, etc.
b. Relationships & Data Flow
• From individual scripts → External C2 channels (HTTP(S), DNS, ICMP, email, SMB)
• From scripts → Windows subsystems (Registry, ADS, Scheduled Tasks, WMI, DCOM)
• From “Client” module → Social-engineering docs/web pages generated, then delivered to victim
c. Architectural Patterns & Principles
• Plugin/Module pattern – central loader with many loosely-coupled script files
• Layered by engagement phase (Recon, Exploitation, Persistence, Exfil, Pivot, Cleanup)
• Extensibility – add new scripts under appropriate category and they auto-export via module manifest
• In-memory execution – minimize disk footprint, evade AV/AMSI
d. Key Technologies & Frameworks
• PowerShell v3+ scripting engine
• .NET WebClient for in-memory download & execution
• Windows APIs for persistence (registry keys, ADS, screen-saver hijack)
• Standard PS Remoting / WMI / DCOM for pivoting
• Networking protocols: HTTP, HTTPS, DNS TXT, ICMP, TCP, UDP