From f31eff4566655bc9aff2e5efe4ac24ef941020f0 Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 29 Jul 2017 10:46:42 -0700 Subject: wew --- ShiftOS.Frontend/Hacking/HackingCommands.cs | 42 +++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Frontend/Hacking') diff --git a/ShiftOS.Frontend/Hacking/HackingCommands.cs b/ShiftOS.Frontend/Hacking/HackingCommands.cs index d07b174..5d51006 100644 --- a/ShiftOS.Frontend/Hacking/HackingCommands.cs +++ b/ShiftOS.Frontend/Hacking/HackingCommands.cs @@ -9,8 +9,19 @@ namespace ShiftOS.Frontend { class HackingCommands { + [Command("sploitset")] + public static void SploitSetEnter(Dictionary args) + { + TerminalBackend.SetShellOverride("sploitset> "); + } + [Command("ftp")] + public static void FTPEnter(Dictionary args) + { + TerminalBackend.SetShellOverride("SimplFTP> "); + } //TODO: Implement firewall cracking [Command("connect")] + [MetaCommand] [RequiresArgument("id")] public static void Connect(Dictionary args) { @@ -25,6 +36,7 @@ namespace ShiftOS.Frontend } [Command("exploit")] + [ShellConstraint("sploitset> ")] [RequiresArgument("id")] [RequiresArgument("port")] public static void Exploit(Dictionary args) @@ -32,6 +44,7 @@ namespace ShiftOS.Frontend if (Hacking.CurrentHackable == null) { Console.WriteLine("[connectlib] not connected"); + return; } string Port = args["port"].ToString(); string ExploitName = args["id"].ToString(); @@ -58,12 +71,14 @@ namespace ShiftOS.Frontend } [Command("inject")] + [ShellConstraint("sploitset> ")] [RequiresArgument("id")] public static void InjectPayload(Dictionary args) { if (Hacking.CurrentHackable == null) { Console.WriteLine("[connectlib] not connected"); + return; } string PayloadName = args["id"].ToString(); var PayloadID = Hacking.AvailablePayloads.FirstOrDefault(x => x.ID == PayloadName); @@ -83,11 +98,13 @@ namespace ShiftOS.Frontend } [Command("listports")] + [ShellConstraint("sploitset> ")] public static void ListPorts(Dictionary args) { if (Hacking.CurrentHackable == null) { Console.WriteLine("[connectlib] not connected"); + return; } foreach (var port in Hacking.CurrentHackable.PortsToUnlock) { @@ -96,6 +113,7 @@ namespace ShiftOS.Frontend } [Command("devicescan")] + [ShellConstraint("sploitset> ")] public static void ScanDevices() { Console.WriteLine("[sploitset] found " + Hacking.AvailableToHack.Length + " devices on the network"); @@ -106,6 +124,7 @@ namespace ShiftOS.Frontend } [Command("exploits")] + [ShellConstraint("sploitset> ")] public static void ScanExploits() { Console.WriteLine("[sploitset] found " + Hacking.AvailableExploits.Length + " exploits installed"); @@ -116,6 +135,7 @@ namespace ShiftOS.Frontend } [Command("payloads")] + [ShellConstraint("sploitset> ")] public static void ListAllPayloads() { Console.WriteLine("[sploitset] found " + Hacking.AvailablePayloads.Length + " payloads"); @@ -126,11 +146,13 @@ namespace ShiftOS.Frontend } [Command("disconnect")] + [MetaCommand] public static void Disconnect(Dictionary args) { if (Hacking.CurrentHackable == null) { Console.WriteLine("[connectlib] not connected"); + return; } if (Hacking.CurrentHackable.PayloadExecuted.Count == 0) { @@ -140,12 +162,20 @@ namespace ShiftOS.Frontend Hacking.FinishHack(); } - [Command("ftp-list")] + [Command("list")] + [ShellConstraint("SimplFTP> ")] public static void ListAllFTP(Dictionary args) { if (Hacking.CurrentHackable == null) { Console.WriteLine("[connectlib] not connected"); + return; + } + var PayloadID = Hacking.CurrentHackable.PayloadExecuted.FirstOrDefault(x => x.EffectiveAgainst.HasFlag(Objects.SystemType.FileServer)); + if (PayloadID == null) + { + Console.WriteLine("[SimplFTP] Not authorised."); + return; } foreach (var loot in Hacking.CurrentHackable.ServerFTPLoot) { @@ -153,13 +183,21 @@ namespace ShiftOS.Frontend } } - [Command("ftp-download")] + [Command("download")] + [ShellConstraint("SimplFTP> ")] [RequiresArgument("file")] public static void DownloadFTP(Dictionary args) { if (Hacking.CurrentHackable == null) { Console.WriteLine("[connectlib] not connected"); + return; + } + var PayloadID = Hacking.CurrentHackable.PayloadExecuted.FirstOrDefault(x => x.EffectiveAgainst.HasFlag(Objects.SystemType.FileServer)); + if (PayloadID == null) + { + Console.WriteLine("[SimplFTP] Not authorised."); + return; } string FindName = args["file"].ToString(); var LootID = Hacking.AvailableLoot.FirstOrDefault(x => x.LootName == FindName); -- cgit v1.2.3 From 3d22591f46a18ee3f585f169b34ccb5a0457e39f Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 Jul 2017 13:49:37 -0400 Subject: debug shell and clear metacmd --- ShiftOS.Frontend/Commands.cs | 10 +++++++++- ShiftOS.Frontend/Hacking/HackerTestCommands.cs | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'ShiftOS.Frontend/Hacking') diff --git a/ShiftOS.Frontend/Commands.cs b/ShiftOS.Frontend/Commands.cs index 61f7ed2..da1d1c1 100644 --- a/ShiftOS.Frontend/Commands.cs +++ b/ShiftOS.Frontend/Commands.cs @@ -47,6 +47,7 @@ namespace ShiftOS.Frontend [TutorialLock] public static class TerminalCommands { + [MetaCommand] [Command("clear", description = "{DESC_CLEAR}")] public static bool Clear() { @@ -60,8 +61,15 @@ namespace ShiftOS.Frontend public static class ShiftOSCommands { +#if DEBUG + [Command("debug")] + public static void EnterDebug() + { + TerminalBackend.SetShellOverride("shiftos_debug> "); + } +#endif - [Command("setsfxenabled", description = "{DESC_SETSFXENABLED}")] + [Command("setsfxenabled", description = "{DESC_SETSFXENABLED}")] [RequiresArgument("id")] public static bool SetSfxEnabled(Dictionary args) { diff --git a/ShiftOS.Frontend/Hacking/HackerTestCommands.cs b/ShiftOS.Frontend/Hacking/HackerTestCommands.cs index 1b6a1c1..72c648e 100644 --- a/ShiftOS.Frontend/Hacking/HackerTestCommands.cs +++ b/ShiftOS.Frontend/Hacking/HackerTestCommands.cs @@ -10,6 +10,7 @@ namespace ShiftOS.Frontend { public static class HackerTestCommands { + [ShellConstraint("shiftos_debug> ")] [Command("lsports")] public static void ListAllPorts() { @@ -19,6 +20,7 @@ namespace ShiftOS.Frontend } } + [ShellConstraint("shiftos_debug> ")] [Command("describehackable")] [RequiresArgument("id")] public static void DescribeHackable(Dictionary args) @@ -41,6 +43,7 @@ namespace ShiftOS.Frontend Console.WriteLine(hackable.WelcomeMessage); } + [ShellConstraint("shiftos_debug> ")] [Command("describeport")] [RequiresArgument("id")] public static void DescribePort(Dictionary args) -- cgit v1.2.3 From 38c78acaffdc8d04fb2201ac4517d20895c31759 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Jul 2017 12:12:26 -0400 Subject: fuckng hell --- ShiftOS.Frontend/Apps/Terminal.cs | 27 +++++++++++++++------------ ShiftOS.Frontend/Hacking/HackingCommands.cs | 2 ++ ShiftOS_TheReturn/CommandParser.cs | 4 ++-- ShiftOS_TheReturn/Hacking.cs | 3 +++ 4 files changed, 22 insertions(+), 14 deletions(-) (limited to 'ShiftOS.Frontend/Hacking') diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs index 0621139..4af1196 100644 --- a/ShiftOS.Frontend/Apps/Terminal.cs +++ b/ShiftOS.Frontend/Apps/Terminal.cs @@ -164,34 +164,37 @@ namespace ShiftOS.Frontend.Apps /// An absolute fucking mess. Seriously, can someone fix this method so it uhh WORKS PROPERLY? public System.Drawing.Point GetPointAtIndex(Graphics gfx) { - int vertMeasure = 2; + var font = new Font(LoadedSkin.TerminalFont.Name, LoadedSkin.TerminalFont.Size * _zoomFactor, LoadedSkin.TerminalFont.Style); + + int _textHeight = (int)gfx.SmartMeasureString("#", font).Height; + float vertMeasure = 2; int horizMeasure = 2; if (string.IsNullOrEmpty(Text)) - return new System.Drawing.Point(horizMeasure, vertMeasure); + return new System.Drawing.Point(horizMeasure, (int)vertMeasure); int lineindex = 0; int line = GetCurrentLine(); for (int l = 0; l < line; l++) { - if (string.IsNullOrEmpty(Lines[l])) + lineindex += Lines[l].Length; + if (string.IsNullOrWhiteSpace(Lines[l])) { - vertMeasure += LoadedSkin.TerminalFont.Height * _zoomFactor; + vertMeasure += _textHeight; continue; } - lineindex += Lines[l].Length; - var stringMeasure = gfx.SmartMeasureString(Lines[l] == "\r" ? " " : Lines[l], LoadedSkin.TerminalFont, Width - 4); - vertMeasure += (int)stringMeasure.Height * _zoomFactor; - + var stringMeasure = gfx.SmartMeasureString(Lines[l], font, Width - 4); + vertMeasure += (int)(stringMeasure.Height); + } - var lnMeasure = gfx.SmartMeasureString(Text.Substring(lineindex, Index - lineindex), LoadedSkin.TerminalFont); - int w = (int)Math.Floor(lnMeasure.Width) * _zoomFactor; + var lnMeasure = gfx.SmartMeasureString(Text.Substring(lineindex, Index - lineindex), font); + int w = (int)Math.Floor(lnMeasure.Width); while (w > Width - 4) { w = w - (Width - 4); - vertMeasure += (int)lnMeasure.Height * _zoomFactor; + vertMeasure += (int)lnMeasure.Height; } horizMeasure += w; - return new System.Drawing.Point(horizMeasure, vertMeasure); + return new System.Drawing.Point(horizMeasure, (int)vertMeasure); } private PointF CaretPosition = new PointF(2, 2); diff --git a/ShiftOS.Frontend/Hacking/HackingCommands.cs b/ShiftOS.Frontend/Hacking/HackingCommands.cs index 5d51006..9ebb824 100644 --- a/ShiftOS.Frontend/Hacking/HackingCommands.cs +++ b/ShiftOS.Frontend/Hacking/HackingCommands.cs @@ -14,11 +14,13 @@ namespace ShiftOS.Frontend { TerminalBackend.SetShellOverride("sploitset> "); } + [Command("ftp")] public static void FTPEnter(Dictionary args) { TerminalBackend.SetShellOverride("SimplFTP> "); } + //TODO: Implement firewall cracking [Command("connect")] [MetaCommand] diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index bd274cd..7568b98 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -131,9 +131,9 @@ namespace ShiftOS.Engine if(id_found == false) { id_found = true; - id_text = inp; + id_text = inp.Remove(0,1); res = ""; - arguments.Add("id", inp); + arguments.Add("id", id_text); } } } diff --git a/ShiftOS_TheReturn/Hacking.cs b/ShiftOS_TheReturn/Hacking.cs index 0186e51..8412203 100644 --- a/ShiftOS_TheReturn/Hacking.cs +++ b/ShiftOS_TheReturn/Hacking.cs @@ -124,10 +124,13 @@ namespace ShiftOS.Engine throw new NaughtyDeveloperException("Someone tried to fail a non-existent hack."); if (CurrentHackable.IsPwn3d) throw new NaughtyDeveloperException("A developer tried to un-pwn a pwn3d hackable."); + Console.WriteLine(); Console.WriteLine("[sploitset] [FAIL] disconnected - connection terminated by remote machine "); if (!string.IsNullOrWhiteSpace(CurrentHackable.Data.OnHackFailedStoryEvent)) Story.Start(CurrentHackable.Data.OnHackFailedStoryEvent); CurrentHackable = null; + TerminalBackend.SetShellOverride(""); + TerminalBackend.PrintPrompt(); } public static void EndHack() -- cgit v1.2.3