源碼分析 | 咋嘞?你的IDEA過期了吧!加個Jar包就破解了,爲什麼?

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作者:小傅哥"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"博客:"},{"type":"link","attrs":{"href":"https://bugstack.cn","title":""},"content":[{"type":"text","text":"https://bugstack.cn"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"沉澱、分享、成長,讓自己和他人都能有所收穫!😄"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"一、前言介紹"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2020年了,對於一個程序猿來說;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"2020 = 1024 + 996 | 404 + 404 + 404 + 404 + 404\n2021 = 1024 + 997\n2022 = 1024 + 9106\n2023 = 1024 + 9107\n...\n20xx = 從今年開始可怕"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當你過了元旦,爽了週末,清早上班,拿起杯子,加點新(薪)水,打開電腦,收起煩惱,翹起小腳,上揚嘴角。一切就緒都準備好,好!擼代碼!啊!!!IDEA duang duang duang,過期了!"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3d/3d35f9f7be5ab06c6033f517f94fa6c8.jpeg","alt":"微信公衆號:bugstack蟲洞棧 & IDEA 過期","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"腦瓜一熱趕緊搜索破解碼;"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第一個,失敗"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第二個,失敗"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第三個,失敗"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"..."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第N個,終於,破解了三個月,先用着,先用着,以後再說!"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可能大部分夥伴都在搜各種一堆一大串的破解碼往裏面粘,一個個試到最後終於過了。但也有一部分老司機是不搜破解碼的,他們使用jar包破解,有效期100年。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"那麼!本文並不想引導用戶都去使用破解版,像IDEA這麼優秀,其實給你提供了很多選擇;"}]},{"type":"numberedlist","attrs":{"start":"1","normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"如果你是學生可以免費使用"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"分爲社區版和旗艦版,你可以使用社區版 Free, open-source"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":"一般大公司都是有正版授權的,可以使用"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","text":"如果你有開源項目也可以申請 IDEA 授權"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所以,個人開發使用社區版本即可,不要使用破解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"好!迴歸正題,本文主要講解是爲什麼放個Jar包就能破解,最後在使用一個jar進行破解演示。在以下章節中你可以學習到如下知識;"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Java Agent 非硬編碼式代理類,這也就是常說的探針技術"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ASM 字節碼編程簡單使用"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"工程打包額外加載其他 jar 方法"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最後是一個破解演示,僅適合個人學習使用"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"二、案例工程"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們通過一個案例工程來模擬破解過程是怎麼做到的,其實每個版本的IDEA都在增強防護機制,破解也越來越難。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"itstack-demo-code-idea\n└── src\n ├── main\n │ ├── java\n │ │ └── org.itstack.demo\n │ │ └── JetbrainsCrack.java\n │ └── resources\t\n │ └── META-INF\t\n │ └── MANIFEST.MF\n └── test\n └── java\n ├── com.jetbrains.ls.newLicenses\n │ └── DecodeCertificates.java\t\t\t \n └── org.itstack.demo.test\n └── ApiTest.java"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"三、環境配置"}]},{"type":"numberedlist","attrs":{"start":"1","normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"JDK 1.8"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"IDEA 2019.3.1"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":"asm-all 3.3.1"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"四、代碼講述"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在案例中我們模擬 IDEA 有一個 DecodeCertificates 類,用於做授權碼校驗。之後通過我們的 java agent 編程模擬授權被破解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1. Java Agent 介紹 "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在 JDK1.5 以後,JVM 提供了 agent 技術構建一個獨立於應用程序的代理程序(即爲Agent),用來協助監測、運行甚至替換其他JVM上的程序。使用它可以實現虛擬機級別的AOP功能。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2. ASM 介紹"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ASM 是一個 JAVA 字節碼分析、創建和修改的開源應用框架。在 ASM 中提供了諸多的API用於對類的內容進行字節碼操作的方法。與傳統的 BCEL 和 SERL 不同,在 ASM 中提供了更爲優雅和靈活的操作字節碼的方式。目前 ASM 已被廣泛的開源應用架構所使用,例如:Spring、Hibernate 等。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"3. 開始我們的模擬破解之路"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":">JetbrainsCrack.java & Agent 操作類"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"/**\n * 博客:http://bugstack.cn\n * 公衆號:bugstack蟲洞棧 | 更多原處優質乾貨\n * Agent 類,所有程序啓動只要配置了 -javaagent: 都會走到 premain 方法\n */\npublic class JetbrainsCrack {\n\n public static void premain(String args, Instrumentation inst) {\n System.out.println(\"**************************************\");\n System.out.println(\"* 公衆號:bugstack蟲洞棧 *\");\n System.out.println(\"* 博客:https://bugstack.cn *\");\n System.out.println(\"* 你用劍,我用刀,好的代碼都很燒! *\");\n System.out.println(\"**************************************\");\n inst.addTransformer(new MethodEntryTransformer());\n }\n\n static class MethodEntryTransformer implements ClassFileTransformer {\n\n private Logger logger = LoggerFactory.getLogger(MethodEntryTransformer.class);\n\n public byte[] transform(ClassLoader loader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {\n\n try {\n if (className.equals(\"com/jetbrains/ls/newLicenses/DecodeCertificates\")) {\n ClassReader cr = new ClassReader(classfileBuffer);\n ClassNode cn = new ClassNode();\n cr.accept(cn, 0);\n List methodNodes = cn.methods;\n for (MethodNode methodNode : methodNodes) {\n if (\"decodeLicense\".equals(methodNode.name)) {\n InsnList insns = methodNode.instructions;\n //清除指令\n insns.clear();\n insns.add(new VarInsnNode(Opcodes.ALOAD, 1)); // 將本地指定的引用存入棧中\n insns.add(new InsnNode(Opcodes.ARETURN)); // 從方法中返回引用類型的數據\n // 訪問結束\n methodNode.visitEnd();\n ClassWriter cw = new ClassWriter(0);\n cn.accept(cw);\n byte[] bytes = cw.toByteArray();\n // 輸出字節碼到Class\n this.outputClazz(bytes);\n // 返回最新字節碼\n return cw.toByteArray();\n }\n }\n }\n } catch (Exception e) {\n return classfileBuffer;\n }\n\n return classfileBuffer;\n }\n\n private void outputClazz(byte[] bytes) {\n // 輸出類字節碼\n FileOutputStream out = null;\n try {\n out = new FileOutputStream(\"ASMDecodeCertificates.class\");\n logger.info(\"ASM類輸出路徑:{}\", (new File(\"\")).getAbsolutePath());\n out.write(bytes);\n } catch (Exception e) {\n e.printStackTrace();\n } finally {\n if (null != out) try {\n out.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n }\n\n }\n\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在這個類中可以看到有一個 premain 方法,這個是在被 java agent 處理後的程序入口,所有信息類和方法都會到這個入口"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"之後我們使用 inst.addTransformer(new MethodEntryTransformer()); 添加我們自己的處理邏輯,這個邏輯也是用字節碼編程技術代理類的過程。這個過程也就是我們平時開發中那些不需硬編碼就可以監控方法執行時長的邏輯一樣"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"MethodEntryTransformer 實現了 ClassFileTransformer 的 transform 方法,也就是真正操作字節碼的過程。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t- 在這個類方法中首先需要找到我們的授權碼校驗類 com/jetbrains/ls/newLicenses/DecodeCertificates ,每一個版本的IDEA不一樣,同時授權邏輯校驗也不一樣"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t- 緊接着在找到授權校驗類裏面的校驗方法,if (\"decodeLicense\".equals(methodNode.name))"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t- 接下來就需要對字節碼進行處理了,這裏面的處理過程比較粗暴,直接將原來方法裏的指令內容清空。然後使用 new VarInsnNode(Opcodes.ALOAD, 1) 將本地指定的引用存入棧中"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t- 之後將我們的入參內容直接返回,new InsnNode(Opcodes.ARETURN),從方法中返回引用類型的數據。在以往舊版本的 IDEA 破解中比較簡單,直接把最終需要的破解內容返回即可,裏面描述了 IDEA 各個軟件的使用期限"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t- 最終將我們處理後的字節碼返回給方法,return cw.toByteArray();這個時候雖然你大爺還是你大爺,但你大娘已經不是你大娘了"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爲了測試的驗證我們將變更後的字節碼代碼(大娘)輸出到工程目錄下,也就是一個 class 文件,下文測試時候驗證"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4. DecodeCertificates.java & 模擬 ideaIU-15.0.1 軟件授權碼校驗類\t"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t"}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"public class DecodeCertificates {\n\n public String decodeLicense(String usingKey) {\n // 模擬校驗授權碼\n return \"usingKey is error:\"+ usingKey;\n }\n\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這個類比較簡單只是模擬有這麼個方法用於校驗授權碼"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"5. ApiTest.java & 測試類"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"/**\n * 博客:http://bugstack.cn\n * 公衆號:bugstack蟲洞棧 | 更多原處優質乾貨\n * 測試類配置 VM 參數\n * Idea VM options:-javaagent:E:\\itstack\\GIT\\itstack.org\\itstack-demo-code\\itstack-demo-code-idea\\target\\itstack-demo-code-idea-1.0-SNAPSHOT.jar\n */\npublic class ApiTest {\n\n private static Logger logger = LoggerFactory.getLogger(ApiTest.class);\n\n public static void main(String[] args) throws Exception {\n DecodeCertificates decodeCertificates = new DecodeCertificates();\n // 模擬usingKey:認購有效期至2089年7月8日\n String license = decodeCertificates.decodeLicense(\"Subscription is active until July 8, 2089\");\n logger.info(\"測試結果:{}\", license);\n }\n\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"6. MANIFEST.MF 配置引導啓動時加載"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"Manifest-Version: 1.0\nPremain-Class: org.itstack.demo.JetbrainsCrack\nCan-Redefine-Classes: true\n"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"7. POM 配置打包時加入ASM包"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"\n\n org.apache.maven.plugins\n maven-shade-plugin\n \n \n package\n \n shade\n \n \n \n \n \n \n asm:asm-all:jar:\n \n \n \n"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"五、工程測試"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"1","normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"先單純的直接運行ApiTest.java ,測試結果如下(模擬返回授權不可用);"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t```java"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t21:23:46.101 [main] INFO org.itstack.demo.test.ApiTest - 測試結果:usingKey is error:Subscription is active until July 8, 2089"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t```"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"2","normalizeStart":"2"},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"第二步測試前先打包下工程,這個時候你會看到如下結果;"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t```java"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] --- maven-install-plugin:2.4:install (default-install) @ itstack-demo-code-idea ---"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] Installing E:\\itstack\\GIT\\itstack.org\\itstack-demo-code\\itstack-demo-code-idea\\target\\itstack-demo-code-idea-1.0-SNAPSHOT.jar to D:\\Program Files (x86)\\apache-maven-3.6.2\\repository\\org\\itstack\\demo\\itstack-demo-code-idea\\1.0-SNAPSHOT\\itstack-demo-code-idea-1.0-SNAPSHOT.jar"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] Installing E:\\itstack\\GIT\\itstack.org\\itstack-demo-code\\itstack-demo-code-idea\\dependency-reduced-pom.xml to D:\\Program Files (x86)\\apache-maven-3.6.2\\repository\\org\\itstack\\demo\\itstack-demo-code-idea\\1.0-SNAPSHOT\\itstack-demo-code-idea-1.0-SNAPSHOT.pom"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] Installing E:\\itstack\\GIT\\itstack.org\\itstack-demo-code\\itstack-demo-code-idea\\target\\itstack-demo-code-idea-1.0-SNAPSHOT-sources.jar to D:\\Program Files (x86)\\apache-maven-3.6.2\\repository\\org\\itstack\\demo\\itstack-demo-code-idea\\1.0-SNAPSHOT\\itstack-demo-code-idea-1.0-SNAPSHOT-sources.jar"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] ------------------------------------------------------------------------"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] BUILD SUCCESS"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] ------------------------------------------------------------------------"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] Total time: 3.080 s"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] Finished at: 2020-01-05T23:25:08+08:00"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t[INFO] ------------------------------------------------------------------------"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t```"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這裏的 itstack-demo-code-idea-1.0-SNAPSHOT.jar 就是我們的 Agent 包,按實際情況複製自己的路徑"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"3","normalizeStart":"3"},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":"配置 VM options:-javaagent:E:\\itstack\\GIT\\itstack.org\\itstack-demo-code\\itstack-demo-code-idea\\target\\itstack-demo-code-idea-1.0-SNAPSHOT.jar"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/c5/c5bb05e910063714226d94562d2fdd99.png","alt":"微信公衆號:bugstack蟲洞棧 & IDEA VM options","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"4","normalizeStart":"4"},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","text":"運行 ApiTest 測試,正確結果如下;"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t```java"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t23:29:42.803 [main] INFO org.itstack.demo.test.ApiTest - 測試結果:usingKey is error:Subscription is active until July 8, 2089"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\tProcess finished with exit code 0"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"\t```"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - 這個過程就是你使用 jar 包破解 IDEA 的過程,瞭解這個技術點可以用在很多不需要硬編碼就能做到的服務中,比如監控,調試等"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"5","normalizeStart":"5"},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":5,"align":null,"origin":null},"content":[{"type":"text","text":"別忘了我們還在 Agent 中輸出了新的字節碼,看看這個時候的類是什麼樣(你大爺還是你大爺,但你大娘可不是你大娘了)"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":">被代理前"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"public class DecodeCertificates {\n\n\tpublic String decodeLicense(String usingKey) {\n\t\t// 模擬校驗授權碼\n\t\treturn \"usingKey is error:\"+ usingKey;\n\t}\n\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":">被代理後"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"package com.jetbrains.ls.newLicenses;\n\npublic class DecodeCertificates {\n\tpublic DecodeCertificates() {\n\t}\n\n\tpublic String decodeLicense(String usingKey) {\n\t\treturn usingKey;\n\t}\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"六、綜上總結"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"建議個人使用社區版即可,不要嘗試破解尊重IDEA,本文只爲學習 javaagent 技術"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ASM 這個東西特別強大,其實字節碼編程還有 javassist,在一起 RPC 框架中有非常多的使用"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"關於 java agent 我已經專題方式寫過案例文章,可以參考;https://bugstack.cn/itstack-demo-agent/itstack-demo-agent.html"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"七、推薦閱讀"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://bugstack.cn/itstack-code-life/2020/03/31/%E5%A4%A7%E5%AD%A6%E5%9B%9B%E5%B9%B4%E5%88%B0%E6%AF%95%E4%B8%9A%E5%B7%A5%E4%BD%9C5%E5%B9%B4%E7%9A%84%E5%AD%A6%E4%B9%A0%E8%B7%AF%E7%BA%BF%E8%B5%84%E6%BA%90%E6%B1%87%E6%80%BB.html","title":""},"content":[{"type":"text","text":"大學四年到畢業工作5年的學習路線資源彙總"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://bugstack.cn/itstack-demo-drools/2020/03/07/%E8%BF%99%E7%A7%8D%E5%9C%BA%E6%99%AF%E4%BD%A0%E8%BF%98%E5%86%99ifelse%E4%BD%A0%E8%B7%9F%E5%AD%A9%E5%AD%90%E5%9D%90%E4%B8%80%E6%A1%8C%E5%8E%BB%E5%90%A7.html","title":""},"content":[{"type":"text","text":"這種場景你還寫ifelse你跟孩子坐一桌去吧"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://bugstack.cn/itstack-demo-agent/2020/03/25/ASM%E5%AD%97%E8%8A%82%E7%A0%81%E7%BC%96%E7%A8%8B-%E5%A6%82%E6%9E%9C%E4%BD%A0%E5%8F%AA%E5%86%99CRUD-%E9%82%A3%E8%BF%99%E7%A7%8D%E6%8A%80%E6%9C%AF%E4%BD%A0%E6%B0%B8%E8%BF%9C%E7%A2%B0%E4%B8%8D%E5%88%B0.html","title":""},"content":[{"type":"text","text":"ASM字節碼編程 | 如果你只寫CRUD,那這種技術你永遠碰不到"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://bugstack.cn/itstack-demo-any/2020/01/18/%E4%BC%BC%E4%B9%8E%E4%BD%A0%E6%80%BB%E4%B9%9F%E8%AE%B0%E4%B8%8D%E4%BD%8F-byte%E7%9A%84%E5%8F%96%E5%80%BC%E8%8C%83%E5%9B%B4%E6%98%AF-127~128-%E8%BF%98%E6%98%AF-128~127.html","title":""},"content":[{"type":"text","text":"似乎你總也記不住,byte取值範圍是 -127~128 還是 -128~127"}]}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章