githubEdit

WinRM AKA Powershell Remoting

Powershell Remoting

Permissions: Administrator OR user in Remote Management Users group

Requirements: WinRM (port 5985/5986) open

Use case: You want modern, interactive access to a remote system (preferred for clean environments). Use it with valid credentials.

Ways to use:

  • One-to-One

  • Interactive

  • Stateful

  • Executes in a new process (wsmprovhost)

  • Execute command on multiple systems at once

  • Runs background jobs

  • -Credential parameter can be used to pass credentials

Create a session

Enable PowerShell Remoting on local system (Requires elevated privileges)

Create new PSSession

Connect to PSSession

Connect to PSSession with a trusted remote account

Store session as variable

If you have sessions stored as variables then commands with the -Computername parameter can be replaced with -Session $session.

Run commands on target

Run locally loaded functions on target system

Load script into remote session

Reverse shell

Bypass AMSI

Run commands on multiple systems

Execute commands on multiple systems

Execute scripts on multiple systems

Execute functions on multiple systems

Bypass AMSI on multiple systems

Disable Defenses

Turns off Defender, sets an exclusion path

Turns off all firewall profiles

Turns off Defender and Firewall on multiple systems

Wmic

Execute calc.exe on remote system

Executing reverse shell on remote system from a SMB share hosted on attackers system

Setting up persistence with schtasks on a remote system to execute a reverse shell every minute/

Winrs

Connect remotely to system and execute a command

Get an interactive shell

Get a remote shell using Docker

Then, in the session, run

Connect to a remote session

Get a remote shell using Ruby Script

Link: https://raw.githubusercontent.com/Alamot/codesnippets/master/winrm/winrm_shell_with_upload.rb

Modify the script by giving a valid username, password and endpoint.

Once modified, run it with ruby

Last updated