2021-06-27 21:45:36 +00:00
import java.lang.reflect.Field ;
2022-01-08 10:48:25 +00:00
import java.util.List ;
2024-10-03 03:12:58 +00:00
2021-06-27 21:45:36 +00:00
import org.objectweb.asm.tree.ClassNode ;
2022-01-08 10:48:25 +00:00
import org.objectweb.asm.tree.FieldNode ;
2024-10-03 03:12:58 +00:00
import the.bytecode.club.bytecodeviewer.* ;
2022-01-08 10:48:25 +00:00
import the.bytecode.club.bytecodeviewer.api.* ;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog ;
2021-06-27 21:45:36 +00:00
2024-10-03 03:12:58 +00:00
import static the.bytecode.club.bytecodeviewer.Constants.NL ;
2021-06-27 21:45:36 +00:00
/ * *
2024-10-03 03:12:58 +00:00
* * This is an example of a String Decrypter Java Plugin for BCV .
* *
* * @author [ Your - Name - Goes - Here ]
2022-01-22 19:20:47 +00:00
* * /
2024-10-03 03:12:58 +00:00
public class ExampleStringDecrypter extends Plugin
{
2021-06-27 21:45:36 +00:00
@Override
2024-10-03 03:12:58 +00:00
public void execute ( List < ClassNode > classNodesList )
{
2022-01-18 01:35:13 +00:00
PluginConsole gui = new PluginConsole ( " Example String Decrypter Java Edition " ) ;
2021-06-27 21:45:36 +00:00
2024-10-03 03:12:58 +00:00
MultipleChoiceDialog dialog = new MultipleChoiceDialog ( " Bytecode Viewer - WARNING " , " WARNING: This will load the classes into the JVM and execute the initialize function " + NL +
" for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE. " , new String [ ] { " Continue " , " Cancel " } ) ;
2021-06-27 21:45:36 +00:00
2024-10-03 03:12:58 +00:00
if ( dialog . promptChoice ( ) = = 0 )
{
2022-01-22 19:02:24 +00:00
boolean needsWarning = false ;
2024-10-03 03:12:58 +00:00
for ( ClassNode cn : classNodesList )
{
try
{
2022-01-22 19:06:18 +00:00
//load the class node into the classloader
BCV . getClassNodeLoader ( ) . addClass ( cn ) ;
2024-10-03 03:12:58 +00:00
for ( Object o : cn . fields . toArray ( ) )
{
2022-01-22 19:06:18 +00:00
FieldNode f = ( FieldNode ) o ;
2024-10-03 03:12:58 +00:00
2022-01-22 19:06:18 +00:00
//if the class contains the field z, get the class object from the class node
//then print out the value of the fields inside the class
//if the strings get decrypted on init, this allows you to dump the current values
2024-10-03 03:12:58 +00:00
if ( f . name . equals ( " z " ) )
{
try
{
for ( Field f2 : BCV . getClassNodeLoader ( ) . nodeToClass ( cn ) . getFields ( ) )
{
2022-01-22 19:06:18 +00:00
String s = ( String ) f2 . get ( null ) ;
if ( s ! = null & & ! s . isEmpty ( ) )
gui . appendText ( cn + " : " + s ) ;
}
2024-10-03 03:12:58 +00:00
}
catch ( Exception ignored )
{
2021-06-27 21:45:36 +00:00
}
2022-01-08 10:48:25 +00:00
}
2021-06-27 21:45:36 +00:00
}
2024-10-03 03:12:58 +00:00
}
catch ( Exception e )
{
2022-01-22 19:06:18 +00:00
gui . appendText ( " Failed loading class " + cn . name ) ;
e . printStackTrace ( ) ;
needsWarning = true ;
2021-06-27 21:45:36 +00:00
}
2022-01-22 19:02:24 +00:00
}
2024-10-03 03:12:58 +00:00
if ( needsWarning )
{
BytecodeViewer . showMessage ( " Some classes failed to decrypt, if you'd like to decrypt all of them " + NL +
" makes sure you include ALL the libraries it requires. " ) ;
2021-06-27 21:45:36 +00:00
}
gui . setVisible ( true ) ;
}
}
2024-10-03 03:12:58 +00:00
2022-01-08 10:48:25 +00:00
}