aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill <HarmJ0y@users.noreply.github.com>2017-09-17 14:25:57 -0400
committerGitHub <noreply@github.com>2017-09-17 14:25:57 -0400
commite24d64224b24d5cbf895bae2f21c3607b0e3e612 (patch)
tree7cd1b03e5f83584223cfc129a28c0fd90b4bbda5
parent41cef58b7510f94f49bf443bbfcf5d3c4a8f56a9 (diff)
parent226c1c1cce4ee587495bc6e9db8731a68429ed52 (diff)
downloadPowerSploit-e24d64224b24d5cbf895bae2f21c3607b0e3e612.tar.gz
PowerSploit-e24d64224b24d5cbf895bae2f21c3607b0e3e612.zip
Merge pull request #243 from cfalta/master
Host parsing extension for IP ranges
-rw-r--r--Recon/Invoke-Portscan.ps161
1 files changed, 61 insertions, 0 deletions
diff --git a/Recon/Invoke-Portscan.ps1 b/Recon/Invoke-Portscan.ps1
index 7e28709..ce76088 100644
--- a/Recon/Invoke-Portscan.ps1
+++ b/Recon/Invoke-Portscan.ps1
@@ -262,6 +262,8 @@ http://webstersprodigy.net
[String[]] $iHosts = $Hosts.Split(",")
+ $IPRangeRegex = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}-\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
+
foreach($iHost in $iHosts)
{
$iHost = $iHost.Replace(" ", "")
@@ -316,6 +318,65 @@ http://webstersprodigy.net
}
}
+
+ if($iHost -match $IPRangeRegex)
+ {
+
+ $iHostPart1 = ($iHost.Split("-"))[0]
+ $iHostPart2 = ($iHost.Split("-"))[1]
+
+ $LowerBound = $iHostPart1.Split(".")
+ $UpperBound = $iHostPart2.Split(".")
+
+ $LowerBoundInt = ($LowerBound[0].ToInt32($null),$LowerBound[1].ToInt32($null),$LowerBound[2].ToInt32($null),$LowerBound[3].ToInt32($null))
+ $UpperBoundInt = ($UpperBound[0].ToInt32($null),$UpperBound[1].ToInt32($null),$UpperBound[2].ToInt32($null),$UpperBound[3].ToInt32($null))
+
+ $CurrentIP = $LowerBoundInt
+ $CurrentIPString = $null
+ $ControlArray = @(0,0,0,0)
+
+ $null = $hostList.Add($iHostPart1)
+
+ while($CurrentIPString -ne $iHostPart2)
+ {
+ for($i=0;$i -lt 4;$i++)
+ {
+
+ if(($CurrentIP[$i] -eq $UpperBoundInt[$i]) -and (($i -eq 0) -or $ControlArray[$i-1] -eq 1))
+ {
+ $ControlArray[$i] = 1
+ continue
+ }
+ else
+ {
+
+ $Max = 254
+ if(($i -ne 0) -and ($ControlArray[$i-1] -eq 1))
+ {
+ $Max = $UpperBoundInt[$i]
+ }
+
+ if(($i -ne 3) -and ($CurrentIP[$i+1] -eq 254))
+ {
+ $CurrentIP[$i]++
+ $CurrentIP[$i+1]=0
+
+ $CurrentIPString = ($CurrentIP[0].ToString() + "." + $CurrentIP[1].ToString() + "." + $CurrentIP[2].ToString() + "." + $CurrentIP[3].ToString())
+ $null = $hostList.Add($CurrentIPString)
+ }
+
+ if(($i -eq 3) -and ($CurrentIP[$i] -lt $Max))
+ {
+ $CurrentIP[$i]++
+
+ $CurrentIPString = ($CurrentIP[0].ToString() + "." + $CurrentIP[1].ToString() + "." + $CurrentIP[2].ToString() + "." + $CurrentIP[3].ToString())
+ $null = $hostList.Add($CurrentIPString)
+ }
+ }
+ }
+ }
+
+ }
else
{
$hostList.Add($iHost)