Server now FULLY encrypts saves

This commit is contained in:
Michael 2017-02-05 10:56:48 -05:00
parent b192315409
commit 19b13528f6
11 changed files with 401 additions and 67 deletions

View file

@ -0,0 +1,108 @@
namespace ShiftOS.MFSProfiler
{
partial class FileCreator
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txtfname = new System.Windows.Forms.TextBox();
this.txtcontents = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 13);
this.label1.TabIndex = 0;
this.label1.Text = "File name:";
//
// txtfname
//
this.txtfname.Location = new System.Drawing.Point(16, 30);
this.txtfname.Name = "txtfname";
this.txtfname.Size = new System.Drawing.Size(416, 20);
this.txtfname.TabIndex = 1;
//
// txtcontents
//
this.txtcontents.Location = new System.Drawing.Point(16, 78);
this.txtcontents.Multiline = true;
this.txtcontents.Name = "txtcontents";
this.txtcontents.Size = new System.Drawing.Size(416, 200);
this.txtcontents.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 61);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Contents:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(357, 284);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// FileCreator
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(444, 312);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtcontents);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtfname);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "FileCreator";
this.Text = "FileCreator";
this.Load += new System.EventHandler(this.FileCreator_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtfname;
private System.Windows.Forms.TextBox txtcontents;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
}
}

View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShiftOS.MFSProfiler
{
public partial class FileCreator : Form
{
public FileCreator(string fileToCreate)
{
InitializeComponent();
FileToCreate = fileToCreate;
}
public string FileToCreate { get; private set; }
private void FileCreator_Load(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void button1_Click(object sender, EventArgs e)
{
ShiftOS.Objects.ShiftFS.Utils.WriteAllText(FileToCreate + "/" + txtfname.Text, txtcontents.Text);
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -52,31 +52,37 @@ namespace ShiftOS.MFSProfiler
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tvfiles = new System.Windows.Forms.TreeView();
this.pnlfileinfo = new System.Windows.Forms.Panel();
this.pnldirectorylisting = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pnlfileinfo = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.txtascii = new System.Windows.Forms.TextBox();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.txtbinary = new System.Windows.Forms.TextBox();
this.txtascii = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lbfileinfo = new System.Windows.Forms.Label();
this.pnldirectorylisting = new System.Windows.Forms.Panel();
this.ctxfileoptions = new System.Windows.Forms.ContextMenuStrip(this.components);
this.newFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.pnlfileinfo.SuspendLayout();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.pnlfileinfo.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.ctxfileoptions.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
@ -107,24 +113,6 @@ namespace ShiftOS.MFSProfiler
this.tvfiles.TabIndex = 0;
this.tvfiles.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvfiles_AfterSelect);
//
// pnlfileinfo
//
this.pnlfileinfo.Controls.Add(this.groupBox2);
this.pnlfileinfo.Controls.Add(this.groupBox1);
this.pnlfileinfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlfileinfo.Location = new System.Drawing.Point(0, 0);
this.pnlfileinfo.Name = "pnlfileinfo";
this.pnlfileinfo.Size = new System.Drawing.Size(489, 466);
this.pnlfileinfo.TabIndex = 0;
//
// pnldirectorylisting
//
this.pnldirectorylisting.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnldirectorylisting.Location = new System.Drawing.Point(0, 0);
this.pnldirectorylisting.Name = "pnldirectorylisting";
this.pnldirectorylisting.Size = new System.Drawing.Size(489, 466);
this.pnldirectorylisting.TabIndex = 1;
//
// panel1
//
this.panel1.Controls.Add(this.button1);
@ -144,16 +132,15 @@ namespace ShiftOS.MFSProfiler
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox1
// pnlfileinfo
//
this.groupBox1.Controls.Add(this.lbfileinfo);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(489, 164);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "File record information";
this.pnlfileinfo.Controls.Add(this.groupBox2);
this.pnlfileinfo.Controls.Add(this.groupBox1);
this.pnlfileinfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlfileinfo.Location = new System.Drawing.Point(0, 0);
this.pnlfileinfo.Name = "pnlfileinfo";
this.pnlfileinfo.Size = new System.Drawing.Size(489, 466);
this.pnlfileinfo.TabIndex = 0;
//
// groupBox2
//
@ -188,6 +175,15 @@ namespace ShiftOS.MFSProfiler
this.tabPage2.Text = "ASCII";
this.tabPage2.UseVisualStyleBackColor = true;
//
// txtascii
//
this.txtascii.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtascii.Location = new System.Drawing.Point(3, 3);
this.txtascii.Multiline = true;
this.txtascii.Name = "txtascii";
this.txtascii.Size = new System.Drawing.Size(469, 251);
this.txtascii.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.txtbinary);
@ -208,14 +204,16 @@ namespace ShiftOS.MFSProfiler
this.txtbinary.Size = new System.Drawing.Size(469, 251);
this.txtbinary.TabIndex = 0;
//
// txtascii
// groupBox1
//
this.txtascii.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtascii.Location = new System.Drawing.Point(3, 3);
this.txtascii.Multiline = true;
this.txtascii.Name = "txtascii";
this.txtascii.Size = new System.Drawing.Size(469, 251);
this.txtascii.TabIndex = 0;
this.groupBox1.Controls.Add(this.lbfileinfo);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(489, 164);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "File record information";
//
// lbfileinfo
//
@ -226,27 +224,64 @@ namespace ShiftOS.MFSProfiler
this.lbfileinfo.TabIndex = 0;
this.lbfileinfo.Text = "label1";
//
// Form1
// pnldirectorylisting
//
this.pnldirectorylisting.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnldirectorylisting.Location = new System.Drawing.Point(0, 0);
this.pnldirectorylisting.Name = "pnldirectorylisting";
this.pnldirectorylisting.Size = new System.Drawing.Size(489, 466);
this.pnldirectorylisting.TabIndex = 1;
//
// ctxfileoptions
//
this.ctxfileoptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newFileToolStripMenuItem,
this.newDirectoryToolStripMenuItem,
this.deleteToolStripMenuItem});
this.ctxfileoptions.Name = "ctxfileoptions";
this.ctxfileoptions.Size = new System.Drawing.Size(153, 92);
//
// newFileToolStripMenuItem
//
this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem";
this.newFileToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newFileToolStripMenuItem.Text = "New file";
this.newFileToolStripMenuItem.Click += new System.EventHandler(this.newFileToolStripMenuItem_Click);
//
// newDirectoryToolStripMenuItem
//
this.newDirectoryToolStripMenuItem.Name = "newDirectoryToolStripMenuItem";
this.newDirectoryToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newDirectoryToolStripMenuItem.Text = "New directory";
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.deleteToolStripMenuItem.Text = "Delete";
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(739, 466);
this.Controls.Add(this.splitContainer1);
this.Name = "Form1";
this.Name = "Main";
this.Text = "Form1";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.pnlfileinfo.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.pnlfileinfo.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.ctxfileoptions.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -267,6 +302,10 @@ namespace ShiftOS.MFSProfiler
private System.Windows.Forms.TextBox txtbinary;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lbfileinfo;
private System.Windows.Forms.ContextMenuStrip ctxfileoptions;
private System.Windows.Forms.ToolStripMenuItem newFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newDirectoryToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
}
}

View file

@ -65,6 +65,7 @@ namespace ShiftOS.MFSProfiler
public void RecursiveDirectoryAdd(TreeNode node)
{
node.ContextMenuStrip = ctxfileoptions;
foreach (var dir in GetDirectories(node.Tag.ToString()))
{
var dirInf = GetDirectoryInfo(dir);
@ -131,5 +132,14 @@ System path: {tvfiles.SelectedNode.Tag.ToString()}";
}
} catch { }
}
private void newFileToolStripMenuItem_Click(object sender, EventArgs e)
{
var fCreator = new FileCreator(tvfiles.SelectedNode.Tag.ToString());
if(fCreator.ShowDialog() == DialogResult.OK)
{
SetupTree();
}
}
}
}

View file

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ctxfileoptions.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -46,6 +46,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileCreator.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FileCreator.Designer.cs">
<DependentUpon>FileCreator.cs</DependentUpon>
</Compile>
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
@ -54,6 +60,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FileCreator.resx">
<DependentUpon>FileCreator.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>

View file

@ -220,6 +220,16 @@ namespace ShiftOS.Server
}
public static string ReadEncFile(string fPath)
{
return Encryption.Decrypt(File.ReadAllText(fPath));
}
public static void WriteEncFile(string fPath, string contents)
{
File.WriteAllText(fPath, Encryption.Encrypt(contents));
}
/// <summary>
/// Interpret the specified msg.
/// </summary>
@ -268,11 +278,11 @@ Contents:
{
foreach (var saveFile in Directory.GetFiles("saves"))
{
var saveFileContents = JsonConvert.DeserializeObject<Save>(File.ReadAllText(saveFile));
var saveFileContents = JsonConvert.DeserializeObject<Save>(ReadEncFile(saveFile));
if (saveFileContents.Username == userName && saveFileContents.Password == passw)
{
saveFileContents.Codepoints += amount;
File.WriteAllText(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented));
WriteEncFile(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented));
server.DispatchAll(new NetObject("stop_being_drunk_michael", new ServerMessage
{
Name = "update_your_cp",
@ -372,11 +382,11 @@ Contents:
{
foreach(var saveFile in Directory.GetFiles("saves"))
{
var saveFileContents = JsonConvert.DeserializeObject<Save>(File.ReadAllText(saveFile));
var saveFileContents = JsonConvert.DeserializeObject<Save>(ReadEncFile(saveFile));
if(saveFileContents.Username == userName)
{
saveFileContents.Codepoints += amount;
File.WriteAllText(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented));
WriteEncFile(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented));
server.DispatchAll(new NetObject("pikachu_use_thunderbolt_oh_yeah_and_if_you_happen_to_be_doing_backend_and_see_this_post_a_picture_of_ash_ketchum_from_the_unova_series_in_the_discord_dev_room_holy_crap_this_is_a_long_snake_case_thing_about_ash_ketchum_and_pikachu", new ServerMessage
{
Name = "update_your_cp",
@ -399,14 +409,11 @@ Contents:
{
try
{
var save = JsonConvert.DeserializeObject<Save>(File.ReadAllText(savefile));
var save = JsonConvert.DeserializeObject<Save>(ReadEncFile(savefile));
string hashedPass = Encryption.Encrypt(args["password"].ToString());
if(save.Username == args["username"].ToString() && save.Password == hashedPass)
if(save.Username == args["username"].ToString() && save.Password == args["password"].ToString())
{
if(save.PasswordHashed == true)
save.Password = Encryption.Decrypt(save.Password);
server.DispatchTo(new Guid(msg.GUID), new NetObject("mud_savefile", new ServerMessage
{
@ -537,13 +544,8 @@ Contents:
break;
case "mud_save":
var sav = JsonConvert.DeserializeObject<Save>(msg.Contents);
if (!sav.PasswordHashed)
{
sav.Password = Encryption.Encrypt(sav.Password.ToString());
sav.PasswordHashed = true;
}
File.WriteAllText("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented));
WriteEncFile("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented));
server.DispatchTo(new Guid(msg.GUID), new NetObject("auth_failed", new ServerMessage
{
@ -559,11 +561,10 @@ Contents:
{
try
{
var save = JsonConvert.DeserializeObject<Save>(File.ReadAllText(savefile));
var save = JsonConvert.DeserializeObject<Save>(ReadEncFile(savefile));
string hashed = Encryption.Encrypt(args["password"].ToString());
if (save.Username == args["username"].ToString() && save.Password == hashed)
if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString())
{
server.DispatchTo(new Guid(msg.GUID), new NetObject("mud_savefile", new ServerMessage
{

View file

@ -347,7 +347,7 @@ So make sure your password is secure enough that it can't be guessed, but easy f
{
ShiftOS.Objects.ShiftFS.Utils.Delete(Paths.GetPath("user.dat"));
System.IO.File.WriteAllText(Paths.SaveFile, ShiftOS.Objects.ShiftFS.Utils.ExportMount(0));
Application.Restart();
SaveSystem.Restart();
}
}
}

View file

@ -190,11 +190,14 @@ namespace ShiftOS.WinForms
TextType("I will reboot your system in Tutorial Mode now. Complete the tutorial, and you shall be on your way.");
SaveSystem.CurrentSave = MySave;
SaveSystem.CurrentSave.StoryPosition = 1;
SaveSystem.SaveGame();
this.Invoke(new Action(() =>
Utils.WriteAllText(Paths.GetPath("user.dat"), JsonConvert.SerializeObject(new
{
this.Close();
username = MySave.Username,
password = MySave.Password
}));
SaveSystem.SaveGame();
Thread.Sleep(5000);
SaveSystem.Restart();
}));
this.Show();
this.BringToFront();

View file

@ -216,6 +216,12 @@ namespace ShiftOS.Engine
Console.WriteLine($"{{SHIFTORIUM_TRANSFERRED_TO}}: {amount} -> sys");
}
public static void Restart()
{
TerminalBackend.InvokeCommand("sos.shutdown");
System.Windows.Forms.Application.Restart();
}
public static void ReadSave()
{
//Migrate old saves.