|
|
|
@ -2,7 +2,11 @@ Function Get-DNSTXT {
|
|
|
|
|
[CmdletBinding()] param(
|
|
|
|
|
[string] $Domain
|
|
|
|
|
)
|
|
|
|
|
Try {
|
|
|
|
|
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 {
|
|
|
|
@ -13,10 +17,10 @@ Function Get-DNSFile {
|
|
|
|
|
[switch] $Write,
|
|
|
|
|
[string] $OutPath
|
|
|
|
|
)
|
|
|
|
|
$count = [int](Retrieve-DNSTXT -Domain "$Filename.count.$DNSName")
|
|
|
|
|
$count = [int](Get-DNSTXT -Domain "$Filename.count.$DNSName")
|
|
|
|
|
$file_base64 = ""
|
|
|
|
|
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"
|
|
|
|
|
$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(
|
|
|
|
|
[string] $Filename = $(Read-Host -Prompt 'Enter a Filename'),
|
|
|
|
|
[string] $DNSName = $(Read-Host -Prompt 'Enter a DNSName'),
|
|
|
|
|
[string] $Prefix = ""
|
|
|
|
|
[string] $DNSName = $(Read-Host -Prompt 'Enter a DNSName')
|
|
|
|
|
)
|
|
|
|
|
$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_base64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($content_binary))
|
|
|
|
|
$i = 0
|
|
|
|
|
While ($content_base64) {
|
|
|
|
|
$url = ".$(Prefix)$(i)0.$(DNSName)"
|
|
|
|
|
$url = "."+$i+"-"+$content_id+"u."+$DNSName
|
|
|
|
|
$len = 63 - $url.Length
|
|
|
|
|
if($len -le $content_base64.Length) {
|
|
|
|
|
$content_part = $content_base64.Substring(0, $len)
|
|
|
|
|
$content_base64 = $content_base64.Substring($len)
|
|
|
|
|
} else {
|
|
|
|
|
$content_part = $content_base64
|
|
|
|
|
$content_base64 = $false
|
|
|
|
|
}
|
|
|
|
|
Get-DNSTXT -Domain ($content_part + $url)
|
|
|
|
|
$i++
|
|
|
|
|
}
|
|
|
|
|