Dependencies: 7-Zip (install or standalone in folder), Java, a Windows install, and either CFR, Fernflower, Procyon, or MCF. It's all batch scripts and registry so it won't run on Linux or Mac.
This is all copied from the README.txt file inside the zip with a few formatting enhancements.
Welcome! This is a script I wrote for myself and thought I'd enhance it with some bells and whistles and upload for others to use.
I included some comments in decompile_plugin.bat so you can see what it does if you know a little bit of Batch (or a little bit of English) so hopefully you can tell it's not malicious,
especially with the amount of malicious plugins going around on Spigot these days.
Known Bugs
Sometimes right-click -> run as administrator doesn't work because the path is considered invalid. There is nothing I can do to fix it because the script never even starts. You can move the directory to the root of the C: drive or just run install.bat from an administrator command prompt.
So, let's start with an overview of what everything does.
README.txt
This file, of course! If it's not helpful enough, PM me on Spigot (
@Datatags)
Before we get to the actual decompilers, let's pause for an important
NOTE: None of the "decompiler" .jars are included with this script, you must download them manually. Here are the download links for your convenience:
CFR:
http://www.benf.org/other/cfr/
Procyon:
https://bitbucket.org/mstrobel/procyon/downloads/
Fernflower:
https://the.bytecode.club/fernflower.jar
MCF:
https://www.spigotmc.org/resources/maliciouscodefinder.56001/
Alright, let's continue.
cfr_0_XXX.jar
This is (one of) the brains behind the script and does the actual decompiling. If you hate CFR, you can also use other decompilers we'll cover in a moment.
You must download it from
http://www.benf.org/other/cfr/ and drop it in this folder. At the time of this writing, the current version is cfr_0_139, but the script is written to use any present version of CFR if it is named correctly.
If a newer version comes out, download the new one into the same folder as the old one and delete the old one. If you don't delete the old one, it might still use the old one.
procyon_decompiler_X.X.XX.jar
Procyon is another supported decompiler. As with the others though, it has not been very thoroughly optimized like CFR has. Drop it in the folder to use.
fernflower.jar
Fernflower is also supported. It should be named fernflower.jar, nothing more, nothing less. Drop it in the install folder.
MCF.jar
Malicious Code Finder by HoverCatz is also a supported "decompiler." It is not a decompiler per se, but just inspects it for you to see if it has anything remotely suspicious in it.
It should be named exactly MCF.jar. Drop it in the install folder.
Its options are optimized to give you a no-nonsense result list. If it's a large plugin or a famous plugin, it might have several results, but this does not necessarily mean it's malicious.
You should be able to decide for yourself what is good and what is bad in a plugin if you're capable of decompiling it, but you should probably still decompile the entire thing and look at the places where it tells you about.
MCAntiMalware.jar
Spigot Anti-Malware (or MC Anti-Malware, or MCAM) by Optic_Fusion1 is now supported. It's essentially a souped up version of MCF, so I recommend you use MCAM rather than MCF.
One thing to note, the process hangs around for several seconds after it's done, so just be patient with it
decompile_plugin_interactive.bat
This is an alternative script that starts up CFR with the proper parameters. It takes one (optional) argument, the .jar to use. If no .jar is specified or the .jar specified does not exist, it will prompt you.
You can choose the decompiler in the script. It will save the output in a folder named whatever the jar file you wanted to decompile, in the same folder.
If you like, you could probably adjust it so that it uses a folder called, for example, <jar name>_source_from_cfr
This file basically starts up CFR (or your decompiler of choice), searches for a 7-Zip executable, and if it finds it, tries to extract the plugin.yml, .classpath, and .project files.
It searches for it in the default installation path (C:\Program Files\7-Zip\ or C:\Program Files (x86)\7-Zip\) and if it doesn't find it there, it will look in the current directory for 7za.exe
If it cannot find either version of 7-Zip, it will not extract plugin.yml or any of the other files and you will have to do it manually if you want them.
In the future, it may support extracting with PowerShell and not require 7-Zip, but not yet.
decompile_plugin_noninteractive.bat
This is the script that runs when you use the context menu item and is not designed to be used manually, but you can if you want. It does pretty much the same as decompile_plugin_interactive.bat except simplified a bit.
install.bat
This script will add registry entry (or entries) so that there will be a "Decompile with <decompiler>" option. These entries may be nested under a parent Decompile menu, or just straight in the explorer menu.
It's in a batch file so that it can point the registry to the right directory.
The "right directory" means the directory it's in, (and it's assumed that the other files will be there too) so run it only once you've put it in a place you intend to keep it and not move it.
THIS MUST BE RUN AS ADMINISTRATOR!
To run as administrator, right click and select Run As Administrator and select yes at the UAC prompt.
This is necessary because only administrator-privileged programs/scripts can edit the registry.
As it says some paragraphs later, you can also do it manually.
As a side note, if you do need to move the install directory, move it and then re-run install.bat (as administrator of course), telling it to delete the previously-installed registry entries and then set it up again.
uninstall.bat
This script will DELETE any registry entries created by install.bat. It will prompt you multiple times to make sure you want to.
nested_entries.reg
This is a file you can use if you don't trust install.bat, but it will by default point to <your user profile>\Downloads\plugin_decompile_2.0\decompile_plugin_noninteractive.bat so if you use it, be sure to change the path.
non_nested_entries.reg
This is the same thing as nested_entries, except it makes it so the context menu items are not nested under a parent Decompile item.
Or, if you don't trust either of the automated installers, (which is probably good since you just downloaded a random file off the internet) you can do it manually by following the tutorial at:
https://www.howtogeek.com/107965/ho...n-shortcut-to-windows-explorers-context-menu/
As it should say, you should be careful when editing the registry. But if you follow the directions closely, you'll be fine.
So, like it says, you'll need to find the name of the .jar type. As you can see in the automated installers, it's jarfile.
Also, it says to use double backslashes, but it seems to work with single backslashes as well.
Well, hope this tool makes your life slightly easier!