This commit is contained in:
Daniel Kallendorf 2022-11-10 00:06:01 +01:00
commit b3120b69b0
7 changed files with 75 additions and 0 deletions

1
.vscode/ajc.properties vendored Normal file
View file

@ -0,0 +1 @@
cantFindType = warning

21
README.md Normal file
View file

@ -0,0 +1,21 @@
# Getting Started
## Dependencies
- FirstSpirit installation
- OpenJDK11 (On Windows this gets installed together with FS `C:/Users/<User>/.firstspirit/FSLauncher/jre/11.0.11/jre-win/jdk-11.0.11+9-jre/bin/java.exe`)
- AspectJ https://www.eclipse.org/aspectj/ (already included)
- copy `.firstspirit/FSLauncher/jar/*`, `.firstspirit_<version>/jars/*` (usually located in $HOME) of the FS installation into `lib/`
- Fix some FirstSpirit crap: open
## Paths
- `<java>` point to your (or FSs) OpenJDK11 installation
- `<aspectjweaver.jar>` can be found in `FSHook/tool`
- `<classpath>` points to `lib/*` and `tool/*`
- The seperator is `:` on Linux and `;` on Windows.
## Building
``` java -cp <classpath> org.aspectj.tools.ajc.Main -sourceroots 'src/' -injars lib/fs-isolated-client-*.jar -outjar bin/uploadPlugin.jar -outxml -9 -Xlintfile .vscode/ajc.properties", ```
## What the hell?
AspectJ is a bytecode manipulation framework. In our case the method `Plugins.getPlugins(ServerConnection, Class, BaseContext)` from `de.espirit.firstspirit.client.plugin.Plugins` gets overriden to load the plugins registered in `com.kallendorf.fshook.CustomLoader.pluginsToLoad` in addition to the default ones.
This allows th execution of arbitrary code within the FirstSprit client.

BIN
lib/aspectjrt.jar Normal file

Binary file not shown.

View file

@ -0,0 +1,17 @@
package com.kallendorf.fshook;
import java.util.HashSet;
import java.util.Set;
import de.espirit.common.bootstrap.Bootstrap;
import de.espirit.firstspirit.client.plugin.Plugin;
public class CustomLoader{
public static HashSet<Plugin> pluginsToLoad = new HashSet<>();
public static void launchFS(String[] args, Set<Plugin> pluginsToAdd) {
pluginsToLoad.addAll(pluginsToAdd);
Bootstrap.main(args);
}
}

View file

@ -0,0 +1,36 @@
package com.kallendorf.fshook;
import java.util.Collection;
import de.espirit.common.bootstrap.Bootstrap;
import de.espirit.firstspirit.access.BaseContext;
import de.espirit.firstspirit.client.plugin.JavaClientEditorialToolbarItemsPlugin;
import de.espirit.firstspirit.client.plugin.Plugins;
import de.espirit.firstspirit.io.ServerConnection;
import de.espirit.firstspirit.client.plugin.Plugin;
public aspect PluginLoadAspect {
pointcut main(): execution(void Bootstrap.main(String[]));
before(): main(){
System.out.println("Hooked It!");
}
Collection around(ServerConnection con, Class cls, BaseContext context):
call(* Plugins.getPlugins(ServerConnection, Class, BaseContext))
&& args(con,cls,context)
{
System.out.println("Hooking Plugins: "+cls);
Collection col=proceed(con,cls,context);
for(Plugin p: CustomLoader.pluginsToLoad){
if(cls.isInstance(p)) {
System.out.println("Loaded "+p);
col.add(p);
}
}
return col;
}
}

BIN
tool/aspectjtools.jar Normal file

Binary file not shown.

BIN
tool/aspectjweaver.jar Normal file

Binary file not shown.