diff --git a/.gitignore b/.gitignore index 23dbbe28..bb32bcf9 100644 --- a/.gitignore +++ b/.gitignore @@ -263,9 +263,7 @@ __pycache__/ /Remotely_Server/wwwroot/Downloads/*.exe /Remotely_Server/wwwroot/Downloads/*.zip /Remotely_Server/wwwroot/Downloads/*.appimage -/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt /Remotely_Server/Server.db -/Remotely_Agent/Resources/* /Remotely_Server/Recordings/* /Remotely_Server/ffmpeg.exe -/Remotely_Server/Properties/PublishProfiles +/Remotely_Server/Properties/PublishProfiles \ No newline at end of file diff --git a/README.md b/README.md index 5153606a..45f89255 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Remotely [![Build Status](https://dev.azure.com/translucency/Remotely/_apis/build/status/Remotely-GitHub?branchName=master)](https://dev.azure.com/translucency/Remotely/_build/latest?definitionId=5&branchName=master) - A remote control and remote scripting solution, built with .NET Core and SignalR Core. > ## Repo is "On Pause" @@ -11,6 +10,8 @@ A remote control and remote scripting solution, built with .NET Core and SignalR > > Also, I'm looking for work. If you might entertain the idea of hiring me, please shoot me an email! :) (translucency@outlook.com) +(Please Note: Documentation and setup processes will improve eventually. Compatibility for older OS versions will likely never happen. I have a full-time job and a family/kids, which leaves me very little time to work on this. Right now, my focus is on getting features built that I already have planned.) + ## Build Instructions (Windows 10) The following steps will configure your Windows 10 machine for building the Remotely server and clients. * Install Visual Studio 2019. @@ -28,18 +29,19 @@ The following steps will configure your Windows 10 machine for building the Remo * Download and install the .NET Core Runtime. * Link: https://dotnet.microsoft.com/download * This includes the Hosting Bundle for Windows, which allows you to run ASP.NET Core in IIS. -* Download and unzip the Remotely Windows server package into your IIS site folder. -* An SSL certificate for HTTPS is required. You can install one for free using Let's Encrypt. +* Obtain a copy of the server files, either by building (above) or downloading the Windows server package from the website. +* Put the server files into your IIS site folder. +* An SSL certificate for HTTPS is recommended. You can install one for free using Let's Encrypt. * Resources: https://letsencrypt.org/, https://certifytheweb.com/ * Documentation for hosting in IIS can be found here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.2 ## Hosting a Server (Linux) -* Download and install the .NET Core Runtime. - * Link: https://dotnet.microsoft.com/download -* Download and unzip the Remotely Linux server package. -* These files would typically go in /var/www/remotely/. -* Run Remotely_Server_Setup.sh (with sudo), which is in the Utilities folder in source control. - * Certbot is used in this script and will install an SSL certificate for your site. Your server needs to have a public domain name that is accessible from the internet. +* Obtain a copy of the server files, either by building (above) or downloading the Linux server package from the website. +* Copy the server files to the location from which they will be run. + * This would typically be in /var/www/remotely/. +* Run Remotely_Server_Setup.sh (with sudo), which is in the [Utilities folder in source control](https://raw.githubusercontent.com/Jay-Rad/Remotely/master/Utilities/Remotely_Server_Install.sh). + * The script installs the .NET Core runtime, as well as other dependencies. + * Certbot is used in this script and will install an SSL certificate for your site. Your server needs to have a public domain name that is accessible from the internet for this to work. * More information: https://letsencrypt.org/, https://certbot.eff.org/ * App root will be the above output folder. * Change values in appsettings.json for your environment. @@ -49,7 +51,7 @@ The following steps will configure your Windows 10 machine for building the Remo * You can turn on session recording in appsettings.json. * The following requirements must be met for it to work: * On Linux, libgdiplus must be installed (sudo apt-get install libdgiplus). - * The process running the app must have access to create and/or modify a folder name "Recordings" in the site's root content folder. + * The process running the app must have access to create and modify a folder name "Recordings" in the site's root content folder. * FFmpeg must be executable from the process running the Remotely server. * Link: https://www.ffmpeg.org/download.html * Remote control sessions will first be recorded as a series of images, which will then be converted to MP4 using FFmpeg. diff --git a/Remotely.sln b/Remotely.sln index 42d32c3e..f50f508e 100644 --- a/Remotely.sln +++ b/Remotely.sln @@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{ Utilities\Get-PSCommands.ps1 = Utilities\Get-PSCommands.ps1 Utilities\Get-WindowsCommands.ps1 = Utilities\Get-WindowsCommands.ps1 Utilities\Publish.ps1 = Utilities\Publish.ps1 - Utilities\Register-TURNServer.ps1 = Utilities\Register-TURNServer.ps1 Utilities\Remotely_Server_Install.sh = Utilities\Remotely_Server_Install.sh Utilities\Setup_Ubuntu_Builder.sh = Utilities\Setup_Ubuntu_Builder.sh EndProjectSection diff --git a/Remotely_Agent/Remotely_Agent.csproj b/Remotely_Agent/Remotely_Agent.csproj index 242a0b63..2044425b 100644 --- a/Remotely_Agent/Remotely_Agent.csproj +++ b/Remotely_Agent/Remotely_Agent.csproj @@ -17,14 +17,6 @@ Remotely_Agent - - - - - - - - diff --git a/Remotely_Agent/Services/DeviceSocket.cs b/Remotely_Agent/Services/DeviceSocket.cs index 0dd33e90..96e395df 100644 --- a/Remotely_Agent/Services/DeviceSocket.cs +++ b/Remotely_Agent/Services/DeviceSocket.cs @@ -264,7 +264,12 @@ namespace Remotely_Agent.Services return; } - var filePath = ExtractScreenCasterEXE(); + if (!File.Exists(OSUtils.ScreenCastExecutableFileName)) + { + await hubConnection.InvokeAsync("DisplayConsoleMessage", "Remote control executable not found on target device.", requesterID); + return; + } + // Start ScreenCast. await hubConnection.InvokeAsync("DisplayConsoleMessage", $"Starting remote control...", requesterID); @@ -273,11 +278,11 @@ namespace Remotely_Agent.Services if (Program.IsDebug) { - Process.Start(filePath, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -desktop default"); + Process.Start(OSUtils.ScreenCastExecutableFileName, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -desktop default"); } else { - var result = Win32Interop.OpenInteractiveProcess(filePath + $" -mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -desktop default", "default", true, out _); + var result = Win32Interop.OpenInteractiveProcess(OSUtils.ScreenCastExecutableFileName + $" -mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -desktop default", "default", true, out _); if (!result) { await hubConnection.InvokeAsync("DisplayConsoleMessage", "Remote control failed to start on target device.", requesterID); @@ -311,16 +316,15 @@ namespace Remotely_Agent.Services { // Start ScreenCast. if (OSUtils.IsWindows) - { - var filePath = ExtractScreenCasterEXE(); + { if (Program.IsDebug) { - Process.Start(filePath, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -relaunch true -desktop default -viewers {String.Join(",", viewerIDs)}"); + Process.Start(OSUtils.ScreenCastExecutableFileName, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -relaunch true -desktop default -viewers {String.Join(",", viewerIDs)}"); } else { - var result = Win32Interop.OpenInteractiveProcess(filePath + $" -mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -relaunch true -desktop default -viewers {String.Join(",", viewerIDs)}", "default", true, out _); + var result = Win32Interop.OpenInteractiveProcess(OSUtils.ScreenCastExecutableFileName + $" -mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -relaunch true -desktop default -viewers {String.Join(",", viewerIDs)}", "default", true, out _); if (!result) { Logger.Write("Failed to relaunch screen caster."); @@ -368,38 +372,6 @@ namespace Remotely_Agent.Services }); } - private static string ExtractScreenCasterEXE() - { - // Cleanup old files. - foreach (var file in Directory.GetFiles(Path.GetTempPath(), "Remotely_ScreenCast*")) - { - try - { - File.Delete(file); - } - catch { } - } - - // Get temp file name. - var count = 0; - var filePath = Path.Combine(Path.GetTempPath(), "Remotely_ScreenCast.exe"); - while (File.Exists(filePath)) - { - filePath = Path.Combine(Path.GetTempPath(), $"Remotely_ScreenCast{count}.exe"); - count++; - } - - // Extract ScreenCast. - using (var mrs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Remotely_Agent.Resources.Remotely_ScreenCast.exe")) - { - using (var fs = new FileStream(filePath, FileMode.Create)) - { - mrs.CopyTo(fs); - } - } - return filePath; - } - private static void SendResultsViaAjax(string resultType, object result) { var targetURL = Utilities.GetConnectionInfo().Host + $"/API/Commands/{resultType}"; diff --git a/Remotely_Library/Services/OSUtils.cs b/Remotely_Library/Services/OSUtils.cs index f8211e99..aff6ae8f 100644 --- a/Remotely_Library/Services/OSUtils.cs +++ b/Remotely_Library/Services/OSUtils.cs @@ -43,11 +43,11 @@ namespace Remotely_Library.Services { if (IsWindows) { - return "Remotely Remote Control.exe"; + return "Remotely_ScreenCast.exe"; } else if (IsLinux) { - return "remotely_remote_control"; + return "Remotely_ScreenCast"; } else { diff --git a/Remotely_ScreenCast/Remotely_ScreenCast.csproj b/Remotely_ScreenCast/Remotely_ScreenCast.csproj index 5ec1c92a..0fae9056 100644 --- a/Remotely_ScreenCast/Remotely_ScreenCast.csproj +++ b/Remotely_ScreenCast/Remotely_ScreenCast.csproj @@ -195,7 +195,7 @@ if $(ConfigurationName) == Debug ( - copy /y "$(TargetPath)" "$(SolutionDir)Remotely_Agent\Resources\" + copy /y "$(TargetPath)" "$(SolutionDir)Remotely_Agent\bin\Debug\netcoreapp2.2\" ) diff --git a/Remotely_Server/CurrentVersion.txt b/Remotely_Server/CurrentVersion.txt index 5b428a85..77defffe 100644 --- a/Remotely_Server/CurrentVersion.txt +++ b/Remotely_Server/CurrentVersion.txt @@ -1 +1 @@ -2019.03.23.1213 +2019.03.25.0814 diff --git a/Utilities/Publish.ps1 b/Utilities/Publish.ps1 index 273b1634..3dcd7534 100644 --- a/Utilities/Publish.ps1 +++ b/Utilities/Publish.ps1 @@ -58,16 +58,7 @@ if ($ArgList.Contains("c")) { # Add Current Version file to root content folder for client update checks. Set-Content -Path ".\Remotely_Server\CurrentVersion.txt" -Value $CurrentVersion.Trim() -Encoding UTF8 -Force - # Copy .NET Framework ScreenCaster to Agent resources for embedding. - if ((Test-Path -Path ".\Remotely_Agent\Resources") -eq $false) { - New-Item -Path ".\Remotely_Agent\Resources" -ItemType Directory - } - if ((Test-Path -Path ".\Remotely_ScreenCast\bin\Release\Remotely_ScreenCast.exe") -eq $true) { - Copy-Item -Path ".\Remotely_ScreenCast\bin\Release\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\Resources\Remotely_ScreenCast.exe" -Force - } - elseif ((Test-Path -Path ".\Remotely_ScreenCast\bin\Debug\Remotely_ScreenCast.exe") -eq $true) { - Copy-Item -Path ".\Remotely_ScreenCast\bin\Debug\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\Resources\Remotely_ScreenCast.exe" -Force - } + # Clear publish folders. if ((Test-Path -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish") -eq $true) { Get-ChildItem -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish" | Remove-Item -Force -Recurse @@ -88,6 +79,16 @@ if ($ArgList.Contains("c")) { Pop-Location + # Copy .NET Framework ScreenCaster to Agent output. + if ((Test-Path -Path ".\Remotely_ScreenCast\bin\Release\Remotely_ScreenCast.exe") -eq $true) { + Copy-Item -Path ".\Remotely_ScreenCast\bin\Release\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\Remotely_ScreenCast.exe" -Force + Copy-Item -Path ".\Remotely_ScreenCast\bin\Release\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x86\publish\Remotely_ScreenCast.exe" -Force + } + elseif ((Test-Path -Path ".\Remotely_ScreenCast\bin\Debug\Remotely_ScreenCast.exe") -eq $true) { + Copy-Item -Path ".\Remotely_ScreenCast\bin\Debug\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\Remotely_ScreenCast.exe" -Force + Copy-Item -Path ".\Remotely_ScreenCast\bin\Debug\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x86\publish\Remotely_ScreenCast.exe" -Force + } + # Compress Core clients. Push-Location -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish" Compress-Archive -Path ".\*" -DestinationPath "Remotely-Win10-x64.zip" -CompressionLevel Optimal -Force