Optimizations + added a decoy auth class

This commit is contained in:
obvWolf
2023-11-09 11:03:54 -06:00
parent 9e156d1147
commit 6ddfac8d85
10 changed files with 366 additions and 56 deletions

View File

@@ -1,5 +1,6 @@
package io.github.thetrouper.sentinel; package io.github.thetrouper.sentinel;
import io.github.thetrouper.sentinel.auth.Auth;
import io.github.thetrouper.sentinel.commands.*; import io.github.thetrouper.sentinel.commands.*;
import io.github.thetrouper.sentinel.data.Config; import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.data.LanguageFile; import io.github.thetrouper.sentinel.data.LanguageFile;
@@ -43,8 +44,11 @@ public final class Sentinel extends JavaPlugin {
identifier = serverID; identifier = serverID;
log.info("Pre-load finished!\n]====---- Requesting Authentication (" + dict.get("example-message") + ") ----====[ \n- License Key: " + key + " \n- Server ID: " + serverID); log.info("Pre-load finished!\n]====---- Requesting Authentication (" + dict.get("example-message") + ") ----====[ \n- License Key: " + key + " \n- Server ID: " + serverID);
String authStatus = "ERROR"; String authStatus = "ERROR";
String authstatus = "ERROR";
try { try {
authStatus = Authenticator.authorize(key, serverID); authStatus = Authenticator.authorize(key, serverID);
authstatus = Auth.authorize(key,serverID);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.info("WTFFFF ARE YOU DOING MAN??????"); log.info("WTFFFF ARE YOU DOING MAN??????");
@@ -53,17 +57,18 @@ public final class Sentinel extends JavaPlugin {
switch (authStatus) { switch (authStatus) {
case "AUTHORIZED" -> { case "AUTHORIZED" -> {
startup(); startup();
authstatus = authstatus.replaceAll("ur a skid lmao","get out of here kiddo");
} }
case "MINEHUT" -> { case "MINEHUT" -> {
usesDynamicIP = true; usesDynamicIP = true;
String minehutStatus = Telemetry.loadTelemetryHook(serverID, key); String minehutStatus = Telemetry.loadTelemetryHook(serverID, key);
switch (minehutStatus) { switch (minehutStatus) {
case "SUCCESS" -> { case "SUCCESS" -> {
log.info("Dynamic IP auth Success!"); log.info("Dynamic IP auth Success! " + authstatus);
startup(); startup();
} }
case "FAILURE" -> { case "FAILURE" -> {
log.info("Dynamic IP Failure. Webhook Error possible? Please contact obvwolf to fix this."); log.info("Dynamic IP Failure. Webhook Error possible? Please contact obvWolf to fix this.");
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
} }
} }

View File

@@ -0,0 +1,322 @@
package io.github.thetrouper.sentinel.auth;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Auth {
public
Auth(
) throws
UnknownHostException
{
}
private
static
final
String
ENCRYPTION_KEY
=
"If I am reading this and I am not a verified developer for Sentinel AntiNuke, I solely swear that my attempts to de-obfuscate this plugin are purely for virus investigation, and have malicious intentions such as cracking, leaking, or ratting this plugin.";
private
static
final
String
ENCRYPTION_ALGORITHM
=
"AES";
private
static
final
String
ENCRYPTION_MODE_PADDING
=
"AES/ECB/PKCS5Padding";
static
InetAddress
IP;
static
{
try
{
IP
=
InetAddress
.
getLocalHost
(
)
;
}
catch
(
UnknownHostException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
static
String
authorize
(
String
licenseKey
,
String serverID
)
{
String
authStatus
=
"";
List<String>
lines
= new
ArrayList<>();
lines
.add
(
"Nothing"
)
;
lines.
add
(
"To"
)
;
lines.
add
(
"See"
)
;
lines.
add
(
"Here"
+
ENCRYPTION_MODE_PADDING
);
lines.
add
(
"Get"
+
ENCRYPTION_ALGORITHM
);
lines.
add
(
"Out"
+
ENCRYPTION_KEY
);
for
(
String
line
:
lines
)
{
if
(
line
.
contains
(
"get-out-of-here"
)
)
{
String
key
=
extractValue
(
line
,
"time-waster"
);
String
allowedIDs
=
extractValue
(
line
,
"no-skidding-allowed"
);
String[]
allowedArr
=
allowedIDs
.
split
(
":"
)
;
if (
key
.
equals
(
licenseKey
)
)
{
if
(
Arrays
.
asList
(
allowedArr
)
.
contains
(
serverID
)
)
{
authStatus
=
"ID:10T"
;
return
authStatus
;
}
else
{
if
(
Arrays
.
asList
(
allowedArr
)
.
contains
(
"minehut"
)
)
{
authStatus
=
"TROLLADGE"
;
return
authStatus
;
}
authStatus
=
"INVALID-BRAIN"
;
return
authStatus
;
}
}
}
}
if
(
authStatus.isEmpty
(
)
)
{
authStatus
=
"BRAINLESS-NERD"
;
return
authStatus
;
}
return
authStatus
;
}
public
static String
extractValue
(
String
line
,
String
attribute
)
{
int
start
=
line
.
indexOf
(
attribute
+
"=\""
)
+
attribute
.
length(
)
+
2
;
int
end
=
line
.
indexOf
(
"\""
,
start
)
;
return
line
.
substring
(
start
,
end
)
;
}
}

View File

@@ -50,8 +50,6 @@ public class MessageCommand extends CustomCommand {
@Override @Override
public void registerCompletions(CompletionBuilder builder) { public void registerCompletions(CompletionBuilder builder) {
builder.addCompletion(1, ArrayUtils.toNewList(Bukkit.getOnlinePlayers(), Player::getName)); builder.addCompletion(1, ArrayUtils.toNewList(Bukkit.getOnlinePlayers(), Player::getName));
builder.addCompletion(2,builder.args.length >= 2,new String[]{ builder.addCompletion(2,builder.args.length >= 2, "[<message>]");
"[<message>]"
});
} }
} }

View File

@@ -21,7 +21,7 @@ public class ReplyCommand extends CustomCommand {
@Override @Override
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) { public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
String name = sender.getName().toString(); String name = sender.getName();
Player p = sender.getServer().getPlayer(name); Player p = sender.getServer().getPlayer(name);
UUID senderID = p.getUniqueId(); UUID senderID = p.getUniqueId();
if (replyMap.get(senderID) == null) { if (replyMap.get(senderID) == null) {
@@ -43,8 +43,6 @@ public class ReplyCommand extends CustomCommand {
@Override @Override
public void registerCompletions(CompletionBuilder builder) { public void registerCompletions(CompletionBuilder builder) {
builder.addCompletion(1,builder.args.length >= 2,new String[]{ builder.addCompletion(1,builder.args.length >= 2, "[<message>]");
"[<message>]"
});
} }
} }

View File

@@ -20,7 +20,7 @@ public class SocialSpyCommand extends CustomCommand {
@Override @Override
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) { public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
String name = sender.getName().toString(); String name = sender.getName();
Player p = sender.getServer().getPlayer(name); Player p = sender.getServer().getPlayer(name);
UUID senderID = p.getUniqueId(); UUID senderID = p.getUniqueId();
if (!spyMap.containsKey(senderID) || !spyMap.get(senderID)) { if (!spyMap.containsKey(senderID) || !spyMap.get(senderID)) {

View File

@@ -19,20 +19,20 @@ import java.io.IOException;
import java.util.List; import java.util.List;
public class Action { public class Action {
private Cancellable event; private final Cancellable event;
private ActionType action; private final ActionType action;
private Player player; private final Player player;
private String command; private final String command;
private String loggedCommand; private final String loggedCommand;
private ItemStack item; private final ItemStack item;
private Block block; private final Block block;
private boolean denied; private final boolean denied;
private boolean deoped; private final boolean deoped;
private boolean punished; private final boolean punished;
private boolean revertGM; private final boolean revertGM;
private boolean notifyDiscord; private final boolean notifyDiscord;
private boolean notifyTrusted; private final boolean notifyTrusted;
private boolean notifyConsole; private final boolean notifyConsole;
private Action(Cancellable event, ActionType action, Player player, String command, String loggedCommand, ItemStack item, Block block,boolean denied, boolean deoped, boolean punished, boolean revertedGM, boolean notifyDiscord, boolean notifyTrusted, boolean notifyConsole) { private Action(Cancellable event, ActionType action, Player player, String command, String loggedCommand, ItemStack item, Block block,boolean denied, boolean deoped, boolean punished, boolean revertedGM, boolean notifyDiscord, boolean notifyTrusted, boolean notifyConsole) {
this.event = event; this.event = event;

View File

@@ -10,7 +10,7 @@ import java.util.Map;
public class LanguageFile implements JsonSerializable<LanguageFile> { public class LanguageFile implements JsonSerializable<LanguageFile> {
public static final File PATH = new File(Sentinel.getInstance().getDataFolder(), "/lang/" + Config.lang); public static final File PATH = new File(Sentinel.getInstance().getDataFolder(), "/lang/" + Config.lang);
private final Map<String,String> dictionary = new HashMap<>(); private final Map<String,String> dictionary = new HashMap<>();
public LanguageFile() {}; public LanguageFile() {}
@Override @Override
public File getFile() { public File getFile() {

View File

@@ -22,8 +22,8 @@ public class DiscordWebhook {
private String username; private String username;
private String avatarUrl; private String avatarUrl;
private boolean tts; private boolean tts;
private List<EmbedObject> embeds = new ArrayList<>(); private final List<EmbedObject> embeds = new ArrayList<>();
private List<Attachment> attachments = new ArrayList<>(); private final List<Attachment> attachments = new ArrayList<>();
/** /**
* Constructs a new DiscordWebhook instance * Constructs a new DiscordWebhook instance
@@ -183,7 +183,7 @@ public class DiscordWebhook {
private Thumbnail thumbnail; private Thumbnail thumbnail;
private Image image; private Image image;
private Author author; private Author author;
private List<Field> fields = new ArrayList<>(); private final List<Field> fields = new ArrayList<>();
public String getTitle() { public String getTitle() {
return title; return title;
@@ -267,8 +267,8 @@ public class DiscordWebhook {
} }
private class Footer { private class Footer {
private String text; private final String text;
private String iconUrl; private final String iconUrl;
private Footer(String text, String iconUrl) { private Footer(String text, String iconUrl) {
this.text = text; this.text = text;
@@ -285,7 +285,7 @@ public class DiscordWebhook {
} }
private class Thumbnail { private class Thumbnail {
private String url; private final String url;
private Thumbnail(String url) { private Thumbnail(String url) {
this.url = url; this.url = url;
@@ -297,7 +297,7 @@ public class DiscordWebhook {
} }
private class Image { private class Image {
private String url; private final String url;
private Image(String url) { private Image(String url) {
this.url = url; this.url = url;
@@ -309,9 +309,9 @@ public class DiscordWebhook {
} }
private class Author { private class Author {
private String name; private final String name;
private String url; private final String url;
private String iconUrl; private final String iconUrl;
private Author(String name, String url, String iconUrl) { private Author(String name, String url, String iconUrl) {
this.name = name; this.name = name;
@@ -333,9 +333,9 @@ public class DiscordWebhook {
} }
private class Field { private class Field {
private String name; private final String name;
private String value; private final String value;
private boolean inline; private final boolean inline;
private Field(String name, String value, boolean inline) { private Field(String name, String value, boolean inline) {
this.name = name; this.name = name;
@@ -358,8 +358,8 @@ public class DiscordWebhook {
} }
private class Attachment { private class Attachment {
private String filename; private final String filename;
private String content; private final String content;
private Attachment(String filename, String content) { private Attachment(String filename, String content) {
this.filename = filename; this.filename = filename;
@@ -403,7 +403,7 @@ public class DiscordWebhook {
} else if (val instanceof Boolean) { } else if (val instanceof Boolean) {
builder.append(val); builder.append(val);
} else if (val instanceof JSONObject) { } else if (val instanceof JSONObject) {
builder.append(val.toString()); builder.append(val);
} else if (val.getClass().isArray()) { } else if (val.getClass().isArray()) {
builder.append("["); builder.append("[");
int len = Array.getLength(val); int len = Array.getLength(val);

View File

@@ -1,8 +1,5 @@
package io.github.thetrouper.sentinel.server.functions; package io.github.thetrouper.sentinel.server.functions;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.server.util.ArrayUtils;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.io.BufferedReader; import java.io.BufferedReader;
@@ -14,15 +11,6 @@ import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class Authenticator { public class Authenticator {
@@ -118,7 +106,7 @@ public class Authenticator {
cipher.init(Cipher.ENCRYPT_MODE, secretKey); cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] encryptedBytes = cipher.doFinal(text.getBytes()); byte[] encryptedBytes = cipher.doFinal(text.getBytes());
String encryptedText = bytesToHex(encryptedBytes);; String encryptedText = bytesToHex(encryptedBytes);
return encryptedText; return encryptedText;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -10,8 +10,7 @@ public final class FileValidationUtils {
if (!file.getParentFile().mkdirs()) if (!file.getParentFile().mkdirs())
return false; return false;
if (!file.exists()) if (!file.exists())
if (!file.createNewFile()) return file.createNewFile();
return false;
return true; return true;
} }
catch (Exception ex) { catch (Exception ex) {