aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/Hacking
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-07-27 19:36:46 -0700
committerwilliam341 <[email protected]>2017-07-27 19:37:00 -0700
commitf4e39bb9117a692c543ecf17e79ed98c95ffc70e (patch)
treead5f80b83dcd66bfc0c057a9020ea3993159281f /ShiftOS.Frontend/Hacking
parentb2e3a661ee6ab3308968efeb275e457776abebc3 (diff)
downloadshiftos_thereturn-f4e39bb9117a692c543ecf17e79ed98c95ffc70e.tar.gz
shiftos_thereturn-f4e39bb9117a692c543ecf17e79ed98c95ffc70e.tar.bz2
shiftos_thereturn-f4e39bb9117a692c543ecf17e79ed98c95ffc70e.zip
hacking works like actually it does kindof
Diffstat (limited to 'ShiftOS.Frontend/Hacking')
-rw-r--r--ShiftOS.Frontend/Hacking/HackingCommands.cs99
-rw-r--r--ShiftOS.Frontend/Hacking/PayloadFunc.cs24
2 files changed, 123 insertions, 0 deletions
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<string, object> 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<string, object> 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<string, object> 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<string, object> 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;
+ }
+ }
+ }
+}