From 2a747334bd926d79537b9e8d4f38c79a815752e5 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 7 Mar 2017 14:56:48 -0500 Subject: WHOA HACKING --- ShiftOS_TheReturn/TerminalBackend.cs | 156 ++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 74 deletions(-) (limited to 'ShiftOS_TheReturn/TerminalBackend.cs') diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 3c8e62a..8be54d0 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -139,121 +139,129 @@ namespace ShiftOS.Engine { if (Shiftorium.UpgradeAttributesUnlocked(type)) { - foreach (var a in type.GetCustomAttributes(false)) + if (KernelWatchdog.IsSafe(type)) { - if (a is Namespace) + foreach (var a in type.GetCustomAttributes(false)) { - var ns = a as Namespace; - if (text.Split('.')[0] == ns.name) + if (a is Namespace) { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + var ns = a as Namespace; + if (text.Split('.')[0] == ns.name) { - if (Shiftorium.UpgradeAttributesUnlocked(method)) + foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - if (CanRunRemotely(method, isRemote)) + if (Shiftorium.UpgradeAttributesUnlocked(method)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (KernelWatchdog.IsSafe(method)) { - if (ma is Command) + if (CanRunRemotely(method, isRemote)) { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) + foreach (var ma in method.GetCustomAttributes(false)) { - - var attr = method.GetCustomAttribute(); - - if (attr != null) + if (ma is Command) { - string newcommand = attr.newcommand; - if (attr.warn) + var cmd = ma as Command; + if (text.Split('.')[1] == cmd.name) { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { + + var attr = method.GetCustomAttribute(); + + if (attr != null) + { + string newcommand = attr.newcommand; + if (attr.warn) + { + Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { {"%newcommand", newcommand} })); - } - if (newcommand != "") - { - // redo the entire process running newcommand - - return RunClient(newcommand, args); - } - } + } + if (newcommand != "") + { + // redo the entire process running newcommand - var requiresArgs = method.GetCustomAttributes(); + return RunClient(newcommand, args); + } + } - bool error = false; - bool providedusage = false; + var requiresArgs = method.GetCustomAttributes(); - foreach (RequiresArgument argument in requiresArgs) - { - if (!args.ContainsKey(argument.argument)) - { + bool error = false; + bool providedusage = false; - if (!providedusage) + foreach (RequiresArgument argument in requiresArgs) { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { + if (!args.ContainsKey(argument.argument)) + { + + if (!providedusage) + { + string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; + if (usageparse == Localization.Parse(usageparse)) + usageparse = ""; + else + usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { {"%ns", ns.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine(usageparse); + Console.WriteLine(usageparse); - providedusage = true; - } + providedusage = true; + } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { + if (Shiftorium.UpgradeInstalled("help_usage")) + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { {"%argument", argument.argument} })); + } + else + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + } + + error = true; + } } - else + + if (error) { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + throw new Exception("{ERROR_COMMAND_WRONG}"); } - error = true; + try + { + return (bool)method.Invoke(null, new[] { args }); + } + catch (TargetInvocationException e) + { + Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); + Console.WriteLine(e.InnerException.Message); + Console.WriteLine(e.InnerException.StackTrace); + return true; + } + catch + { + return (bool)method.Invoke(null, new object[] { }); + } } } - - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); - } - - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } } } + 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; + } } } } } } + } } } -- cgit v1.2.3