Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement password hashing #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/org/itxtech/nemisys/Server.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.itxtech.nemisys;

import com.google.common.hash.Hashing;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gson.Gson;
import lombok.Getter;
Expand Down Expand Up @@ -29,6 +30,7 @@
import org.itxtech.nemisys.utils.*;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
Expand Down Expand Up @@ -118,7 +120,7 @@ public Server(MainLogger logger, final String filePath, String dataPath, String
put("server-port", 19132);
put("synapse-ip", "0.0.0.0");
put("synapse-port", 10305);
put("password", "1234567890123456"/* TODO MD5 Password*/);
put("password", "1234567890123456");
put("lang", "eng");
put("async-workers", "auto");
put("enable-profiling", false);
Expand Down Expand Up @@ -285,7 +287,7 @@ public void updateClientData() {

public boolean comparePassword(String pass) {
String truePass = this.getPropertyString("password", "1234567890123456");
return (truePass.equals(pass));
return Hashing.md5().hashBytes(truePass.getBytes(StandardCharsets.UTF_8)).toString().equals(pass);
}

public void enablePlugins() {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/itxtech/nemisys/synapse/SynapseEntry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.itxtech.nemisys.synapse;

import com.google.common.hash.Hashing;
import com.google.gson.Gson;
import org.itxtech.nemisys.Nemisys;
import org.itxtech.nemisys.Player;
Expand All @@ -14,6 +15,7 @@

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import java.util.*;

/**
Expand Down Expand Up @@ -165,7 +167,7 @@ public void connect() {
this.getSynapse().getLogger().notice("Connecting " + this.getHash());
this.verified = false;
ConnectPacket pk = new ConnectPacket();
pk.password = this.password;
pk.password = Hashing.md5().hashBytes(this.password.getBytes(StandardCharsets.UTF_8)).toString();
pk.isMainServer = this.isMainServer();
pk.description = this.serverDescription;
pk.maxPlayers = this.getSynapse().getServer().getMaxPlayers();
Expand Down