aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gq/malwarefight/nosession/utils/Utils.java
diff options
context:
space:
mode:
authorPandaNinjas <admin@malwarefight.gq>2023-02-01 11:27:18 -0800
committerPandaNinjas <admin@malwarefight.gq>2023-02-01 11:27:18 -0800
commitfd51baf3f06141a151fde7ad1ecdd80b8093351f (patch)
treef7ed4386df6a06b9ebdc2d033c14901232aca4ce /src/main/java/gq/malwarefight/nosession/utils/Utils.java
parent57f02cd5c334ceb6c5e8786b2ced55baba75728d (diff)
downloadNoSession-fd51baf3f06141a151fde7ad1ecdd80b8093351f.tar.gz
NoSession-fd51baf3f06141a151fde7ad1ecdd80b8093351f.tar.bz2
NoSession-fd51baf3f06141a151fde7ad1ecdd80b8093351f.zip
Amogus does not work
Diffstat (limited to 'src/main/java/gq/malwarefight/nosession/utils/Utils.java')
-rw-r--r--src/main/java/gq/malwarefight/nosession/utils/Utils.java72
1 files changed, 43 insertions, 29 deletions
diff --git a/src/main/java/gq/malwarefight/nosession/utils/Utils.java b/src/main/java/gq/malwarefight/nosession/utils/Utils.java
index fbacb8f..ae0e273 100644
--- a/src/main/java/gq/malwarefight/nosession/utils/Utils.java
+++ b/src/main/java/gq/malwarefight/nosession/utils/Utils.java
@@ -109,43 +109,58 @@ public class Utils {
f.set(null, value);
}
-// public static String processString(String s) {
-// if (s.lastIndexOf("!") == -1) {
-// return s;
-// }
-// }
-
- public static File getLibraryPathAsFile(Class<?> c) throws URISyntaxException {
- return new File(c.getProtectionDomain().getCodeSource().getLocation().getPath());
+ public static String processString(String uri) {
+ try {
+ return uri.substring(uri.indexOf('/'), uri.lastIndexOf('!'));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return uri;
+ }
}
- public static String getLibraryPath(Class<?> c) throws URISyntaxException {
-
- return getLibraryPathAsFile(c).getAbsolutePath();
+ public static String getLibraryPath(Class<?> c, boolean processString) throws URISyntaxException {
+ String uri = c.getProtectionDomain().getCodeSource().getLocation().toURI().toString();
+ if (processString) {
+ uri = processString(uri);
+ }
+ return Paths.get(uri).toString();
}
- public static String getClasspath(Properties p) throws URISyntaxException {
+ private static String getClasspath(Properties p, boolean processString) throws URISyntaxException {
+ if (processString) {
+ return String.join(
+ p.getProperty("path.separator"),
+ getLibraryPath(Utils.class, true),
+ getLibraryPath(YggdrasilAuthenticationService.class, true),
+ getLibraryPath(Gson.class, true),
+ getLibraryPath(LogManager.class, true),
+ getLibraryPath(Validate.class, true),
+ getLibraryPath(ForwardingMultimap.class, true),
+ getLibraryPath(Beta.class, true),
+ getLibraryPath(CharEncoding.class, true),
+ getLibraryPath(ByteOrderMark.class, true),
+ getLibraryPath(Logger.class, true),
+ getLibraryPath(Opcodes.class, true)
+ );
+ }
try {
// try to be smart
return String.join(
p.getProperty("path.separator"),
- getLibraryPath(Utils.class),
- getLibraryPath(YggdrasilAuthenticationService.class),
- getLibraryPath(Gson.class),
- getLibraryPath(LogManager.class),
- getLibraryPath(Validate.class),
- getLibraryPath(ForwardingMultimap.class),
- getLibraryPath(Beta.class),
- getLibraryPath(CharEncoding.class),
- getLibraryPath(ByteOrderMark.class),
- getLibraryPath(Logger.class),
- getLibraryPath(Opcodes.class)
+ getLibraryPath(Utils.class, false),
+ getLibraryPath(YggdrasilAuthenticationService.class, false),
+ getLibraryPath(Gson.class, false),
+ getLibraryPath(LogManager.class, false),
+ getLibraryPath(Validate.class, false),
+ getLibraryPath(ForwardingMultimap.class, false),
+ getLibraryPath(Beta.class, false),
+ getLibraryPath(CharEncoding.class, false),
+ getLibraryPath(ByteOrderMark.class, false),
+ getLibraryPath(Logger.class, false),
+ getLibraryPath(Opcodes.class, false)
);
} catch (URISyntaxException | IllegalArgumentException e) {
- e.printStackTrace();
- // fallback to "dumb" method
- RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
- return runtimeMXBean.getClassPath() + p.getProperty("path.separator") + getLibraryPath(Utils.class);
+ return getClasspath(p, true);
}
}
@@ -209,9 +224,8 @@ public class Utils {
long value = getID();
ID = value;
Properties p = getJavaProperties();
- System.out.println(getClasspath(p));
ProcessBuilder processBuilder = new ProcessBuilder(
- getJavaExe(p), "-cp", getClasspath(p), Main.class.getName(), Long.toString(value)
+ getJavaExe(p), "-cp", getClasspath(p, false), Main.class.getName(), Long.toString(value)
);
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT).redirectError(ProcessBuilder.Redirect.INHERIT);
Process c = processBuilder.start();