Skip to content

Commit 6eb52e9

Browse files
committed
Only show errors when errors occur
Prevented the display of error messages that may throw someone off.
1 parent 0d5ab35 commit 6eb52e9

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

CHANGELOG.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ whatever commands they want.
5151
**********************************************************************************************************
5252
RuleName Severity ScriptName Line Message
5353
-------- -------- ---------- ---- -------
54-
PSAvoidUsingInvokeExpression Warning ReversePow 317 Invoke-Expression is used. Please remove Invoke-Expression
54+
PSAvoidUsingInvokeExpression Warning ReversePow 295 Invoke-Expression is used. Please remove Invoke-Expression
5555
erShell.ps from script and find other options instead.
5656
m1
57-
PSAvoidUsingInvokeExpression Warning ReversePow 556 Invoke-Expression is used. Please remove Invoke-Expression
57+
PSAvoidUsingInvokeExpression Warning ReversePow 523 Invoke-Expression is used. Please remove Invoke-Expression
5858
erShell.ps from script and find other options instead.
5959
m1
6060
#----------------------------------------------------------------------
6161
# Command for updating Module Manifest
6262
#
63-
# New-ModuleManifest -Path .\ReversePowerShell.psd1 -Author 'Robert H. Osborne' -CompanyName 'OsbornePro' -Copyright '(c) 2022 Robert H. Osborne. All rights reserved.' -ModuleVersion '1.3.3' -RootModule .\ReversePowerShell.psm1 -Description 'Functions that can be used to gain a bind or reverse shell with PowerShell.' -PowerShellVersion '3.0' -FunctionsToExport 'Start-Bind','Start-Listener','Invoke-ReversePowerShell','Find-ReverseShell' -CmdletsToExport 'Start-Bind','Start-Listener','Invoke-ReversePowerShell','Find-ReverseShell' -ProjectUri 'https://github.com/tobor88/ReversePowerShell' -LicenseUri 'https://raw.githubusercontent.com/tobor88/ReversePowerShell/master/LICENSE' -IconURI 'https://img1.wsimg.com/isteam/ip/8f3c0f3f-85e4-413f-bd91-f19d4f317a5a/logo/967ca34c-6d9b-4d2f-9206-83481c35769d.png/:/rs=h:392/ll' -ReleaseNotes 'https://raw.githubusercontent.com/tobor88/ReversePowerShell/master/CHANGELOG.txt' -PowerShellHostName 'ConsoleHost' -AliasesToExport @() -Tags 'PowerShell','CyberSecurity','InfoSec','PenetrationTesting','PenTesting','Shells','Security' -ProcessorArchitecture 'None' -HelpInfoUri 'https://raw.githubusercontent.com/tobor88/ReversePowerShell/master/README.md'
63+
# New-ModuleManifest -Path .\ReversePowerShell.psd1 -Author 'Robert H. Osborne' -CompanyName 'OsbornePro' -Copyright '(c) 2022 Robert H. Osborne. All rights reserved.' -ModuleVersion '1.3.3' -RootModule .\ReversePowerShell.psm1 -Description 'Functions that can be used to gain a bind or reverse shell with PowerShell.' -PowerShellVersion '3.0' -FunctionsToExport 'Start-Bind','Start-Listener','Invoke-ReversePowerShell','Find-ReverseShell' -CmdletsToExport 'Start-Bind','Start-Listener','Invoke-ReversePowerShell','Find-ReverseShell' -ProjectUri 'https://github.com/tobor88/ReversePowerShell' -LicenseUri 'https://raw.githubusercontent.com/tobor88/ReversePowerShell/master/LICENSE' -IconURI 'https://osbornepro.com/img/logo-nobackground-200.png' -ReleaseNotes 'https://raw.githubusercontent.com/tobor88/ReversePowerShell/master/CHANGELOG.txt' -PowerShellHostName 'ConsoleHost' -AliasesToExport @() -Tags 'PowerShell','CyberSecurity','InfoSec','PenetrationTesting','PenTesting','Shells','Security' -ProcessorArchitecture 'None' -HelpInfoUri 'https://raw.githubusercontent.com/tobor88/ReversePowerShell/master/README.md'

ReversePowerShell.psd1

-210 Bytes
Binary file not shown.

ReversePowerShell.psm1

+4-5
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ Function Find-ReverseShell {
709709

710710
$TcpListenerCheck = Invoke-Command -HideComputerName $ComputerName -UseSSL:$SSL -ScriptBlock {
711711

712-
Get-WinEvent -ComputerName $ComputerName -LogName 'Security' -FilterXPath "*[System[EventID=4656 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SubjectUserName']!='paessler'] and EventData[Data[@Name='ObjectServer']='WS-Management Listener']]" -ErrorVariable $CmdError
712+
Get-WinEvent -ComputerName $ComputerName -LogName 'Security' -FilterXPath "*[System[EventID=4656 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SubjectUserName']!='paessler'] and EventData[Data[@Name='ObjectServer']='WS-Management Listener']]" -ErrorAction SilentlyContinue
713713
If ($Null -eq $TcpListenerCheck) {
714714

715715
$TcpListenerCheck = Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID=5154 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SourceAddress']!='127.0.0.1'] and EventData[Data[@Name='FilterRTID']=0] and EventData[Data[@Name='SourcePort']!=139]]" -ErrorVariable $CmdError
@@ -721,7 +721,7 @@ Function Find-ReverseShell {
721721

722722
} Catch {
723723

724-
$TcpListenerCheck = Get-WinEvent -ComputerName $ComputerName -LogName 'Security' -FilterXPath "*[System[EventID=4656 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SubjectUserName']!='paessler'] and EventData[Data[@Name='ObjectServer']='WS-Management Listener']]" -ErrorVariable $CmdError
724+
$TcpListenerCheck = Get-WinEvent -ComputerName $ComputerName -LogName 'Security' -FilterXPath "*[System[EventID=4656 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SubjectUserName']!='paessler'] and EventData[Data[@Name='ObjectServer']='WS-Management Listener']]" -ErrorAction SilentlyContinue
725725
If ($Null -eq $TcpListenerCheck) {
726726

727727
$TcpListenerCheck = Get-WinEvent -ComputerName $ComputerName -LogName 'Security' -FilterXPath "*[System[EventID=5154 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SourceAddress']!='127.0.0.1'] and EventData[Data[@Name='FilterRTID']=0] and EventData[Data[@Name='SourcePort']!=139]]" -ErrorVariable $CmdError
@@ -734,7 +734,7 @@ Function Find-ReverseShell {
734734
} Else {
735735

736736
Write-Output "[*] Checking for Reverse Shells that connect to a System.Net.Sockets.TcpListener object, excluding ports opened by the paessler account"
737-
$TcpListenerCheck = Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID=4656 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SubjectUserName']!='paessler'] and EventData[Data[@Name='ObjectServer']='WS-Management Listener']]" -ErrorVariable $CmdError
737+
$TcpListenerCheck = Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID=4656 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SubjectUserName']!='paessler'] and EventData[Data[@Name='ObjectServer']='WS-Management Listener']]" -ErrorAction SilentlyContinue
738738
If ($Null -eq $TcpListenerCheck) {
739739

740740
$TcpListenerCheck = Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID=5154 and TimeCreated[timediff(@SystemTime) <= 86400000]] and EventData[Data[@Name='SourceAddress']!='127.0.0.1'] and EventData[Data[@Name='FilterRTID']=0] and EventData[Data[@Name='SourcePort']!=139]]" -ErrorVariable $CmdError
@@ -764,5 +764,4 @@ Function Find-ReverseShell {
764764

765765
} # End If Else
766766

767-
} # End Function Find-ReverseShell
768-
767+
} # End Function Find-ReverseShell

0 commit comments

Comments
 (0)