This commit is contained in:
TheRandomMelon 2017-01-08 20:03:03 -06:00
commit 7d176cf647
33 changed files with 291 additions and 173 deletions

View file

@ -1,2 +1,22 @@
# ShiftOS
[![Discord](https://discordapp.com/api/guilds/234414439330349056/widget.png?style=shield)]
(https://discord.gg/Kd8BJ93)
The official, open-source, C# revamp of ShiftOS by Michael VanOverbeek and the ShiftOS devs.
## Repository status:
AppVeyor build status:
[![Build status](https://ci.appveyor.com/api/projects/status/ktdv3nt6c3q88g2t?svg=true)](https://ci.appveyor.com/project/ComputeLinux/shiftos)
## License
We are licensed under the MIT license. All we ask is that you:
1. Don't steal our code and call it yours
2. If you fork us, please leave any copyright statements and license info at the top of all .cs files. You can use the InsertLicense executable to insert the statement into any code files missing the copyright statement.
## Using our code for your own front-end project
You may use the ShiftOS.Engine, ShiftOS.Objects, and ShiftOS.Server projects to create your own games. Just, please, include our original license and linkback to us in your game. After all, we spend a lot of time working on this!

View file

@ -24,7 +24,7 @@
namespace ShiftOS.MFSProfiler
{
partial class Form1
partial class Main
{
/// <summary>
/// Required designer variable.

View file

@ -39,9 +39,9 @@ using System.Threading;
namespace ShiftOS.MFSProfiler
{
public partial class Form1 : Form
public partial class Main : Form
{
public Form1()
public Main()
{
InitializeComponent();
SetupTree();

View file

@ -40,7 +40,7 @@ namespace ShiftOS.MFSProfiler
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new Main());
}
}
}

View file

@ -46,16 +46,16 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="Main.Designer.cs">
<DependentUpon>Main.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public class ClientSave
{
public string Username { get; set; }
public string Password { get; set; }
}
}

View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public abstract class Exploit
{
public void BeginExploit(string remote_user, bool isMud)
{
var ctx = new ExploitContext();
SendToMUD(remote_user, "hack_getcontext");
MessageReceived += (u, c, j) =>
{
};
ThisContext = ctx;
}
public ExploitContext ThisContext { get; internal set; }
public virtual void SendToMUD(string target_user, string command, string json = "")
{
ThisContext.IsMUDHack = false;
if (command == "hack_getcontext")
{
MessageReceived?.Invoke(target_user, "context_info", ExploitContext.CreateRandom());
}
}
public event MUDMessageEventHandler MessageReceived;
public abstract void OnRun(ExploitContext ctx);
}
}

View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public class ExploitContext
{
public static string CreateRandom()
{
//We can't use JSON.NET. We must construct the JSON ourselves.
StringBuilder jBuilder = new StringBuilder();
jBuilder.AppendLine("{");
jBuilder.Append("\tIsMUDHack: \"false\",");
jBuilder.AppendLine("}");
return jBuilder.ToString();
}
/// <summary>
/// Gets or sets whether or not this exploit context belongs to a MUD hack session.
/// </summary>
public bool IsMUDHack { get; set; }
/// <summary>
/// Gets or sets the target username for this exploit context. Used for talking with the MUD about it.
/// </summary>
public string TargetUsername { get; set; }
/// <summary>
/// Gets or sets the target's locks.
/// </summary>
public List<Lock> TargetLocks { get; set; }
}
}

View file

@ -30,67 +30,11 @@ using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public abstract class Exploit
{
public void BeginExploit(string remote_user, bool isMud)
{
var ctx = new ExploitContext();
SendToMUD(remote_user, "hack_getcontext");
MessageReceived += (u, c, j) =>
{
};
ThisContext = ctx;
}
public ExploitContext ThisContext { get; internal set; }
public virtual void SendToMUD(string target_user, string command, string json = "")
{
ThisContext.IsMUDHack = false;
if (command == "hack_getcontext")
{
MessageReceived?.Invoke(target_user, "context_info", ExploitContext.CreateRandom());
}
}
public event MUDMessageEventHandler MessageReceived;
public abstract void OnRun(ExploitContext ctx);
}
public delegate void MUDMessageEventHandler(string target_user, string command, string json);
public class ExploitContext
{
public static string CreateRandom()
{
//We can't use JSON.NET. We must construct the JSON ourselves.
StringBuilder jBuilder = new StringBuilder();
jBuilder.AppendLine("{");
jBuilder.Append("\tIsMUDHack: \"false\",");
jBuilder.AppendLine("}");
return jBuilder.ToString();
}
/// <summary>
/// Gets or sets whether or not this exploit context belongs to a MUD hack session.
/// </summary>
public bool IsMUDHack { get; set; }
/// <summary>
/// Gets or sets the target username for this exploit context. Used for talking with the MUD about it.
/// </summary>
public string TargetUsername { get; set; }
/// <summary>
/// Gets or sets the target's locks.
/// </summary>
public List<Lock> TargetLocks { get; set; }
}
public abstract class Lock
{

39
ShiftOS.Objects/Legion.cs Normal file
View file

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public enum LegionRole
{
Admin,
Manager,
Committed,
Trainee,
AwaitingInvite
}
public enum LegionPublicity
{
Public, //Will display on the 'Join Legion' page, anyone can join
PublicInviteOnly, //Will display on the 'Join Legion' page but you must be invited
Unlisted, //Won't display on 'Join Legion', but anyone can join
UnlistedInviteOnly //Won't display in 'Join Legion', and admin/manager invitation is required.
}
public class Legion
{
public string Name { get; set; }
public LegionPublicity Publicity { get; set; }
public ConsoleColor BannerColor { get; set; }
public string Description { get; set; }
public string ShortName { get; set; }
public Dictionary<string, LegionRole> Roles { get; set; }
public Dictionary<LegionRole, string> RoleNames { get; set; }
}
}

View file

@ -30,37 +30,6 @@ using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public enum LegionRole
{
Admin,
Manager,
Committed,
Trainee,
AwaitingInvite
}
public enum LegionPublicity
{
Public, //Will display on the 'Join Legion' page, anyone can join
PublicInviteOnly, //Will display on the 'Join Legion' page but you must be invited
Unlisted, //Won't display on 'Join Legion', but anyone can join
UnlistedInviteOnly //Won't display in 'Join Legion', and admin/manager invitation is required.
}
public class Legion
{
public string Name { get; set; }
public LegionPublicity Publicity { get; set; }
public ConsoleColor BannerColor { get; set; }
public string Description { get; set; }
public string ShortName { get; set; }
public Dictionary<string, LegionRole> Roles { get; set; }
public Dictionary<LegionRole, string> RoleNames { get; set; }
}
public class MUDMemo
{
public string UserFrom { get; set; }
@ -70,12 +39,6 @@ namespace ShiftOS.Objects
public string Subject { get; set; }
}
public class ClientSave
{
public string Username { get; set; }
public string Password { get; set; }
}
public enum MemoType
{
Regular,
@ -121,45 +84,4 @@ namespace ShiftOS.Objects
public string Contents { get; set; }
public string GUID { get; set; }
}
//Better to store this stuff server-side so we can do some neat stuff with hacking...
public class Save
{
public string Username { get; set; }
public int Codepoints { get; set; }
public Dictionary<string, bool> Upgrades { get; set; }
public int StoryPosition { get; set; }
public string Language { get; set; }
public List<string> CurrentLegions { get; set; }
public int MajorVersion { get; set; }
public int MinorVersion { get; set; }
public int Revision { get; set; }
public string Password { get; set; }
public string SystemName { get; set; }
public string DiscourseName { get; set; }
/// <summary>
/// If the user has entered their Discourse account into ShiftOS, this is the password they gave.
///
/// ANY developer caught abusing this property will have their dev status revoked and their account PERMANENTLY SUSPENDED. - Michael
/// </summary>
public string DiscoursePass { get; set; }
public int CountUpgrades()
{
int count = 0;
foreach (var upg in Upgrades)
{
if (upg.Value == true)
count++;
}
return count;
}
}
}

48
ShiftOS.Objects/Save.cs Normal file
View file

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
//Better to store this stuff server-side so we can do some neat stuff with hacking...
public class Save
{
public string Username { get; set; }
public int Codepoints { get; set; }
public Dictionary<string, bool> Upgrades { get; set; }
public int StoryPosition { get; set; }
public string Language { get; set; }
public List<string> CurrentLegions { get; set; }
public int MajorVersion { get; set; }
public int MinorVersion { get; set; }
public int Revision { get; set; }
public string Password { get; set; }
public string SystemName { get; set; }
public string DiscourseName { get; set; }
/// <summary>
/// If the user has entered their Discourse account into ShiftOS, this is the password they gave.
///
/// ANY developer caught abusing this property will have their dev status revoked and their account PERMANENTLY SUSPENDED. - Michael
/// </summary>
public string DiscoursePass { get; set; }
public int CountUpgrades()
{
int count = 0;
foreach (var upg in Upgrades)
{
if (upg.Value == true)
count++;
}
return count;
}
}
}

View file

@ -54,10 +54,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClientSave.cs" />
<Compile Include="DiscourseUser.cs" />
<Compile Include="Exploit.cs" />
<Compile Include="ExploitContext.cs" />
<Compile Include="Hack.cs" />
<Compile Include="Legion.cs" />
<Compile Include="Objects.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Save.cs" />
<Compile Include="ShiftFS.cs" />
<Compile Include="ShiftOSMenuRenderer.cs" />
</ItemGroup>

View file

@ -119,9 +119,9 @@
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Home" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Home.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
<value>..\Resources\index.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="NotFound" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NotFound.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
<value>..\Resources\404.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>
</root>

View file

@ -1,9 +1,11 @@
<html>
<!DOCTYPE html>
<html lang="en" dir="ltr>
<head>
<title>Multi-User Domain &bull; Administration Panel - Page not found.</title>
<meta charset="UTF-8">
</head>
<body>
<h1>This page wasn't found.</h1>
<p>We couldn't find this page...</p>
</body>
</html>
</html>

View file

@ -1,17 +1,16 @@
<html>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>ShiftOS Multi-User Domain &bull; Admin Panel</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta charset="UTF-8">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<a class="navbar-brand" href="/">MUD Admin Panel</a>
<ul class="nav navbar-nav">
<li><a href="/chats">Chat manager</a></li>
<li><a href="/status" class="active">System status</a></li>
@ -20,12 +19,10 @@
</nav>
<div class="container">
{BODY}
<footer>
<p>MUD server on {IP_ADDR}:{PORT}</p>
</footer>
</div>
</body>
</html>
</html>

View file

@ -93,7 +93,7 @@ namespace ShiftOS.WinForms.Applications
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "Chat";
this.Text = "Chat";
this.Text = "{CHAT_NAME}";
this.Size = new System.Drawing.Size(633, 318);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();

View file

@ -3266,7 +3266,7 @@ namespace ShiftOS.WinForms.Applications
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pgcontents);
this.Name = "ColorPicker";
this.Text = "Color Picker";
this.Text = "{COLOR_PICKER_NAME}";
this.Size = new System.Drawing.Size(552, 657);
this.Load += new System.EventHandler(this.Color_Picker_Load);
this.pgcontents.ResumeLayout(false);

View file

@ -54,7 +54,7 @@ namespace ShiftOS.WinForms.Applications
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Dialog";
this.Text = "{DIALOG_NAME}";
}
#endregion

View file

@ -149,7 +149,7 @@ namespace ShiftOS.WinForms.Applications
this.ClientSize = new System.Drawing.Size(634, 369);
this.Controls.Add(this.panel1);
this.Name = "FileDialog";
this.Text = "File Dialog";
this.Text = "{FILE_DIALOG_NAME}";
this.panel1.ResumeLayout(false);
this.pnlfiletype.ResumeLayout(false);
this.pnlfiletype.PerformLayout();

View file

@ -94,7 +94,7 @@ namespace ShiftOS.WinForms.Applications
this.ClientSize = new System.Drawing.Size(634, 369);
this.Controls.Add(this.panel1);
this.Name = "FileSkimmer";
this.Text = "File Skimmer";
this.Text = "{FILE_SKIMMER_NAME}";
this.Load += new System.EventHandler(this.FileSkimmer_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

View file

@ -252,7 +252,7 @@ namespace ShiftOS.WinForms.Applications
this.ClientSize = new System.Drawing.Size(390, 383);
this.Controls.Add(this.pgcontents);
this.Name = "GraphicPicker";
this.Text = "Graphic Picker";
this.Text = "{GRAPHIC_PICKER_NAME}";
this.Load += new System.EventHandler(this.Graphic_Picker_Load);
this.pgcontents.ResumeLayout(false);
this.pgcontents.PerformLayout();

View file

@ -206,7 +206,7 @@ namespace ShiftOS.WinForms.Applications
this.ClientSize = new System.Drawing.Size(622, 430);
this.Controls.Add(this.panel1);
this.Name = "MUDAuthenticator";
this.Text = "Multi-User Domain Admin Panel";
this.Text = "{MUD_AUTHENTICATOR_NAME}";
this.panel1.ResumeLayout(false);
this.pnlmain.ResumeLayout(false);
this.pnlusers.ResumeLayout(false);

View file

@ -748,6 +748,7 @@ namespace ShiftOS.WinForms.Applications
this.Controls.Add(this.toolStripContainer1);
this.ForeColor = System.Drawing.Color.White;
this.Name = "MUDControlCentre";
this.Text = "{MUD_CONTROL_CENTRE_NAME}";
this.Size = new System.Drawing.Size(756, 488);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();

View file

@ -162,7 +162,7 @@ namespace ShiftOS.WinForms.Applications
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "Shifter";
this.Text = "Shifter";
this.Text = "{SHIFTER_NAME}";
this.Size = new System.Drawing.Size(893, 539);
this.Load += new System.EventHandler(this.Shifter_Load);
this.panel1.ResumeLayout(false);

View file

@ -85,6 +85,7 @@ namespace ShiftOS.WinForms.Applications
lbupgrades.Items.Clear();
upgrades.Clear();
Timer();
label2.Text = "You have: " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints";
foreach (var upg in backend.GetAvailable())
{

View file

@ -426,7 +426,7 @@ namespace ShiftOS.WinForms.Applications
this.Controls.Add(this.pnlborder);
this.Controls.Add(this.pnldesktop);
this.Name = "Skin_Loader";
this.Text = "Skin Loader";
this.Text = "{SKIN_LOADER_NAME}";
this.pnldesktop.ResumeLayout(false);
this.pnlborder.ResumeLayout(false);
this.flbuttons.ResumeLayout(false);

View file

@ -199,7 +199,7 @@ namespace ShiftOS.WinForms.Applications
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pgcontents);
this.Name = "VirusScanner";
this.Text = "Virus Scanner";
this.Text = "{VIRUS_SCANNER_NAME}";
this.Size = new System.Drawing.Size(565, 343);
this.Load += new System.EventHandler(this.VirusScanner_Load);
this.grpresults.ResumeLayout(false);

View file

@ -224,4 +224,17 @@ Wenn eine Systemdatei von dem Virenscanner erkannt wird, wird sie ersetzt.",
"{WAV_PLAYER_NAME}":"WAV Player",
"{SHIFTORIUM_NAME}":"Shiftorium",
"{TEXTPAD_NAME}":"TextPad",
"{VIRUS_SCANNER_NAME}":"Virus Scanner",
"{SKIN_LOADER_NAME}":"Skin Loader",
"{SHIFTER_NAME}":"Shifter",
"{NAME_CHANGER_NAME}":"Name Changer",
"{MUD_PASSWORD_CRACKER_NAME}":"Multi-User Domain Password Cracker v1.0",
"{MUD_CONTROL_CENTRE_NAME}":"MUD Control Centre",
"{MUD_AUTHENTICATOR_NAME}":"Multi-User Domain Admin Panel",
"{GRAPHIC_PICKER_NAME}":"Graphic Picker",
"{FILE_SKIMMER_NAME}":"File Skimmer",
"{FILE_DIALOG_NAME}":"File Dialog",
"{DIALOG_NAME}":"Dialog",
"{COLOR_PICKER_NAME}":"Color Picker",
"{CHAT_NAME}":"Chat",
}

View file

@ -223,4 +223,17 @@ If a system file is deleted by the virus scanner, it will be replaced.",
"{WAV_PLAYER_NAME}":"WAV Player",
"{SHIFTORIUM_NAME}":"Shiftorium",
"{TEXTPAD_NAME}":"TextPad",
"{VIRUS_SCANNER_NAME}":"Virus Scanner",
"{SKIN_LOADER_NAME}":"Skin Loader",
"{SHIFTER_NAME}":"Shifter",
"{NAME_CHANGER_NAME}":"Name Changer",
"{MUD_PASSWORD_CRACKER_NAME}":"Multi-User Domain Password Cracker v1.0",
"{MUD_CONTROL_CENTRE_NAME}":"MUD Control Centre",
"{MUD_AUTHENTICATOR_NAME}":"Multi-User Domain Admin Panel",
"{GRAPHIC_PICKER_NAME}":"Graphic Picker",
"{FILE_SKIMMER_NAME}":"File Skimmer",
"{FILE_DIALOG_NAME}":"File Dialog",
"{DIALOG_NAME}":"Dialog",
"{COLOR_PICKER_NAME}":"Color Picker",
"{CHAT_NAME}":"Chat",
}

View file

@ -169,6 +169,13 @@ namespace ShiftOS.Engine {
AppearanceManager.ConsoleOut.Clear();
return true;
}
[Command("echo")]
[RequiresArgument("text")]
public static bool Echo(Dictionary<string, object> args) {
Console.WriteLine(args["text"]);
return true;
}
}
#if DEVEL

View file

@ -36,25 +36,41 @@ namespace ShiftOS.Engine
{
public class Infobox
{
// Set the infobox's interface to null
private static IInfobox _infobox = null;
/// <summary>
/// Creates a new infobox
/// </summary>
/// <param name="title">Infobox title</param>
/// <param name="message">Infobox message</param>
[Obsolete("Please use Infobox.Show instead.")]
public Infobox(string title, string message)
{
Infobox.Show(title, message);
}
/// <summary>
/// Shows an infobox
/// </summary>
/// <param name="title">Infobox title</param>
/// <param name="message">Infobox message</param>
public static void Show(string title, string message)
{
_infobox.Open(title, message);
}
/// <summary>
/// Inits an infobox
/// </summary>
/// <param name="info">Interface for infobox</param>
public static void Init(IInfobox info)
{
_infobox = info;
}
}
// Infobox Interface
public interface IInfobox
{
void Open(string title, string msg);