mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-23 02:12:14 +00:00
my hands are typing words\
This commit is contained in:
parent
f26bab8310
commit
a41f947d8a
2 changed files with 66 additions and 17 deletions
|
@ -66,41 +66,54 @@ namespace ShiftOS.Engine
|
|||
|
||||
public static bool IsSafe(Type type)
|
||||
{
|
||||
if (InKernelMode == true)
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
|
||||
foreach (var attrib in type.GetCustomAttributes(false))
|
||||
{
|
||||
if (attrib is KernelModeAttribute)
|
||||
{
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsSafe(MethodInfo type)
|
||||
{
|
||||
if (InKernelMode == true)
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
|
||||
foreach (var attrib in type.GetCustomAttributes(false))
|
||||
{
|
||||
if (attrib is KernelModeAttribute)
|
||||
{
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static string regularUsername = "";
|
||||
|
||||
|
||||
public static void EnterKernelMode()
|
||||
{
|
||||
InKernelMode = true;
|
||||
Console.WriteLine("<kernel> Watchdog deactivated, system-level access granted.");
|
||||
regularUsername = SaveSystem.CurrentUser.Username;
|
||||
SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == "root");
|
||||
|
||||
}
|
||||
|
||||
public static void LeaveKernelMode()
|
||||
{
|
||||
InKernelMode = false;
|
||||
Console.WriteLine("<kernel> Kernel mode disabled.");
|
||||
var user = SaveSystem.Users.FirstOrDefault(x => x.Username == regularUsername);
|
||||
if (user == null)
|
||||
throw new Exception("User not in root mode.");
|
||||
SaveSystem.CurrentUser = user;
|
||||
}
|
||||
|
||||
internal static bool CanRunOffline(Type method)
|
||||
|
|
|
@ -323,6 +323,23 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
else
|
||||
{
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin)
|
||||
{
|
||||
Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) =>
|
||||
{
|
||||
if (pass == SaveSystem.CurrentUser.Password)
|
||||
{
|
||||
KernelWatchdog.EnterKernelMode();
|
||||
RunClient(text, args, isRemote);
|
||||
KernelWatchdog.LeaveKernelMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Infobox.Show("Access denied.", "You did not type in the correct password.");
|
||||
}
|
||||
}, true);
|
||||
return true;
|
||||
}
|
||||
Console.Write("<");
|
||||
ConsoleEx.Bold = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkRed;
|
||||
|
@ -332,25 +349,27 @@ namespace ShiftOS.Engine
|
|||
Console.Write(">");
|
||||
ConsoleEx.Italic = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine(" You cannot run this command.");
|
||||
Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported.");
|
||||
KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(text + " cannot be ran in a remote session");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Console.WriteLine(text + " cannot be ran in a remote session");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
Console.Write("<");
|
||||
|
@ -366,10 +385,27 @@ namespace ShiftOS.Engine
|
|||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin)
|
||||
{
|
||||
Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) =>
|
||||
{
|
||||
if (pass == SaveSystem.CurrentUser.Password)
|
||||
{
|
||||
KernelWatchdog.EnterKernelMode();
|
||||
RunClient(text, args, isRemote);
|
||||
KernelWatchdog.LeaveKernelMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Infobox.Show("Access denied.", "You did not type in the correct password.");
|
||||
}
|
||||
}, true);
|
||||
return true;
|
||||
}
|
||||
Console.Write("<");
|
||||
ConsoleEx.Bold = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkRed;
|
||||
|
@ -379,7 +415,7 @@ namespace ShiftOS.Engine
|
|||
Console.Write(">");
|
||||
ConsoleEx.Italic = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine(" You cannot run this command.");
|
||||
Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported.");
|
||||
KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir.");
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue