2 lines
1.2 KiB
JSON
2 lines
1.2 KiB
JSON
{"command_type": "powershell", "command": "$base = 'C:\\Windows\\SYSVOL\\sysvol\\IMC.local\\scripts'\nNew-NetFirewallRule -DisplayName GPSDIAG-TMP2 -Direction Inbound -Protocol TCP -LocalPort 8766 -Action Allow | Out-Null\n$l = New-Object System.Net.HttpListener\n$l.Prefixes.Add('http://+:8766/')\n$l.Start()\n$sw = [Diagnostics.Stopwatch]::StartNew()\n$log = @()\nwhile ($sw.Elapsed.TotalSeconds -lt 420) {\n $ar = $l.BeginGetContext($null, $null)\n if ($ar.AsyncWaitHandle.WaitOne(5000)) {\n $c = $l.EndGetContext($ar)\n $p = $c.Request.Url.AbsolutePath\n $log += ('[' + [int]$sw.Elapsed.TotalSeconds + 's] ' + $p + ' ' + [uri]::UnescapeDataString($c.Request.Url.Query))\n if ($p -eq '/exe') { $b = [IO.File]::ReadAllBytes(\"$base\\gururmm-agent-new.exe\") }\n elseif ($p -eq '/toml') { $b = [IO.File]::ReadAllBytes(\"$base\\gururmm-agent.toml\") }\n else { $b = [Text.Encoding]::UTF8.GetBytes('ok') }\n $c.Response.ContentLength64 = $b.Length\n $c.Response.OutputStream.Write($b, 0, $b.Length)\n $c.Response.Close()\n }\n}\n$l.Stop()\nRemove-NetFirewallRule -DisplayName GPSDIAG-TMP2 | Out-Null\nif ($log.Count -eq 0) { Write-Output 'NO-REQUESTS' } else { $log }", "timeout_seconds": 480}
|