mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Remove old library files.
This commit is contained in:
parent
ff6df42892
commit
9cb6d36cfb
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Enums
|
||||
{
|
||||
public enum RemoteControlMode
|
||||
{
|
||||
Unattended,
|
||||
Normal
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class CommandContext
|
||||
{
|
||||
[Key]
|
||||
public string ID { get; set; } = Guid.NewGuid().ToString();
|
||||
public string CommandMode { get; set; }
|
||||
public string CommandText { get; set; }
|
||||
public string SenderUserID { get; set; }
|
||||
public string SenderConnectionID { get; set; }
|
||||
public string[] TargetDeviceIDs { get; set; }
|
||||
public ICollection<PSCoreCommandResult> PSCoreResults { get; set; } = new List<PSCoreCommandResult>();
|
||||
public ICollection<GenericCommandResult> CommandResults { get; set; } = new List<GenericCommandResult>();
|
||||
public DateTime TimeStamp { get; set; } = DateTime.Now;
|
||||
[IgnoreDataMember]
|
||||
public virtual Organization Organization { get; set; }
|
||||
public string OrganizationID { get; set; }
|
||||
}
|
||||
}
|
||||
12
Remotely_Library/Models/CommandContext.d.ts
vendored
12
Remotely_Library/Models/CommandContext.d.ts
vendored
@ -1,12 +0,0 @@
|
||||
interface CommandContext {
|
||||
ID: string;
|
||||
CommandMode: string;
|
||||
CommandText: string;
|
||||
SenderUserID: string;
|
||||
SenderConnectionID: string;
|
||||
TargetDeviceIDs: string[];
|
||||
PSCoreResults: any[];
|
||||
CommandResults: any[];
|
||||
TimeStamp: Date;
|
||||
OrganizationID: string;
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class ConnectionInfo
|
||||
{
|
||||
public string DeviceID { get; set; } = Guid.NewGuid().ToString();
|
||||
private string host;
|
||||
public string Host
|
||||
{
|
||||
get
|
||||
{
|
||||
return host;
|
||||
}
|
||||
set
|
||||
{
|
||||
host = value.Trim();
|
||||
if (host.EndsWith("/"))
|
||||
{
|
||||
host = host.Substring(0, host.LastIndexOf("/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
public string OrganizationID { get; set; }
|
||||
public string ServerVerificationToken { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class CursorInfo
|
||||
{
|
||||
|
||||
public CursorInfo(byte[] imageBytes, Point hotspot, string cssOverride = null)
|
||||
{
|
||||
ImageBytes = imageBytes;
|
||||
HotSpot = hotspot;
|
||||
CssOverride = cssOverride;
|
||||
}
|
||||
|
||||
public byte[] ImageBytes { get; set; }
|
||||
public Point HotSpot { get; set; }
|
||||
public string CssOverride { get; set; }
|
||||
}
|
||||
}
|
||||
5
Remotely_Library/Models/CursorInfo.d.ts
vendored
5
Remotely_Library/Models/CursorInfo.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
interface CursorInfo {
|
||||
ImageBytes: any[];
|
||||
HotSpot: any;
|
||||
CssOverride: string;
|
||||
}
|
||||
@ -1,201 +0,0 @@
|
||||
using Remotely_Library.Services;
|
||||
using Microsoft.Management.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
public string CurrentUser { get; set; }
|
||||
public List<Drive> Drives { get; set; }
|
||||
|
||||
public double FreeMemory { get; set; }
|
||||
|
||||
public double FreeStorage { get; set; }
|
||||
|
||||
[Key]
|
||||
public string ID { get; set; }
|
||||
|
||||
public bool Is64Bit { get; set; }
|
||||
|
||||
public bool IsOnline { get; set; }
|
||||
|
||||
public DateTime LastOnline { get; set; }
|
||||
|
||||
public string DeviceName { get; set; }
|
||||
|
||||
public virtual Organization Organization { get; set; }
|
||||
public string OrganizationID { get; set; }
|
||||
public Architecture OSArchitecture { get; set; }
|
||||
|
||||
public string OSDescription { get; set; }
|
||||
|
||||
public virtual ICollection<DevicePermissionLink> DevicePermissionLinks { get; set; } = new List<DevicePermissionLink>();
|
||||
public string Platform { get; set; }
|
||||
|
||||
public int ProcessorCount { get; set; }
|
||||
public string ServerVerificationToken { get; set; }
|
||||
[StringLength(200)]
|
||||
public string Tags { get; set; } = "";
|
||||
|
||||
public double TotalMemory { get; set; }
|
||||
public double TotalStorage { get; set; }
|
||||
public static Device Create(ConnectionInfo connectionInfo)
|
||||
{
|
||||
OSPlatform platform = OSUtils.GetPlatform();
|
||||
DriveInfo systemDrive;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Environment.SystemDirectory))
|
||||
{
|
||||
systemDrive = DriveInfo.GetDrives()
|
||||
.Where(x=>x.IsReady)
|
||||
.FirstOrDefault(x =>
|
||||
x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
systemDrive = DriveInfo.GetDrives().FirstOrDefault(x =>
|
||||
x.IsReady &&
|
||||
x.RootDirectory.FullName == Path.GetPathRoot(Environment.CurrentDirectory));
|
||||
}
|
||||
|
||||
var device = new Device()
|
||||
{
|
||||
ID = connectionInfo.DeviceID,
|
||||
DeviceName = Environment.MachineName,
|
||||
Platform = platform.ToString(),
|
||||
ProcessorCount = Environment.ProcessorCount,
|
||||
OSArchitecture = RuntimeInformation.OSArchitecture,
|
||||
OSDescription = RuntimeInformation.OSDescription,
|
||||
Is64Bit = Environment.Is64BitOperatingSystem,
|
||||
Drives = DriveInfo.GetDrives().Where(x => x.IsReady).Select(x => new Drive()
|
||||
{
|
||||
DriveFormat = x.DriveFormat,
|
||||
DriveType = x.DriveType,
|
||||
Name = x.Name,
|
||||
RootDirectory = x.RootDirectory.FullName,
|
||||
FreeSpace = x.TotalSize > 0 ? x.TotalFreeSpace / x.TotalSize : 0,
|
||||
TotalSize = x.TotalSize > 0 ? Math.Round((double)(x.TotalSize / 1024 / 1024 / 1024), 2) : 0,
|
||||
VolumeLabel = x.VolumeLabel
|
||||
}).ToList(),
|
||||
OrganizationID = connectionInfo.OrganizationID,
|
||||
CurrentUser = GetCurrentUser()
|
||||
};
|
||||
|
||||
if (systemDrive != null && systemDrive.TotalSize > 0 && systemDrive.TotalFreeSpace > 0)
|
||||
{
|
||||
device.TotalStorage = Math.Round((double)(systemDrive.TotalSize / 1024 / 1024 / 1024), 2);
|
||||
var freeStorage = Math.Round((double)(systemDrive.TotalFreeSpace / 1024 / 1024 / 1024), 2);
|
||||
device.FreeStorage = freeStorage / device.TotalStorage;
|
||||
}
|
||||
|
||||
Tuple<double, double> totalMemory = new Tuple<double, double>(0, 0);
|
||||
|
||||
if (OSUtils.IsWindows)
|
||||
{
|
||||
totalMemory = GetWinMemoryInGB();
|
||||
}
|
||||
else if (OSUtils.IsLinux)
|
||||
{
|
||||
totalMemory = GetLinxMemoryInGB();
|
||||
}
|
||||
|
||||
if (totalMemory.Item2 > 0)
|
||||
{
|
||||
device.FreeMemory = totalMemory.Item1 / totalMemory.Item2;
|
||||
}
|
||||
else
|
||||
{
|
||||
device.FreeMemory = 0;
|
||||
}
|
||||
device.TotalMemory = totalMemory.Item2;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
private static string GetCurrentUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OSUtils.IsWindows)
|
||||
{
|
||||
var session = CimSession.Create(null);
|
||||
var computerSystem = session.EnumerateInstances("root\\cimv2", "CIM_ComputerSystem");
|
||||
var username = computerSystem.FirstOrDefault().CimInstanceProperties["UserName"].Value ?? "";
|
||||
return username as string;
|
||||
}
|
||||
else if (OSUtils.IsLinux)
|
||||
{
|
||||
var users = OSUtils.StartProcessWithResults("users", "");
|
||||
var username = users?.Split()?.FirstOrDefault()?.Trim();
|
||||
return $"{Environment.UserDomainName}\\{username}";
|
||||
}
|
||||
throw new Exception("Unsupported operating system.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Error Retrieving";
|
||||
}
|
||||
}
|
||||
|
||||
private static Tuple<double, double> GetLinxMemoryInGB()
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = OSUtils.StartProcessWithResults("cat", "/proc/meminfo");
|
||||
var resultsArr = results.Split('n');
|
||||
var freeKB = resultsArr
|
||||
.FirstOrDefault(x => x.StartsWith("FreeMem"))
|
||||
.Split(" ".ToCharArray(), 2)
|
||||
.Last() // 9168236 kB
|
||||
.Trim()
|
||||
.Split(' ')
|
||||
.First(); // 9168236
|
||||
|
||||
var totalKB = resultsArr
|
||||
.FirstOrDefault(x => x.StartsWith("MemTotal"))
|
||||
.Split(" ".ToCharArray(), 2)
|
||||
.Last() // 16637468 kB
|
||||
.Trim()
|
||||
.Split(' ')
|
||||
.First(); // 16637468
|
||||
|
||||
var freeGB = Math.Round((double.Parse(freeKB) / 1024 / 1024), 2);
|
||||
var totalGB = Math.Round((double.Parse(totalKB) / 1024 / 1024), 2);
|
||||
|
||||
return new Tuple<double, double>(freeGB, totalGB);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new Tuple<double, double>(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static Tuple<double, double> GetWinMemoryInGB()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = CimSession.Create(null);
|
||||
var cimOS = session.EnumerateInstances("root\\cimv2", "CIM_OperatingSystem");
|
||||
var free = (ulong)(cimOS.FirstOrDefault()?.CimInstanceProperties["FreePhysicalMemory"]?.Value ?? 0);
|
||||
var freeGB = Math.Round(((double)free / 1024 / 1024), 2);
|
||||
var total = (ulong)(cimOS.FirstOrDefault()?.CimInstanceProperties["TotalVisibleMemorySize"]?.Value ?? 0);
|
||||
var totalGB = Math.Round(((double)total / 1024 / 1024), 2);
|
||||
|
||||
return new Tuple<double, double>(freeGB, totalGB);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new Tuple<double, double>(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Remotely_Library/Models/Device.d.ts
vendored
32
Remotely_Library/Models/Device.d.ts
vendored
@ -1,32 +0,0 @@
|
||||
interface Device {
|
||||
CurrentUser: string;
|
||||
Drives: any[];
|
||||
FreeMemory: number;
|
||||
FreeStorage: number;
|
||||
ID: string;
|
||||
Is64Bit: boolean;
|
||||
IsOnline: boolean;
|
||||
LastOnline: Date;
|
||||
DeviceName: string;
|
||||
Organization: {
|
||||
ID: string;
|
||||
OrganizationName: string;
|
||||
RemotelyUsers: any[];
|
||||
Devices: .Device[];
|
||||
CommandContexts: any[];
|
||||
EventLogs: any[];
|
||||
PermissionGroups: any[];
|
||||
InviteLinks: any[];
|
||||
SharedFiles: any[];
|
||||
};
|
||||
OrganizationID: string;
|
||||
OSArchitecture: any;
|
||||
OSDescription: string;
|
||||
DevicePermissionLinks: any[];
|
||||
Platform: string;
|
||||
ProcessorCount: number;
|
||||
ServerVerificationToken: string;
|
||||
Tags: string;
|
||||
TotalMemory: number;
|
||||
TotalStorage: number;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class DevicePermissionLink
|
||||
{
|
||||
public string DeviceID { get; set; }
|
||||
public Device Device { get; set; }
|
||||
public string PermissionGroupID { get; set; }
|
||||
public PermissionGroup PermissionGroup { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
interface DevicePermissionLink {
|
||||
DeviceID: string;
|
||||
Device: {
|
||||
CurrentUser: string;
|
||||
Drives: any[];
|
||||
FreeMemory: number;
|
||||
FreeStorage: number;
|
||||
ID: string;
|
||||
Is64Bit: boolean;
|
||||
IsOnline: boolean;
|
||||
LastOnline: Date;
|
||||
DeviceName: string;
|
||||
Organization: {
|
||||
ID: string;
|
||||
OrganizationName: string;
|
||||
RemotelyUsers: any[];
|
||||
Devices: any[];
|
||||
CommandContexts: any[];
|
||||
EventLogs: any[];
|
||||
PermissionGroups: any[];
|
||||
InviteLinks: any[];
|
||||
SharedFiles: any[];
|
||||
};
|
||||
OrganizationID: string;
|
||||
OSArchitecture: any;
|
||||
OSDescription: string;
|
||||
DevicePermissionLinks: any[];
|
||||
Platform: string;
|
||||
ProcessorCount: number;
|
||||
ServerVerificationToken: string;
|
||||
Tags: string;
|
||||
TotalMemory: number;
|
||||
TotalStorage: number;
|
||||
};
|
||||
PermissionGroupID: string;
|
||||
PermissionGroup: {
|
||||
ID: string;
|
||||
Name: string;
|
||||
Organization: {
|
||||
ID: string;
|
||||
OrganizationName: string;
|
||||
RemotelyUsers: any[];
|
||||
Devices: any[];
|
||||
CommandContexts: any[];
|
||||
EventLogs: any[];
|
||||
PermissionGroups: any[];
|
||||
InviteLinks: any[];
|
||||
SharedFiles: any[];
|
||||
};
|
||||
UserPermissionLinks: any[];
|
||||
DevicePermissionLinks: any[];
|
||||
};
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class Drive
|
||||
{
|
||||
public DriveType DriveType { get; set; }
|
||||
public string RootDirectory { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string DriveFormat { get; set; }
|
||||
public double FreeSpace { get; set; }
|
||||
public double TotalSize { get; set; }
|
||||
public string VolumeLabel { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class EventLog
|
||||
{
|
||||
[Key]
|
||||
public string ID { get; set; } = Guid.NewGuid().ToString();
|
||||
public EventTypes EventType { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string StackTrace { get; set; }
|
||||
public string OrganizationID { get; set; }
|
||||
public DateTime TimeStamp { get; set; } = DateTime.Now;
|
||||
[JsonIgnore]
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
public enum EventTypes
|
||||
{
|
||||
Info = 0,
|
||||
Error = 1,
|
||||
Debug = 2
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class GenericCommandResult
|
||||
{
|
||||
public string DeviceID { get; set; }
|
||||
public string CommandContextID { get; set; }
|
||||
public string CommandType { get; set; }
|
||||
public string StandardOutput { get; set; }
|
||||
public string ErrorOutput { get; set; }
|
||||
public DateTime TimeStamp { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class InviteLink
|
||||
{
|
||||
[Key]
|
||||
public string ID { get; set; } = Guid.NewGuid().ToString();
|
||||
public string InvitedUser { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public DateTime DateSent { get; set; }
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
using Remotely_Library.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class Organization
|
||||
{
|
||||
[Key]
|
||||
public string ID { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
[StringLength(25)]
|
||||
public string OrganizationName { get; set; }
|
||||
public virtual ICollection<RemotelyUser> RemotelyUsers { get; set; }
|
||||
public virtual ICollection<Device> Devices { get; set; }
|
||||
public virtual ICollection<CommandContext> CommandContexts { get; set; }
|
||||
public virtual ICollection<EventLog> EventLogs { get; set; }
|
||||
public virtual ICollection<PermissionGroup> PermissionGroups { get; set; } = new List<PermissionGroup>();
|
||||
public virtual ICollection<InviteLink> InviteLinks { get; set; }
|
||||
public virtual ICollection<SharedFile> SharedFiles { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class PSCoreCommandResult
|
||||
{
|
||||
public string CommandContextID { get; set; }
|
||||
public string DeviceID { get; set; }
|
||||
public List<string> VerboseOutput { get; set; }
|
||||
public List<string> DebugOutput { get; set; }
|
||||
public List<string> ErrorOutput { get; set; }
|
||||
public string HostOutput { get; set; }
|
||||
public List<string> InformationOutput { get; set; }
|
||||
public List<string> WarningOutput { get; set; }
|
||||
public DateTime TimeStamp { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class PSError
|
||||
{
|
||||
public string Exception { get; set; }
|
||||
public string StackTrace { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class PermissionGroup
|
||||
{
|
||||
[Key]
|
||||
public string ID { get; set; } = Guid.NewGuid().ToString();
|
||||
[StringLength(100)]
|
||||
public string Name { get; set; }
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual ICollection<UserPermissionLink> UserPermissionLinks { get; set; } = new List<UserPermissionLink>();
|
||||
public virtual ICollection<DevicePermissionLink> DevicePermissionLinks { get; set; } = new List<DevicePermissionLink>();
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class RemotelyUser : IdentityUser
|
||||
{
|
||||
public RemotelyUser()
|
||||
{
|
||||
UserOptions = new RemotelyUserOptions();
|
||||
Organization = new Organization();
|
||||
}
|
||||
public RemotelyUserOptions UserOptions { get; set; }
|
||||
|
||||
public virtual Organization Organization { get; set; }
|
||||
public string OrganizationID { get; set; }
|
||||
|
||||
public virtual ICollection<UserPermissionLink> UserPermissionLinks { get; set; } = new List<UserPermissionLink>();
|
||||
|
||||
public bool IsAdministrator { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class RemotelyUserOptions
|
||||
{
|
||||
[Display(Name ="Console Prompt")]
|
||||
[StringLength(5)]
|
||||
public string ConsolePrompt { get; set; } = "~>";
|
||||
|
||||
[Display(Name = "Web Shortcut")]
|
||||
[StringLength(10)]
|
||||
public string CommandModeShortcutWeb { get; set; } = "/web";
|
||||
[Display(Name = "PS Core Shortcut")]
|
||||
[StringLength(10)]
|
||||
public string CommandModeShortcutPSCore { get; set; } = "/pscore";
|
||||
[Display(Name = "Windows PS Shortcut")]
|
||||
[StringLength(10)]
|
||||
public string CommandModeShortcutWinPS { get; set; } = "/winps";
|
||||
[Display(Name = "CMD Shortcut")]
|
||||
[StringLength(10)]
|
||||
public string CommandModeShortcutCMD { get; set; } = "/cmd";
|
||||
[Display(Name = "Bash Shortcut")]
|
||||
[StringLength(10)]
|
||||
public string CommandModeShortcutBash { get; set; } = "/bash";
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
interface RemotelyUserOptions {
|
||||
ConsolePrompt: string;
|
||||
CommandModeShortcutWeb: string;
|
||||
CommandModeShortcutPSCore: string;
|
||||
CommandModeShortcutWinPS: string;
|
||||
CommandModeShortcutCMD: string;
|
||||
CommandModeShortcutBash: string;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class ScreenCastRequest
|
||||
{
|
||||
public string ViewerID { get; set; }
|
||||
public string RequesterName { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class SharedFile
|
||||
{
|
||||
[Key]
|
||||
public string ID { get; set; } = Guid.NewGuid().ToString();
|
||||
public string FileName { get; set; }
|
||||
public string ContentType { get; set; }
|
||||
public byte[] FileContents { get; set; }
|
||||
public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.Models
|
||||
{
|
||||
public class UserPermissionLink
|
||||
{
|
||||
public string RemotelyUserID { get; set; }
|
||||
public RemotelyUser RemotelyUser { get; set; }
|
||||
public string PermissionGroupID { get; set; }
|
||||
public PermissionGroup PermissionGroup { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Models\Device.d.ts">
|
||||
<DependentUpon>Device.cs</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
</None>
|
||||
<None Include="Models\PSCoreCommandResult.d.ts">
|
||||
<DependentUpon>PSCoreCommandResult.cs</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Models\CommandContext.cs">
|
||||
<LastGenOutput>CommandContext.d.ts</LastGenOutput>
|
||||
<Generator>DtsGenerator</Generator>
|
||||
</Compile>
|
||||
<Compile Update="Models\CursorInfo.cs">
|
||||
<Generator>DtsGenerator</Generator>
|
||||
<LastGenOutput>CursorInfo.d.ts</LastGenOutput>
|
||||
</Compile>
|
||||
<Compile Update="Models\DevicePermissionLink.cs">
|
||||
<Generator>DtsGenerator</Generator>
|
||||
<LastGenOutput>DevicePermissionLink.d.ts</LastGenOutput>
|
||||
</Compile>
|
||||
<Compile Update="Models\RemotelyUserOptions.cs">
|
||||
<LastGenOutput>RemotelyUserOptions.d.ts</LastGenOutput>
|
||||
<Generator>DtsGenerator</Generator>
|
||||
</Compile>
|
||||
<Compile Update="Models\GenericCommandResult.cs">
|
||||
<LastGenOutput>GenericCommandResult.cs.d.ts</LastGenOutput>
|
||||
<Generator>DtsGenerator</Generator>
|
||||
</Compile>
|
||||
<Compile Update="Models\Device.cs">
|
||||
<LastGenOutput>Device.d.ts</LastGenOutput>
|
||||
<Generator>DtsGenerator</Generator>
|
||||
</Compile>
|
||||
<Compile Update="Models\PSCoreCommandResult.cs">
|
||||
<LastGenOutput>PSCoreCommandResult.cs.d.ts</LastGenOutput>
|
||||
<Generator>DtsGenerator</Generator>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Models\CommandContext.d.ts">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>CommandContext.cs</DependentUpon>
|
||||
</None>
|
||||
<None Update="Models\CursorInfo.d.ts">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>CursorInfo.cs</DependentUpon>
|
||||
</None>
|
||||
<None Update="Models\DevicePermissionLink.d.ts">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>DevicePermissionLink.cs</DependentUpon>
|
||||
</None>
|
||||
<None Update="Models\RemotelyUserOptions.d.ts">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>RemotelyUserOptions.cs</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,122 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Remotely_Library.Services
|
||||
{
|
||||
public static class OSUtils
|
||||
{
|
||||
public static bool IsLinux
|
||||
{
|
||||
get
|
||||
{
|
||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsWindows
|
||||
{
|
||||
get
|
||||
{
|
||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
}
|
||||
}
|
||||
public static string ClientExecutableFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
string fileExt = "";
|
||||
if (IsWindows)
|
||||
{
|
||||
fileExt = "Remotely_Agent.exe";
|
||||
}
|
||||
else if (IsLinux)
|
||||
{
|
||||
fileExt = "Remotely_Agent";
|
||||
}
|
||||
return fileExt;
|
||||
}
|
||||
}
|
||||
public static string ScreenCastExecutableFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsWindows)
|
||||
{
|
||||
return "Remotely_ScreenCast.exe";
|
||||
}
|
||||
else if (IsLinux)
|
||||
{
|
||||
return "Remotely_ScreenCast.Linux";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsupported operating system.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string CoreZipFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsWindows)
|
||||
{
|
||||
if (Environment.Is64BitOperatingSystem)
|
||||
{
|
||||
return "Remotely-Win10-x64.zip";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Remotely-Win10-x86.zip";
|
||||
}
|
||||
|
||||
}
|
||||
else if (OSUtils.IsLinux)
|
||||
{
|
||||
return "Remotely-Linux.zip";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsupported operating system.");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static OSPlatform GetPlatform()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return OSPlatform.Windows;
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
return OSPlatform.Linux;
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
return OSPlatform.OSX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return OSPlatform.Create("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
public static string StartProcessWithResults(string command, string arguments)
|
||||
{
|
||||
var psi = new ProcessStartInfo(command, arguments);
|
||||
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
psi.Verb = "RunAs";
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardOutput = true;
|
||||
|
||||
var proc = new Process();
|
||||
proc.StartInfo = psi;
|
||||
|
||||
proc.Start();
|
||||
proc.WaitForExit();
|
||||
|
||||
return proc.StandardOutput.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
namespace Remotely_Library.Services
|
||||
{
|
||||
public class RandomGenerator
|
||||
{
|
||||
private const string allowableCharacters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
public string GenerateString(int length)
|
||||
{
|
||||
var bytes = new byte[length];
|
||||
|
||||
using (var random = RandomNumberGenerator.Create())
|
||||
{
|
||||
random.GetBytes(bytes);
|
||||
}
|
||||
|
||||
return new string(bytes.Select(x => allowableCharacters[x % allowableCharacters.Length]).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely_Library.ViewModels
|
||||
{
|
||||
public class Permission
|
||||
{
|
||||
public string ID { get; set; }
|
||||
[StringLength(100)]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
public class OrganizationUser
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public List<Permission> Permissions { get; set; }
|
||||
}
|
||||
public class Invite
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public DateTime DateSent { get; set; }
|
||||
public string InvitedUser { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,372 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace Remotely_Library.Win32
|
||||
{
|
||||
public static class ADVAPI32
|
||||
{
|
||||
#region Structs
|
||||
public struct TOKEN_PRIVILEGES
|
||||
{
|
||||
public struct LUID
|
||||
{
|
||||
public UInt32 LowPart;
|
||||
public Int32 HighPart;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct LUID_AND_ATTRIBUTES
|
||||
{
|
||||
public LUID Luid;
|
||||
public UInt32 Attributes;
|
||||
}
|
||||
public int PrivilegeCount;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = ANYSIZE_ARRAY)]
|
||||
public LUID_AND_ATTRIBUTES[] Privileges;
|
||||
}
|
||||
public class USEROBJECTFLAGS
|
||||
{
|
||||
public int fInherit = 0;
|
||||
public int fReserved = 0;
|
||||
public int dwFlags = 0;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SECURITY_ATTRIBUTES
|
||||
{
|
||||
public int Length;
|
||||
public IntPtr lpSecurityDescriptor;
|
||||
public bool bInheritHandle;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PROCESS_INFORMATION
|
||||
{
|
||||
public IntPtr hProcess;
|
||||
public IntPtr hThread;
|
||||
public int dwProcessId;
|
||||
public int dwThreadId;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct STARTUPINFO
|
||||
{
|
||||
public Int32 cb;
|
||||
public string lpReserved;
|
||||
public string lpDesktop;
|
||||
public string lpTitle;
|
||||
public Int32 dwX;
|
||||
public Int32 dwY;
|
||||
public Int32 dwXSize;
|
||||
public Int32 dwYSize;
|
||||
public Int32 dwXCountChars;
|
||||
public Int32 dwYCountChars;
|
||||
public Int32 dwFillAttribute;
|
||||
public Int32 dwFlags;
|
||||
public Int16 wShowWindow;
|
||||
public Int16 cbReserved2;
|
||||
public IntPtr lpReserved2;
|
||||
public IntPtr hStdInput;
|
||||
public IntPtr hStdOutput;
|
||||
public IntPtr hStdError;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Enums
|
||||
public enum TOKEN_INFORMATION_CLASS
|
||||
{
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_USER structure that contains the user account of the token.
|
||||
/// </summary>
|
||||
TokenUser = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token.
|
||||
/// </summary>
|
||||
TokenGroups,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token.
|
||||
/// </summary>
|
||||
TokenPrivileges,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects.
|
||||
/// </summary>
|
||||
TokenOwner,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects.
|
||||
/// </summary>
|
||||
TokenPrimaryGroup,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects.
|
||||
/// </summary>
|
||||
TokenDefaultDacl,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information.
|
||||
/// </summary>
|
||||
TokenSource,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token.
|
||||
/// </summary>
|
||||
TokenType,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a SECURITY_IMPERSONATION_LEVEL value that indicates the impersonation level of the token. If the access token is not an impersonation token, the function fails.
|
||||
/// </summary>
|
||||
TokenImpersonationLevel,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics.
|
||||
/// </summary>
|
||||
TokenStatistics,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token.
|
||||
/// </summary>
|
||||
TokenRestrictedSids,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token.
|
||||
/// </summary>
|
||||
TokenSessionId,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_GROUPS_AND_PRIVILEGES structure that contains the user SID, the group accounts, the restricted SIDs, and the authentication ID associated with the token.
|
||||
/// </summary>
|
||||
TokenGroupsAndPrivileges,
|
||||
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
TokenSessionReference,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag.
|
||||
/// </summary>
|
||||
TokenSandBoxInert,
|
||||
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
TokenAuditPolicy,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ORIGIN value.
|
||||
/// </summary>
|
||||
TokenOrigin,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token.
|
||||
/// </summary>
|
||||
TokenElevationType,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token.
|
||||
/// </summary>
|
||||
TokenLinkedToken,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated.
|
||||
/// </summary>
|
||||
TokenElevation,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if the token has ever been filtered.
|
||||
/// </summary>
|
||||
TokenHasRestrictions,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token.
|
||||
/// </summary>
|
||||
TokenAccessInformation,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token.
|
||||
/// </summary>
|
||||
TokenVirtualizationAllowed,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token.
|
||||
/// </summary>
|
||||
TokenVirtualizationEnabled,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level.
|
||||
/// </summary>
|
||||
TokenIntegrityLevel,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set.
|
||||
/// </summary>
|
||||
TokenUIAccess,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy.
|
||||
/// </summary>
|
||||
TokenMandatoryPolicy,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives the token's logon security identifier (SID).
|
||||
/// </summary>
|
||||
TokenLogonSid,
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value for this enumeration
|
||||
/// </summary>
|
||||
MaxTokenInfoClass
|
||||
}
|
||||
public enum LOGON_TYPE
|
||||
{
|
||||
LOGON32_LOGON_INTERACTIVE = 2,
|
||||
LOGON32_LOGON_NETWORK,
|
||||
LOGON32_LOGON_BATCH,
|
||||
LOGON32_LOGON_SERVICE,
|
||||
LOGON32_LOGON_UNLOCK = 7,
|
||||
LOGON32_LOGON_NETWORK_CLEARTEXT,
|
||||
LOGON32_LOGON_NEW_CREDENTIALS
|
||||
}
|
||||
public enum LOGON_PROVIDER
|
||||
{
|
||||
LOGON32_PROVIDER_DEFAULT,
|
||||
LOGON32_PROVIDER_WINNT35,
|
||||
LOGON32_PROVIDER_WINNT40,
|
||||
LOGON32_PROVIDER_WINNT50
|
||||
}
|
||||
[Flags]
|
||||
public enum CreateProcessFlags
|
||||
{
|
||||
CREATE_BREAKAWAY_FROM_JOB = 0x01000000,
|
||||
CREATE_DEFAULT_ERROR_MODE = 0x04000000,
|
||||
CREATE_NEW_CONSOLE = 0x00000010,
|
||||
CREATE_NEW_PROCESS_GROUP = 0x00000200,
|
||||
CREATE_NO_WINDOW = 0x08000000,
|
||||
CREATE_PROTECTED_PROCESS = 0x00040000,
|
||||
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000,
|
||||
CREATE_SEPARATE_WOW_VDM = 0x00000800,
|
||||
CREATE_SHARED_WOW_VDM = 0x00001000,
|
||||
CREATE_SUSPENDED = 0x00000004,
|
||||
CREATE_UNICODE_ENVIRONMENT = 0x00000400,
|
||||
DEBUG_ONLY_THIS_PROCESS = 0x00000002,
|
||||
DEBUG_PROCESS = 0x00000001,
|
||||
DETACHED_PROCESS = 0x00000008,
|
||||
EXTENDED_STARTUPINFO_PRESENT = 0x00080000,
|
||||
INHERIT_PARENT_AFFINITY = 0x00010000
|
||||
}
|
||||
public enum TOKEN_TYPE : int
|
||||
{
|
||||
TokenPrimary = 1,
|
||||
TokenImpersonation = 2
|
||||
}
|
||||
|
||||
public enum SECURITY_IMPERSONATION_LEVEL : int
|
||||
{
|
||||
SecurityAnonymous = 0,
|
||||
SecurityIdentification = 1,
|
||||
SecurityImpersonation = 2,
|
||||
SecurityDelegation = 3,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
public const int TOKEN_DUPLICATE = 0x0002;
|
||||
public const uint MAXIMUM_ALLOWED = 0x2000000;
|
||||
public const int CREATE_NEW_CONSOLE = 0x00000010;
|
||||
public const int CREATE_NO_WINDOW = 0x08000000;
|
||||
public const int DETACHED_PROCESS = 0x00000008;
|
||||
public const int TOKEN_ALL_ACCESS = 0x000f01ff;
|
||||
public const int PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF;
|
||||
public const int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
|
||||
public const int SYNCHRONIZE = 0x00100000;
|
||||
|
||||
public const int IDLE_PRIORITY_CLASS = 0x40;
|
||||
public const int NORMAL_PRIORITY_CLASS = 0x20;
|
||||
public const int HIGH_PRIORITY_CLASS = 0x80;
|
||||
public const int REALTIME_PRIORITY_CLASS = 0x100;
|
||||
public const UInt32 SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001;
|
||||
public const UInt32 SE_PRIVILEGE_ENABLED = 0x00000002;
|
||||
public const UInt32 SE_PRIVILEGE_REMOVED = 0x00000004;
|
||||
public const UInt32 SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000;
|
||||
public const Int32 ANYSIZE_ARRAY = 1;
|
||||
|
||||
public const int UOI_FLAGS = 1;
|
||||
public const int UOI_NAME = 2;
|
||||
public const int UOI_TYPE = 3;
|
||||
public const int UOI_USER_SID = 4;
|
||||
public const int UOI_HEAPSIZE = 5;
|
||||
public const int UOI_IO = 6;
|
||||
#endregion
|
||||
|
||||
#region DLL Imports
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool AdjustTokenPrivileges(IntPtr tokenHandle,
|
||||
[MarshalAs(UnmanagedType.Bool)]bool disableAllPrivileges,
|
||||
ref TOKEN_PRIVILEGES newState,
|
||||
UInt32 bufferLengthInBytes,
|
||||
ref TOKEN_PRIVILEGES previousState,
|
||||
out UInt32 returnLengthInBytes);
|
||||
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool CreateProcessAsUser(
|
||||
IntPtr hToken,
|
||||
string lpApplicationName,
|
||||
string lpCommandLine,
|
||||
ref SECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
ref SECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
bool bInheritHandles,
|
||||
uint dwCreationFlags,
|
||||
IntPtr lpEnvironment,
|
||||
string lpCurrentDirectory,
|
||||
ref STARTUPINFO lpStartupInfo,
|
||||
out PROCESS_INFORMATION lpProcessInformation);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool AllocateLocallyUniqueId(out IntPtr pLuid);
|
||||
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern SECUR32.WinErrors LsaNtStatusToWinError(SECUR32.WinStatusCodes status);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool GetTokenInformation(
|
||||
IntPtr TokenHandle,
|
||||
SECUR32.TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||
IntPtr TokenInformation,
|
||||
uint TokenInformationLength,
|
||||
out uint ReturnLength);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool LogonUser(
|
||||
[MarshalAs(UnmanagedType.LPStr)] string pszUserName,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string pszDomain,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string pszPassword,
|
||||
int dwLogonType,
|
||||
int dwLogonProvider,
|
||||
out IntPtr phToken);
|
||||
|
||||
[DllImport("advapi32", SetLastError = true), SuppressUnmanagedCodeSecurityAttribute]
|
||||
public static extern bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, ref IntPtr TokenHandle);
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public extern static bool DuplicateTokenEx(
|
||||
IntPtr hExistingToken,
|
||||
uint dwDesiredAccess,
|
||||
ref SECURITY_ATTRIBUTES lpTokenAttributes,
|
||||
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
||||
TOKEN_TYPE TokenType,
|
||||
out IntPtr phNewToken);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = false)]
|
||||
public static extern uint LsaNtStatusToWinError(uint status);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool GetUserObjectInformationW(IntPtr hObj, int nIndex,
|
||||
[Out] byte[] pvInfo, uint nLength, out uint lpnLengthNeeded);
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely_Library.Win32
|
||||
{
|
||||
public static class GDI32
|
||||
{
|
||||
#region Enums
|
||||
/// <summary>
|
||||
/// Specifies a raster-operation code. These codes define how the color data for the
|
||||
/// source rectangle is to be combined with the color data for the destination
|
||||
/// rectangle to achieve the final color.
|
||||
/// </summary>
|
||||
public enum TernaryRasterOperations : uint
|
||||
{
|
||||
/// <summary>dest = source</summary>
|
||||
SRCCOPY = 0x00CC0020,
|
||||
/// <summary>dest = source OR dest</summary>
|
||||
SRCPAINT = 0x00EE0086,
|
||||
/// <summary>dest = source AND dest</summary>
|
||||
SRCAND = 0x008800C6,
|
||||
/// <summary>dest = source XOR dest</summary>
|
||||
SRCINVERT = 0x00660046,
|
||||
/// <summary>dest = source AND (NOT dest)</summary>
|
||||
SRCERASE = 0x00440328,
|
||||
/// <summary>dest = (NOT source)</summary>
|
||||
NOTSRCCOPY = 0x00330008,
|
||||
/// <summary>dest = (NOT src) AND (NOT dest)</summary>
|
||||
NOTSRCERASE = 0x001100A6,
|
||||
/// <summary>dest = (source AND pattern)</summary>
|
||||
MERGECOPY = 0x00C000CA,
|
||||
/// <summary>dest = (NOT source) OR dest</summary>
|
||||
MERGEPAINT = 0x00BB0226,
|
||||
/// <summary>dest = pattern</summary>
|
||||
PATCOPY = 0x00F00021,
|
||||
/// <summary>dest = DPSnoo</summary>
|
||||
PATPAINT = 0x00FB0A09,
|
||||
/// <summary>dest = pattern XOR dest</summary>
|
||||
PATINVERT = 0x005A0049,
|
||||
/// <summary>dest = (NOT dest)</summary>
|
||||
DSTINVERT = 0x00550009,
|
||||
/// <summary>dest = BLACK</summary>
|
||||
BLACKNESS = 0x00000042,
|
||||
/// <summary>dest = WHITE</summary>
|
||||
WHITENESS = 0x00FF0062,
|
||||
/// <summary>
|
||||
/// Capture window as seen on screen. This includes layered windows
|
||||
/// such as WPF windows with AllowsTransparency="true"
|
||||
/// </summary>
|
||||
CAPTUREBLT = 0x40000000
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DLL Imports
|
||||
|
||||
[DllImport("gdi32.dll", EntryPoint = "BitBlt", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool BitBlt([In] IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, [In] IntPtr hdcSrc, int nXSrc, int nYSrc, TernaryRasterOperations dwRop);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData);
|
||||
|
||||
[DllImport("GDI32.dll")]
|
||||
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);[DllImport("GDI32.dll")]
|
||||
public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||
|
||||
[DllImport("GDI32.dll")]
|
||||
public static extern bool DeleteDC(IntPtr hdc);
|
||||
|
||||
[DllImport("GDI32.dll")]
|
||||
public static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
[DllImport("GDI32.dll")]
|
||||
public static extern IntPtr GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
|
||||
[DllImport("GDI32.dll")]
|
||||
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Remotely_Library.Win32
|
||||
{
|
||||
public static class Kernel32
|
||||
{
|
||||
#region DLL Imports
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool CloseHandle(IntPtr hSnapshot);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern uint WTSGetActiveConsoleSessionId();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool ProcessIdToSessionId(uint dwProcessId, ref uint pSessionId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,373 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using Remotely_Library.Win32;
|
||||
|
||||
public static class SECUR32
|
||||
{
|
||||
public enum WinStatusCodes : uint
|
||||
{
|
||||
STATUS_SUCCESS = 0
|
||||
}
|
||||
|
||||
public enum WinErrors : uint
|
||||
{
|
||||
NO_ERROR = 0,
|
||||
}
|
||||
public enum WinLogonType
|
||||
{
|
||||
LOGON32_LOGON_INTERACTIVE = 2,
|
||||
LOGON32_LOGON_NETWORK = 3,
|
||||
LOGON32_LOGON_BATCH = 4,
|
||||
LOGON32_LOGON_SERVICE = 5,
|
||||
LOGON32_LOGON_UNLOCK = 7,
|
||||
LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
|
||||
LOGON32_LOGON_NEW_CREDENTIALS = 9
|
||||
}
|
||||
|
||||
// SECURITY_LOGON_TYPE
|
||||
public enum SecurityLogonType
|
||||
{
|
||||
Interactive = 2, // Interactively logged on (locally or remotely)
|
||||
Network, // Accessing system via network
|
||||
Batch, // Started via a batch queue
|
||||
Service, // Service started by service controller
|
||||
Proxy, // Proxy logon
|
||||
Unlock, // Unlock workstation
|
||||
NetworkCleartext, // Network logon with cleartext credentials
|
||||
NewCredentials, // Clone caller, new default credentials
|
||||
RemoteInteractive, // Remote, yet interactive. Terminal server
|
||||
CachedInteractive, // Try cached credentials without hitting the net.
|
||||
CachedRemoteInteractive, // Same as RemoteInteractive, this is used internally for auditing purpose
|
||||
CachedUnlock // Cached Unlock workstation
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LSA_UNICODE_STRING
|
||||
{
|
||||
public UInt16 Length;
|
||||
public UInt16 MaximumLength;
|
||||
public IntPtr Buffer;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TOKEN_SOURCE
|
||||
{
|
||||
public TOKEN_SOURCE(string name)
|
||||
{
|
||||
SourceName = new byte[8];
|
||||
System.Text.Encoding.GetEncoding(1252).GetBytes(name, 0, name.Length, SourceName, 0);
|
||||
if (!ADVAPI32.AllocateLocallyUniqueId(out SourceIdentifier))
|
||||
throw new System.ComponentModel.Win32Exception();
|
||||
}
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] SourceName;
|
||||
public IntPtr SourceIdentifier;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct KERB_INTERACTIVE_LOGON
|
||||
{
|
||||
public KERB_LOGON_SUBMIT_TYPE MessageType;
|
||||
public string LogonDomainName;
|
||||
public string UserName;
|
||||
public string Password;
|
||||
}
|
||||
public enum KERB_LOGON_SUBMIT_TYPE
|
||||
{
|
||||
KerbInteractiveLogon = 2,
|
||||
KerbSmartCardLogon = 6,
|
||||
KerbWorkstationUnlockLogon = 7,
|
||||
KerbSmartCardUnlockLogon = 8,
|
||||
KerbProxyLogon = 9,
|
||||
KerbTicketLogon = 10,
|
||||
KerbTicketUnlockLogon = 11,
|
||||
KerbS4ULogon = 12,
|
||||
KerbCertificateLogon = 13,
|
||||
KerbCertificateS4ULogon = 14,
|
||||
KerbCertificateUnlockLogon = 15
|
||||
}
|
||||
public enum TOKEN_INFORMATION_CLASS
|
||||
{
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_USER structure that contains the user account of the token.
|
||||
/// </summary>
|
||||
TokenUser = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token.
|
||||
/// </summary>
|
||||
TokenGroups,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token.
|
||||
/// </summary>
|
||||
TokenPrivileges,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects.
|
||||
/// </summary>
|
||||
TokenOwner,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects.
|
||||
/// </summary>
|
||||
TokenPrimaryGroup,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects.
|
||||
/// </summary>
|
||||
TokenDefaultDacl,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information.
|
||||
/// </summary>
|
||||
TokenSource,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token.
|
||||
/// </summary>
|
||||
TokenType,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a SECURITY_IMPERSONATION_LEVEL value that indicates the impersonation level of the token. If the access token is not an impersonation token, the function fails.
|
||||
/// </summary>
|
||||
TokenImpersonationLevel,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics.
|
||||
/// </summary>
|
||||
TokenStatistics,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token.
|
||||
/// </summary>
|
||||
TokenRestrictedSids,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token.
|
||||
/// </summary>
|
||||
TokenSessionId,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_GROUPS_AND_PRIVILEGES structure that contains the user SID, the group accounts, the restricted SIDs, and the authentication ID associated with the token.
|
||||
/// </summary>
|
||||
TokenGroupsAndPrivileges,
|
||||
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
TokenSessionReference,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag.
|
||||
/// </summary>
|
||||
TokenSandBoxInert,
|
||||
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
TokenAuditPolicy,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ORIGIN value.
|
||||
/// </summary>
|
||||
TokenOrigin,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token.
|
||||
/// </summary>
|
||||
TokenElevationType,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token.
|
||||
/// </summary>
|
||||
TokenLinkedToken,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated.
|
||||
/// </summary>
|
||||
TokenElevation,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if the token has ever been filtered.
|
||||
/// </summary>
|
||||
TokenHasRestrictions,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token.
|
||||
/// </summary>
|
||||
TokenAccessInformation,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token.
|
||||
/// </summary>
|
||||
TokenVirtualizationAllowed,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token.
|
||||
/// </summary>
|
||||
TokenVirtualizationEnabled,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level.
|
||||
/// </summary>
|
||||
TokenIntegrityLevel,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set.
|
||||
/// </summary>
|
||||
TokenUIAccess,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy.
|
||||
/// </summary>
|
||||
TokenMandatoryPolicy,
|
||||
|
||||
/// <summary>
|
||||
/// The buffer receives the token's logon security identifier (SID).
|
||||
/// </summary>
|
||||
TokenLogonSid,
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value for this enumeration
|
||||
/// </summary>
|
||||
MaxTokenInfoClass
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct QUOTA_LIMITS
|
||||
{
|
||||
UInt32 PagedPoolLimit;
|
||||
UInt32 NonPagedPoolLimit;
|
||||
UInt32 MinimumWorkingSetSize;
|
||||
UInt32 MaximumWorkingSetSize;
|
||||
UInt32 PagefileLimit;
|
||||
Int64 TimeLimit;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LSA_STRING
|
||||
{
|
||||
public UInt16 Length;
|
||||
public UInt16 MaximumLength;
|
||||
public /*PCHAR*/ IntPtr Buffer;
|
||||
}
|
||||
|
||||
|
||||
[DllImport("secur32.dll", SetLastError = true)]
|
||||
public static extern WinStatusCodes LsaLogonUser(
|
||||
[In] IntPtr LsaHandle,
|
||||
[In] ref LSA_STRING OriginName,
|
||||
[In] SecurityLogonType LogonType,
|
||||
[In] UInt32 AuthenticationPackage,
|
||||
[In] IntPtr AuthenticationInformation,
|
||||
[In] UInt32 AuthenticationInformationLength,
|
||||
[In] /*PTOKEN_GROUPS*/ IntPtr LocalGroups,
|
||||
[In] ref TOKEN_SOURCE SourceContext,
|
||||
[Out] /*PVOID*/ out IntPtr ProfileBuffer,
|
||||
[Out] out UInt32 ProfileBufferLength,
|
||||
[Out] out Int64 LogonId,
|
||||
[Out] out IntPtr Token,
|
||||
[Out] out QUOTA_LIMITS Quotas,
|
||||
[Out] out WinStatusCodes SubStatus
|
||||
);
|
||||
|
||||
[DllImport("secur32.dll", SetLastError = true)]
|
||||
public static extern WinStatusCodes LsaRegisterLogonProcess(
|
||||
IntPtr LogonProcessName,
|
||||
out IntPtr LsaHandle,
|
||||
out ulong SecurityMode
|
||||
);
|
||||
|
||||
[DllImport("secur32.dll", SetLastError = false)]
|
||||
public static extern WinStatusCodes LsaLookupAuthenticationPackage([In] IntPtr LsaHandle, [In] ref LSA_STRING PackageName, [Out] out UInt32 AuthenticationPackage);
|
||||
|
||||
[DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
internal static extern int LsaConnectUntrusted(
|
||||
[In, Out] ref SafeLsaLogonProcessHandle LsaHandle);
|
||||
|
||||
[DllImport("secur32.dll", SetLastError = false)]
|
||||
public static extern WinStatusCodes LsaConnectUntrusted([Out] out IntPtr LsaHandle);
|
||||
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
internal sealed class SafeLsaLogonProcessHandle : SafeHandleZeroOrMinusOneIsInvalid
|
||||
{
|
||||
private SafeLsaLogonProcessHandle() : base(true) { }
|
||||
|
||||
// 0 is an Invalid Handle
|
||||
internal SafeLsaLogonProcessHandle(IntPtr handle) : base(true)
|
||||
{
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
internal static SafeLsaLogonProcessHandle InvalidHandle
|
||||
{
|
||||
get { return new SafeLsaLogonProcessHandle(IntPtr.Zero); }
|
||||
}
|
||||
|
||||
[System.Security.SecurityCritical]
|
||||
override protected bool ReleaseHandle()
|
||||
{
|
||||
// LsaDeregisterLogonProcess returns an NTSTATUS
|
||||
return LsaDeregisterLogonProcess(handle) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("secur32.dll", SetLastError = true)]
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
internal static extern int LsaDeregisterLogonProcess(IntPtr handle);
|
||||
|
||||
|
||||
public static void CreateNewSession()
|
||||
{
|
||||
var kli = new SECUR32.KERB_INTERACTIVE_LOGON()
|
||||
{
|
||||
MessageType = SECUR32.KERB_LOGON_SUBMIT_TYPE.KerbInteractiveLogon,
|
||||
UserName = "",
|
||||
Password = ""
|
||||
};
|
||||
IntPtr pluid;
|
||||
IntPtr lsaHan;
|
||||
uint authPackID;
|
||||
IntPtr kerbLogInfo;
|
||||
SECUR32.LSA_STRING logonProc = new SECUR32.LSA_STRING()
|
||||
{
|
||||
Buffer = Marshal.StringToHGlobalAuto("InstaLogon"),
|
||||
Length = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon")),
|
||||
MaximumLength = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon"))
|
||||
};
|
||||
SECUR32.LSA_STRING originName = new SECUR32.LSA_STRING()
|
||||
{
|
||||
Buffer = Marshal.StringToHGlobalAuto("InstaLogon"),
|
||||
Length = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon")),
|
||||
MaximumLength = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon"))
|
||||
};
|
||||
SECUR32.LSA_STRING authPackage = new SECUR32.LSA_STRING()
|
||||
{
|
||||
Buffer = Marshal.StringToHGlobalAuto("MICROSOFT_KERBEROS_NAME_A"),
|
||||
Length = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("MICROSOFT_KERBEROS_NAME_A")),
|
||||
MaximumLength = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("MICROSOFT_KERBEROS_NAME_A"))
|
||||
};
|
||||
IntPtr hLogonProc = Marshal.AllocHGlobal(Marshal.SizeOf(logonProc));
|
||||
Marshal.StructureToPtr(logonProc, hLogonProc, false);
|
||||
ADVAPI32.AllocateLocallyUniqueId(out pluid);
|
||||
LsaConnectUntrusted(out lsaHan);
|
||||
//SECUR32.LsaRegisterLogonProcess(hLogonProc, out lsaHan, out secMode);
|
||||
SECUR32.LsaLookupAuthenticationPackage(lsaHan, ref authPackage, out authPackID);
|
||||
|
||||
kerbLogInfo = Marshal.AllocHGlobal(Marshal.SizeOf(kli));
|
||||
Marshal.StructureToPtr(kli, kerbLogInfo, false);
|
||||
|
||||
var ts = new SECUR32.TOKEN_SOURCE("Insta");
|
||||
IntPtr profBuf;
|
||||
uint profBufLen;
|
||||
long logonID;
|
||||
IntPtr logonToken;
|
||||
SECUR32.QUOTA_LIMITS quotas;
|
||||
SECUR32.WinStatusCodes subStatus;
|
||||
SECUR32.LsaLogonUser(lsaHan, ref originName, SECUR32.SecurityLogonType.Interactive, authPackID, kerbLogInfo, (uint)Marshal.SizeOf(kerbLogInfo), IntPtr.Zero, ref ts, out profBuf, out profBufLen, out logonID, out logonToken, out quotas, out subStatus);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,43 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Remotely_Library.Win32
|
||||
{
|
||||
public static class WTSAPI32
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WTS_SESSION_INFO
|
||||
{
|
||||
public Int32 SessionID;
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public String pWinStationName;
|
||||
public WTS_CONNECTSTATE_CLASS State;
|
||||
}
|
||||
public enum WTS_CONNECTSTATE_CLASS
|
||||
{
|
||||
WTSActive,
|
||||
WTSConnected,
|
||||
WTSConnectQuery,
|
||||
WTSShadow,
|
||||
WTSDisconnected,
|
||||
WTSIdle,
|
||||
WTSListen,
|
||||
WTSReset,
|
||||
WTSDown,
|
||||
WTSInit
|
||||
}
|
||||
public static IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
|
||||
|
||||
[DllImport("wtsapi32.dll", SetLastError = true)]
|
||||
static extern IntPtr WTSOpenServer(string pServerName);
|
||||
|
||||
[DllImport("wtsapi32.dll", SetLastError = true)]
|
||||
public static extern int WTSEnumerateSessions(
|
||||
System.IntPtr hServer,
|
||||
int Reserved,
|
||||
int Version,
|
||||
ref System.IntPtr ppSessionInfo,
|
||||
ref int pCount);
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
using Remotely_Library.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using static Remotely_Library.Win32.ADVAPI32;
|
||||
using static Remotely_Library.Win32.User32;
|
||||
|
||||
namespace Remotely_Library.Win32
|
||||
{
|
||||
public class Win32Interop
|
||||
{
|
||||
public static bool OpenInteractiveProcess(string applicationName, string desktopName, bool hiddenWindow, out PROCESS_INFORMATION procInfo)
|
||||
{
|
||||
uint winlogonPid = 0;
|
||||
IntPtr hUserTokenDup = IntPtr.Zero, hPToken = IntPtr.Zero, hProcess = IntPtr.Zero;
|
||||
procInfo = new PROCESS_INFORMATION();
|
||||
|
||||
// Obtain session ID for active session.
|
||||
uint dwSessionId = Kernel32.WTSGetActiveConsoleSessionId();
|
||||
|
||||
// Check for RDP session. If active, use that session ID instead.
|
||||
var rdpSessionID = GetRDPSession();
|
||||
if (rdpSessionID > 0)
|
||||
{
|
||||
dwSessionId = rdpSessionID;
|
||||
}
|
||||
|
||||
// Obtain the process ID of the winlogon process that is running within the currently active session.
|
||||
Process[] processes = Process.GetProcessesByName("winlogon");
|
||||
foreach (Process p in processes)
|
||||
{
|
||||
if ((uint)p.SessionId == dwSessionId)
|
||||
{
|
||||
winlogonPid = (uint)p.Id;
|
||||
}
|
||||
}
|
||||
|
||||
// Obtain a handle to the winlogon process.
|
||||
hProcess = Kernel32.OpenProcess(MAXIMUM_ALLOWED, false, winlogonPid);
|
||||
|
||||
// Obtain a handle to the access token of the winlogon process.
|
||||
if (!OpenProcessToken(hProcess, TOKEN_DUPLICATE, ref hPToken))
|
||||
{
|
||||
Kernel32.CloseHandle(hProcess);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Security attibute structure used in DuplicateTokenEx and CreateProcessAsUser.
|
||||
SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
|
||||
sa.Length = Marshal.SizeOf(sa);
|
||||
|
||||
// Copy the access token of the winlogon process; the newly created token will be a primary token.
|
||||
if (!DuplicateTokenEx(hPToken, MAXIMUM_ALLOWED, ref sa, SECURITY_IMPERSONATION_LEVEL.SecurityIdentification, TOKEN_TYPE.TokenPrimary, out hUserTokenDup))
|
||||
{
|
||||
Kernel32.CloseHandle(hProcess);
|
||||
Kernel32.CloseHandle(hPToken);
|
||||
return false;
|
||||
}
|
||||
|
||||
// By default, CreateProcessAsUser creates a process on a non-interactive window station, meaning
|
||||
// the window station has a desktop that is invisible and the process is incapable of receiving
|
||||
// user input. To remedy this we set the lpDesktop parameter to indicate we want to enable user
|
||||
// interaction with the new process.
|
||||
STARTUPINFO si = new STARTUPINFO();
|
||||
si.cb = Marshal.SizeOf(si);
|
||||
si.lpDesktop = @"winsta0\" + desktopName;
|
||||
|
||||
// Flags that specify the priority and creation method of the process.
|
||||
uint dwCreationFlags;
|
||||
if (hiddenWindow)
|
||||
{
|
||||
dwCreationFlags = NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW | DETACHED_PROCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwCreationFlags = NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE;
|
||||
}
|
||||
|
||||
// Create a new process in the current user's logon session.
|
||||
bool result = CreateProcessAsUser(hUserTokenDup, null, applicationName, ref sa, ref sa, false, dwCreationFlags, IntPtr.Zero, null, ref si, out procInfo);
|
||||
|
||||
// Invalidate the handles.
|
||||
Kernel32.CloseHandle(hProcess);
|
||||
Kernel32.CloseHandle(hPToken);
|
||||
Kernel32.CloseHandle(hUserTokenDup);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static uint GetRDPSession()
|
||||
{
|
||||
IntPtr ppSessionInfo = IntPtr.Zero;
|
||||
Int32 count = 0;
|
||||
Int32 retval = WTSAPI32.WTSEnumerateSessions(WTSAPI32.WTS_CURRENT_SERVER_HANDLE, 0, 1, ref ppSessionInfo, ref count);
|
||||
Int32 dataSize = Marshal.SizeOf(typeof(WTSAPI32.WTS_SESSION_INFO));
|
||||
var sessList = new List<WTSAPI32.WTS_SESSION_INFO>();
|
||||
Int64 current = (Int64)ppSessionInfo;
|
||||
|
||||
if (retval != 0)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
WTSAPI32.WTS_SESSION_INFO sessInf = (WTSAPI32.WTS_SESSION_INFO)Marshal.PtrToStructure((System.IntPtr)current, typeof(WTSAPI32.WTS_SESSION_INFO));
|
||||
current += dataSize;
|
||||
sessList.Add(sessInf);
|
||||
}
|
||||
}
|
||||
uint retVal = 0;
|
||||
var rdpSession = sessList.Find(ses => ses.pWinStationName.ToLower().Contains("rdp") && ses.State == 0);
|
||||
if (sessList.Exists(ses => ses.pWinStationName.ToLower().Contains("rdp") && ses.State == 0))
|
||||
{
|
||||
retVal = (uint)rdpSession.SessionID;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public static IntPtr OpenInputDesktop()
|
||||
{
|
||||
return User32.OpenInputDesktop(0, false, ACCESS_MASK.GENERIC_ALL);
|
||||
}
|
||||
public static string GetCurrentDesktop()
|
||||
{
|
||||
var inputDesktop = OpenInputDesktop();
|
||||
byte[] deskBytes = new byte[256];
|
||||
uint lenNeeded;
|
||||
var success = GetUserObjectInformationW(inputDesktop, UOI_NAME, deskBytes, 256, out lenNeeded);
|
||||
if (!success)
|
||||
{
|
||||
CloseDesktop(inputDesktop);
|
||||
return "Default";
|
||||
}
|
||||
var desktopName = Encoding.Unicode.GetString(deskBytes.Take((int)lenNeeded).ToArray()).Replace("\0", "");
|
||||
CloseDesktop(inputDesktop);
|
||||
return desktopName;
|
||||
}
|
||||
public static void SetMonitorState(MonitorState state)
|
||||
{
|
||||
User32.SendMessage(0xFFFF, 0x112, 0xF170, (int)state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1 +1 @@
|
||||
2019.04.04.0721
|
||||
2019.04.05.2344
|
||||
|
||||
@ -52,7 +52,9 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
Set-Location -Path (Get-Item -Path $PSScriptRoot).Parent.FullName
|
||||
$Root = (Get-Item -Path $PSScriptRoot).Parent.FullName
|
||||
|
||||
Set-Location -Path $Root
|
||||
|
||||
if ($ArgList.Contains("c")) {
|
||||
# Add Current Version file to root content folder for client update checks.
|
||||
@ -79,15 +81,15 @@ if ($ArgList.Contains("c")) {
|
||||
|
||||
Pop-Location
|
||||
|
||||
New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\ScreenCast\" -ItemType Directory -Force
|
||||
New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x86\publish\ScreenCast\" -ItemType Directory -Force
|
||||
New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" -ItemType Directory -Force
|
||||
|
||||
|
||||
# Publish Linux ScreenCaster
|
||||
dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion --runtime linux-x64 --configuration Release --output ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" ".\Remotely_ScreenCast.Linux\"
|
||||
dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion --runtime linux-x64 --configuration Release --output "$Root\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" "$Root\Remotely_ScreenCast.Linux\"
|
||||
|
||||
|
||||
New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\ScreenCast\" -ItemType Directory -Force
|
||||
New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x86\publish\ScreenCast\" -ItemType Directory -Force
|
||||
#New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" -ItemType Directory -Force
|
||||
|
||||
# Copy .NET Framework ScreenCaster to Agent output folder.
|
||||
if ((Test-Path -Path ".\Remotely_ScreenCast.Win\bin\Release\Remotely_ScreenCast.exe") -eq $true) {
|
||||
Copy-Item -Path ".\Remotely_ScreenCast.Win\bin\Release\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\ScreenCast\Remotely_ScreenCast.exe" -Force
|
||||
|
||||
Loading…
Reference in New Issue
Block a user