From 18079c6f43981f1bf9fc093b3c5b68873fe90348 Mon Sep 17 00:00:00 2001 From: william341 Date: Thu, 27 Jul 2017 16:34:27 -0700 Subject: [PATCH] hacking p1 --- .../{ => Hacking}/HackableProvider.cs | 10 ++++ .../{ => Hacking}/HackerTestCommands.cs | 0 .../Properties/Resources.Designer.cs | 53 +++++++++++++++---- ShiftOS.Frontend/Resources/Exploits.txt | 13 +++++ ShiftOS.Frontend/Resources/Payloads.txt | 14 +++++ ShiftOS.Objects/Hacking/Exploit.cs | 30 +++++++++++ ShiftOS.Objects/{ => Hacking}/Hackable.cs | 0 ShiftOS.Objects/Hacking/Payload.cs | 31 +++++++++++ .../{ => GUI}/FileSkimmerBackend.cs | 0 ShiftOS_TheReturn/{ => GUI}/IShiftOSWindow.cs | 0 ShiftOS_TheReturn/{ => GUI}/IStatusIcon.cs | 0 .../{ => GUI}/OutOfBoxExperience.cs | 0 ShiftOS_TheReturn/{ => GUI}/Skinning.cs | 0 .../{ => GUI}/TutorialManager.cs | 0 .../{ => GUI}/WinOpenAttribute.cs | 0 ShiftOS_TheReturn/Hacking.cs | 23 +++++++- 16 files changed, 161 insertions(+), 13 deletions(-) rename ShiftOS.Frontend/{ => Hacking}/HackableProvider.cs (70%) rename ShiftOS.Frontend/{ => Hacking}/HackerTestCommands.cs (100%) create mode 100644 ShiftOS.Frontend/Resources/Exploits.txt create mode 100644 ShiftOS.Frontend/Resources/Payloads.txt create mode 100644 ShiftOS.Objects/Hacking/Exploit.cs rename ShiftOS.Objects/{ => Hacking}/Hackable.cs (100%) create mode 100644 ShiftOS.Objects/Hacking/Payload.cs rename ShiftOS_TheReturn/{ => GUI}/FileSkimmerBackend.cs (100%) rename ShiftOS_TheReturn/{ => GUI}/IShiftOSWindow.cs (100%) rename ShiftOS_TheReturn/{ => GUI}/IStatusIcon.cs (100%) rename ShiftOS_TheReturn/{ => GUI}/OutOfBoxExperience.cs (100%) rename ShiftOS_TheReturn/{ => GUI}/Skinning.cs (100%) rename ShiftOS_TheReturn/{ => GUI}/TutorialManager.cs (100%) rename ShiftOS_TheReturn/{ => GUI}/WinOpenAttribute.cs (100%) diff --git a/ShiftOS.Frontend/HackableProvider.cs b/ShiftOS.Frontend/Hacking/HackableProvider.cs similarity index 70% rename from ShiftOS.Frontend/HackableProvider.cs rename to ShiftOS.Frontend/Hacking/HackableProvider.cs index 1c57f37..6198b0c 100644 --- a/ShiftOS.Frontend/HackableProvider.cs +++ b/ShiftOS.Frontend/Hacking/HackableProvider.cs @@ -16,6 +16,16 @@ namespace ShiftOS.Frontend return JsonConvert.DeserializeObject(Properties.Resources.Hackables); } + public Exploit[] GetExploits() + { + return JsonConvert.DeserializeObject(Properties.Resources.Exploits); + } + + public Payload[] GetPayloads() + { + return JsonConvert.DeserializeObject(Properties.Resources.Payloads); + } + public byte[] GetLootFromResource(string resId) { return new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }; //nyi diff --git a/ShiftOS.Frontend/HackerTestCommands.cs b/ShiftOS.Frontend/Hacking/HackerTestCommands.cs similarity index 100% rename from ShiftOS.Frontend/HackerTestCommands.cs rename to ShiftOS.Frontend/Hacking/HackerTestCommands.cs diff --git a/ShiftOS.Frontend/Properties/Resources.Designer.cs b/ShiftOS.Frontend/Properties/Resources.Designer.cs index 3d40c29..e21b46e 100644 --- a/ShiftOS.Frontend/Properties/Resources.Designer.cs +++ b/ShiftOS.Frontend/Properties/Resources.Designer.cs @@ -22,7 +22,7 @@ namespace ShiftOS.Frontend.Properties { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { + public class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ namespace ShiftOS.Frontend.Properties { /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShiftOS.Frontend.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ namespace ShiftOS.Frontend.Properties { /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -63,13 +63,22 @@ namespace ShiftOS.Frontend.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap cursor_9x_pointer { + public static System.Drawing.Bitmap cursor_9x_pointer { get { object obj = ResourceManager.GetObject("cursor_9x_pointer", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } + /// + /// Looks up a localized string similar to . + /// + public static string Exploits { + get { + return ResourceManager.GetString("Exploits", resourceCulture); + } + } + /// /// Looks up a localized string similar to /* ShiftOS hackables data file /// * @@ -93,7 +102,7 @@ namespace ShiftOS.Frontend.Properties { /// } ///]. /// - internal static string Hackables { + public static string Hackables { get { return ResourceManager.GetString("Hackables", resourceCulture); } @@ -102,7 +111,7 @@ namespace ShiftOS.Frontend.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap justthes { + public static System.Drawing.Bitmap justthes { get { object obj = ResourceManager.GetObject("justthes", resourceCulture); return ((System.Drawing.Bitmap)(obj)); @@ -114,16 +123,38 @@ namespace ShiftOS.Frontend.Properties { /// ///[]. /// - internal static string LootInfo { + public static string LootInfo { get { return ResourceManager.GetString("LootInfo", resourceCulture); } } + /// + /// Looks up a localized string similar to /* ShiftOS Payloads data file + /// * + /// * This file contains information about all payloads in the game's campaign. + /// * + /// */ + /// + ///[ + /// { + /// FriendlyName: "FTP Exploit", + /// PayloadName: "ftpull" + /// EffectiveAgainstFirewall: 1, + /// EffectiveAgainstPort: "FileServer", + /// } + ///]. + /// + public static string Payloads { + get { + return ResourceManager.GetString("Payloads", resourceCulture); + } + } + /// /// Looks up a localized string similar to []. /// - internal static string Shiftorium { + public static string Shiftorium { get { return ResourceManager.GetString("Shiftorium", resourceCulture); } @@ -140,7 +171,7 @@ namespace ShiftOS.Frontend.Properties { /// ///Commands können mit argumenten versehen werden, indem du ein key-value Paar in einem {} Block hinter dem command angibst. Zum Be [rest of string was truncated]";. /// - internal static string strings_de { + public static string strings_de { get { return ResourceManager.GetString("strings_de", resourceCulture); } @@ -165,7 +196,7 @@ namespace ShiftOS.Frontend.Properties { /// "{GEN_PASSWORD}": "Password", /// "{GEN_LPROMPT [rest of string was truncated]";. /// - internal static string strings_en { + public static string strings_en { get { return ResourceManager.GetString("strings_en", resourceCulture); } @@ -189,7 +220,7 @@ namespace ShiftOS.Frontend.Properties { /// "{GEN_SYSTEMNAME}": "Nom de système", /// "{GEN_PASSWORD}": "Mot de [rest of string was truncated]";. /// - internal static string strings_fr { + public static string strings_fr { get { return ResourceManager.GetString("strings_fr", resourceCulture); } diff --git a/ShiftOS.Frontend/Resources/Exploits.txt b/ShiftOS.Frontend/Resources/Exploits.txt new file mode 100644 index 0000000..0e0dd64 --- /dev/null +++ b/ShiftOS.Frontend/Resources/Exploits.txt @@ -0,0 +1,13 @@ +/* ShiftOS Exploits data file + * + * This file contains information about all exploits in the game's campaign. + * + */ + +[ + { + FriendlyName: "FTP Exploit", + ExploitName: "ftpwn" + EffectiveAgainstPort: "FileServer", + } +] \ No newline at end of file diff --git a/ShiftOS.Frontend/Resources/Payloads.txt b/ShiftOS.Frontend/Resources/Payloads.txt new file mode 100644 index 0000000..926a23f --- /dev/null +++ b/ShiftOS.Frontend/Resources/Payloads.txt @@ -0,0 +1,14 @@ +/* ShiftOS Payloads data file + * + * This file contains information about all payloads in the game's campaign. + * + */ + +[ + { + FriendlyName: "FTP Exploit", + PayloadName: "ftpull" + EffectiveAgainstFirewall: 1, + EffectiveAgainstPort: "FileServer", + } +] \ No newline at end of file diff --git a/ShiftOS.Objects/Hacking/Exploit.cs b/ShiftOS.Objects/Hacking/Exploit.cs new file mode 100644 index 0000000..7e83c3a --- /dev/null +++ b/ShiftOS.Objects/Hacking/Exploit.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class Exploit + { + public string FriendlyName { get; set; } + public string ExploitName { get; set; } + public SystemType EffectiveAgainst { get; set; } + public string Dependencies { get; set; } + + public string ID + { + get + { + return ExploitName.ToLower().Replace(" ", "_"); + } + } + + public override string ToString() + { + return $"{FriendlyName} ({ExploitName})"; + } + } + +} diff --git a/ShiftOS.Objects/Hackable.cs b/ShiftOS.Objects/Hacking/Hackable.cs similarity index 100% rename from ShiftOS.Objects/Hackable.cs rename to ShiftOS.Objects/Hacking/Hackable.cs diff --git a/ShiftOS.Objects/Hacking/Payload.cs b/ShiftOS.Objects/Hacking/Payload.cs new file mode 100644 index 0000000..a3800fa --- /dev/null +++ b/ShiftOS.Objects/Hacking/Payload.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class Payload + { + public string FriendlyName { get; set; } + public string PayloadName { get; set; } + public int EffectiveAgainstFirewall { get; set; } + public SystemType EffectiveAgainstPort { get; set; } + public string Dependencies { get; set; } + + public string ID + { + get + { + return PayloadName.ToLower().Replace(" ", "_"); + } + } + + public override string ToString() + { + return $"{FriendlyName} ({PayloadName})"; + } + } + +} diff --git a/ShiftOS_TheReturn/FileSkimmerBackend.cs b/ShiftOS_TheReturn/GUI/FileSkimmerBackend.cs similarity index 100% rename from ShiftOS_TheReturn/FileSkimmerBackend.cs rename to ShiftOS_TheReturn/GUI/FileSkimmerBackend.cs diff --git a/ShiftOS_TheReturn/IShiftOSWindow.cs b/ShiftOS_TheReturn/GUI/IShiftOSWindow.cs similarity index 100% rename from ShiftOS_TheReturn/IShiftOSWindow.cs rename to ShiftOS_TheReturn/GUI/IShiftOSWindow.cs diff --git a/ShiftOS_TheReturn/IStatusIcon.cs b/ShiftOS_TheReturn/GUI/IStatusIcon.cs similarity index 100% rename from ShiftOS_TheReturn/IStatusIcon.cs rename to ShiftOS_TheReturn/GUI/IStatusIcon.cs diff --git a/ShiftOS_TheReturn/OutOfBoxExperience.cs b/ShiftOS_TheReturn/GUI/OutOfBoxExperience.cs similarity index 100% rename from ShiftOS_TheReturn/OutOfBoxExperience.cs rename to ShiftOS_TheReturn/GUI/OutOfBoxExperience.cs diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/GUI/Skinning.cs similarity index 100% rename from ShiftOS_TheReturn/Skinning.cs rename to ShiftOS_TheReturn/GUI/Skinning.cs diff --git a/ShiftOS_TheReturn/TutorialManager.cs b/ShiftOS_TheReturn/GUI/TutorialManager.cs similarity index 100% rename from ShiftOS_TheReturn/TutorialManager.cs rename to ShiftOS_TheReturn/GUI/TutorialManager.cs diff --git a/ShiftOS_TheReturn/WinOpenAttribute.cs b/ShiftOS_TheReturn/GUI/WinOpenAttribute.cs similarity index 100% rename from ShiftOS_TheReturn/WinOpenAttribute.cs rename to ShiftOS_TheReturn/GUI/WinOpenAttribute.cs diff --git a/ShiftOS_TheReturn/Hacking.cs b/ShiftOS_TheReturn/Hacking.cs index 9ace50e..1e66f26 100644 --- a/ShiftOS_TheReturn/Hacking.cs +++ b/ShiftOS_TheReturn/Hacking.cs @@ -10,6 +10,8 @@ namespace ShiftOS.Engine { private static List _activeConnections = new List(); private static List Hackables = new List(); + private static List Exploits = new List(); + private static List Payloads = new List(); private static List Loot = new List(); public static HackableSystem CurrentHackable { get; private set; } @@ -22,6 +24,21 @@ namespace ShiftOS.Engine } } + public static Objects.Exploit[] AvailableExploits + { + get + { + return Exploits.Where(x => Shiftorium.UpgradeInstalled(x.Dependencies) && !Shiftorium.UpgradeInstalled(x.ID)).ToArray(); + } + } + + public static Objects.Payload[] AvailablePayloads + { + get + { + return Payloads.Where(x => Shiftorium.UpgradeInstalled(x.Dependencies) && !Shiftorium.UpgradeInstalled(x.ID)).ToArray(); + } + } public static HackableSystem[] ActiveConnections { @@ -178,10 +195,10 @@ namespace ShiftOS.Engine public class NaughtyDeveloperException : Exception { /// - /// Create a new instance of the , with the specified message, which will cause Visual Studio to call the person who caused the exception a scrotem. + /// Create a new instance of the , with the specified message, which will cause Visual Studio to call the person who caused the exception a scrotum. /// /// The message you want to yell at the user. - public NaughtyDeveloperException(string message) : base(message + " - FIX IT, YOU SCROTEM") + public NaughtyDeveloperException(string message) : base(message + " - FIX IT, YOU SCROTUM") { } @@ -198,6 +215,8 @@ namespace ShiftOS.Engine public interface IHackableProvider { Objects.Hackable[] GetHackables(); + Objects.Exploit[] GetExploits(); + Objects.Payload[] GetPayloads(); Objects.LootInfo[] GetLootInfo(); byte[] GetLootFromResource(string resId); }