Add missing DNS Record Type Implementations

Add missing DNS Record Type Implementations based on
https://raw.githubusercontent.com/mmessano/PowerShell/master/dns-dump.ps1
This commit is contained in:
Prashant Mahajan 2017-12-18 17:16:45 +11:00
parent be932ce2be
commit 2ecfb8d029
1 changed files with 72 additions and 10 deletions

View File

@ -3635,8 +3635,30 @@ https://raw.githubusercontent.com/mmessano/PowerShell/master/dns-dump.ps1
} }
elseif ($RDataType -eq 6) { elseif ($RDataType -eq 6) {
# TODO: how to implement properly? nested object? $PrimaryNS = Get-Name $DNSRecord[44..$DNSRecord.length]
$Data = $([System.Convert]::ToBase64String($DNSRecord[24..$DNSRecord.length])) $ResponsibleParty = Get-Name $DNSRecord[$(46+$DNSRecord[44])..$DNSRecord.length]
$SerialRaw = $DNSRecord[24..27]
# reverse for big endian
$Null = [array]::Reverse($SerialRaw)
$Serial = [BitConverter]::ToUInt32($SerialRaw, 0)
$RefreshRaw = $DNSRecord[28..31]
$Null = [array]::Reverse($RefreshRaw)
$Refresh = [BitConverter]::ToUInt32($RefreshRaw, 0)
$RetryRaw = $DNSRecord[32..35]
$Null = [array]::Reverse($RetryRaw)
$Retry = [BitConverter]::ToUInt32($RetryRaw, 0)
$ExpiresRaw = $DNSRecord[36..39]
$Null = [array]::Reverse($ExpiresRaw)
$Expires = [BitConverter]::ToUInt32($ExpiresRaw, 0)
$MinTTLRaw = $DNSRecord[40..43]
$Null = [array]::Reverse($MinTTLRaw)
$MinTTL = [BitConverter]::ToUInt32($MinTTLRaw, 0)
$Data = "[" + $Serial + "][" + $PrimaryNS + "][" + $ResponsibleParty + "][" + $Refresh + "][" + $Retry + "][" + $Expires + "][" + $MinTTL + "]"
$DNSRecordObject | Add-Member Noteproperty 'RecordType' 'SOA' $DNSRecordObject | Add-Member Noteproperty 'RecordType' 'SOA'
} }
@ -3647,14 +3669,31 @@ https://raw.githubusercontent.com/mmessano/PowerShell/master/dns-dump.ps1
} }
elseif ($RDataType -eq 13) { elseif ($RDataType -eq 13) {
# TODO: how to implement properly? nested object? [string]$CPUType = ""
$Data = $([System.Convert]::ToBase64String($DNSRecord[24..$DNSRecord.length])) [string]$OSType = ""
[int]$SegmentLength = $DNSRecord[24]
$Index = 25
while ($SegmentLength-- -gt 0)
{
$CPUType += [char]$DNSRecord[$Index++]
}
$Index = 24 + $DNSRecord[24] + 1
[int]$SegmentLength = $Index++
while ($SegmentLength-- -gt 0)
{
$OSType += [char]$DNSRecord[$Index++]
}
$Data = "[" + $CPUType + "][" + $OSType + "]"
$DNSRecordObject | Add-Member Noteproperty 'RecordType' 'HINFO' $DNSRecordObject | Add-Member Noteproperty 'RecordType' 'HINFO'
} }
elseif ($RDataType -eq 15) { elseif ($RDataType -eq 15) {
# TODO: how to implement properly? nested object? $PriorityRaw = $DNSRecord[24..25]
$Data = $([System.Convert]::ToBase64String($DNSRecord[24..$DNSRecord.length])) # reverse for big endian
$Null = [array]::Reverse($PriorityRaw)
$Priority = [BitConverter]::ToUInt16($PriorityRaw, 0)
$MXHost = Get-Name $DNSRecord[26..$DNSRecord.length]
$Data = "[" + $Priority + "][" + $MXHost + "]"
$DNSRecordObject | Add-Member Noteproperty 'RecordType' 'MX' $DNSRecordObject | Add-Member Noteproperty 'RecordType' 'MX'
} }
@ -3672,14 +3711,37 @@ https://raw.githubusercontent.com/mmessano/PowerShell/master/dns-dump.ps1
} }
elseif ($RDataType -eq 28) { elseif ($RDataType -eq 28) {
# TODO: how to implement properly? nested object? ### yeah, this doesn't do all the fancy formatting that can be done for IPv6
$Data = $([System.Convert]::ToBase64String($DNSRecord[24..$DNSRecord.length])) $AAAA = ""
for ($i = 24; $i -lt 40; $i+=2)
{
$BlockRaw = $DNSRecord[$i..$($i+1)]
# reverse for big endian
$Null = [array]::Reverse($BlockRaw)
$Block = [BitConverter]::ToUInt16($BlockRaw, 0)
$AAAA += ($Block).ToString('x4')
If ($i -ne 38) { $AAAA += ':' }
}
$Data = $AAAA
$DNSRecordObject | Add-Member Noteproperty 'RecordType' 'AAAA' $DNSRecordObject | Add-Member Noteproperty 'RecordType' 'AAAA'
} }
elseif ($RDataType -eq 33) { elseif ($RDataType -eq 33) {
# TODO: how to implement properly? nested object? $PriorityRaw = $DNSRecord[24..25]
$Data = $([System.Convert]::ToBase64String($DNSRecord[24..$DNSRecord.length])) # reverse for big endian
$Null = [array]::Reverse($PriorityRaw)
$Priority = [BitConverter]::ToUInt16($PriorityRaw, 0)
$WeightRaw = $DNSRecord[26..27]
$Null = [array]::Reverse($WeightRaw)
$Weight = [BitConverter]::ToUInt16($WeightRaw, 0)
$PortRaw = $DNSRecord[28..29]
$Null = [array]::Reverse($PortRaw)
$Port = [BitConverter]::ToUInt16($PortRaw, 0)
$SRVHost = Get-Name $DNSRecord[30..$DNSRecord.length]
$Data = "[" + $Priority + "][" + $Weight + "][" + $Port + "][" + $SRVHost + "]"
$DNSRecordObject | Add-Member Noteproperty 'RecordType' 'SRV' $DNSRecordObject | Add-Member Noteproperty 'RecordType' 'SRV'
} }