java防反編譯最簡單的技巧分享
前言
本文主要跟大家介紹了關(guān)于java防反編譯的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面話不多說了,來一起看看詳細(xì)的介紹吧。
示例代碼:
源碼使用try-catch代碼包裝下,如下:
public class CompileForbid {
public static void main(String[] args) {
try {
System.out.println("-------");
//防止反編譯的處理
if (654789 == new Random().nextInt()) {
throw new Exception("fewt43");
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
//防止反編譯的處理
if (654789 == new Random().nextInt()) {
throw new Exception("fewt43");
}
} catch (Exception ex) {
System.out.print(ex);
}
}
}
}
使用 jd 反編譯工具翻遍后的效果,別的反編譯可能會(huì)反編譯出來,效果不是很好,但是簡單實(shí)用
public class CompileForbid
{
// ERROR //
public static void main(java.lang.String[] args)
{
// Byte code:
// 0: getstatic 16 java/lang/System:out Ljava/io/PrintStream;
// 3: ldc 22
// 5: invokevirtual 24 java/io/PrintStream:println (Ljava/lang/String;)V
// 8: ldc 30
// 10: new 31 java/util/Random
// 13: dup
// 14: invokespecial 33 java/util/Random:<init> ()V
// 17: invokevirtual 34 java/util/Random:nextInt ()I
// 20: if_icmpne +90 -> 110
// 23: new 38 java/lang/Exception
// 26: dup
// 27: ldc 40
// 29: invokespecial 42 java/lang/Exception:<init> (Ljava/lang/String;)V
// 32: athrow
// 33: astore_1
// 34: aload_1
// 35: invokevirtual 44 java/lang/Exception:printStackTrace ()V
// 38: ldc 30
// 40: new 31 java/util/Random
// 43: dup
// 44: invokespecial 33 java/util/Random:<init> ()V
// 47: invokevirtual 34 java/util/Random:nextInt ()I
// 50: if_icmpne +93 -> 143
// 53: new 38 java/lang/Exception
// 56: dup
// 57: ldc 40
// 59: invokespecial 42 java/lang/Exception:<init> (Ljava/lang/String;)V
// 62: athrow
// 63: astore_3
// 64: getstatic 16 java/lang/System:out Ljava/io/PrintStream;
// 67: aload_3
// 68: invokevirtual 47 java/io/PrintStream:print (Ljava/lang/Object;)V
// 71: goto +72 -> 143
// 74: astore_2
// 75: ldc 30
// 77: new 31 java/util/Random
// 80: dup
// 81: invokespecial 33 java/util/Random:<init> ()V
// 84: invokevirtual 34 java/util/Random:nextInt ()I
// 87: if_icmpne +21 -> 108
// 90: new 38 java/lang/Exception
// 93: dup
// 94: ldc 40
// 96: invokespecial 42 java/lang/Exception:<init> (Ljava/lang/String;)V
// 99: athrow
// 100: astore_3
// 101: getstatic 16 java/lang/System:out Ljava/io/PrintStream;
// 104: aload_3
// 105: invokevirtual 47 java/io/PrintStream:print (Ljava/lang/Object;)V
// 108: aload_2
// 109: athrow
// 110: ldc 30
// 112: new 31 java/util/Random
// 115: dup
// 116: invokespecial 33 java/util/Random:<init> ()V
// 119: invokevirtual 34 java/util/Random:nextInt ()I
// 122: if_icmpne +21 -> 143
// 125: new 38 java/lang/Exception
// 128: dup
// 129: ldc 40
// 131: invokespecial 42 java/lang/Exception:<init> (Ljava/lang/String;)V
// 134: athrow
// 135: astore_3
// 136: getstatic 16 java/lang/System:out Ljava/io/PrintStream;
// 139: aload_3
// 140: invokevirtual 47 java/io/PrintStream:print (Ljava/lang/Object;)V
// 143: return
//
// Exception table:
// from to target type
// 0 33 33 java/lang/Exception
// 38 63 63 java/lang/Exception
// 0 38 74 finally
// 75 100 100 java/lang/Exception
// 110 135 135 java/lang/Exception
}
}
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對(duì)腳本之家的支持。
相關(guān)文章
IDEA提示 add *** to custom tags問題及解決
文章介紹了如何在文檔注釋中添加自定義注解(@xxx),并提供了添加和刪除注解的方法,總結(jié)了個(gè)人經(jīng)驗(yàn),希望對(duì)大家有所幫助2024-12-12
讓Java程序自動(dòng)重啟的實(shí)現(xiàn)方法(推薦)
下面小編就為大家?guī)硪黄孞ava程序自動(dòng)重啟的實(shí)現(xiàn)方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-03-03
Spring+SpringMVC+Hibernate項(xiàng)目環(huán)境搭建的步驟(圖文)
這篇文章主要介紹了Spring+SpringMVC+Hibernate項(xiàng)目環(huán)境搭建的步驟(圖文),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05
使用?Spring?AI?+?Ollama?構(gòu)建生成式?AI?應(yīng)用的方法
通過集成SpringBoot和Ollama,本文詳細(xì)介紹了如何構(gòu)建生成式AI應(yīng)用,首先,介紹了AI大模型服務(wù)的兩種實(shí)現(xiàn)方式,選擇使用ollama進(jìn)行部署,隨后,通過SpringBoot+SpringAI來實(shí)現(xiàn)應(yīng)用構(gòu)建,本文為開發(fā)者提供了一個(gè)實(shí)用的指南,幫助他們快速入門生成式AI應(yīng)用的開發(fā)2024-11-11
Spring Cloud 如何保證微服務(wù)內(nèi)安全
這篇文章主要介紹了Spring Cloud 如何保證微服務(wù)內(nèi)安全的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07

