loot kinda works lol

This commit is contained in:
william341 2017-07-28 21:38:44 -07:00
parent 669bd3c090
commit 56a3080c7b
10 changed files with 115 additions and 50 deletions

View file

@ -36,9 +36,9 @@ namespace ShiftOS.Frontend
return new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }; //nyi
}
public LootInfo[] GetLootInfo()
public Loot[] GetLoot()
{
return JsonConvert.DeserializeObject<LootInfo[]>(Properties.Resources.LootInfo);
return JsonConvert.DeserializeObject<Loot[]>(Properties.Resources.LootInfo);
}
}
}

View file

@ -18,7 +18,7 @@ namespace ShiftOS.Frontend
var hackable = Hacking.AvailableToHack.FirstOrDefault(x => x.ID == id);
if (hackable == null)
{
Console.WriteLine("[sploitset] device not found on network.");
Console.WriteLine("[connectlib] device not found on network.");
return;
}
Hacking.InitHack(hackable);
@ -31,7 +31,7 @@ namespace ShiftOS.Frontend
{
if (Hacking.CurrentHackable == null)
{
Console.WriteLine("[sploitset] not connected");
Console.WriteLine("[connectlib] not connected");
}
string Port = args["port"].ToString();
string ExploitName = args["id"].ToString();
@ -63,7 +63,7 @@ namespace ShiftOS.Frontend
{
if (Hacking.CurrentHackable == null)
{
Console.WriteLine("[sploitset] not connected");
Console.WriteLine("[connectlib] not connected");
}
string PayloadName = args["id"].ToString();
var PayloadID = Hacking.AvailablePayloads.FirstOrDefault(x => x.ID == PayloadName);
@ -87,7 +87,7 @@ namespace ShiftOS.Frontend
{
if (Hacking.CurrentHackable == null)
{
Console.WriteLine("[sploitset] not connected");
Console.WriteLine("[connectlib] not connected");
}
foreach (var port in Hacking.CurrentHackable.PortsToUnlock)
{
@ -130,7 +130,7 @@ namespace ShiftOS.Frontend
{
if (Hacking.CurrentHackable == null)
{
Console.WriteLine("[sploitset] not connected");
Console.WriteLine("[connectlib] not connected");
}
if (Hacking.CurrentHackable.PayloadExecuted.Count == 0)
{
@ -139,5 +139,46 @@ namespace ShiftOS.Frontend
}
Hacking.FinishHack();
}
[Command("ftp-list")]
public static void ListAllFTP(Dictionary<string, object> args)
{
if (Hacking.CurrentHackable == null)
{
Console.WriteLine("[connectlib] not connected");
}
foreach (var loot in Hacking.CurrentHackable.ServerFTPLoot)
{
Console.WriteLine(loot.LootName + ": (assumed: " + loot.FriendlyName + ")" );
}
}
[Command("ftp-download")]
[RequiresArgument("file")]
public static void DownloadFTP(Dictionary<string, object> args)
{
if (Hacking.CurrentHackable == null)
{
Console.WriteLine("[connectlib] not connected");
}
string FindName = args["file"].ToString();
var LootID = Hacking.AvailableLoot.FirstOrDefault(x => x.LootName == FindName);
if (LootID == null)
{
Console.WriteLine("[SimplFTP] file not found on server.");
return;
}
if (!Hacking.CurrentHackable.ServerFTPLoot.Contains(LootID))
{
Console.WriteLine("[SimplFTP] file not found on server.");
return;
}
if (!Shiftorium.Buy(FindName, 0))
{
Console.WriteLine("[SimplFTP] Could not download file. Either the upgrade does not exist or the user doesn't have 0 codepoints (wat)");
return;
}
Console.WriteLine("[SimplFTP] downloaded file");
}
}
}

View file

@ -70,6 +70,33 @@ namespace ShiftOS.Frontend.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to /* ShiftOS Exploits data file
/// *
/// * This file contains information about all exploits in the game&apos;s campaign.
/// *
/// */
///
///[
/// {
/// FriendlyName: &quot;FTP Exploit&quot;,
/// ExploitName: &quot;ftpwn&quot;,
/// EffectiveAgainstPort: &quot;FileServer&quot;
/// },
/// {
/// FriendlyName: &quot;SSH Exploit&quot;,
/// ExploitName: &quot;sshardline&quot;,
/// EffectiveAgainstPort: &quot;SSHServer&quot;,
/// Dependencies: &quot;sploitset_sshardline&quot;
/// }
///].
/// </summary>
public static string Exploits {
get {
return ResourceManager.GetString("Exploits", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to /* ShiftOS hackables data file
/// *
@ -86,7 +113,7 @@ namespace ShiftOS.Frontend.Properties {
/// WelcomeMessage: &quot;Don&apos;t make fun of SpamSyndicate web design.&quot;,
/// FirewallStrength: 0,
/// LootRarity: 1,
/// LootAmount: 4,
/// LootAmount: 2,
/// ConnectionTimeoutLevel: 4,
/// SystemType: &quot;FileServer, SSHServer&quot;,
///

View file

@ -148,4 +148,7 @@
<data name="Ports" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Ports.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="Exploits" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\exploits.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View file

@ -8,12 +8,12 @@
{
FriendlyName: "FTP Exploit",
ExploitName: "ftpwn",
EffectiveAgainstPort: "FileServer"
EffectiveAgainstPort: "FileServer",
},
{
FriendlyName: "SSH Exploit",
ExploitName: "sshardline",
EffectiveAgainstPort: "SSHServer",
Dependencies: "sploitset_sshardline"
Dependencies: "sploitset_sshardline",
}
]

View file

@ -13,7 +13,7 @@
WelcomeMessage: "Don't make fun of SpamSyndicate web design.",
FirewallStrength: 0,
LootRarity: 1,
LootAmount: 4,
LootAmount: 2,
ConnectionTimeoutLevel: 4,
SystemType: "FileServer, SSHServer",

View file

@ -9,7 +9,7 @@
FriendlyName: "FTP Payload",
PayloadName: "ftpull",
EffectiveAgainstFirewall: 1,
EffectiveAgainst: "FileServer"
EffectiveAgainst: "FileServer",
},
{
FriendlyName: "Force Heartbeat",
@ -17,6 +17,6 @@
EffectiveAgainstFirewall: 1,
EffectiveAgainst: "SSHServer",
Function: 1,
Dependencies: "sploitset_keepalive"
Dependencies: "sploitset_keepalive",
}
]

View file

@ -1,11 +1,11 @@
[
}
{
Name: "sploitset_keepalive",
Cost: 1000000000,
Description: "lolyouarentsupposedtobeabletobuythis",
Dependencies: "thisupgradeshouldneverexistever;sploitset_sshardline",
},
}
{
Name: "sploitset_sshardline",
Cost: 1000000000,
Description: "lolyouarentsupposedtobeabletobuythis",

View file

@ -61,11 +61,4 @@ namespace ShiftOS.Objects
public string Contents { get; set; }
}
public class LootInfo
{
public string Filename { get; set; }
public string ResourceId { get; set; }
public int Rarity { get; set; }
}
}

View file

@ -13,7 +13,7 @@ namespace ShiftOS.Engine
private static List<Objects.Exploit> Exploits = new List<Objects.Exploit>();
private static List<Objects.Payload> Payloads = new List<Objects.Payload>();
private static List<Objects.Port> Ports = new List<Objects.Port>();
private static List<Objects.Loot> Loot = new List<Objects.Loot>();
private static List<Objects.Loot> LootFiles = new List<Objects.Loot>();
public static HackableSystem CurrentHackable { get; private set; }
@ -49,6 +49,14 @@ namespace ShiftOS.Engine
}
}
public static Objects.Loot[] AvailableLoot
{
get
{
return LootFiles.ToArray();
}
}
public static HackableSystem[] ActiveConnections
{
get
@ -78,12 +86,6 @@ namespace ShiftOS.Engine
var hsys = new HackableSystem();
hsys.Data = data;
hsys.IsPwn3d = false;
var fs = new Objects.ShiftFS.Directory();
fs.Name = data.FriendlyName;
Objects.ShiftFS.Utils.Mounts.Add(fs);
var mountid = Objects.ShiftFS.Utils.Mounts.IndexOf(fs);
Objects.ShiftFS.Utils.Mounts.Remove(fs);
hsys.Filesystem = fs;
hsys.FirewallCracked = (data.FirewallStrength == 0);
hsys.DoConnectionTimeout = (data.ConnectionTimeoutLevel > 0);
if (hsys.DoConnectionTimeout)
@ -97,11 +99,22 @@ namespace ShiftOS.Engine
hsys.PortsToUnlock = new List<Objects.Port>();
hsys.VectorsUnlocked = new List<Objects.SystemType>();
hsys.PayloadExecuted = new List<Objects.Payload>();
hsys.ServerFTPLoot = new List<Objects.Loot>();
foreach(Objects.Port porttocheck in Ports)
{
if (data.SystemType.HasFlag(porttocheck.AttachTo))
hsys.PortsToUnlock.Add(porttocheck);
}
var rnd = new Random();
List<Objects.Loot> loot = new List<Objects.Loot>();
loot.AddRange(LootFiles.Where(x => x.Rarity <= hsys.Data.LootRarity));
var amount = data.LootAmount;
for (int i = 0; i < amount && i < loot.Count - 1; i++)
{
var randomLoot = loot[rnd.Next(0, loot.Count - 1)];
hsys.ServerFTPLoot.Add(randomLoot);
loot.Remove(randomLoot);
}
CurrentHackable = hsys;
}
@ -114,8 +127,6 @@ namespace ShiftOS.Engine
Console.WriteLine("[sploitset] [FAIL] disconnected - connection terminated by remote machine ");
if (!string.IsNullOrWhiteSpace(CurrentHackable.Data.OnHackFailedStoryEvent))
Story.Start(CurrentHackable.Data.OnHackFailedStoryEvent);
if (Objects.ShiftFS.Utils.Mounts.Contains(CurrentHackable.Filesystem))
Objects.ShiftFS.Utils.Mounts.Remove(CurrentHackable.Filesystem);
CurrentHackable = null;
}
@ -123,8 +134,6 @@ namespace ShiftOS.Engine
{
if (CurrentHackable == null)
throw new NaughtyDeveloperException("Someone tried to end a non-existent hack.");
if (Objects.ShiftFS.Utils.Mounts.Contains(CurrentHackable.Filesystem))
Objects.ShiftFS.Utils.Mounts.Remove(CurrentHackable.Filesystem);
Console.WriteLine("[sploitset] [FAIL] disconnected for unknown reason");
CurrentHackable = null;
}
@ -135,8 +144,6 @@ namespace ShiftOS.Engine
throw new NaughtyDeveloperException("Someone tried to finish a non-existent hack.");
if (!string.IsNullOrWhiteSpace(CurrentHackable.Data.OnHackCompleteStoryEvent))
Story.Start(CurrentHackable.Data.OnHackCompleteStoryEvent);
if (Objects.ShiftFS.Utils.Mounts.Contains(CurrentHackable.Filesystem))
Objects.ShiftFS.Utils.Mounts.Remove(CurrentHackable.Filesystem);
Console.WriteLine("[sploitset] disconnected with payload applied");
CurrentHackable = null;
}
@ -150,29 +157,24 @@ namespace ShiftOS.Engine
Ports.AddRange(@interface.GetPorts());
Payloads.AddRange(@interface.GetPayloads());
Exploits.AddRange(@interface.GetExploits());
var lootinfo = @interface.GetLootInfo();
foreach(var loot in lootinfo)
{
var existing = Loot.FirstOrDefault(x => x.Info.Filename == loot.Filename);
if (existing != null)
throw new DataConflictException("Data conflict encountered while reading loot data. Two or more loot resources with the filename \"" + loot.Filename + "\" were found. This can cause major bugs and confusion in the game.");
var @new = new Objects.Loot(loot, @interface.GetLootFromResource(loot.ResourceId));
Loot.Add(@new);
}
LootFiles.AddRange(@interface.GetLoot());
}
var hackable = Hackables.FirstOrDefault(x => Hackables.Where(y => x.SystemName == y.SystemName).Count() > 1);
if(hackable != null)
throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more hackables were found with the same hostname \"" + hackable.SystemName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend.");
var ports = Ports.FirstOrDefault(x => Ports.Where(y => x.Name == y.Name).Count() > 1);
if (hackable != null)
if (ports != null)
throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more ports were found with the same name \"" + ports.Name + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend.");
var payloads = Payloads.FirstOrDefault(x => Payloads.Where(y => x.PayloadName == y.PayloadName).Count() > 1);
if (hackable != null)
if (payloads != null)
throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more payloads were found with the same name \"" + payloads.PayloadName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend.");
var exploits = Exploits.FirstOrDefault(x => Exploits.Where(y => x.ExploitName == y.ExploitName).Count() > 1);
if (hackable != null)
if (exploits != null)
throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more exploits were found with the same name \"" + exploits.ExploitName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend.");
var loot = LootFiles.FirstOrDefault(x => LootFiles.Where(y => x.LootName == y.LootName).Count() > 1);
if (loot != null)
throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more loot files were found with the same name \"" + loot.LootName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend.");
}
}
@ -205,8 +207,7 @@ namespace ShiftOS.Engine
Objects.Exploit[] GetExploits();
Objects.Payload[] GetPayloads();
Objects.Port[] GetPorts();
Objects.LootInfo[] GetLootInfo();
byte[] GetLootFromResource(string resId);
Objects.Loot[] GetLoot();
}
public class HackableSystem
@ -216,7 +217,7 @@ namespace ShiftOS.Engine
public List<Objects.SystemType> VectorsUnlocked { get; set; }
public List<Objects.Payload> PayloadExecuted { get; set; }
public bool FirewallCracked { get; set; }
public Objects.ShiftFS.Directory Filesystem { get; set; }
public List<Objects.Loot> ServerFTPLoot { get; set; }
public double MillisecondsCountdown { get; set; }
public bool DoConnectionTimeout { get; set; }
public bool IsPwn3d { get; set; }