mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-12-06 16:59:37 +01:00
cube doesn't like calling it malware
This commit is contained in:
@@ -92,7 +92,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
private final TaskScheduler scheduler = UniversalScheduler.getScheduler(this);
|
||||
|
||||
private BukkitAudiences adventure;
|
||||
private boolean malwareDetected = false;
|
||||
private boolean maliciousExpansions = false;
|
||||
|
||||
|
||||
/**
|
||||
@@ -153,9 +153,9 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
public void onLoad() {
|
||||
saveDefaultConfig();
|
||||
|
||||
malwareDetected = new MaliciousExpansionCheck(this).runChecks();
|
||||
maliciousExpansions = new MaliciousExpansionCheck(this).runChecks();
|
||||
|
||||
if (malwareDetected) {
|
||||
if (maliciousExpansions) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (malwareDetected) {
|
||||
if (maliciousExpansions) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -185,6 +185,10 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (maliciousExpansions) {
|
||||
return;
|
||||
}
|
||||
|
||||
getCloudExpansionManager().kill();
|
||||
getLocalExpansionManager().kill();
|
||||
|
||||
|
||||
@@ -46,35 +46,35 @@ public final class MaliciousExpansionCheck {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Set<String> knownMalware;
|
||||
final Set<String> knownMaliciousExpansions;
|
||||
|
||||
try {
|
||||
final String malware = Resources.toString(new URL("https://check.placeholderapi.com"), StandardCharsets.UTF_8);
|
||||
knownMalware = Arrays.stream(malware.split("\n")).collect(Collectors.toSet());
|
||||
knownMaliciousExpansions = Arrays.stream(malware.split("\n")).collect(Collectors.toSet());
|
||||
} catch (Exception e) {
|
||||
main.getLogger().log(Level.SEVERE, "Failed to download anti malware hash check list from https://check.placeholderapi.com", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Set<String> malwarePaths = new HashSet<>();
|
||||
final Set<String> maliciousPaths = new HashSet<>();
|
||||
|
||||
for (File file : expansionsFolder.listFiles()) {
|
||||
try {
|
||||
final String hash = Hashing.sha256().hashBytes(Files.asByteSource(file).read()).toString();
|
||||
|
||||
if (knownMalware.contains(hash)) {
|
||||
malwarePaths.add(file.getAbsolutePath());
|
||||
if (knownMaliciousExpansions.contains(hash)) {
|
||||
maliciousPaths.add(file.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
main.getLogger().log(Level.SEVERE, "Error occurred while trying to read " + file.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (malwarePaths.isEmpty()) {
|
||||
if (maliciousPaths.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
main.getLogger().severe(String.format(MESSAGE, malwarePaths.stream().map(p -> "HASH OF " + p + " MATCHES KNOWN MALICIOUS EXPANSION DELETE IMMEDIATELY\n").collect(Collectors.joining())));
|
||||
main.getLogger().severe(String.format(MESSAGE, maliciousPaths.stream().map(p -> "HASH OF " + p + " MATCHES KNOWN MALICIOUS EXPANSION DELETE IMMEDIATELY\n").collect(Collectors.joining())));
|
||||
|
||||
main.getServer().shutdown();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user