Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added presentation (and the used patch) #264

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
374 changes: 208 additions & 166 deletions README.md

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions jrd-WeakPoint/01.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# java-runtime-(de)compiler

https://github.com/judovana/java-runtime-decompiler

* why? Because we can!
* binary blob reproducers
* obfuscated
* debuginfo
* swap lines
* oversee instrumetnations
* what!
* how? This talk!
* standard APIS only

Jiri Vanek
Red Hat














30 changes: 30 additions & 0 deletions jrd-WeakPoint/02.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Demo I

* install
* overview
* list and read

























30 changes: 30 additions & 0 deletions jrd-WeakPoint/03.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How - Agent attach I

https://docs.oracle.com/javase/8/docs/jdk/api/attach/spec/com/sun/tools/attach/VirtualMachine.html

```
VirtualMachine vm = VirtualMachine.attach(Integer.toString(pid));
vm.loadAgent(agentJar,”param1:value1,param:value2,…valueN”);
vm.detach();
```
* Agent is just bunch of classes which does nothing. No logic, no communication
* unless you write that



















30 changes: 30 additions & 0 deletions jrd-WeakPoint/04.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How - Agent attach II
```
public static void premain(String agentArgs, Instrumentation inst);
```
* Is the launched start point after agent is loaded, and instrumentation is what matters
* For example you can open ServerSocket to receive commands
* Agents can not be unloaded. Can be just turned off in best effort
* And you can register transformer!






















30 changes: 30 additions & 0 deletions jrd-WeakPoint/05.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Demo II
.
* self modifications
* classes
* classloaders I
* desompilers/disassemblers/hex
* –-patch-module
* (keyword based) code completion
* inner classes
* additional sources/binaries/diffs
* back compile/assemble
* real changes
* bytecode level
* java.lang.Override
















30 changes: 30 additions & 0 deletions jrd-WeakPoint/06.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How - Transformers

https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html
https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/ClassFileTransformer.html

```
Transformer transformer = new Transformer();
inst.addTransformer(transformer, true);
//repeat(work-earn-spend)until die
instrumentation.removeTransformer(transformer);
```
* Classes can NEVER EVER be unloaded
* Depends on JVM?

















30 changes: 30 additions & 0 deletions jrd-WeakPoint/07.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Demo III
.
* self modifications
* Class Redefinition - hotswap - limits
* No new methods, no new fields, no renaming, no signatures…
* even non used BYTECODE fieLds limits
* bytecode level!
* Generally you can only change content of methods bodies (including new variables)
* byteman and JRD apis
* not add jar/classes
* dcevm/jrebel
* global counter


















30 changes: 30 additions & 0 deletions jrd-WeakPoint/08.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How - Trasnformer api
```
byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
Byte[] -> byte[] //… can not be more simple
```
* asm ow2
* If the class was never used, it will not be reachable from there
* Calling Class.forName on it will then do the job
...
* So what actually JRD simply does, is **Map<classname,Map<classloader,body[]>** where overrides are stored, ad transform returns hit front hat map if found
* Similarly, if we require class, to send to client, we record it in this method
* You have to return the “modified” bytecode everytime class redefiniton happens (which is pretty often)
* Depends on VM, but on hotspot, one of the few places where it will not be picked up is during loop in method

















30 changes: 30 additions & 0 deletions jrd-WeakPoint/09.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How - chaining of agents/transformers
.
* agents are modyfying and non modyfying
* agents are processed in order of attach
* modyfing (with Transformer) agents processed in order of reistered Transformer
* original class definition (immutable) -> byte[] ->
* Transformer1 -> byte[] ->
* Transformer.. -> byte[] ->
* TransformerN.. -> byte[] ->
* final class definition usage
*the full chain is always called.
* if you unregister, changes are gone


















30 changes: 30 additions & 0 deletions jrd-WeakPoint/10.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Demo IV

* byteman
* second agent!
* silent non sucess
* chaining of agents
* code coverage instrumentation
* multiple class defintions classloaders II
* no change in gui
* modules




















30 changes: 30 additions & 0 deletions jrd-WeakPoint/11.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Demo V

* cli
* adding classes
* ServerImplNw
* patch
* not as simple
* split?
* full java files?
* full binary classes?
* Future - debugger attach
* source-codeless IDE


















30 changes: 30 additions & 0 deletions jrd-WeakPoint/12.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# More hardcore ways to overcome hotswap limitations
.
* Class Redefinition - hotswap - limits
* No new methods, no new fields, no renaming…
* Generally you can only change content of methods bodies (including new variables)
* DCEVM JDK based on Phd these is removing those limits with (huge) cost of performance
* Take ages after JDK (jdk 17 not yet properly out, last udpate December 2022)
* Jetbrains took it recently over
* Jrebel JVMTI hacks
* Tricks
* In agent predefined map of objects to store fields/methods
* Bytemen do it behind the doors
* JRD offer sclumsy appi for it
* Add a new class with reimplementation and call it where needed
* inst.appendToSystem/BootClassLoader















Loading
Loading