Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Binary patching for fun and profit
Search
Anton Arhipov
February 26, 2012
Technology
91
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Binary patching for fun and profit
Anton Arhipov
February 26, 2012
More Decks by Anton Arhipov
See All by Anton Arhipov
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
670
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
4
580
Spec-Driven Development with AI Agents. Java Day Istanbul 2026
antonarhipov
3
160
Spec-Driven Development with AI Agents: From High-Level Requirements to Working Software
antonarhipov
3
190
Strengthening Immutability in Kotlin. A Glimpse into Valhalla
antonarhipov
3
120
Kotlin—the New and Noteworthy in 2.2
antonarhipov
1
58
Levels of AI-assisted programming
antonarhipov
0
190
Devoxx France 2024. Kotlin - the new and noteworthy
antonarhipov
2
120
Harnessing the power of AI in IntelliJ IDEA
antonarhipov
1
270
Other Decks in Technology
See All in Technology
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
5
25k
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
1
1.4k
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
160
aws-iot-platform-architecture-use-cases.pdf
ma2shita
0
170
Deployment の 先にある AI Agent 基盤 - kagent vNext、Agent Substrate、Hermes から読み解く Agent Runtime の現在地 / k8s-matsuri-2-ai-agent-platform-amsy810
masayaaoyama
3
580
おい、エージェントを使って終わらせろ
nwiizo
0
270
The Agent Builder Loop from Daily Work to OSS
minorun365
PRO
3
200
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
260
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
0
2.2k
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
29
24k
2026-09-18 gotanda.sre Terraformで複数環境作ったり、複数Stateに分割したりそれとTerragrunt / Terraform multi envs and multi states
masasuzu
1
360
すぐできる衛星通信対応 あとは山奥に行くだけ
tatetate55
0
130
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.3k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
280
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
700
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
368
27k
Building Applications with DynamoDB
mza
96
7.2k
Color Theory Basics | Prateek | Gurzu
gurzu
1
470
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Side Projects
sachag
456
43k
ラッコキーワード サービス紹介資料
rakko
1
4.9M
Transcript
Binary Patching for Fun and Profit with
JRebel SDK
Binary Patching 10101010101 11000101010 10101010001 00010001110 11011101011 10101010101 11100001010
10101010001 00010001110 11011101110 Ninja.class Ninja.class’ a.k.a instrumenta9on
Binary Patching MyClass.class New code: 1001010010010 0101011001010 ClassLoader MyObject
Transformer Application
Why? • Programming model (AOP, ORM) • Tooling
(profilers, coverage) • Legacy integraFon … or maybe you’re just bored? J
How? • Add –javaagent to hook into class loading
process • Implement ClassFileTransformer • Use bytecode manipulaFon libraries (Javassist, cglib, asm) to add any custom logic java.lang.instrument
java.lang.instrument import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumenta9on; public
class Agent { public sta9c void premain(String args, Instrumenta9on inst) throws Excep9on { inst.addTransformer(new ClassFileTransformer { … }); } }
java.lang.instrument import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumenta9on; public
class Agent { public sta9c void premain(String args, Instrumenta9on inst) throws Excep9on { inst.addTransformer(new ClassFileTransformer { … }); } }
java.lang.instrument import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumenta9on; public
class Agent { public sta9c void premain(String args, Instrumenta9on inst) throws Excep9on { inst.addTransformer(new ClassFileTransformer { … }); } } META-INF/MANIFEST.MF Premain-Class: Agent java –javaagent:agent.jar …
j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String
className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault(); CtClass ct = cp.makeClass(new ByteArrayInputStream(classfileBuffer)); transformClass(ct, cp); return ct.toBytecode(); } }
j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String
className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault(); CtClass ct = cp.makeClass(new ByteArrayInputStream(classfileBuffer)); transformClass(ct, cp); return ct.toBytecode(); } }
j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String
className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault(); CtClass ct = cp.makeClass(new ByteArrayInputStream(classfileBuffer)); transformClass(ct, cp); return ct.toBytecode(); } }
j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String
className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault(); CtClass ct = cp.makeClass(new ByteArrayInputStream(classfileBuffer)); transformClass(ct, cp); return ct.toBytecode(); } }
Javassist 1-‐2-‐3
Javassist • Bytecode manipulaFon made easy • Source-‐level
and bytecode-‐level API • Uses the vocabulary of Java language • On-‐the-‐fly compilaFon of the injected code • hVp://www.jboss.org/javassist
Adding Interfaces ClassPool cp = ClassPool.getDefault(); CtClass
ct = cp.get("org.geecon.Alarm"); ct.addInterface(cp.get(Listener.class.getName())); ct.addMethod(CtNewMethod.make("public void fire(){ alert(); }", ct)); public interface Listener { void fire(); } public class Alarm { void alert() {} }
Adding Interfaces ClassPool cp = ClassPool.getDefault(); CtClass
ct = cp.get("org.geecon.Alarm"); ct.addInterface(cp.get(Listener.class.getName())); ct.addMethod(CtNewMethod.make("public void fire(){ alert(); }", ct)); public interface Listener { void fire(); } public class Alarm { void alert() {} }
Adding Interfaces ClassPool cp = ClassPool.getDefault(); CtClass
ct = cp.get("org.geecon.Alarm"); ct.addInterface(cp.get(Listener.class.getName())); ct.addMethod(CtNewMethod.make("public void fire(){ alert(); }", ct)); public interface Listener { void fire(); } public class Alarm { void alert() {} }
Adding Interfaces ClassPool cp = ClassPool.getDefault(); CtClass
ct = cp.get("org.geecon.Alarm"); ct.addInterface(cp.get(Listener.class.getName())); ct.addMethod(CtNewMethod.make("public void fire(){ alert(); }", ct)); public interface Listener { void fire(); } public class Alarm { void alert() {} }
Simple AOP ProxyFactory pf = new ProxyFactory();
pf.setSuperclass(No9fier.class); pf.setFilter(new MethodFilter() { … }); No9fier no9fier = (No9fier) pf.createClass().newInstance(); ((ProxyObject) no9fier).setHandler(new MethodHandler() { … }); System.out.println("calling on()"); no9fier.on(); System.out.println("calling off()"); no9fier.off(); public class No9fier { public void on(){ } @Pointcut public void off(){} }
Intercept Statements ClassPool pool = ClassPool.getDefault();
CtClass ct = pool.get("org.geecon.PaymentMachine"); ct.getDeclaredMethod("process") .instrument(new ExprEditor() { public void edit(NewExpr e) throws CannotCompileExcep9on { e.replace("$_ = $proceed($$);"); } });
JRebel SDK Ö_õ
IDEs Containers Frameworks Build Tools More at h^p://www.jrebel.com/features
None