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;
import io.github.thetrouper.sentinel.auth.Auth;
import io.github.thetrouper.sentinel.commands.*;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.data.LanguageFile;
@@ -43,8 +44,11 @@ public final class Sentinel extends JavaPlugin {
identifier = 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";
try {
authStatus = Authenticator.authorize(key, serverID);
authstatus = Auth.authorize(key,serverID);
} catch (Exception e) {
e.printStackTrace();
log.info("WTFFFF ARE YOU DOING MAN??????");
@@ -53,17 +57,18 @@ public final class Sentinel extends JavaPlugin {
switch (authStatus) {
case "AUTHORIZED" -> {
startup();
authstatus = authstatus.replaceAll("ur a skid lmao","get out of here kiddo");
}
case "MINEHUT" -> {
usesDynamicIP = true;
String minehutStatus = Telemetry.loadTelemetryHook(serverID, key);
switch (minehutStatus) {
case "SUCCESS" -> {
log.info("Dynamic IP auth Success!");
log.info("Dynamic IP auth Success! " + authstatus);
startup();
}
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);
}
}

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
public void registerCompletions(CompletionBuilder builder) {
builder.addCompletion(1, ArrayUtils.toNewList(Bukkit.getOnlinePlayers(), Player::getName));
builder.addCompletion(2,builder.args.length >= 2,new String[]{
"[<message>]"
});
builder.addCompletion(2,builder.args.length >= 2, "[<message>]");
}
}

View File

@@ -21,7 +21,7 @@ public class ReplyCommand extends CustomCommand {
@Override
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);
UUID senderID = p.getUniqueId();
if (replyMap.get(senderID) == null) {
@@ -43,8 +43,6 @@ public class ReplyCommand extends CustomCommand {
@Override
public void registerCompletions(CompletionBuilder builder) {
builder.addCompletion(1,builder.args.length >= 2,new String[]{
"[<message>]"
});
builder.addCompletion(1,builder.args.length >= 2, "[<message>]");
}
}

View File

@@ -20,7 +20,7 @@ public class SocialSpyCommand extends CustomCommand {
@Override
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);
UUID senderID = p.getUniqueId();
if (!spyMap.containsKey(senderID) || !spyMap.get(senderID)) {

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,5 @@
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.spec.SecretKeySpec;
import java.io.BufferedReader;
@@ -14,15 +11,6 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
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 {
@@ -118,7 +106,7 @@ public class Authenticator {
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] encryptedBytes = cipher.doFinal(text.getBytes());
String encryptedText = bytesToHex(encryptedBytes);;
String encryptedText = bytesToHex(encryptedBytes);
return encryptedText;
} catch (Exception e) {
e.printStackTrace();

View File

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