hacking works like actually it does kindof

This commit is contained in:
william341 2017-07-27 19:36:46 -07:00
parent b2e3a661ee
commit f4e39bb911
9 changed files with 167 additions and 3 deletions

View file

@ -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();
}
}
}

View file

@ -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;
}
}
}
}

View file

@ -9,5 +9,10 @@
FriendlyName: "FTP Exploit",
ExploitName: "ftpwn",
EffectiveAgainstPort: "FileServer",
},
{
FriendlyName: "SSH Exploit",
ExploitName: "sshardline",
EffectiveAgainstPort: "SSHServer",
}
]

View file

@ -11,7 +11,7 @@
Password: "h0ldy0urc0l0ur",
PasswordHint: "Prepare to hold your colour...",
WelcomeMessage: "Don't make fun of SpamSyndicate web design.",
FirewallStrength: 1,
FirewallStrength: 0,
LootRarity: 1,
LootAmount: 4,
ConnectionTimeoutLevel: 4,

View file

@ -10,5 +10,11 @@
PayloadName: "ftpull",
EffectiveAgainstFirewall: 1,
EffectiveAgainst: "FileServer",
},
{
FriendlyName: "Ping Spam",
PayloadName: "keepalive",
EffectiveAgainstFirewall: 1,
EffectiveAgainst: "SSHServer",
}
]

View file

@ -64,8 +64,10 @@
<Compile Include="GUI\ProgressBar.cs" />
<Compile Include="GUI\TextControl.cs" />
<Compile Include="GUI\TextInput.cs" />
<Compile Include="Hacking\HackingCommands.cs" />
<Compile Include="Hacking\HackableProvider.cs" />
<Compile Include="Hacking\HackerTestCommands.cs" />
<Compile Include="Hacking\PayloadFunc.cs" />
<Compile Include="Infobox.cs" />
<Compile Include="MainMenu.cs" />
<Compile Include="MonoGameLanguageProvider.cs" />

View file

@ -295,7 +295,7 @@ namespace ShiftOS.Frontend
{
if (Hacking.CurrentHackable.DoConnectionTimeout)
{
string str = $"Connection TImeout in {(Hacking.CurrentHackable.MillisecondsCountdown / 1000).ToString("#.##")} seconds.";
string str = $"Timeout in {(Hacking.CurrentHackable.MillisecondsCountdown / 1000).ToString("#.##")} seconds.";
var gfx = new GraphicsContext(GraphicsDevice, spriteBatch, 0, 0, UIManager.Viewport.Width, UIManager.Viewport.Height);
var measure = gfx.MeasureString(str, SkinEngine.LoadedSkin.HeaderFont);
gfx.DrawString(str, 5, (gfx.Height - ((int)measure.Y) - 5), Color.Red, SkinEngine.LoadedSkin.HeaderFont);
@ -310,7 +310,7 @@ namespace ShiftOS.Frontend
if (fps <= 20)
color = Color.Red;
gfxContext.DrawString($@"ShiftOS 1.0 Beta 4
Copyright (c) 2017 Michael VanOverbeek, Rylan Arbour, RogueAI
Copyright (c) 2017 Michael VanOverbeek, Rylan Arbour, RogueAI, william341
This is an unstable build.
FPS: {(fps)}
An FPS below 20 can cause glitches in keyboard and mouse handling. It is advised that if you are getting these

View file

@ -12,6 +12,7 @@ namespace ShiftOS.Objects
public string PayloadName { get; set; }
public int EffectiveAgainstFirewall { get; set; }
public SystemType EffectiveAgainst { get; set; }
public int Function { get; set; }
public string Dependencies { get; set; }
public string ID

View file

@ -95,6 +95,8 @@ namespace ShiftOS.Engine
hsys.MillisecondsCountdown = 0;
}
hsys.PortsToUnlock = new List<Objects.Port>();
hsys.VectorsUnlocked = new List<Objects.SystemType>();
hsys.PayloadExecuted = new List<Objects.Payload>();
foreach(Objects.Port porttocheck in Ports)
{
if (data.SystemType.HasFlag(porttocheck.AttachTo))
@ -109,6 +111,7 @@ 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("[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))
@ -116,6 +119,28 @@ namespace ShiftOS.Engine
CurrentHackable = null;
}
public static void EndHack()
{
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;
}
public static void FinishHack()
{
if (CurrentHackable == null)
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;
}
public static void Initiate()
{
foreach(var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IHackableProvider))))
@ -188,6 +213,8 @@ namespace ShiftOS.Engine
{
public Objects.Hackable Data { get; set; }
public List<Objects.Port> PortsToUnlock { get; set; }
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 double MillisecondsCountdown { get; set; }