如何解码那些JD-GUI错误反编译的Bytecode

时间:2017-06-25 02:10:36

标签: apk bytecode jd-gui

我想反编译一个apk文件以查看其源代码的某些部分,但是当我到达我感兴趣的部分时,JD-GUI提供以下反编译代码

  /* Error */
  public void loginV2(Context paramContext, String paramString1, int paramInt, String paramString2, String paramString3, String paramString4, AsyncHttpResponseHandler paramAsyncHttpResponseHandler)
  {
    // Byte code:
    //   0: new 20  java/lang/StringBuilder
    //   3: dup
    //   4: getstatic 91    com/ipanel/join/homed/mobile/myt/Config:SERVER_ACCESS   Ljava/lang/String;
    //   7: invokestatic 32 java/lang/String:valueOf    (Ljava/lang/Object;)Ljava/lang/String;
    //   10: invokespecial 35   java/lang/StringBuilder:<init>  (Ljava/lang/String;)V
    //   13: ldc_w 491
    //   16: invokevirtual 41   java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   19: invokevirtual 45   java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   22: astore 10
    //   24: new 226    cn/ipanel/android/net/http/AsyncHttpClient
    //   27: dup
    //   28: invokespecial 227  cn/ipanel/android/net/http/AsyncHttpClient:<init>   ()V
    //   31: astore 11
    //   33: new 429    org/json/JSONObject
    //   36: dup
    //   37: invokespecial 430  org/json/JSONObject:<init>  ()V
    //   40: astore 12
    //   42: aconst_null
    //   43: astore 9
    //   45: aconst_null
    //   46: astore 8
    //   48: new 20 java/lang/StringBuilder
    //   51: dup
    //   52: invokespecial 169  java/lang/StringBuilder:<init>  ()V
    //   55: aload_1
    //   56: invokestatic 300   com/ipanel/join/homed/mobile/myt/utils/DeviceUtils:getDeviceId  (Landroid/content/Context;)Ljava/lang/String;
    //   59: invokevirtual 41   java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   62: invokevirtual 45   java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   65: astore 13
    //   67: new 20 java/lang/StringBuilder
    //   70: dup
    //   71: aload 13
    //   73: invokestatic 32    java/lang/String:valueOf    (Ljava/lang/Object;)Ljava/lang/String;
    //   76: invokespecial 35   java/lang/StringBuilder:<init>  (Ljava/lang/String;)V
    //   79: aload 13
    //   81: invokestatic 497   com/ipanel/join/homed/helper/OperationUtils:getMD5  (Ljava/lang/String;)Ljava/lang/String;
    //   84: bipush 7
    //   86: bipush 8
    //   88: invokevirtual 501  java/lang/String:substring  (II)Ljava/lang/String;
    //   91: invokevirtual 41   java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   94: invokevirtual 45   java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   97: astore 13
    //   99: invokestatic 506   java/util/Calendar:getInstance  ()Ljava/util/Calendar;
    //   102: invokevirtual 510 java/util/Calendar:getTimeInMillis  ()J
    //   105: lstore 14
    //   107: aload 12
    //   109: ldc_w 294
    //   112: aload 13
    //   114: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   117: pop
    //   118: aload 12
    //   120: ldc_w 302
    //   123: aload_2
    //   124: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   127: pop
    //   128: aload 12
    //   130: ldc_w 469
    //   133: iload_3
    //   134: invokevirtual 513 org/json/JSONObject:put (Ljava/lang/String;I)Lorg/json/JSONObject;
    //   137: pop
    //   138: aload 12
    //   140: ldc_w 467
    //   143: aload 4
    //   145: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   148: pop
    //   149: aload 12
    //   151: ldc_w 515
    //   154: aload 5
    //   156: invokestatic 497  com/ipanel/join/homed/helper/OperationUtils:getMD5  (Ljava/lang/String;)Ljava/lang/String;
    //   159: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   162: pop
    //   163: aload 6
    //   165: invokestatic 112  android/text/TextUtils:isEmpty  (Ljava/lang/CharSequence;)Z
    //   168: ifne +13 -> 181
    //   171: aload 12
    //   173: ldc 99
    //   175: aload 6
    //   177: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   180: pop
    //   181: aload 12
    //   183: ldc_w 517
    //   186: new 20    java/lang/StringBuilder
    //   189: dup
    //   190: invokespecial 169 java/lang/StringBuilder:<init>  ()V
    //   193: lload 14
    //   195: invokevirtual 520 java/lang/StringBuilder:append  (J)Ljava/lang/StringBuilder;
    //   198: invokevirtual 45  java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   201: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   204: pop
    //   205: aload 12
    //   207: ldc_w 522
    //   210: ldc 124
    //   212: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   215: pop
    //   216: aload 12
    //   218: ldc_w 524
    //   221: new 20    java/lang/StringBuilder
    //   224: dup
    //   225: aload 13
    //   227: invokestatic 32   java/lang/String:valueOf    (Ljava/lang/Object;)Ljava/lang/String;
    //   230: invokespecial 35  java/lang/StringBuilder:<init>  (Ljava/lang/String;)V
    //   233: ldc_w 526
    //   236: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   239: aload_2
    //   240: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   243: ldc_w 526
    //   246: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   249: iload_3
    //   250: invokevirtual 176 java/lang/StringBuilder:append  (I)Ljava/lang/StringBuilder;
    //   253: ldc_w 526
    //   256: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   259: aload 4
    //   261: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   264: ldc_w 526
    //   267: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   270: lload 14
    //   272: invokevirtual 520 java/lang/StringBuilder:append  (J)Ljava/lang/StringBuilder;
    //   275: invokevirtual 45  java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   278: invokestatic 497  com/ipanel/join/homed/helper/OperationUtils:getMD5  (Ljava/lang/String;)Ljava/lang/String;
    //   281: invokevirtual 435 org/json/JSONObject:put (Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   284: pop
    //   285: new 223   org/apache/http/entity/StringEntity
    //   288: dup
    //   289: aload 12
    //   291: invokevirtual 438 org/json/JSONObject:toString    ()Ljava/lang/String;
    //   294: ldc_w 440
    //   297: invokespecial 442 org/apache/http/entity/StringEntity:<init>  (Ljava/lang/String;Ljava/lang/String;)V
    //   300: astore_2
    //   301: getstatic 448 java/lang/System:out    Ljava/io/PrintStream;
    //   304: new 20    java/lang/StringBuilder
    //   307: dup
    //   308: ldc_w 450
    //   311: invokespecial 35  java/lang/StringBuilder:<init>  (Ljava/lang/String;)V
    //   314: aload 12
    //   316: invokevirtual 438 org/json/JSONObject:toString    ()Ljava/lang/String;
    //   319: invokevirtual 41  java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   322: invokevirtual 45  java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   325: invokevirtual 455 java/io/PrintStream:println (Ljava/lang/String;)V
    //   328: aload 11
    //   330: aload_1
    //   331: aload 10
    //   333: aload_2
    //   334: ldc -27
    //   336: aload 7
    //   338: invokevirtual 233 cn/ipanel/android/net/http/AsyncHttpClient:post (Landroid/content/Context;Ljava/lang/String;Lorg/apache/http/HttpEntity;Ljava/lang/String;Lcn/ipanel/android/net/http/AsyncHttpResponseHandler;)V
    //   341: return
    //   342: astore 4
    //   344: aload 8
    //   346: astore_2
    //   347: aload 4
    //   349: invokevirtual 456 org/json/JSONException:printStackTrace  ()V
    //   352: goto -24 -> 328
    //   355: astore 4
    //   357: aload 9
    //   359: astore_2
    //   360: aload 4
    //   362: invokevirtual 236 java/io/UnsupportedEncodingException:printStackTrace    ()V
    //   365: goto -37 -> 328
    //   368: astore 4
    //   370: goto -10 -> 360
    //   373: astore 4
    //   375: goto -28 -> 347
    // Local variable table:
    //   start  length  slot    name    signature
    //   0  378 0   this    APIManager
    //   0  378 1   paramContext    Context
    //   0  378 2   paramString1    String
    //   0  378 3   paramInt    int
    //   0  378 4   paramString2    String
    //   0  378 5   paramString3    String
    //   0  378 6   paramString4    String
    //   0  378 7   paramAsyncHttpResponseHandler   AsyncHttpResponseHandler
    //   46 299 8   localObject1    Object
    //   43 315 9   localObject2    Object
    //   22 310 10  str1    String
    //   31 298 11  localAsyncHttpClient    AsyncHttpClient
    //   40 275 12  localJSONObject JSONObject
    //   65 161 13  str2    String
    //   105    166 14  l   long
    // Exception table:
    //   from   to  target  type
    //   48 181 342 org/json/JSONException
    //   181    301 342 org/json/JSONException
    //   48 181 355 java/io/UnsupportedEncodingException
    //   181    301 355 java/io/UnsupportedEncodingException
    //   301    328 368 java/io/UnsupportedEncodingException
    //   301    328 373 org/json/JSONException
  }

我搜索了网页,发现原因可能是apk&#39;作者故意犯了这个错误,以保护代码的关键部分被JD-GUI反编译。

我想问的是

  1. 这些所谓的&#34;字节代码&#34;明白了吗?我读了代码,虽然我无法完全理解代码,我认为它仍然保留了实际的代码信息,我在代码中找到了getMD5函数,所以有人可以向我解释代码使用哪些参数以及如何编写MD5 (实际上这是我感兴趣的部分)

  2. 有人可以给我一些建议,帮助我自己理解这些代码,例如,给我一些参考网站链接,以了解所谓的&#34;字节代码&#34;语言的规范(就像c ++或C#),所以下次也许我可以自己完成这项工作

  3. 谢谢!

    PS: 我尝试了另一个十六进制查看器,并获得以下结果代码

    public void loginV2(final Context p0, final String p1, final int p2, final String p3, final String p4, final String p5, final AsyncHttpResponseHandler p6) {
            // 
            // This method could not be decompiled.
            // 
            // Original Bytecode:
            // 
            //     0: new             Ljava/lang/StringBuilder;
            //     3: dup            
            //     4: getstatic       com/ipanel/join/homed/mobile/myt/Config.SERVER_ACCESS:Ljava/lang/String;
            //     7: invokestatic    java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
            //    10: invokespecial   java/lang/StringBuilder.<init>:(Ljava/lang/String;)V
            //    13: ldc_w           "account/user/v2/login"
            //    16: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //    19: invokevirtual   java/lang/StringBuilder.toString:()Ljava/lang/String;
            //    22: astore          8
            //    24: new             Lcn/ipanel/android/net/http/AsyncHttpClient;
            //    27: dup            
            //    28: invokespecial   cn/ipanel/android/net/http/AsyncHttpClient.<init>:()V
            //    31: astore          9
            //    33: new             Lorg/json/JSONObject;
            //    36: dup            
            //    37: invokespecial   org/json/JSONObject.<init>:()V
            //    40: astore          10
            //    42: aconst_null    
            //    43: astore          11
            //    45: new             Ljava/lang/StringBuilder;
            //    48: dup            
            //    49: invokespecial   java/lang/StringBuilder.<init>:()V
            //    52: aload_1        
            //    53: invokestatic    com/ipanel/join/homed/mobile/myt/utils/DeviceUtils.getDeviceId:(Landroid/content/Context;)Ljava/lang/String;
            //    56: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //    59: invokevirtual   java/lang/StringBuilder.toString:()Ljava/lang/String;
            //    62: astore          14
            //    64: new             Ljava/lang/StringBuilder;
            //    67: dup            
            //    68: aload           14
            //    70: invokestatic    java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
            //    73: invokespecial   java/lang/StringBuilder.<init>:(Ljava/lang/String;)V
            //    76: aload           14
            //    78: invokestatic    com/ipanel/join/homed/helper/OperationUtils.getMD5:(Ljava/lang/String;)Ljava/lang/String;
            //    81: bipush          7
            //    83: bipush          8
            //    85: invokevirtual   java/lang/String.substring:(II)Ljava/lang/String;
            //    88: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //    91: invokevirtual   java/lang/StringBuilder.toString:()Ljava/lang/String;
            //    94: astore          15
            //    96: invokestatic    java/util/Calendar.getInstance:()Ljava/util/Calendar;
            //    99: invokevirtual   java/util/Calendar.getTimeInMillis:()J
            //   102: lstore          16
            //   104: aload           10
            //   106: ldc_w           "deviceno"
            //   109: aload           15
            //   111: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   114: pop            
            //   115: aload           10
            //   117: ldc_w           "devicetype"
            //   120: aload_2        
            //   121: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   124: pop            
            //   125: aload           10
            //   127: ldc_w           "accounttype"
            //   130: iload_3        
            //   131: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;I)Lorg/json/JSONObject;
            //   134: pop            
            //   135: aload           10
            //   137: ldc_w           "account"
            //   140: aload           4
            //   142: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   145: pop            
            //   146: aload           10
            //   148: ldc_w           "pwd"
            //   151: aload           5
            //   153: invokestatic    com/ipanel/join/homed/helper/OperationUtils.getMD5:(Ljava/lang/String;)Ljava/lang/String;
            //   156: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   159: pop            
            //   160: aload           6
            //   162: invokestatic    android/text/TextUtils.isEmpty:(Ljava/lang/CharSequence;)Z
            //   165: ifne            178
            //   168: aload           10
            //   170: ldc             "code"
            //   172: aload           6
            //   174: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   177: pop            
            //   178: aload           10
            //   180: ldc_w           "timestamp"
            //   183: new             Ljava/lang/StringBuilder;
            //   186: dup            
            //   187: invokespecial   java/lang/StringBuilder.<init>:()V
            //   190: lload           16
            //   192: invokevirtual   java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
            //   195: invokevirtual   java/lang/StringBuilder.toString:()Ljava/lang/String;
            //   198: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   201: pop            
            //   202: aload           10
            //   204: ldc_w           "isforce"
            //   207: ldc             "1"
            //   209: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   212: pop            
            //   213: aload           10
            //   215: ldc_w           "signature"
            //   218: new             Ljava/lang/StringBuilder;
            //   221: dup            
            //   222: aload           15
            //   224: invokestatic    java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
            //   227: invokespecial   java/lang/StringBuilder.<init>:(Ljava/lang/String;)V
            //   230: ldc_w           "|"
            //   233: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   236: aload_2        
            //   237: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   240: ldc_w           "|"
            //   243: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   246: iload_3        
            //   247: invokevirtual   java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
            //   250: ldc_w           "|"
            //   253: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   256: aload           4
            //   258: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   261: ldc_w           "|"
            //   264: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   267: lload           16
            //   269: invokevirtual   java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
            //   272: invokevirtual   java/lang/StringBuilder.toString:()Ljava/lang/String;
            //   275: invokestatic    com/ipanel/join/homed/helper/OperationUtils.getMD5:(Ljava/lang/String;)Ljava/lang/String;
            //   278: invokevirtual   org/json/JSONObject.put:(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
            //   281: pop            
            //   282: new             Lorg/apache/http/entity/StringEntity;
            //   285: dup            
            //   286: aload           10
            //   288: invokevirtual   org/json/JSONObject.toString:()Ljava/lang/String;
            //   291: ldc_w           "UTF-8"
            //   294: invokespecial   org/apache/http/entity/StringEntity.<init>:(Ljava/lang/String;Ljava/lang/String;)V
            //   297: astore          26
            //   299: getstatic       java/lang/System.out:Ljava/io/PrintStream;
            //   302: new             Ljava/lang/StringBuilder;
            //   305: dup            
            //   306: ldc_w           "para: "
            //   309: invokespecial   java/lang/StringBuilder.<init>:(Ljava/lang/String;)V
            //   312: aload           10
            //   314: invokevirtual   org/json/JSONObject.toString:()Ljava/lang/String;
            //   317: invokevirtual   java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
            //   320: invokevirtual   java/lang/StringBuilder.toString:()Ljava/lang/String;
            //   323: invokevirtual   java/io/PrintStream.println:(Ljava/lang/String;)V
            //   326: aload           26
            //   328: astore          11
            //   330: aload           9
            //   332: aload_1        
            //   333: aload           8
            //   335: aload           11
            //   337: ldc             "text/html"
            //   339: aload           7
            //   341: invokevirtual   cn/ipanel/android/net/http/AsyncHttpClient.post:(Landroid/content/Context;Ljava/lang/String;Lorg/apache/http/HttpEntity;Ljava/lang/String;Lcn/ipanel/android/net/http/AsyncHttpResponseHandler;)V
            //   344: return         
            //   345: astore          13
            //   347: aload           13
            //   349: invokevirtual   org/json/JSONException.printStackTrace:()V
            //   352: goto            330
            //   355: astore          12
            //   357: aload           12
            //   359: invokevirtual   java/io/UnsupportedEncodingException.printStackTrace:()V
            //   362: goto            330
            //   365: astore          12
            //   367: aload           26
            //   369: astore          11
            //   371: goto            357
            //   374: astore          13
            //   376: aload           26
            //   378: astore          11
            //   380: goto            347
            //    Exceptions:
            //  Try           Handler
            //  Start  End    Start  End    Type                                  
            //  -----  -----  -----  -----  --------------------------------------
            //  45     178    345    347    Lorg/json/JSONException;
            //  45     178    355    357    Ljava/io/UnsupportedEncodingException;
            //  178    299    345    347    Lorg/json/JSONException;
            //  178    299    355    357    Ljava/io/UnsupportedEncodingException;
            //  299    326    374    383    Lorg/json/JSONException;
            //  299    326    365    374    Ljava/io/UnsupportedEncodingException;
            // 
            // The error that occurred was:
            // 
            // java.lang.IllegalStateException: Expression is linked from several locations: Label_0330:
            //     at com.strobel.decompiler.ast.Error.expressionLinkedFromMultipleLocations(Error.java:27)
            //     at com.strobel.decompiler.ast.AstOptimizer.mergeDisparateObjectInitializations(AstOptimizer.java:2592)
            //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:235)
            //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:42)
            //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:214)
            //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:99)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethodBody(AstBuilder.java:757)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethod(AstBuilder.java:655)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addTypeMembers(AstBuilder.java:532)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeCore(AstBuilder.java:499)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeNoCache(AstBuilder.java:141)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createType(AstBuilder.java:130)
            //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addType(AstBuilder.java:105)
            //     at com.strobel.decompiler.languages.java.JavaLanguage.buildAst(JavaLanguage.java:71)
            //     at com.strobel.decompiler.languages.java.JavaLanguage.decompileType(JavaLanguage.java:59)
            //     at the.bytecode.club.bytecodeviewer.decompilers.ProcyonDecompiler.decompileClassNode(ProcyonDecompiler.java:120)
            //     at the.bytecode.club.bytecodeviewer.gui.ClassViewer$13.doShit(ClassViewer.java:624)
            //     at the.bytecode.club.bytecodeviewer.gui.PaneUpdaterThread.run(PaneUpdaterThread.java:16)
            // 
            throw new IllegalStateException("An error occurred while decompiling this method.");
        }
    

2 个答案:

答案 0 :(得分:5)

尝试反编译使用try-with-resources和lambdas的Java 8文件时遇到了类似的问题。

尝试以下失败后:

这家伙做了诀窍:

答案 1 :(得分:2)

首先,JD-GUI不是一个非常好的反编译器。您几乎肯定会使用其他反编译器获得更好的结果。

话虽如此,如果您想要认真对待Java逆向工程,学习如何理解字节码非常重要。

实际上有两种不同的字节码&#34;语言&#34;。第一种是Java类文件格式,由JVM执行。这是您运行Java桌面应用程序或applet时获得的。您可以在此处找到规范:http://docs.oracle.com/javase/specs/jvms/se8/html/index.html

然而,Android根本不使用Java字节码。相反,它使用自己的系统,称为Dex字节码,它类似,但略有不同。您可以在此处找到Dex字节码的规范:https://source.android.com/devices/tech/dalvik/dalvik-bytecode

APK由Dex字节码组成。但是,您显示的列表是Java字节码。据推测,您要么首先通过Dex2Jar运行它以将Dex文件转换为Java字节码,要么您使用了为您执行此操作的工具。 (您也可以使用Enjarify来执行此操作,但您发布的字节码看起来并不像Enjarify的输出)。

无论如何,如果您正在尝试理解混淆的二进制文件,您也可以直接查看源代码并查看Dex字节码,而不是输出不完美的转换工具。我建议查看smali / baksmali和apktool,这是我所知道的使用dex文件的最佳工具。

更新:现在您已经提供了apk,我自己反编译了它,它看起来并不像任何邪恶的东西。代码碰巧有一个带有多个catch块的try / catch,这会混淆你使用的反编译器。

由于你的apk中有多个带有loginV2方法的类,我决定专注于com/ipanel/join/homed/utils/APIManager

使用Enjarify + Krakatau,我得到以下反编译代码。

public void loginV2(android.content.Context a, String s, int i, String s0, String s1, String s2, cn.ipanel.android.net.http.AsyncHttpResponseHandler a0)
{
    org.apache.http.entity.StringEntity a1 = null;
    String s3 = new StringBuilder(String.valueOf((Object)com.ipanel.join.homed.Config.SERVER_ACCESS)).append("account/user/v2/login").toString();
    cn.ipanel.android.net.http.AsyncHttpClient a2 = new cn.ipanel.android.net.http.AsyncHttpClient();
    org.json.JSONObject a3 = new org.json.JSONObject();
    label1: {
        java.io.UnsupportedEncodingException a4 = null;
        label0: {
            org.json.JSONException a5 = null;
            label2: {
                java.io.PrintStream a6 = null;
                label4: {
                    label3: {
                        try
                        {
                            try
                            {
                                String s4 = new StringBuilder().append(com.ipanel.join.homed.utils.DeviceUtils.getDeviceId(a)).toString();
                                String s5 = new StringBuilder(String.valueOf((Object)s4)).append(com.ipanel.join.homed.helper.OperationUtils.getMD5(s4).substring(7, 8)).toString();
                                long j = java.util.Calendar.getInstance().getTimeInMillis();
                                a3.put("deviceno", (Object)s5);
                                a3.put("devicetype", (Object)s);
                                a3.put("accounttype", i);
                                a3.put("account", (Object)s0);
                                a3.put("pwd", (Object)com.ipanel.join.homed.helper.OperationUtils.getMD5(s1));
                                if (!android.text.TextUtils.isEmpty((CharSequence)(Object)s2))
                                {
                                    a3.put("code", (Object)s2);
                                }
                                a3.put("timestamp", (Object)new StringBuilder().append(j).toString());
                                a3.put("isforce", (Object)"1");
                                a3.put("signature", (Object)com.ipanel.join.homed.helper.OperationUtils.getMD5(new StringBuilder(String.valueOf((Object)s5)).append("|").append(s).append("|").append(i).append("|").append(s0).append("|").append(j).toString()));
                                a1 = new org.apache.http.entity.StringEntity(a3.toString(), "UTF-8");
                                a6 = System.out;
                                break label4;
                            }
                            catch(org.json.JSONException a7)
                            {
                                a5 = a7;
                            }
                        }
                        catch(java.io.UnsupportedEncodingException a8)
                        {
                            a4 = a8;
                            break label3;
                        }
                        a1 = null;
                        break label2;
                    }
                    a1 = null;
                    break label0;
                }
                {
                    try
                    {
                        try
                        {
                            a6.println(new StringBuilder("para: ").append(a3.toString()).toString());
                            break label1;
                        }
                        catch(org.json.JSONException a9)
                        {
                            a5 = a9;
                        }
                    }
                    catch(java.io.UnsupportedEncodingException a10)
                    {
                        a4 = a10;
                        break label0;
                    }
                    break label2;
                }
            }
            a5.printStackTrace();
            break label1;
        }
        a4.printStackTrace();
    }
    a2.post(a, s3, (org.apache.http.HttpEntity)(Object)a1, "text/html", a0);
}

Krakatau有点难以使用,但它具有能够处理几乎任何东西的优势(除了invokedynamic,Android很幸运没有)。然而,虽然它总会给你一些东西,但有些情况下产生的代码不必要地复杂,而且这是其中之一 - 使用多个catch块的try / catch处理得非常糟糕。

幸运的是,很容易看到代码实际上正在尝试做什么并手动清理它。这是我上面的手动清理版本,除了变量名和完全限定的类引用之外,它可能接近原始代码。如你所见,没有故意的混淆。它恰好是偶然使用反编译器挣扎的try / catch。

public void loginV2(android.content.Context a, String s, int i, String s0, String s1, String s2, cn.ipanel.android.net.http.AsyncHttpResponseHandler a0)
{
    org.apache.http.entity.StringEntity a1 = null;
    String s3 = com.ipanel.join.homed.Config.SERVER_ACCESS + "account/user/v2/login";
    cn.ipanel.android.net.http.AsyncHttpClient a2 = new cn.ipanel.android.net.http.AsyncHttpClient();
    org.json.JSONObject a3 = new org.json.JSONObject();

    try
    {
        String s4 = com.ipanel.join.homed.utils.DeviceUtils.getDeviceId(a);
        String s5 = s4 + com.ipanel.join.homed.helper.OperationUtils.getMD5(s4).substring(7, 8);
        long j = java.util.Calendar.getInstance().getTimeInMillis();
        a3.put("deviceno", s5);
        a3.put("devicetype", s);
        a3.put("accounttype", i);
        a3.put("account", s0);
        a3.put("pwd", com.ipanel.join.homed.helper.OperationUtils.getMD5(s1));
        if (!android.text.TextUtils.isEmpty(s2))
        {
            a3.put("code", s2);
        }
        a3.put("timestamp", "" + j);
        a3.put("isforce", "1");
        a3.put("signature", com.ipanel.join.homed.helper.OperationUtils.getMD5(s5 + "|" + s + "|" + i + "|" + s0 + "|" + j);
        a1 = new org.apache.http.entity.StringEntity(a3.toString(), "UTF-8");
        System.out.println("para: " + a3);
    }
    catch(org.json.JSONException a7)
    {
        a7.printStackTrace();
    }
    catch(java.io.UnsupportedEncodingException a8)
    {
        a8.printStackTrace();
    }

    a2.post(a, s3, a1, "text/html", a0);
}