Added help information etc
parent
503522b6d6
commit
58c5ca4fd0
|
@ -1,4 +1,5 @@
|
||||||
function Invoke-EgressCheck {
|
function Invoke-EgressCheck {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ function Invoke-EgressCheck {
|
||||||
Example: -protocol "TCP"
|
Example: -protocol "TCP"
|
||||||
Default: TCP
|
Default: TCP
|
||||||
|
|
||||||
.PARAMETER verbose
|
.PARAMETER verbosity
|
||||||
|
|
||||||
The verbosity of the console output.
|
The verbosity of the console output.
|
||||||
If this is 0, there is no intentional verbosity.
|
If this is 0, there is no intentional verbosity.
|
||||||
|
@ -38,13 +39,21 @@ function Invoke-EgressCheck {
|
||||||
'u' - Sending a UDP packet
|
'u' - Sending a UDP packet
|
||||||
'W' - Waiting (i.e. sleep/delay)
|
'W' - Waiting (i.e. sleep/delay)
|
||||||
|
|
||||||
Example: -verbose 0
|
Example: -verbosity 0
|
||||||
Default: 0
|
Default: 0
|
||||||
|
|
||||||
|
.PARAMETER delay
|
||||||
|
|
||||||
|
The delay between sending packets. This injects a delay in milliseconds between
|
||||||
|
packets generated on a per-port per-protocol basis.
|
||||||
|
|
||||||
|
Example: -delay 100
|
||||||
|
Default: 100
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param([string] $ip, [string] $portrange = "22-25,53,80,443,445,3306,3389", [string] $protocol = "TCP", [int] $verbose=0)
|
param([string] $ip, [string] $portrange = "22-25,53,80,443,445,3306,3389", [string] $protocol = "TCP", [int] $verbosity=0, [int] $delay=100)
|
||||||
|
|
||||||
$pr_split = $portrange -split ','
|
$pr_split = $portrange -split ','
|
||||||
$ports = @()
|
$ports = @()
|
||||||
|
@ -62,38 +71,50 @@ function Invoke-EgressCheck {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($eachport in $ports) {
|
foreach ($eachport in $ports) {
|
||||||
generate_tcp -ip $ip -port $eachport -verbose $verbose
|
if ($protocol.toUpper() -eq 'TCP' -Or $protocol.toUpper() -eq 'ALL') {
|
||||||
generate_udp -ip $ip -port $eachport -verbose $verbose
|
generate_tcp -ip $ip -port $eachport -verbosity $verbosity
|
||||||
Start-Sleep -m (0.2*1000)
|
if ($delay -gt 0) {
|
||||||
|
Start-Sleep -m ($delay)
|
||||||
|
if ($verbosity>0) { Write-Host -NoNewLine "W" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($protocol.toUpper() -eq 'UDP' -Or $protocol.toUpper() -eq 'ALL') {
|
||||||
|
generate_udp -ip $ip -port $eachport -verbosity $verbosity
|
||||||
|
if ($delay -gt 0) {
|
||||||
|
Start-Sleep -m ($delay)
|
||||||
|
if ($verbosity>0) { Write-Host -NoNewLine "W" }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send the TCP packet async
|
# Send the TCP packet
|
||||||
function generate_tcp {
|
function generate_tcp {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param([string]$ip, [int]$port, [int]$verbose)
|
param([string]$ip, [int]$port, [int]$verbosity)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$t = New-Object System.Net.Sockets.TCPClient
|
$t = New-Object System.Net.Sockets.TCPClient
|
||||||
$t.BeginConnect($ip, $port, $null, $null) | Out-Null
|
$t.BeginConnect($ip, $port, $null, $null) | Out-Null
|
||||||
$t.Close()
|
$t.Close()
|
||||||
if ($verbose>0) { Write-Host -NoNewLine "t" }
|
if ($verbosity>0) { Write-Host -NoNewLine "t" }
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send the UDP packet async
|
# Send the UDP packet
|
||||||
function generate_udp {
|
function generate_udp {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param([string]$ip, [int]$port,[int]$verbose)
|
param([string]$ip, [int]$port,[int]$verbosity)
|
||||||
|
|
||||||
$d = [system.Text.Encoding]::UTF8.GetBytes(".")
|
$d = [system.Text.Encoding]::UTF8.GetBytes(".")
|
||||||
try {
|
try {
|
||||||
$t = New-Object System.Net.Sockets.UDPClient
|
$t = New-Object System.Net.Sockets.UDPClient
|
||||||
$t.Send($d, $d.Length, $ip, $port) | Out-Null
|
$t.Send($d, $d.Length, $ip, $port) | Out-Null
|
||||||
$t.Close()
|
$t.Close()
|
||||||
if ($verbose>0) { Write-Host -NoNewLine "u" }
|
if ($verbosity>0) { Write-Host -NoNewLine "u" }
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue