diff --git a/TGBeta.ps1 b/TGBeta.ps1 index 942930f..56c382a 100644 --- a/TGBeta.ps1 +++ b/TGBeta.ps1 @@ -1498,54 +1498,59 @@ try { $response.OutputStream.Close() } - switch ($request.Url.AbsolutePath) { - "/offboard/uninstallSVSMSPModule" { - try { - - $responseString = "Uninstalled SVSMSP Module successfully." - $response.StatusCode = 200 - } catch { - $responseString = "Error uninstalling SVSMSP Module: $_" - $response.StatusCode = 500 + while ($listener.IsListening) { + $context = $listener.GetContext() + $request = $context.Request + $response = $context.Response + switch ($request.Url.AbsolutePath) { + "/offboard/uninstallSVSMSPModule" { + try { + + $responseString = "Uninstalled SVSMSP Module successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error uninstalling SVSMSP Module: $_" + $response.StatusCode = 500 + } + } + + "/offboard/uninstallThreatLocker" { + try { + + $responseString = "Uninstalled ThreatLocker successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error uninstalling ThreatLocker: $_" + $response.StatusCode = 500 + } + } + + "/offboard/uninstallCyberQP" { + try { + + $responseString = "Uninstalled CyberQP successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error uninstalling CyberQP: $_" + $response.StatusCode = 500 + } + } + + # Add routes for other tasks here... + + default { + $response.StatusCode = 404 + $responseString = "Task not found." + } } - } - - "/offboard/uninstallThreatLocker" { - try { - - $responseString = "Uninstalled ThreatLocker successfully." - $response.StatusCode = 200 - } catch { - $responseString = "Error uninstalling ThreatLocker: $_" - $response.StatusCode = 500 - } - } - - "/offboard/uninstallCyberQP" { - try { - - $responseString = "Uninstalled CyberQP successfully." - $response.StatusCode = 200 - } catch { - $responseString = "Error uninstalling CyberQP: $_" - $response.StatusCode = 500 - } - } - - # Add routes for other tasks here... - - default { - $response.StatusCode = 404 - $responseString = "Task not found." - } } - # Send the response - $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) - $response.ContentType = "text/plain" - $response.ContentLength64 = $buffer.Length - $response.OutputStream.Write($buffer, 0, $buffer.Length) - $response.OutputStream.Close() - + # Send the response + $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) + $response.ContentType = "text/plain" + $response.ContentLength64 = $buffer.Length + $response.OutputStream.Write($buffer, 0, $buffer.Length) + $response.OutputStream.Close() +