From f4e39bb9117a692c543ecf17e79ed98c95ffc70e Mon Sep 17 00:00:00 2001 From: william341 Date: Thu, 27 Jul 2017 19:36:46 -0700 Subject: hacking works like actually it does kindof --- ShiftOS.Frontend/Hacking/HackingCommands.cs | 99 +++++++++++++++++++++++++++++ ShiftOS.Frontend/Hacking/PayloadFunc.cs | 24 +++++++ 2 files changed, 123 insertions(+) create mode 100644 ShiftOS.Frontend/Hacking/HackingCommands.cs create mode 100644 ShiftOS.Frontend/Hacking/PayloadFunc.cs (limited to 'ShiftOS.Frontend/Hacking') diff --git a/ShiftOS.Frontend/Hacking/HackingCommands.cs b/ShiftOS.Frontend/Hacking/HackingCommands.cs new file mode 100644 index 0000000..fe9ccbc --- /dev/null +++ b/ShiftOS.Frontend/Hacking/HackingCommands.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.Frontend +{ + class HackingCommands + { + //TODO: Implement firewall cracking + [Command("connect")] + [RequiresArgument("id")] + public static void Connect(Dictionary args) + { + string id = args["id"].ToString(); + var hackable = Hacking.AvailableToHack.FirstOrDefault(x => x.ID == id); + if (hackable == null) + { + Console.WriteLine("[sploitset] device not found on network."); + return; + } + Hacking.InitHack(hackable); + } + + [Command("exploit")] + [RequiresArgument("exploit")] + [RequiresArgument("port")] + public static void Exploit(Dictionary args) + { + if (Hacking.CurrentHackable == null) + { + Console.WriteLine("[sploitset] not connected"); + } + string Port = args["port"].ToString(); + string ExploitName = args["exploit"].ToString(); + var Exploit = Hacking.AvailableExploits.FirstOrDefault(x => x.ID == ExploitName); + if (Exploit == null) + { + Console.WriteLine("[sploitset] invalid exploit."); + return; + } + var ExploitTarget = Hacking.CurrentHackable.PortsToUnlock.FirstOrDefault(x => x.AttachTo == Exploit.EffectiveAgainst); + if (ExploitTarget == null) + { + Console.WriteLine("[sploitset] the connected machine doesn't have that service running."); + return; + } + if (ExploitTarget.Value.ToString() != Port) + { + Console.WriteLine("[sploitset] port not open"); + return; + } + Hacking.CurrentHackable.VectorsUnlocked.Add(ExploitTarget.AttachTo); + Console.WriteLine("[sploitset] exploited service"); + } + + [Command("inject")] + [RequiresArgument("payload")] + public static void InjectPayload(Dictionary args) + { + if (Hacking.CurrentHackable == null) + { + Console.WriteLine("[sploitset] not connected"); + } + string PayloadName = args["payload"].ToString(); + var Payload = Hacking.AvailablePayloads.FirstOrDefault(x => x.ID == PayloadName); + if (Payload == null) + { + Console.WriteLine("[sploitset] invalid payload."); + return; + } + if (!Hacking.CurrentHackable.VectorsUnlocked.Contains(Payload.EffectiveAgainst)) + { + Console.WriteLine("[sploitset] the connected machine doesn't have that service exploited."); + return; + } + PayloadFunc.DoHackFunction(Payload.Function); + Hacking.CurrentHackable.PayloadExecuted.Add(Payload); + Console.WriteLine("[sploitset] injected payload"); + } + + [Command("disconnect")] + public static void Disconnect(Dictionary args) + { + if (Hacking.CurrentHackable == null) + { + Console.WriteLine("[sploitset] not connected"); + } + if (Hacking.CurrentHackable.PayloadExecuted.Count == 0) + { + Hacking.FailHack(); + return; + } + Hacking.FinishHack(); + } + } +} diff --git a/ShiftOS.Frontend/Hacking/PayloadFunc.cs b/ShiftOS.Frontend/Hacking/PayloadFunc.cs new file mode 100644 index 0000000..5252db4 --- /dev/null +++ b/ShiftOS.Frontend/Hacking/PayloadFunc.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.Frontend +{ + class PayloadFunc + { + public static void DoHackFunction(int function) + { + switch (function) + { + default: + break; + case 1: + Hacking.CurrentHackable.DoConnectionTimeout = false; + break; + } + } + } +} -- cgit v1.2.3