Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Binary patching for fun and profit
Search
Anton Arhipov
February 26, 2012
Technology
81
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
590
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
4
520
Spec-Driven Development with AI Agents. Java Day Istanbul 2026
antonarhipov
3
140
Spec-Driven Development with AI Agents: From High-Level Requirements to Working Software
antonarhipov
3
150
Strengthening Immutability in Kotlin. A Glimpse into Valhalla
antonarhipov
3
110
Kotlin—the New and Noteworthy in 2.2
antonarhipov
1
50
Levels of AI-assisted programming
antonarhipov
0
160
Devoxx France 2024. Kotlin - the new and noteworthy
antonarhipov
2
110
Harnessing the power of AI in IntelliJ IDEA
antonarhipov
1
260
Other Decks in Technology
See All in Technology
Multicaで30個のミニプロジェクトをAIエージェント運用して見えてきたこと
eiei114
1
650
複数プロダクトで進めるAI機能実装 ── 実践から得たリアルな学びとロードマップ実現への挑戦 / AICon2026_yanari
rakus_dev
1
280
システム監視入門
grimoh
1
300
AmplifyHostingConstructからSSRフレームワークのためのホスティング設計を考察する/amplify-hosting-construct
fossamagna
1
310
”AIを使う” から ”AIに任せる” へ ─ 開発プロセスを再設計してAIを組織標準にするまで
cyberagentdevelopers
PRO
2
140
論語・武士道・産業革命から見る かわるもの、かわらないもの
ichimichi
5
480
書籍セキュアAPIについて
riiimparm
0
310
AI時代のPlaywright活用(システムテストを自動化する ー 実行エンジンにPla ywrightを選んだ理由)
ynisqa1988
2
990
仕様駆動開発、導入半年。「本当に速くなってるの?」にデータで答える / AICon2026_hirakawa
rakus_dev
0
330
MCPをつなげて作る組織横断のAIエージェント基盤
tsubakimoto_s
0
130
Jitera Company Deck
jitera
0
460
インシデント事例と パッケージの全量解析に学ぶ ソフトウェアサプライチェーンの守り方 / supply-chain-attack-defense
flatt_security
0
970
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
190
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Amusing Abliteration
ianozsvald
1
240
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
560
Odyssey Design
rkendrick25
PRO
2
730
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Building the Perfect Custom Keyboard
takai
2
820
sira's awesome portfolio website redesign presentation
elsirapls
0
310
Documentation Writing (for coders)
carmenintech
77
5.4k
The SEO identity crisis: Don't let AI make you average
varn
0
520
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
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