diff --git a/.gitignore b/.gitignore index 99bfb3d4..7b54b897 100644 --- a/.gitignore +++ b/.gitignore @@ -281,3 +281,5 @@ Server/wwwroot/Downloads/Win-x86/Remotely_Desktop.exe /Desktop.Win.Wrapper/Remotely_Desktop.zip /Server/Remotely.db-wal /Server/Remotely.db-shm +/Server/wwwroot/out.js +/Server/wwwroot/out.js.map diff --git a/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml b/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml index 1f82a5af..d6036950 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml +++ b/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml @@ -92,7 +92,15 @@ - } diff --git a/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml b/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml index b690371f..02ec562e 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml +++ b/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml @@ -223,7 +223,15 @@ } - } diff --git a/Server/Areas/Identity/Pages/Account/Manage/ServerConfig.cshtml b/Server/Areas/Identity/Pages/Account/Manage/ServerConfig.cshtml index e0b54ac8..5a343396 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/ServerConfig.cshtml +++ b/Server/Areas/Identity/Pages/Account/Manage/ServerConfig.cshtml @@ -263,13 +263,21 @@ - + } diff --git a/Server/Pages/RemoteControl.cshtml b/Server/Pages/RemoteControl.cshtml index 5ef6a315..ea14e14a 100644 --- a/Server/Pages/RemoteControl.cshtml +++ b/Server/Pages/RemoteControl.cshtml @@ -260,16 +260,16 @@

© @DateTimeOffset.Now.Year - Translucency Software

- - + diff --git a/Server/Pages/Shared/_Layout.cshtml b/Server/Pages/Shared/_Layout.cshtml index bfaaa451..d47e17be 100644 --- a/Server/Pages/Shared/_Layout.cshtml +++ b/Server/Pages/Shared/_Layout.cshtml @@ -24,7 +24,7 @@ @if (user is RemotelyUser) { - + switch (user.UserOptions.Theme) { case Remotely.Shared.Enums.Theme.Light: @@ -70,6 +70,9 @@ + + +
diff --git a/Server/Pages/_IndexLoggedIn.cshtml b/Server/Pages/_IndexLoggedIn.cshtml index 680f54e7..05afc381 100644 --- a/Server/Pages/_IndexLoggedIn.cshtml +++ b/Server/Pages/_IndexLoggedIn.cshtml @@ -71,20 +71,15 @@ - - \ No newline at end of file diff --git a/Server/Pages/_IndexNotLoggedIn.cshtml b/Server/Pages/_IndexNotLoggedIn.cshtml index 23c5ac7e..9e1758e8 100644 --- a/Server/Pages/_IndexNotLoggedIn.cshtml +++ b/Server/Pages/_IndexNotLoggedIn.cshtml @@ -27,4 +27,14 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Server/Server.csproj b/Server/Server.csproj index 7cae564a..2be03471 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -39,6 +39,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Server/appsettings.json b/Server/appsettings.json index 9943db0e..27a143e6 100644 --- a/Server/appsettings.json +++ b/Server/appsettings.json @@ -31,7 +31,7 @@ "MaxConcurrentUpdates": 10, "MaxOrganizationCount": 1, "RedirectToHttps": false, - "RemoteControlNotifyUser": true, + "RemoteControlNotifyUser": true, "RemoteControlSessionLimit": 3, "RemoteControlRequiresAuthentication": true, "Require2FA": false, diff --git a/Server/package.json b/Server/package.json index bbdcf402..f026c7fc 100644 --- a/Server/package.json +++ b/Server/package.json @@ -3,14 +3,14 @@ "name": "asp.net", "private": true, "devDependencies": { - "@microsoft/signalr": "^3.1.5", - "@microsoft/signalr-protocol-msgpack": "^3.1.5", "@types/bootstrap": "^4.5.0", - "@types/jquery": "^3.5.1", - "msgpack5": "^4.2.1", - "typescript": "^4.0.3" + "@types/jquery": "^3.5.1" }, "dependencies": { + "@microsoft/signalr": "^3.1.5", + "@microsoft/signalr-protocol-msgpack": "^3.1.5", + "msgpack5": "^4.2.1", + "typescript": "^4.0.3", "@msgpack/msgpack": "^1.12.2", "jquery": "^3.5.1" } diff --git a/Server/wwwroot/outMain.js b/Server/wwwroot/outMain.js deleted file mode 100644 index d4901d84..00000000 --- a/Server/wwwroot/outMain.js +++ /dev/null @@ -1,19029 +0,0 @@ -define("Main/UI", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.TotalPagesSpan = exports.TotalDevicesCount = exports.ToastsWrapper = exports.TabContentWrapper = exports.RightPaginationButton = exports.OnlineDevicesCount = exports.MeasurementContext = exports.MeasurementCanvas = exports.LeftPaginationButton = exports.HideOfflineDevicesCheckbox = exports.GridFilter = exports.DevicesSelectedCount = exports.DeviceGroupSelect = exports.DeviceGridBody = exports.DeviceGrid = exports.CurrentPageInput = exports.ConsoleTextArea = exports.ConsoleTab = exports.ConsoleOutputDiv = exports.ConsoleFrame = exports.ConsoleAlert = exports.CommandModeSelect = exports.CommandInfoDiv = exports.CommandCompletionDiv = exports.CloseAlertsButton = exports.AlertsFrame = exports.AlertsCount = exports.AlertsButton = void 0; - exports.AlertsButton = document.getElementById("alertsButton"); - exports.AlertsCount = document.getElementById("alertsCount"); - exports.AlertsFrame = document.getElementById("alertsFrame"); - exports.CloseAlertsButton = document.getElementById("closeAlertsFrameButton"); - exports.CommandCompletionDiv = document.querySelector("#commandCompletionDiv"); - exports.CommandInfoDiv = document.querySelector("#commandInfoDiv"); - exports.CommandModeSelect = document.querySelector("#commandModeSelect"); - exports.ConsoleAlert = document.getElementById("consoleAlert"); - exports.ConsoleFrame = document.getElementById("consoleFrame"); - exports.ConsoleOutputDiv = document.querySelector("#consoleOutputDiv"); - exports.ConsoleTab = document.getElementById("consoleTab"); - exports.ConsoleTextArea = document.querySelector("#consoleTextArea"); - exports.CurrentPageInput = document.querySelector("#currentPageInput"); - exports.DeviceGrid = document.querySelector("#deviceGrid"); - exports.DeviceGridBody = document.querySelector("#deviceGrid tbody"); - exports.DeviceGroupSelect = document.getElementById("deviceGroupSelect"); - exports.DevicesSelectedCount = document.querySelector("#devicesSelectedSpan"); - exports.GridFilter = document.getElementById("gridFilter"); - exports.HideOfflineDevicesCheckbox = document.querySelector("#hideOfflineDevicesCheckbox"); - exports.LeftPaginationButton = document.querySelector("#leftPaginationButton"); - exports.MeasurementCanvas = document.createElement("canvas"); - exports.MeasurementContext = exports.MeasurementCanvas.getContext("2d"); - exports.OnlineDevicesCount = document.querySelector("#onlineDevicesSpan"); - exports.RightPaginationButton = document.querySelector("#rightPaginationButton"); - exports.TabContentWrapper = document.getElementById("tabContentWrapper"); - exports.ToastsWrapper = document.getElementById("toastsWrapper"); - exports.TotalDevicesCount = document.querySelector("#totalDevicesSpan"); - exports.TotalPagesSpan = document.querySelector("#totalPagesSpan"); -}); -define("Main/UserSettings", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.UserSettings = void 0; - exports.UserSettings = { - PromptString: "~>", - CommandModeShortcuts: { - "Web": "/web", - "PSCore": "/pscore", - "WinPS": "/winps", - "CMD": "/cmd", - "Bash": "/bash" - } - }; -}); -define("Main/Console", ["require", "exports", "Main/UserSettings", "Main/UI"], function (require, exports, UserSettings_js_1, UI_js_1) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.IncrementMissedMessageCount = exports.AutoSizeTextArea = exports.AddTransferHarness = exports.AddConsoleHTML = exports.AddConsoleOutput = void 0; - function AddConsoleOutput(strOutputMessage) { - var outputBlock = document.createElement("div"); - outputBlock.classList.add("console-block"); - var prompt = document.createElement("div"); - prompt.classList.add("console-prompt"); - prompt.innerHTML = UserSettings_js_1.UserSettings.PromptString; - var output = document.createElement("div"); - output.classList.add("console-output"); - output.innerHTML = strOutputMessage; - outputBlock.appendChild(prompt); - outputBlock.appendChild(output); - UI_js_1.ConsoleOutputDiv.appendChild(outputBlock); - UI_js_1.ConsoleFrame.scrollTop = UI_js_1.ConsoleFrame.scrollHeight; - IncrementMissedMessageCount(); - } - exports.AddConsoleOutput = AddConsoleOutput; - function AddConsoleHTML(html) { - var contentWrapper = document.createElement("div"); - contentWrapper.innerHTML = html; - UI_js_1.ConsoleOutputDiv.appendChild(contentWrapper); - UI_js_1.ConsoleFrame.scrollTop = UI_js_1.ConsoleFrame.scrollHeight; - IncrementMissedMessageCount(); - } - exports.AddConsoleHTML = AddConsoleHTML; - function AddTransferHarness(transferID, totalDevices) { - var transferHarness = document.createElement("div"); - transferHarness.id = transferID; - transferHarness.classList.add("command-harness"); - transferHarness.innerHTML = ` -
- 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, "
"); - } - exports.FormatScriptOutput = FormatScriptOutput; - function FormatScriptOutputArray(output) { - return output.map(x => EncodeForHTML(x)).join("
"); - } - exports.FormatScriptOutputArray = FormatScriptOutputArray; - function RemoveFromArray(array, item) { - var index = array.indexOf(item); - if (index > -1) { - array.splice(index, 1); - } - } - exports.RemoveFromArray = RemoveFromArray; - ; -}); -define("Shared/UI", ["require", "exports", "Shared/Utilities"], function (require, exports, Utilities_js_1) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ValidateInput = exports.ShowModal = exports.ShowMessage = exports.ToastsWrapper = void 0; - exports.ToastsWrapper = document.getElementById("toastsWrapper"); - function ShowMessage(message) { - var messageDiv = document.createElement("div"); - messageDiv.classList.add("toast-message"); - messageDiv.innerHTML = message; - exports.ToastsWrapper.appendChild(messageDiv); - window.setTimeout(() => { - messageDiv.remove(); - }, 5000); - } - exports.ShowMessage = ShowMessage; - function ShowModal(title, modalBodyHtml, buttonsHTML = "", onDismissCallback = null) { - var modalID = Utilities_js_1.CreateGUID(); - var modalHTML = ``; - var wrapperDiv = document.createElement("div"); - wrapperDiv.innerHTML = modalHTML; - document.body.appendChild(wrapperDiv); - $("#" + modalID).on("hidden.bs.modal", ev => { - try { - if (onDismissCallback) { - onDismissCallback(); - } - } - finally { - ev.currentTarget.parentElement.remove(); - } - }); - $("#" + modalID)["modal"]("show"); - return wrapperDiv; - } - exports.ShowModal = ShowModal; - function ValidateInput(inputElement) { - if (!inputElement.checkValidity()) { - $(inputElement)["tooltip"]({ - template: '', - title: inputElement.validationMessage - }); - $(inputElement)["tooltip"]("show"); - return false; - } - else { - return true; - } - } - exports.ValidateInput = ValidateInput; -}); -define("Main/Chat", ["require", "exports", "Main/HubConnection", "Main/DataGrid", "Shared/UI"], function (require, exports, HubConnection, DataGrid_js_1, UI_js_2) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ReceiveChatText = exports.CreateChatWindow = void 0; - function CreateChatWindow(deviceID, deviceName) { - var chatWindow = document.getElementById("chat-" + deviceID); - if (!chatWindow) { - var windowHtml = ` -
-
Chat with ${deviceName}
-
- -
-
-
-
- - `; - chatWindow = document.createElement("div"); - chatWindow.classList.add("chat-window"); - chatWindow.style.right = "20px"; - chatWindow.style.bottom = "20px"; - chatWindow.setAttribute("id", "chat-" + deviceID); - chatWindow.innerHTML = windowHtml; - document.body.appendChild(chatWindow); - chatWindow.addEventListener("mousedown", (ev) => { - document.querySelectorAll(".chat-window").forEach(x => { - x.style.zIndex = "0"; - }); - ev.currentTarget.style.zIndex = "1"; - }); - chatWindow.querySelector(".close-button").onclick = (ev) => { - ev.preventDefault(); - ev.stopPropagation(); - document.body.removeChild(chatWindow); - }; - chatWindow.querySelector(".chat-header").onmousedown = (ev) => { - ev.preventDefault(); - chatWindow.removeEventListener("mousemove", moveChatWindow); - chatWindow.removeEventListener("mouseup", stopMovingChatWindow); - chatWindow.removeEventListener("mouseleave", stopMovingChatWindow); - chatWindow.addEventListener("mousemove", moveChatWindow); - chatWindow.addEventListener("mouseup", stopMovingChatWindow); - chatWindow.addEventListener("mouseleave", stopMovingChatWindow); - }; - chatWindow.querySelector(".chat-input").onkeypress = (ev) => { - if (ev.key.toLowerCase() == "enter") { - ev.preventDefault(); - ev.stopPropagation(); - if (!DataGrid_js_1.DataSource.find(x => x.ID == deviceID).IsOnline) { - UI_js_2.ShowMessage("Device is offline."); - return; - } - var inputText = ev.currentTarget.value; - if (!inputText) { - return; - } - chatWindow.querySelector(".chat-messages").innerHTML += ` -
- You: - ${inputText} -
- `; - ev.currentTarget.value = ""; - HubConnection.Connection.invoke("Chat", inputText, [deviceID]); - var chatMessages = chatWindow.querySelector(".chat-messages"); - chatMessages.scrollTo({ top: chatMessages.scrollHeight }); - } - }; - } - } - exports.CreateChatWindow = CreateChatWindow; - function ReceiveChatText(deviceID, deviceName, message, disconnected) { - CreateChatWindow(deviceID, deviceName); - var chatWindow = document.getElementById("chat-" + deviceID); - var chatMessages = chatWindow.querySelector(".chat-messages"); - if (disconnected) { - chatMessages.innerHTML += ` -
- ${deviceName} disconnected from chat. - ${message} -
- `; - } - else { - chatMessages.innerHTML += ` -
- ${deviceName}: - ${message} -
- `; - } - chatMessages.scrollTo({ top: chatMessages.scrollHeight }); - } - exports.ReceiveChatText = ReceiveChatText; - function moveChatWindow(ev) { - var chatWindow = ev.currentTarget; - chatWindow.style.right = String(parseInt(chatWindow.style.right || "0") - ev.movementX) + "px"; - chatWindow.style.bottom = String(parseInt(chatWindow.style.bottom || "0") - ev.movementY) + "px"; - } - function stopMovingChatWindow(ev) { - ev.currentTarget.removeEventListener("mousemove", moveChatWindow); - ev.currentTarget.removeEventListener("mouseup", stopMovingChatWindow); - ev.currentTarget.removeEventListener("mouseleave", stopMovingChatWindow); - } -}); -define("Shared/Models/Device", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); -}); -define("Main/DataGrid", ["require", "exports", "Main/UI", "Main/Console", "Main/Chat", "Main/HubConnection", "Shared/UI"], function (require, exports, UI_js_3, Console_js_1, Chat_js_1, HubConnection, UI_js_4) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.UpdateDeviceCounts = exports.ToggleSelectAll = exports.RefreshGrid = exports.PageUp = exports.PageDown = exports.GoToCurrentPage = exports.GetSelectedDevices = exports.RenderDeviceRows = exports.ApplyFilterToDevice = exports.ApplyFilterToAll = exports.AddOrUpdateDevice = exports.AddOrUpdateDevices = exports.GridState = exports.FilteredDevices = exports.DataSource = void 0; - exports.DataSource = new Array(); - exports.FilteredDevices = new Array(); - exports.GridState = new class { - constructor() { - this.GroupFilter = ""; - this.HideOffline = true; - this.SearchFilter = ""; - this.ShowAllGroups = true; - this.CurrentPage = 1; - this.TotalPages = 1; - this.RowsPerPage = 100; - } - }; - function AddOrUpdateDevices(devices) { - exports.DataSource.splice(0); - exports.FilteredDevices.splice(0); - exports.GridState.CurrentPage = 1; - devices.sort((a, b) => { - //if (a.IsOnline && !b.IsOnline) { - // return -1; - //} - //else if (b.IsOnline && !a.IsOnline) { - // return 1; - //} - return a.DeviceName.localeCompare(b.DeviceName, [], { sensitivity: "base" }); - }); - devices.forEach(x => { - AddOrUpdateDevice(x, false); - }); - UpdateDeviceCounts(); - RenderDeviceRows(); - } - exports.AddOrUpdateDevices = AddOrUpdateDevices; - function AddOrUpdateDevice(device, rerenderGrid) { - var existingIndex = exports.DataSource.findIndex(x => x.ID == device.ID); - if (existingIndex > -1) { - exports.DataSource[existingIndex] = device; - } - else { - exports.DataSource.push(device); - } - ApplyFilterToDevice(device); - if (rerenderGrid) { - UpdateDeviceCounts(); - RenderDeviceRows(); - } - } - exports.AddOrUpdateDevice = AddOrUpdateDevice; - function ApplyFilterToAll() { - exports.FilteredDevices.splice(0); - exports.GridState.CurrentPage = 1; - for (var i = 0; i < exports.DataSource.length; i++) { - ApplyFilterToDevice(exports.DataSource[i]); - } - UpdateDeviceCounts(); - RenderDeviceRows(); - } - exports.ApplyFilterToAll = ApplyFilterToAll; - function ApplyFilterToDevice(device) { - if (exports.GridState.HideOffline && !device.IsOnline) { - return; - } - if (!exports.GridState.ShowAllGroups && - (device.DeviceGroupID || "") != (exports.GridState.GroupFilter || "")) { - return; - } - if (deviceMatchesSearchFilter(device)) { - var existingIndex = exports.FilteredDevices.findIndex(x => x.ID == device.ID); - if (existingIndex > -1) { - exports.FilteredDevices[existingIndex] = device; - } - else { - exports.FilteredDevices.push(device); - } - return; - } - } - exports.ApplyFilterToDevice = ApplyFilterToDevice; - function RenderDeviceRows() { - UI_js_3.DeviceGridBody.innerHTML = ""; - var startCurrentDevices = (exports.GridState.CurrentPage - 1) * exports.GridState.RowsPerPage; - var endCurrentDevices = startCurrentDevices + exports.GridState.RowsPerPage; - var currentPageDevices = exports.FilteredDevices.slice(startCurrentDevices, endCurrentDevices); - for (var i = 0; i < currentPageDevices.length; i++) { - let device = currentPageDevices[i]; - let recordRow = document.getElementById(device.ID); - if (recordRow == null) { - recordRow = document.createElement("tr"); - recordRow.classList.add("record-row"); - recordRow.id = device.ID; - UI_js_3.DeviceGridBody.appendChild(recordRow); - recordRow.addEventListener("click", (e) => { - if (!e.ctrlKey && !e.shiftKey) { - var selectedID = e.currentTarget.id; - UI_js_3.DeviceGrid.querySelectorAll(`.record-row.row-selected:not([id='${selectedID}'])`).forEach(elem => { - elem.classList.remove("row-selected"); - }); - } - e.currentTarget.classList.toggle("row-selected"); - UpdateDeviceCounts(); - }); - } - recordRow.innerHTML = ` - - ${device.IsOnline ? - "" : - ""} - - ${device.DeviceName} - ${device.Alias || ""} - ${device.CurrentUser} - ${new Date(device.LastOnline).toLocaleString()} - ${device.PublicIP} - ${device.Platform} - ${device.OSDescription} - ${Math.round(device.CpuUtilization * 100)}% - ${Math.round(device.UsedStorage / device.TotalStorage * 100)}% - ${device.TotalStorage.toLocaleString()} - ${Math.round(device.UsedMemory / device.TotalMemory * 100)}% - ${device.TotalMemory.toLocaleString()} - - - - - `; - recordRow.querySelector(".device-edit-button").onclick = (ev) => { - ev.preventDefault(); - ev.stopPropagation(); - window.open(`${location.origin}/EditDevice?deviceID=${device.ID}`, "_blank"); - }; - recordRow.querySelector(".device-chat-button").onclick = (ev) => { - ev.preventDefault(); - ev.stopPropagation(); - Chat_js_1.CreateChatWindow(device.ID, device.DeviceName); - }; - recordRow.querySelector(".device-remotecontrol-button").onclick = (ev) => { - ev.preventDefault(); - ev.stopPropagation(); - Console_js_1.AddConsoleOutput("Launching remote control on client device..."); - HubConnection.Connection.invoke("RemoteControl", device.ID); - }; - } - } - exports.RenderDeviceRows = RenderDeviceRows; - function GetSelectedDevices() { - var devices = new Array(); - UI_js_3.DeviceGrid.querySelectorAll(".row-selected").forEach(row => { - devices.push(exports.DataSource.find(x => x.ID == row.id)); - }); - return devices; - } - exports.GetSelectedDevices = GetSelectedDevices; - ; - function GoToCurrentPage() { - var newPage = Number(UI_js_3.CurrentPageInput.value); - if (Number.isInteger(newPage) && - newPage > 0 && - newPage < exports.GridState.TotalPages) { - exports.GridState.CurrentPage = newPage; - UpdateDeviceCounts(); - RenderDeviceRows(); - } - else { - UI_js_3.CurrentPageInput.value = String(exports.GridState.CurrentPage); - } - } - exports.GoToCurrentPage = GoToCurrentPage; - function PageDown() { - if (exports.GridState.CurrentPage > 1) { - exports.GridState.CurrentPage--; - UpdateDeviceCounts(); - RenderDeviceRows(); - } - } - exports.PageDown = PageDown; - function PageUp() { - if (exports.GridState.CurrentPage < exports.GridState.TotalPages) { - exports.GridState.CurrentPage++; - UpdateDeviceCounts(); - RenderDeviceRows(); - } - } - exports.PageUp = PageUp; - function RefreshGrid() { - exports.DataSource.splice(0); - UI_js_3.DeviceGridBody.innerHTML = ""; - UpdateDeviceCounts(); - var xhr = new XMLHttpRequest(); - xhr.open("get", "/API/Devices"); - xhr.onerror = () => { - UI_js_4.ShowModal("Request Failure", "Failed to retrieve device data. Please refresh your connection or contact support."); - }; - xhr.onload = () => { - if (xhr.status == 200) { - var devices = JSON.parse(xhr.responseText); - if (devices.length == 0) { - Console_js_1.AddConsoleOutput("It looks like you don't have the Remotely service installed on any devices. You can get the install script from the Client Downloads page."); - } - else { - AddOrUpdateDevices(devices); - } - } - else { - UI_js_4.ShowModal("Request Failure", "Failed to retrieve device data. Please refresh your connection or contact support."); - } - }; - xhr.send(); - } - exports.RefreshGrid = RefreshGrid; - function ToggleSelectAll() { - var hiddenRows = UI_js_3.DeviceGrid.querySelectorAll(".row-selected.hidden.row-selected"); - hiddenRows.forEach(x => { - x.classList.remove("row-selected"); - }); - var currentlySelected = UI_js_3.DeviceGrid.querySelectorAll(".row-selected:not(.hidden)"); - if (currentlySelected.length > 0) { - currentlySelected.forEach(elem => { - elem.classList.remove("row-selected"); - }); - } - else { - UI_js_3.DeviceGrid.querySelectorAll(".record-row:not(.hidden)").forEach(elem => { - elem.classList.add("row-selected"); - }); - } - UpdateDeviceCounts(); - } - exports.ToggleSelectAll = ToggleSelectAll; - function UpdateDeviceCounts() { - exports.GridState.TotalPages = Math.ceil(exports.FilteredDevices.length / exports.GridState.RowsPerPage); - UI_js_3.TotalPagesSpan.innerHTML = String(exports.GridState.TotalPages); - UI_js_3.CurrentPageInput.value = String(exports.GridState.CurrentPage); - UI_js_3.DevicesSelectedCount.innerText = UI_js_3.DeviceGrid.querySelectorAll(".row-selected").length.toString(); - UI_js_3.OnlineDevicesCount.innerText = exports.FilteredDevices.filter(x => x.IsOnline).length.toString(); - UI_js_3.TotalDevicesCount.innerText = exports.FilteredDevices.length.toString(); - if (exports.FilteredDevices.some(x => !x.IsOnline && - document.getElementById(x.ID) && - document.getElementById(x.ID).classList.contains("row-selected"))) { - Console_js_1.AddConsoleOutput(`Your selection contains offline computers. Your commands will only be sent to those that are online.`); - } - } - exports.UpdateDeviceCounts = UpdateDeviceCounts; - function deviceMatchesSearchFilter(device) { - if (!exports.GridState.SearchFilter) { - return true; - } - for (var key in device) { - var value = device[key]; - if (!value) { - continue; - } - if (value.toString().toLowerCase().includes(exports.GridState.SearchFilter.toLowerCase())) { - return true; - } - } - return false; - } -}); -define("Shared/Models/PSCoreCommandResult", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); -}); -define("Shared/Models/GenericCommandResult", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); -}); -define("Shared/Models/CommandResult", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); -}); -define("Main/ResultsParser", ["require", "exports", "Main/DataGrid", "Main/UI", "Shared/Utilities"], function (require, exports, DataGrid, UI_js_5, Utilities_js_2) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.UpdateResultsCount = exports.AddCommandResultsHarness = exports.AddPSCoreResultsHarness = exports.CreateCommandHarness = void 0; - function CreateCommandHarness(result) { - var collapseClass = result.TargetDeviceIDs.length > 1 ? "collapse" : "collapse show"; - var commandHarness = document.createElement("div"); - var contextID = "c" + result.ID; - commandHarness.id = contextID; - commandHarness.classList.add("command-harness"); - commandHarness.innerHTML = ` -
- Command Type: ${result.CommandMode} | - Total Devices: ${result.TargetDeviceIDs.length} | - Completed: 0% | - Errors: 0 | - - JSON - XML -
-
-
`; - return commandHarness; - } - exports.CreateCommandHarness = CreateCommandHarness; - function AddPSCoreResultsHarness(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 = ` -
- Device: ${deviceName} | - Had Errors: ${result.ErrorOutput.length > 1 ? "Yes" : "No"} | - -
-
-
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 = ` -
- Device: ${deviceName} | - Had Errors: ${result.ErrorOutput.length > 1 ? "Yes" : "No"} | - -
-
-
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.", ``); - Console_js_2.AddConsoleOutput("Connection lost."); - }); - } - exports.Connect = Connect; - ; - function applyMessageHandlers(hubConnection) { - hubConnection.on("Chat", (deviceID, deviceName, message, disconnected) => { - if (disconnected) { - Console_js_2.AddConsoleHTML(`${deviceName} disconnected from chat.`); - } - else if (message) { - Console_js_2.AddConsoleHTML(`Chat from ${deviceName}: ${message}`); - } - Chat_js_2.ReceiveChatText(deviceID, deviceName, message, disconnected); - }); - hubConnection.on("UserOptions", (options) => { - App_js_1.MainApp.UserSettings.CommandModeShortcuts.Web = options.CommandModeShortcutWeb; - App_js_1.MainApp.UserSettings.CommandModeShortcuts.PSCore = options.CommandModeShortcutPSCore; - App_js_1.MainApp.UserSettings.CommandModeShortcuts.WinPS = options.CommandModeShortcutWinPS; - App_js_1.MainApp.UserSettings.CommandModeShortcuts.Bash = options.CommandModeShortcutBash; - App_js_1.MainApp.UserSettings.CommandModeShortcuts.CMD = options.CommandModeShortcutCMD; - Console_js_2.AddConsoleOutput("Console connected."); - DataGrid.RefreshGrid(); - }); - hubConnection.on("LockedOut", (args) => { - location.assign("/Identity/Account/Lockout"); - }); - hubConnection.on("DeviceCameOnline", (device) => { - DataGrid.AddOrUpdateDevice(device, true); - }); - hubConnection.on("DeviceWentOffline", (device) => { - DataGrid.AddOrUpdateDevice(device, true); - }); - hubConnection.on("DeviceHeartbeat", (device) => { - DataGrid.AddOrUpdateDevice(device, true); - }); - hubConnection.on("RefreshDeviceList", () => { - DataGrid.RefreshGrid(); - }); - hubConnection.on("PSCoreResult", (result) => { - ResultsParser_js_1.AddPSCoreResultsHarness(result); - ResultsParser_js_1.UpdateResultsCount(result.CommandResultID); - }); - hubConnection.on("CommandResult", (result) => { - ResultsParser_js_1.AddCommandResultsHarness(result); - ResultsParser_js_1.UpdateResultsCount(result.CommandResultID); - }); - hubConnection.on("DisplayMessage", (consoleMessage, popupMessage) => { - if (consoleMessage) { - Console_js_2.AddConsoleOutput(consoleMessage); - } - if (popupMessage) { - UI_js_6.ShowMessage(popupMessage); - } - }); - hubConnection.on("DisplayConsoleHTML", (message) => { - Console_js_2.AddConsoleHTML(message); - }); - hubConnection.on("DownloadFile", (fileID) => { - location.assign(`/API/FileSharing/${fileID}`); - }); - hubConnection.on("DownloadFileProgress", (progressPercent) => { - Console_js_2.AddConsoleOutput(`Remote computer upload progress: ${progressPercent}%`); - }); - hubConnection.on("TransferCompleted", (transferID) => { - var completedWrapper = document.getElementById(transferID + "-completed"); - var count = parseInt(completedWrapper.innerHTML); - completedWrapper.innerHTML = (count + 1).toString(); - }); - hubConnection.on("PSCoreResultViaAjax", (commandID, deviceID) => { - var targetURL = `${location.origin}/API/Commands/PSCoreResult/${commandID}/${deviceID}`; - var xhr = new XMLHttpRequest(); - xhr.open("get", targetURL); - xhr.onload = function () { - if (xhr.status == 200) { - ResultsParser_js_1.AddPSCoreResultsHarness(JSON.parse(xhr.responseText)); - ResultsParser_js_1.UpdateResultsCount(commandID); - } - }; - xhr.send(); - }); - hubConnection.on("WinPSResultViaAjax", (commandID, deviceID) => { - var targetURL = `${location.origin}/API/Commands/WinPSResult/${commandID}/${deviceID}`; - var xhr = new XMLHttpRequest(); - xhr.open("get", targetURL); - xhr.onload = function () { - if (xhr.status == 200) { - ResultsParser_js_1.AddCommandResultsHarness(JSON.parse(xhr.responseText)); - ResultsParser_js_1.UpdateResultsCount(commandID); - } - }; - xhr.send(); - }); - hubConnection.on("CMDResultViaAjax", (commandID, deviceID) => { - var targetURL = `${location.origin}/API/Commands/PSCoreResult/${commandID}/${deviceID}`; - var xhr = new XMLHttpRequest(); - xhr.open("get", targetURL); - xhr.onload = function () { - if (xhr.status == 200) { - ResultsParser_js_1.AddCommandResultsHarness(JSON.parse(xhr.responseText)); - ResultsParser_js_1.UpdateResultsCount(commandID); - } - }; - xhr.send(); - }); - hubConnection.on("BashResultViaAjax", (commandID, deviceID) => { - var targetURL = `${location.origin}/API/Commands/PSCoreResult/${commandID}/${deviceID}`; - var xhr = new XMLHttpRequest(); - xhr.open("get", targetURL); - xhr.onload = function () { - if (xhr.status == 200) { - ResultsParser_js_1.AddCommandResultsHarness(JSON.parse(xhr.responseText)); - ResultsParser_js_1.UpdateResultsCount(commandID); - } - }; - xhr.send(); - }); - hubConnection.on("CommandResultCreated", (result) => { - Console_js_2.AddConsoleHTML(ResultsParser_js_1.CreateCommandHarness(result).outerHTML); - }); - hubConnection.on("ServiceID", (serviceID) => { - exports.ServiceID = serviceID; - }); - hubConnection.on("UnattendedSessionReady", (rcConnectionID) => { - window.open(`/RemoteControl?clientID=${rcConnectionID}&serviceID=${exports.ServiceID}`, "_blank"); - }); - } -}); -define("Shared/Models/Parameter", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Parameter = void 0; - /**A parameter definition for Command Completion. */ - class Parameter { - constructor(name, summary, parameterType) { - this.Name = name; - this.Summary = summary; - this.ParameterType = parameterType; - } - } - exports.Parameter = Parameter; -}); -define("Shared/Models/CommandLineParameter", ["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.CommandLineParameter = void 0; - class CommandLineParameter { - constructor(name, value) { - this.Name = name; - this.Value = value; - } - } - exports.CommandLineParameter = CommandLineParameter; -}); -define("Shared/Models/ConsoleCommand", ["require", "exports", "Shared/Utilities"], function (require, exports, Utilities_js_3) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ConsoleCommand = void 0; - class ConsoleCommand { - constructor(name, parameters, summary, syntax, extendedHelp, callback) { - this.Name = name; - this.Parameters = parameters; - this.Summary = summary; - this.Syntax = syntax; - this.ExtendedHelp = extendedHelp; - this.Callback = callback; - } - get FullHelp() { - if (this.ExtendedHelp) { - var fullHelp = this.PartialHelp.substring(0, this.PartialHelp.lastIndexOf("")); - fullHelp += "

Extended Help:
" + this.ExtendedHelp + ""; - return fullHelp; - } - else { - return this.PartialHelp; - } - } - get PartialHelp() { - var partialHelp = `
-
- 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 = `
Version Results:
- - - - `; - var deviceList = selectedDevices.map(x => { - return ` - - - `; - }); - output += deviceList.join(""); - output += "
Device NameAgent Version
${x.DeviceName} - ${x.AgentVersion} -
"; - Console_js_3.AddConsoleOutput(output); - }), - new ConsoleCommand_js_1.ConsoleCommand("Clear", [], "Clears the output window of text.", "clear", "", (parameters, paramDictionary) => { UI.ConsoleOutputDiv.innerHTML = ""; }), - new ConsoleCommand_js_1.ConsoleCommand("Connect", [], "Connect or reconnect to the server.", "connect", "", (parameters, paramDictionary) => { HubConnection.Connect(); }), - new ConsoleCommand_js_1.ConsoleCommand("Echo", [ - new Parameter_js_1.Parameter("message", "The text to display in the console.", "String") - ], "Writes a message to the console window.", "echo -message This will appear in the console.", "", (parameters, paramDictionary) => { - Console_js_3.AddConsoleOutput(paramDictionary["message"]); - }), - new ConsoleCommand_js_1.ConsoleCommand("ExpandResults", [], "Expands the results of the last scripting command.", "expandresults", "", (parameters, paramDictionary) => { - $(UI.ConsoleOutputDiv).find(".command-harness").last().find(".collapse")['collapse']('show'); - }), - new ConsoleCommand_js_1.ConsoleCommand("CollapseResults", [], "Collapses all scripting results.", "collapseresults", "", (parameters, paramDictionary) => { - $(UI.ConsoleOutputDiv).find(".command-harness").find(".collapse")['collapse']('hide'); - }), - new ConsoleCommand_js_1.ConsoleCommand("Help", [ - new Parameter_js_1.Parameter("command", "The name of the command to look up.", "String") - ], "Displays the full help text for a command.", "help -command Select", "", (parameters) => { - if (parameters.length == 0) { - var output = `Command List:
`; - exports.WebCommands.forEach(x => { - output += `
${x.Name}
${x.Summary}
`; - }); - output += "
"; - Console_js_3.AddConsoleOutput(output); - return; - } - var suppliedCommand = parameters.find(x => x.Name.toLowerCase() == "command") || {}; - var result = commands.filter(command => { - return command.Name.toLowerCase() == (suppliedCommand.Value || "").toLowerCase(); - }); - if (result.length == 0) { - Console_js_3.AddConsoleOutput("No matching commands found."); - } - else if (result.length == 1) { - Console_js_3.AddConsoleHTML("
" + result[0].FullHelp); - } - else { - var outputText = "Multiple commands found:

"; - for (var i = 0; i < result.length; i++) { - outputText += result[i].Name + "
"; - } - Console_js_3.AddConsoleHTML(outputText); - } - }), - new ConsoleCommand_js_1.ConsoleCommand("List", [], "Displays a list of the currently-selected devices.", "list", "", () => { - var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices(); - if (selectedDevices.length == 0) { - Console_js_3.AddConsoleOutput("No devices are selected."); - return; - } - var output = `
Selected Devices:
- - - - `; - var deviceList = selectedDevices.map(x => { - return ` - - - - - - - - - - - - - `; - }); - output += deviceList.join(""); - output += "
OnlineDevice NameAliasCurrent UserLast OnlinePlatformOS DescriptionFree StorageTotal Storage (GB)Free MemoryTotal Memory (GB)Tags
${String(x.IsOnline) - .replace("true", "") - .replace("false", "")}${x.DeviceName}${x.Alias}${x.CurrentUser}${new Date(x.LastOnline).toLocaleString()}${x.Platform}${x.OSDescription}${Math.round(x.UsedStorage / x.TotalStorage * 100)}%${x.TotalStorage.toLocaleString()}${Math.round(x.UsedMemory / x.TotalMemory * 100)}%${x.TotalMemory.toLocaleString()}${x.Tags || ""}
"; - Console_js_3.AddConsoleOutput(output); - }), - new ConsoleCommand_js_1.ConsoleCommand("Remove", [], "Removes the selected devices from the database. (Note: This does not attempt to uninstall the client. Use Uninstall.)", "remove", "", (parameters) => { - var devices = DataGrid.GetSelectedDevices(); - if (devices.length == 0) { - Console_js_3.AddConsoleOutput("No devices are selected."); - } - else { - HubConnection.Connection.invoke("RemoveDevices", devices.map(x => x.ID)); - } - }), - new ConsoleCommand_js_1.ConsoleCommand("Select", [ - new Parameter_js_1.Parameter("all", "If specified, all devices will be selected.", "Switch"), - new Parameter_js_1.Parameter("none", "If specified, no devices will be selected.", "Switch"), - new Parameter_js_1.Parameter("online", "If specified, selects the devices that are currently online.", "Switch"), - new Parameter_js_1.Parameter("filter", "A comma-separated list of search filters (spaces are optional). See the help article for more details.", "String"), - new Parameter_js_1.Parameter("append", "If specified, selected devices will be added list of computers already selected (if any).", "Switch"), - ], "Selects devices based on a supplied filter.", "select -filter isonline=true, devicename*Rig, freestorage<50", `The filter contains a comma-separated list of fields to search, and devices that match all filters will be selected. - There are multiple operator types, and they can be used on any of the fields on the grid (plus some extra hidden ones).

- Operators:
-
    -
  • =    Exactly equal to. "devicename=myrig" would match "MyRig", but not "MyRig2"
  • -
  • *    Like. "currentuser*bus" would match "Business" and "A_Busy_User"
  • -
  • !=   Not equal to. "currentuser!=jon" would match every user except "Jon"
  • -
  • !*   Not like. "currentuser!*jon" would match "Jon", "Jonathan", and "SuperJon"
  • -
  • >    Greater than. "totalmemory>10" would match computers with more than 10GB of RAM
  • -
  • <    Less than. "freestorage<0.1" would match computers with less than 10% disk space left
  • -
- - Fields:
-
    -
  • IsOnline (true or false)
  • -
  • DeviceName (text)
  • -
  • Alias (text)
  • -
  • CurrentUser (text)
  • -
  • LastOnline (date or date+time
  • -
  • Is64Bit (true or false)
  • -
  • OSDescription (text)
  • -
  • Platform (text)
  • -
  • FreeStorage (between 0 and 1)
  • -
  • TotalStorage (number in GB)
  • -
  • FreeMemory (between 0 and 1)
  • -
  • TotalMemory (number in GB)
  • -
  • ProcessorCount (number)
  • -
  • PublicIP (string)
  • -
  • Tags (text)
  • -
  • Notes (text)
  • -
`, (parameters, paramDictionary) => { - if (typeof paramDictionary["all"] != "undefined") { - App_js_2.MainApp.DataGrid.DataSource.forEach(x => { - document.getElementById(x.ID).classList.add("row-selected"); - }); - Console_js_3.AddConsoleOutput(`${DataGrid_js_2.GetSelectedDevices().length} devices selected.`); - } - if (typeof paramDictionary["none"] != "undefined") { - App_js_2.MainApp.UI.DeviceGrid.querySelectorAll(".row-selected").forEach(x => { - x.classList.remove("row-selected"); - }); - Console_js_3.AddConsoleOutput(`${DataGrid_js_2.GetSelectedDevices().length} devices selected.`); - } - if (typeof paramDictionary["online"] != "undefined") { - App_js_2.MainApp.DataGrid.DataSource.filter(x => x.IsOnline).forEach(x => { - document.getElementById(x.ID).classList.add("row-selected"); - }); - Console_js_3.AddConsoleOutput(`${DataGrid_js_2.GetSelectedDevices().length} devices selected.`); - } - if (typeof paramDictionary["filter"] != "undefined") { - try { - var lambda = ""; - var filterString = paramDictionary["filter"]; - var filters = filterString.split(","); - filters.forEach(filter => { - var operatorIndex = filter.search(/([^\w|\d|\s])/i); - var valueIndex = filter.slice(operatorIndex).search(/([\w|\d|\s|.])/i) + operatorIndex; - var key = filter.slice(0, operatorIndex).trim().toLowerCase(); - var operator = filter.slice(operatorIndex, valueIndex).trim().toLowerCase(); - var value = filter.slice(valueIndex).trim().toLowerCase(); - console.log(`Searching by key ${key}, operator ${operator}, value ${value}`); - if (key == "lastonline") { - var parsedDate = Date.parse(value); - switch (operator) { - case "=": - case "*": - case "!=": - case "!*": - Console_js_3.AddConsoleOutput("Only < and > operators can be used with dates."); - return; - case ">": - lambda += `Date.parse(x[Object.keys(x).find(y=>y.toLowerCase().indexOf("${key}") > -1)]) > ${parsedDate} && `; - break; - case "<": - lambda += `Date.parse(x[Object.keys(x).find(y=>y.toLowerCase().indexOf("${key}") > -1)]) < ${parsedDate} && `; - break; - default: - throw "Unable to parse comparison operator."; - } - } - else { - switch (operator) { - case "=": - lambda += `(String(x[Object.keys(x).find(y=>y.toString().toLowerCase().indexOf("${key}") > -1)])).toLowerCase() === "${value}".toString().toLowerCase() && `; - break; - case "*": - lambda += `(String(x[Object.keys(x).find(y=>y.toString().toLowerCase().indexOf("${key}") > -1)])).toLowerCase().search("${value}".toString().toLowerCase()) > -1 && `; - break; - case "!=": - lambda += `(String(x[Object.keys(x).find(y=>y.toString().toLowerCase().indexOf("${key}") > -1)])).toLowerCase() !== "${value}".toString().toLowerCase() && `; - break; - case "!*": - lambda += `(String(x[Object.keys(x).find(y=>y.toString().toLowerCase().indexOf("${key}") > -1)])).toLowerCase().search("${value}".toString().toLowerCase()) === -1 && `; - break; - case ">": - lambda += `parseFloat(x[Object.keys(x).find(y=>y.toString().toLowerCase().indexOf("${key}") > -1)]) > parseFloat("${value}") && `; - break; - case "<": - lambda += `parseFloat(x[Object.keys(x).find(y=>y.toString().toLowerCase().indexOf("${key}") > -1)]) < parseFloat("${value}") && `; - break; - default: - throw "Unable to parse comparison operator."; - } - } - }); - } - catch (ex) { - Console_js_3.AddConsoleOutput("Unable to parse filter. Please check your syntax."); - console.error(ex); - return; - } - lambda = lambda.slice(0, lambda.lastIndexOf(" &&")); - if (paramDictionary["append"] != "true") { - App_js_2.MainApp.UI.DeviceGrid.querySelectorAll(".row-selected").forEach(x => { - x.classList.remove("row-selected"); - }); - } - var selectedDevices = App_js_2.MainApp.DataGrid.DataSource.filter(x => { - try { - return eval(lambda); - } - catch (_a) { - return false; - } - }); - selectedDevices.forEach(x => { - document.getElementById(x.ID).classList.add("row-selected"); - }); - Console_js_3.AddConsoleOutput(`${DataGrid_js_2.GetSelectedDevices().length} devices selected.`); - } - App_js_2.MainApp.DataGrid.UpdateDeviceCounts(); - }), - new ConsoleCommand_js_1.ConsoleCommand("RemoteControl", [], "Connect to a computer with Remotely Remote Control.", "remotecontrol", "", () => { - var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices(); - if (selectedDevices.length == 0) { - Console_js_3.AddConsoleOutput("You must select a device first."); - return; - } - if (selectedDevices.length > 1) { - Console_js_3.AddConsoleOutput("You can only initiate remote control on one device at a time."); - return; - } - Console_js_3.AddConsoleOutput("Launching remote control on client device..."); - HubConnection.Connection.invoke("RemoteControl", selectedDevices[0].ID); - }), - new ConsoleCommand_js_1.ConsoleCommand("Uninstall", [], "Uninstalls the Remotely client from the selected devices. Warning: This can't be undone from the web portal. You would need to redeploy the client.", "uninstall", "", (parameters, parameterDict) => { - var selectedDevices = DataGrid.GetSelectedDevices(); - HubConnection.Connection.invoke("UninstallClients", selectedDevices.map(x => x.ID)); - }), - new ConsoleCommand_js_1.ConsoleCommand("SetTags", [ - new Parameter_js_1.Parameter("Tags", "The tags to set for the device. Max length is 200 characters.", "String"), - new Parameter_js_1.Parameter("Append", "Append the tags to any existing ones.", "Switch") - ], "Set the tag/description for the selected devices. Max length is 200 characters.", "SetTags -tags John's computer, Portland office, desktop", "", (parameters, parameterDict) => { - var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices(); - if (selectedDevices.length == 0) { - Console_js_3.AddConsoleOutput("No devices are selected."); - return; - } - selectedDevices.forEach(x => { - if (typeof parameterDict["append"] != 'undefined') { - var separator = x.Tags.trim().endsWith(",") ? " " : ", "; - parameterDict["tags"] = x.Tags.trim() + separator + parameterDict["tags"]; - } - DataGrid.DataSource.find(y => y.ID == x.ID).Tags = parameterDict["tags"]; - HubConnection.Connection.invoke("UpdateTags", x.ID, parameterDict["tags"]); - }); - }), - new ConsoleCommand_js_1.ConsoleCommand("UploadFiles", [], "Upload file(s) to the selected devices. The files get saved in C:\\Windows\\Temp on the remote computer.", "uploadfiles", "", (parameters, parameterDict) => { - var selectedDevices = App_js_2.MainApp.DataGrid.GetSelectedDevices(); - if (selectedDevices.length == 0) { - Console_js_3.AddConsoleOutput("No devices are selected."); - return; - } - var transferID = App_js_2.MainApp.Utilities.CreateGUID(); - Console_js_3.AddTransferHarness(transferID, selectedDevices.length); - var fileInput = document.createElement("input"); - fileInput.type = "file"; - fileInput.hidden = true; - fileInput.multiple = true; - document.body.appendChild(fileInput); - fileInput.onchange = () => { - uploadFiles(fileInput.files).then(value => { - HubConnection.Connection.invoke("UploadFiles", value, transferID, selectedDevices.map(x => x.ID)); - fileInput.remove(); - }); - }; - fileInput.click(); - }) - ]; - function uploadFiles(fileList) { - return new Promise((resolve, reject) => { - Console_js_3.AddConsoleOutput("File upload started."); - var strPath = "/API/FileSharing/"; - var fd = new FormData(); - for (var i = 0; i < fileList.length; i++) { - fd.append('fileUpload' + i, fileList[i]); - } - var xhr = new XMLHttpRequest(); - xhr.open('POST', strPath, true); - xhr.addEventListener("load", function () { - if (xhr.status === 200) { - Console_js_3.AddConsoleOutput("File upload completed. It might take a while for the agent to download it."); - resolve(JSON.parse(xhr.responseText)); - } - else { - Console_js_3.AddConsoleOutput("File upload failed."); - reject(); - } - }); - xhr.addEventListener("error", () => { - Console_js_3.AddConsoleOutput("File upload failed."); - reject(); - }); - xhr.upload.onprogress = (e) => { - var currentPercent = isFinite(e.loaded / e.total) ? Math.round(e.loaded / e.total * 100) : 0; - if (currentPercent > uploadPercent) { - var uploadPercent = currentPercent; - Console_js_3.AddConsoleOutput("File upload progress: " + String(currentPercent) + "%"); - } - }; - xhr.send(fd); - }); - } - exports.WebCommands = commands; -}); -define("Main/Commands/CMDCommands", ["require", "exports", "Shared/Models/ConsoleCommand", "Shared/Models/Parameter"], function (require, exports, ConsoleCommand_js_2, Parameter_js_2) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.CMDCommands = void 0; - var commands = [ - new ConsoleCommand_js_2.ConsoleCommand(`append`, [ - new Parameter_js_2.Parameter(`[:]`, `Specifies a drive and directory to append.`, ``), - new Parameter_js_2.Parameter(`/x:on`, `Applies appended directories to file searches and launching applications.`, ``), - new Parameter_js_2.Parameter(`/x:off`, `Applies appended directories only to requests to open files.
/x:off is the default setting.`, ``), - new Parameter_js_2.Parameter(`/path:on`, `Applies appended directories to file requests that already specify a path. /path:on is the default setting.`, ``), - new Parameter_js_2.Parameter(`/path:off`, `Turns off the effect of /path:on.`, ``), - new Parameter_js_2.Parameter(`/e`, `Stores a copy of the appended directory list in an environment variable named APPEND. /e may be used only the first time you use append after starting your system.`, ``), - new Parameter_js_2.Parameter(`;`, `Clears the appended directory list.`, ``), - new Parameter_js_2.Parameter(`/?`, `Displays help at the command prompt.`, ``), - ], `Allows programs to open data files in specified directories as if they were in the current directory. If used without parameters, append displays the appended directory list.`, `append [[:][;...]] [/x[:on|:off]] [/path:[:on|:off] [/e] - -append ;`, "", () => { }), - new ConsoleCommand_js_2.ConsoleCommand(`arp`, [ - new Parameter_js_2.Parameter(`/a [] [/n ]`, `Displays current arp cache tables for all interfaces. The /n parameter is case-sensitive.

To display the arp cache entry for a specific IP address, use arp /a with the *Inetaddr* parameter, where *Inetaddr* is an IP address. If *Inetaddr* is not specified, the first applicable interface is used.

To display the arp cache table for a specific interface, use the /n*ifaceaddr* parameter in conjunction with the /a parameter where *ifaceaddr* is the IP address assigned to the interface.`, ``), - new Parameter_js_2.Parameter(`/g [] [/n ]`, `Identical to /a.`, ``), - new Parameter_js_2.Parameter(`[/d []`, `deletes an entry with a specific IP address, where *Inetaddr* is the IP address.

To delete an entry in a table for a specific interface, use the *ifaceaddr* parameter where *ifaceaddr* is the IP address assigned to the interface.

To delete all entries, use the asterisk (*) wildcard character in place of *Inetaddr*.`, ``), - new Parameter_js_2.Parameter(`/s []`, `adds a static entry to the arp cache that resolves the IP address *Inetaddr* to the physical address *Etheraddr*.

To add a static arp cache entry to the table for a specific interface, use the *ifaceaddr* parameter where *ifaceaddr* is an IP address assigned to the interface.`, ``), - new Parameter_js_2.Parameter(`/?`, `Displays help at the command prompt.`, ``), - ], `Displays and modifies entries in the Address Resolution Protocol (ARP) cache. The ARP cache contains one or more tables that are used to store IP addresses and their resolved Ethernet or Token Ring physical addresses. There is a separate table for each Ethernet or Token Ring network adapter installed on your computer. Used without parameters, arp displays help information.`, `arp [/a [] [/n ]] [/g [] [-n ]] [/d []] [/s []]`, "", () => { }), - new ConsoleCommand_js_2.ConsoleCommand(`assoc`, [ - new Parameter_js_2.Parameter(`<.ext>`, `Specifies the file name extension.`, ``), - new Parameter_js_2.Parameter(``, `Specifies the file type to associate with the specified file name extension.`, ``), - new Parameter_js_2.Parameter(`/?`, `Displays help at the command prompt.`, ``), - ], `Displays or modifies file name extension associations. If used without parameters, assoc displays a list of all the current file name extension associations.`, `assoc [<.ext>[=[]]]`, "", () => { }), - new ConsoleCommand_js_2.ConsoleCommand(`at`, [ - new Parameter_js_2.Parameter(`\\`, `Specifies a remote computer. If you omit this parameter, at schedules the commands and programs on the local computer.`, ``), - new Parameter_js_2.Parameter(``, `Specifies the identification number assigned to a scheduled command.`, ``), - new Parameter_js_2.Parameter(`/delete`, `Cancels a scheduled command. If you omit *ID*, all of the scheduled commands on the computer are canceled.`, ``), - new Parameter_js_2.Parameter(`/yes`, `Answers yes to all queries from the system when you delete scheduled events.`, ``), - new Parameter_js_2.Parameter(`