- File Transfer Status |
- Total Devices: ${totalDevices} |
- Completed: 0
-
`;
- AddConsoleHTML(transferHarness.outerHTML);
- }
- exports.AddTransferHarness = AddTransferHarness;
- function AutoSizeTextArea() {
- UI_js_1.ConsoleTextArea.style.height = "1px";
- UI_js_1.ConsoleTextArea.style.height = Math.max(12, UI_js_1.ConsoleTextArea.scrollHeight) + "px";
- }
- exports.AutoSizeTextArea = AutoSizeTextArea;
- function IncrementMissedMessageCount() {
- if (!UI_js_1.ConsoleTab.classList.contains("active")) {
- var currentCount = Number.parseInt(UI_js_1.ConsoleAlert.innerText);
- if (Number.isNaN(currentCount)) {
- UI_js_1.ConsoleAlert.innerText = "1";
- }
- else {
- UI_js_1.ConsoleAlert.innerText = String(currentCount + 1);
- }
- UI_js_1.ConsoleAlert.hidden = false;
- }
- }
- exports.IncrementMissedMessageCount = IncrementMissedMessageCount;
-});
-define("Shared/Utilities", ["require", "exports"], function (require, exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.RemoveFromArray = exports.FormatScriptOutputArray = exports.FormatScriptOutput = exports.ConvertUInt8ArrayToBase64 = exports.ConvertBase64ToUInt8Array = exports.When = exports.GetDistanceBetween = exports.ParseSearchString = exports.EncodeForHTML = exports.CreateGUID = exports.Split = void 0;
- /**
- * Splits a string into "parts" number of pieces. Once "parts" number is
- * reached, additional occurrences of the splitter are ignored.
- * @param splitter
- * @param parts
- */
- function Split(originalString, splitter, parts) {
- var returnArray = [];
- var remainingString = originalString;
- for (var i = 1; i < parts; i++) {
- if (remainingString.indexOf(splitter) == -1) {
- break;
- }
- returnArray.push(remainingString.slice(0, remainingString.indexOf(splitter)));
- remainingString = remainingString.slice(remainingString.indexOf(splitter) + splitter.length);
- }
- returnArray.push(remainingString);
- return returnArray;
- }
- exports.Split = Split;
- function CreateGUID() {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
- var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- }
- exports.CreateGUID = CreateGUID;
- function EncodeForHTML(text) {
- var tempDiv = document.createElement("div");
- tempDiv.innerText = text;
- return tempDiv.innerHTML;
- }
- exports.EncodeForHTML = EncodeForHTML;
- function ParseSearchString() {
- var queryStrings = {};
- var queryArray = location.search.substring(1).split("&");
- queryArray.forEach(value => {
- var keyValue = value.split("=");
- queryStrings[keyValue[0]] = keyValue[1];
- });
- return queryStrings;
- }
- exports.ParseSearchString = ParseSearchString;
- function GetDistanceBetween(fromX, fromY, toX, toY) {
- return Math.sqrt(Math.pow(fromX - toX, 2) +
- Math.pow(fromY - toY, 2));
- }
- exports.GetDistanceBetween = GetDistanceBetween;
- async function When(predicate, pollingTimeMs = 100) {
- return new Promise((resolve, reject) => {
- function checkCondition() {
- if (predicate()) {
- resolve();
- }
- else {
- window.setTimeout(() => {
- checkCondition();
- }, pollingTimeMs);
- }
- }
- checkCondition();
- });
- }
- exports.When = When;
- function ConvertBase64ToUInt8Array(base64) {
- var binaryString = window.atob(base64);
- var bytes = new Uint8ClampedArray(binaryString.length);
- for (var i = 0; i < binaryString.length; i++) {
- bytes[i] = binaryString.charCodeAt(i);
- }
- return bytes;
- }
- exports.ConvertBase64ToUInt8Array = ConvertBase64ToUInt8Array;
- function ConvertUInt8ArrayToBase64(array) {
- var base64String = '';
- for (var i = 0; i < array.byteLength; i++) {
- base64String += String.fromCharCode(array[i]);
- }
- return btoa(base64String);
- }
- exports.ConvertUInt8ArrayToBase64 = ConvertUInt8ArrayToBase64;
- function FormatScriptOutput(output) {
- return EncodeForHTML(output).replace(/ /g, " ").replace(/\n/g, "
-
Host Output:
${Utilities_js_2.FormatScriptOutput(result.HostOutput)}
-
Debug Output:
${Utilities_js_2.FormatScriptOutputArray(result.DebugOutput)}
-
Verbose Output:
${Utilities_js_2.FormatScriptOutputArray(result.VerboseOutput)}
-
Information Output:
${Utilities_js_2.FormatScriptOutputArray(result.InformationOutput)}
-
Error Output:
${Utilities_js_2.FormatScriptOutputArray(result.ErrorOutput)}
-
`;
- if (result.ErrorOutput.length > 0) {
- var errorSpan = document.getElementById(contextID + "-errors");
- var currentErrors = parseInt(errorSpan.innerText);
- currentErrors += 1;
- errorSpan.innerText = String(currentErrors);
- }
- resultsWrapper.appendChild(resultDiv);
- UI_js_5.ConsoleFrame.scrollTop = UI_js_5.ConsoleFrame.scrollHeight;
- }
- exports.AddPSCoreResultsHarness = AddPSCoreResultsHarness;
- function AddCommandResultsHarness(result) {
- var contextID = "c" + result.CommandResultID;
- var deviceName = DataGrid.DataSource.find(x => x.ID == result.DeviceID).DeviceName;
- var resultsWrapper = document.getElementById(contextID + "-results");
- var totalDevices = parseInt(document.getElementById(contextID + "-totaldevices").innerText);
- var collapseClass = totalDevices > 1 ? "collapse" : "collapse show";
- var resultDiv = document.createElement("div");
- resultDiv.innerHTML = `
-
-
-
Standard Output:
${Utilities_js_2.FormatScriptOutput(result.StandardOutput)}
-
Error Output:
${Utilities_js_2.FormatScriptOutput(result.ErrorOutput)}
-
`;
- if (result.ErrorOutput.length > 0) {
- var errorSpan = document.getElementById(`${contextID}-errors`);
- var currentErrors = parseInt(errorSpan.innerText);
- currentErrors += 1;
- errorSpan.innerText = String(currentErrors);
- }
- resultsWrapper.appendChild(resultDiv);
- UI_js_5.ConsoleFrame.scrollTop = UI_js_5.ConsoleFrame.scrollHeight;
- }
- exports.AddCommandResultsHarness = AddCommandResultsHarness;
- function UpdateResultsCount(commandResultID) {
- var contextID = "c" + commandResultID;
- var totalDevices = parseInt(document.getElementById(`${contextID}-totaldevices`).innerText);
- var percentComplete = Math.round(document.getElementById(`${contextID}-results`).children.length / totalDevices * 100);
- document.getElementById(`${contextID}-completed`).innerText = String(percentComplete) + "%";
- }
- exports.UpdateResultsCount = UpdateResultsCount;
-});
-define("Shared/Models/UserOptions", ["require", "exports"], function (require, exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
-});
-define("Main/HubConnection", ["require", "exports", "Main/DataGrid", "Main/ResultsParser", "Main/App", "Main/Console", "Main/Chat", "Shared/UI"], function (require, exports, DataGrid, ResultsParser_js_1, App_js_1, Console_js_2, Chat_js_2, UI_js_6) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Connect = exports.Connected = exports.ServiceID = exports.Connection = void 0;
- function Connect() {
- var signalR = window["signalR"];
- exports.Connection = new signalR.HubConnectionBuilder()
- .withUrl("/BrowserHub")
- .configureLogging(signalR.LogLevel.Information)
- .build();
- applyMessageHandlers(exports.Connection);
- exports.Connection.start().catch(err => {
- console.error(err.toString());
- exports.Connected = false;
- Console_js_2.AddConsoleOutput("Your connection was lost. Refresh the page or enter a command to reconnect.");
- }).then(() => {
- exports.Connected = true;
- });
- this.Connection.closedCallbacks.push((ev) => {
- exports.Connected = false;
- UI_js_6.ShowModal("Connection Failure", "Your connection was lost. Click Reconnect to start a new session.", `
-
- Summary:
- ${Utilities_js_3.EncodeForHTML(this.Summary)}
-
-
- Syntax:
- ${Utilities_js_3.EncodeForHTML(this.Syntax).trim()}
-
`;
- if (this.Parameters.length > 0) {
- partialHelp += "
";
- partialHelp += `
Parameters:
`;
- for (var i = 0; i < this.Parameters.length; i++) {
- var paramText = "";
- if (this.Parameters[i].ParameterType) {
- paramText = ` [${Utilities_js_3.EncodeForHTML(this.Parameters[i].ParameterType)}]`;
- }
- partialHelp += `
-${Utilities_js_3.EncodeForHTML(this.Parameters[i].Name)}${Utilities_js_3.EncodeForHTML(paramText)}: ${Utilities_js_3.EncodeForHTML(this.Parameters[i].Summary).trim()}
`;
- }
- partialHelp += "
";
- }
- partialHelp += "
";
- return partialHelp;
- }
- Execute(parameters) {
- var paramDictionary = {};
- parameters.forEach(x => {
- paramDictionary[x.Name.toLowerCase()] = x.Value;
- });
- this.Callback(parameters, paramDictionary);
- }
- }
- exports.ConsoleCommand = ConsoleCommand;
-});
-define("Main/Commands/WebCommands", ["require", "exports", "Shared/Models/ConsoleCommand", "Shared/Models/Parameter", "Main/UI", "Main/HubConnection", "Main/App", "Main/DataGrid", "Main/Console", "Main/DataGrid"], function (require, exports, ConsoleCommand_js_1, Parameter_js_1, UI, HubConnection, App_js_2, DataGrid, Console_js_3, DataGrid_js_2) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.WebCommands = void 0;
- var commands = [
- new ConsoleCommand_js_1.ConsoleCommand("Chat", [
- new Parameter_js_1.Parameter("message", "The message to send to the remote device.", "String")
- ], "Start a chat session with the selected device.", "chat -message Hey, this is your IT guy.", "", (parameters, paramaterDict) => {
- var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices();
- if (selectedDevices.length == 0) {
- Console_js_3.AddConsoleOutput("You must select a device first.");
- return;
- }
- HubConnection.Connection.invoke("Chat", paramaterDict["message"], selectedDevices.map(x => x.ID));
- }),
- new ConsoleCommand_js_1.ConsoleCommand("DeployScript", [
- new Parameter_js_1.Parameter("pscore", "Indicates that script should be run with PowerShell Core.", "Switch"),
- new Parameter_js_1.Parameter("winps", "Indicates that script should be run with Windows PowerShell.", "Switch"),
- new Parameter_js_1.Parameter("cmd", "Indicates that script should be run with Windows CMD.", "Switch"),
- new Parameter_js_1.Parameter("bash", "Indicates that script should be run with Bash.", "Switch")
- ], "Deploy and run a script on the selected device(s). Note: Only one switch argument can be used.", "deployscript -pscore", "", (parameters, parameterDict) => {
- if (parameters.length != 1) {
- Console_js_3.AddConsoleOutput("There should be exactly 1 argument to indicate the script type.");
- return;
- }
- var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices();
- if (selectedDevices.length == 0) {
- Console_js_3.AddConsoleOutput("No devices are selected.");
- return;
- }
- var fileInput = document.createElement("input");
- fileInput.type = "file";
- fileInput.hidden = true;
- document.body.appendChild(fileInput);
- fileInput.onchange = () => {
- uploadFiles(fileInput.files).then(value => {
- HubConnection.Connection.invoke("DeployScript", value[0], parameters[0].Name, selectedDevices.map(x => x.ID));
- fileInput.remove();
- });
- };
- fileInput.click();
- }),
- new ConsoleCommand_js_1.ConsoleCommand("DownloadFile", [
- new Parameter_js_1.Parameter("path", "The path on the remote computer of the file to download.", "String"),
- ], "Download a file from the remote computer.", `DownloadFile -path "C:\Users\Me\Pictures\ThatFunnyPic.png"`, "", (parameters, paramDictionary) => {
- var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices();
- if (selectedDevices.length == 0) {
- Console_js_3.AddConsoleOutput("No devices are selected.");
- return;
- }
- ;
- HubConnection.Connection.invoke("DownloadFile", paramDictionary["path"], selectedDevices[0].ID);
- }),
- new ConsoleCommand_js_1.ConsoleCommand("GetLogs", [], "Retrieve the logs from the remote agent.", "GetLogs", "", (parameters, paramDictionary) => {
- var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices();
- if (selectedDevices.length == 0) {
- Console_js_3.AddConsoleOutput("No devices are selected.");
- return;
- }
- ;
- HubConnection.Connection.invoke("ExecuteCommandOnClient", "PSCore", 'Get-Content -Path "$([System.IO.Path]::GetTempPath())\\Remotely_Logs.log"', selectedDevices.map(x => x.ID));
- }),
- new ConsoleCommand_js_1.ConsoleCommand("GetVersion", [], "Display the remote agent's version.", "GetVersion", "", (parameters, paramDictionary) => {
- var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices();
- if (selectedDevices.length == 0) {
- Console_js_3.AddConsoleOutput("No devices are selected.");
- return;
- }
- ;
- var output = `