diff --git a/ShiftOS.Frontend/Apps/FileSkimmer.cs b/ShiftOS.Frontend/Apps/FileSkimmer.cs index c4dbb09..58a9908 100644 --- a/ShiftOS.Frontend/Apps/FileSkimmer.cs +++ b/ShiftOS.Frontend/Apps/FileSkimmer.cs @@ -21,6 +21,27 @@ namespace ShiftOS.Frontend.Apps public void OnLoad() { + if(Hacking.CurrentHackable != null) + { + if (Hacking.CurrentHackable.VectorsUnlocked.Contains(Objects.SystemType.FileServer)) + { + if(Mounts.Count > 2) + { + Mounts.RemoveAt(2); + } + var dir = new Objects.ShiftFS.Directory(); + dir.Name = $"{Hacking.CurrentHackable.Data.SystemName} (ftp)"; + Mounts.Add(dir); + foreach (var loot in Hacking.CurrentHackable.ServerFTPLoot) + { + if(!FileExists("2:/" + loot.LootName)) + { + var bytes = Hacking.GetLootBytes(loot.PointTo); + } + } + } + } + Width = 720; Height = 480; _fList = new GUI.ListBox(); diff --git a/ShiftOS.Frontend/Hacking/HackableProvider.cs b/ShiftOS.Frontend/Hacking/HackableProvider.cs index e578fb0..83409c5 100644 --- a/ShiftOS.Frontend/Hacking/HackableProvider.cs +++ b/ShiftOS.Frontend/Hacking/HackableProvider.cs @@ -11,6 +11,37 @@ namespace ShiftOS.Frontend { public class HackableProvider : IHackableProvider { + public byte[] FindLootBytes(string id) + { + foreach(var res in typeof(Properties.Resources).GetProperties(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)) + { + if(res.Name == id) + { + var obj = res.GetValue(null); + if(obj is System.Drawing.Image) + { + var img = (obj as System.Drawing.Bitmap); + using(var memstr = new System.IO.MemoryStream()) + { + img.Save(memstr, System.Drawing.Imaging.ImageFormat.Png); + return memstr.ToArray(); + } + } + else if(obj is System.IO.UnmanagedMemoryStream) + { + var ms = obj as System.IO.MemoryStream; + return ms.ToArray(); + } + else if(obj is string) + { + var bytes = Encoding.UTF8.GetBytes(obj.ToString()); + return bytes; + } + } + } + return null; + } + public Hackable[] GetHackables() { return JsonConvert.DeserializeObject(Properties.Resources.Hackables); diff --git a/ShiftOS.Frontend/Hacking/HackingCommands.cs b/ShiftOS.Frontend/Hacking/HackingCommands.cs index 9ebb824..3ecf7fb 100644 --- a/ShiftOS.Frontend/Hacking/HackingCommands.cs +++ b/ShiftOS.Frontend/Hacking/HackingCommands.cs @@ -51,12 +51,12 @@ namespace ShiftOS.Frontend string Port = args["port"].ToString(); string ExploitName = args["id"].ToString(); var ExploitID = Hacking.AvailableExploits.FirstOrDefault(x => x.ID == ExploitName); - Console.WriteLine(ExploitID.ExploitName); if (ExploitID == null) { Console.WriteLine("[sploitset] invalid exploit."); return; } + Console.WriteLine(ExploitID.ExploitName); var ExploitTarget = Hacking.CurrentHackable.PortsToUnlock.First(x => x.Value.ToString() == Port); if (ExploitTarget == null) { diff --git a/ShiftOS_TheReturn/Hacking.cs b/ShiftOS_TheReturn/Hacking.cs index 5c473df..e670756 100644 --- a/ShiftOS_TheReturn/Hacking.cs +++ b/ShiftOS_TheReturn/Hacking.cs @@ -81,6 +81,18 @@ namespace ShiftOS.Engine } } + public static byte[] GetLootBytes(string lootid) + { + foreach (var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IHackableProvider)))) + { + var @interface = (IHackableProvider)Activator.CreateInstance(type, null); + var bytes = @interface.FindLootBytes(lootid); + if (bytes != null) + return bytes; + } + throw new NaughtyDeveloperException("Seems like the loot system's trying to work without any loot. This isn't normal."); + } + public static void InitHack(Objects.Hackable data) { var hsys = new HackableSystem(); @@ -212,6 +224,7 @@ namespace ShiftOS.Engine Objects.Payload[] GetPayloads(); Objects.Port[] GetPorts(); Objects.Loot[] GetLoot(); + byte[] FindLootBytes(string lootid); } public class HackableSystem