Heavier password encryption
I don't think this fixes actual bugs but the encryption seemed kinda weak.
This commit is contained in:
@@ -6,6 +6,7 @@ using Barotrauma.Networking.ReliableMessages;
|
|||||||
using FarseerPhysics;
|
using FarseerPhysics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
@@ -172,7 +173,7 @@ namespace Barotrauma.Networking
|
|||||||
reconnectBox.Buttons[0].OnClicked += reconnectBox.Close;
|
reconnectBox.Buttons[0].OnClicked += reconnectBox.Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoroutineManager.StartCoroutine(WaitForStartingInfo(password));
|
CoroutineManager.StartCoroutine(WaitForStartingInfo(Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(password)))));
|
||||||
|
|
||||||
// Start the timer
|
// Start the timer
|
||||||
//update.Start();
|
//update.Start();
|
||||||
@@ -336,9 +337,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
var outmsg = client.CreateMessage();
|
var outmsg = client.CreateMessage();
|
||||||
|
|
||||||
NetEncryption algo = new NetXtea(client, password);
|
string saltedPw = password;
|
||||||
|
saltedPw = saltedPw + Convert.ToString(nonce);
|
||||||
|
saltedPw = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(saltedPw)));
|
||||||
|
NetEncryption algo = new NetXtea(client, saltedPw);
|
||||||
outmsg.Write((byte)PacketTypes.Login);
|
outmsg.Write((byte)PacketTypes.Login);
|
||||||
outmsg.Write(nonce);
|
outmsg.Write(saltedPw);
|
||||||
outmsg.Write(myID);
|
outmsg.Write(myID);
|
||||||
outmsg.Write(GameMain.Version.ToString());
|
outmsg.Write(GameMain.Version.ToString());
|
||||||
outmsg.Write(GameMain.SelectedPackage.Name);
|
outmsg.Write(GameMain.SelectedPackage.Name);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
@@ -55,7 +56,7 @@ namespace Barotrauma.Networking
|
|||||||
name = name.Replace(";", "");
|
name = name.Replace(";", "");
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.password = password;
|
this.password = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(password)));
|
||||||
|
|
||||||
config = new NetPeerConfiguration("barotrauma");
|
config = new NetPeerConfiguration("barotrauma");
|
||||||
|
|
||||||
@@ -1510,13 +1511,13 @@ namespace Barotrauma.Networking
|
|||||||
sender.ChatMessages.RemoveAt(0);
|
sender.ChatMessages.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.inGame || (Screen.Selected == GameMain.NetLobbyScreen))
|
if (sender.inGame || (Screen.Selected == GameMain.NetLobbyScreen))
|
||||||
{
|
{
|
||||||
AddChatMessage(message);
|
AddChatMessage(message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameServer.Log(message.Text, message.Color);
|
GameServer.Log(message.Text, message.Color);
|
||||||
}
|
}
|
||||||
sender.ChatSpamSpeed += 5.0f;
|
sender.ChatSpamSpeed += 5.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -62,11 +62,14 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
unauthenticatedClients.Remove(unauthenticatedClient);
|
unauthenticatedClients.Remove(unauthenticatedClient);
|
||||||
|
|
||||||
NetEncryption algo = new NetXtea(server, password);
|
string saltedPw = password;
|
||||||
|
saltedPw = saltedPw + Convert.ToString(unauthenticatedClient.Nonce);
|
||||||
|
saltedPw = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(saltedPw)));
|
||||||
|
NetEncryption algo = new NetXtea(server, saltedPw);
|
||||||
inc.Decrypt(algo);
|
inc.Decrypt(algo);
|
||||||
|
|
||||||
int nonce = inc.ReadInt32();
|
string rdPw = inc.ReadString();
|
||||||
if (nonce != unauthenticatedClient.Nonce)
|
if (rdPw != saltedPw)
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Disconnect("Wrong password!");
|
inc.SenderConnection.Disconnect("Wrong password!");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -647,8 +647,8 @@ namespace Barotrauma.Networking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ManagePlayersFrame(GUIFrame infoFrame)
|
public void ManagePlayersFrame(GUIFrame infoFrame)
|
||||||
{
|
{
|
||||||
GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 280, 300), Color.White * 0.7f, GUI.Style, infoFrame);
|
GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 280, 300), Color.White * 0.7f, GUI.Style, infoFrame);
|
||||||
cList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
cList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||||
//crewList.OnSelected = SelectCrewCharacter;
|
//crewList.OnSelected = SelectCrewCharacter;
|
||||||
@@ -677,7 +677,7 @@ namespace Barotrauma.Networking
|
|||||||
kickButton.OnClicked += GameMain.NetLobbyScreen.KickPlayer;
|
kickButton.OnClicked += GameMain.NetLobbyScreen.KickPlayer;
|
||||||
|
|
||||||
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user