From a3e3a10a5acc2eca2e7d2cc56b871f1a904153d5 Mon Sep 17 00:00:00 2001 From: OpticFusion1 Date: Fri, 1 Mar 2019 18:55:38 -0500 Subject: [PATCH] Changes Updates more checks that were using older code which threw exceptions or logging to console instead of just skipping the class. An issue will be opened up for this one. --- pom.xml | 2 +- .../check/checks/DailyLootBox.java | 16 ++++--- .../check/checks/DirectLeaks.java | 17 ++++--- .../check/checks/GreifingPlugin.java | 16 ++++--- .../mcantimalware/check/checks/ItzPlugin.java | 47 +++++++++++-------- .../check/checks/LagSignFixer.java | 3 ++ .../mcantimalware/check/checks/Minator.java | 16 ++++--- .../check/checks/MoneroMiner.java | 16 ++++--- .../mcantimalware/check/checks/Qlutch.java | 17 ++++--- 9 files changed, 93 insertions(+), 57 deletions(-) diff --git a/pom.xml b/pom.xml index e58ce2d..639df04 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 optic_fusion1 MCAntiMalware - 3.6 + 3.7 jar diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/DailyLootBox.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/DailyLootBox.java index c0f286f..9432573 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/DailyLootBox.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/DailyLootBox.java @@ -32,12 +32,16 @@ public class DailyLootBox extends Check { ZipEntry current = entries.nextElement(); inputStream = zipFile.getInputStream(current); if (current.getName().endsWith(".class")) { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; } } inputStream.close(); diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/DirectLeaks.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/DirectLeaks.java index 067335c..624843a 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/DirectLeaks.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/DirectLeaks.java @@ -33,14 +33,19 @@ public class DirectLeaks extends Check { ZipEntry current = entries.nextElement(); inputStream = zipFile.getInputStream(current); if (current.getName().endsWith(".class")) { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; } } + inputStream.close(); } catch (IOException ex) { Logger.getLogger(Minator.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/GreifingPlugin.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/GreifingPlugin.java index 6ce9b3a..54b0be1 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/GreifingPlugin.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/GreifingPlugin.java @@ -32,12 +32,16 @@ public class GreifingPlugin extends Check { ZipEntry current = entries.nextElement(); inputStream = zipFile.getInputStream(current); if (current.getName().endsWith(".class")) { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; } } inputStream.close(); diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/ItzPlugin.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/ItzPlugin.java index c18fbd5..faa3e35 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/ItzPlugin.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/ItzPlugin.java @@ -40,35 +40,42 @@ public class ItzPlugin extends Check { @Override public boolean process(String fileName, ZipFile zipFile) { - Enumeration zipEntries = zipFile.entries(); + Enumeration entries = zipFile.entries(); InputStream inputStream = null; - while (zipEntries.hasMoreElements()) { - ZipEntry currentZipEntry = (ZipEntry) zipEntries.nextElement(); + while (entries.hasMoreElements()) { try { - inputStream = zipFile.getInputStream(currentZipEntry); - } catch (IOException ex) { - Logger.getLogger(ItzPlugin.class.getName()).log(Level.SEVERE, null, ex); - } - if (currentZipEntry.getName().endsWith(".class")) { - try { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; - } - inputStream.close(); - } catch (IOException ex) { - Logger.getLogger(ItzPlugin.class.getName()).log(Level.SEVERE, null, ex); + ZipEntry current = entries.nextElement(); + inputStream = zipFile.getInputStream(current); + if (getMain().shouldLogDebugMessages()) { + getMain().getLogger().debug("LSF: " + current.getName()); } + if (detect(inputStream)) { + inputStream.close(); + return true; + } + if (current.getName().endsWith(".class")) { + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; + } + } + inputStream.close(); + } catch (IOException ex) { + Logger.getLogger(Minator.class.getName()).log(Level.SEVERE, null, ex); } } if (inputStream != null) { try { inputStream.close(); } catch (IOException ex) { - Logger.getLogger(SkySneak.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(MoneroMiner.class.getName()).log(Level.SEVERE, null, ex); } } return false; diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/LagSignFixer.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/LagSignFixer.java index 217cb98..fc818b2 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/LagSignFixer.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/LagSignFixer.java @@ -44,6 +44,9 @@ public class LagSignFixer extends Check { try { ZipEntry current = entries.nextElement(); inputStream = zipFile.getInputStream(current); + if (getMain().shouldLogDebugMessages()) { + getMain().getLogger().debug("LSF: " + current.getName()); + } if (detect(inputStream)) { inputStream.close(); return true; diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/Minator.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/Minator.java index 8efdca8..0ddcf22 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/Minator.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/Minator.java @@ -34,12 +34,16 @@ public class Minator extends Check { } } if (current.getName().endsWith(".class")) { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; } } inputStream.close(); diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/MoneroMiner.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/MoneroMiner.java index a0c6ac9..8b1d49b 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/MoneroMiner.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/MoneroMiner.java @@ -32,12 +32,16 @@ public class MoneroMiner extends Check { ZipEntry current = entries.nextElement(); inputStream = zipFile.getInputStream(current); if (current.getName().endsWith(".class")) { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; } } inputStream.close(); diff --git a/src/main/java/optic_fusion1/mcantimalware/check/checks/Qlutch.java b/src/main/java/optic_fusion1/mcantimalware/check/checks/Qlutch.java index 403c5b6..fe3a4a9 100644 --- a/src/main/java/optic_fusion1/mcantimalware/check/checks/Qlutch.java +++ b/src/main/java/optic_fusion1/mcantimalware/check/checks/Qlutch.java @@ -47,14 +47,19 @@ public class Qlutch extends Check { ZipEntry current = entries.nextElement(); inputStream = zipFile.getInputStream(current); if (current.getName().endsWith(".class")) { - ClassReader reader = new ClassReader(inputStream); - ClassNode node = new ClassNode(); - reader.accept(node, 0); - if (detect(node)) { - inputStream.close(); - return true; + try { + ClassReader reader = new ClassReader(inputStream); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + if (detect(node)) { + inputStream.close(); + return true; + } + } catch (Exception e) { + continue; } } + inputStream.close(); } catch (IOException ex) { Logger.getLogger(Minator.class.getName()).log(Level.SEVERE, null, ex); }