NetSPI / PowerUpSQL

PowerUpSQL: A PowerShell Toolkit for Attacking SQL Server
Other
2.47k stars 462 forks source link

PowerShell v2.0 Compliance Issue - Bitwise Shift Operators #32

Closed cobbr closed 4 years ago

cobbr commented 6 years ago

It seems as if a bitwise shift operator, -shl, is being used in Test-Subnet:

function Test-Subnet ([string]$cidr, [string]$ip)
{
    $network, [int]$subnetlen = $cidr.Split('/')
    $a = [uint32[]]$network.split('.')
    [uint32] $unetwork = ($a[0] -shl 24) + ($a[1] -shl 16) + ($a[2] -shl 8) + $a[3]

    $mask = (-bnot [uint32]0) -shl (32 - $subnetlen)

    $a = [uint32[]]$ip.split('.')
    [uint32] $uip = ($a[0] -shl 24) + ($a[1] -shl 16) + ($a[2] -shl 8) + $a[3]

    $unetwork -eq ($mask -band $uip)
}

This shift operator is PowerShell 3.0+ only. Which breaks PowerUpSQL on PowerShell v2.0 :(

Have a PR coming in shortly that should make this PowerShell v2.0 compliant :)

JCDavie commented 6 years ago

Same issue

nullbind commented 6 years ago

Thanks for letting me know.

nullbind commented 4 years ago

Cobbr submitted the fix and i finally rolled it in. Closing it out.