-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make sandbox global and for per instance usage. This fixes ZelixLongE…
…ncryptionTransformer not removing decrypter classes correctly
- Loading branch information
1 parent
88c44a4
commit 6af601c
Showing
6 changed files
with
133 additions
and
92 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
deobfuscator-api/src/main/java/dev/xdark/ssvm/classloading/SupplyingClassLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package dev.xdark.ssvm.classloading; | ||
|
||
import dev.xdark.ssvm.VirtualMachine; | ||
import dev.xdark.ssvm.api.MethodInvoker; | ||
import dev.xdark.ssvm.api.VMInterface; | ||
import dev.xdark.ssvm.mirror.member.JavaMethod; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.net.URLStreamHandler; | ||
|
||
/** | ||
* A custom classloader to supply additional content to the {@link VirtualMachine}. | ||
* <br> | ||
* You will want to install this into the VM and use {@link VMInterface#setInvoker(JavaMethod, MethodInvoker)} on the | ||
* providing methods to supply classes and resources. | ||
* | ||
* @see SupplyingClassLoaderInstaller | ||
* | ||
* @author Matt Coley | ||
*/ | ||
public class SupplyingClassLoader extends ClassLoader { | ||
public native byte[] provideResource(String name); | ||
|
||
public native byte[] provideClass(String name); | ||
|
||
@Override | ||
protected Class<?> findClass(String name) throws ClassNotFoundException { | ||
byte[] classBytes = provideClass(name); | ||
if (classBytes != null) | ||
return defineClass(name, classBytes, 0, classBytes.length); | ||
return super.findClass(name); | ||
} | ||
|
||
@Override | ||
protected URL findResource(String name) { | ||
byte[] resourceBytes = provideResource(name); | ||
if (resourceBytes != null) { | ||
try { | ||
return new URL("memory", "", -1, "", new URLStreamHandler() { | ||
@Override | ||
protected URLConnection openConnection(URL u) { | ||
return new URLConnection(u) { | ||
private InputStream is; | ||
|
||
@Override | ||
public void connect() { | ||
// no-op | ||
} | ||
|
||
@Override | ||
public InputStream getInputStream() { | ||
if (is == null) { | ||
is = new ByteArrayInputStream(resourceBytes); | ||
} | ||
return is; | ||
} | ||
}; | ||
} | ||
}); | ||
} catch (MalformedURLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
return super.findResource(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.