前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于反编译的搜索

Java class反编译后的代码还原 - 弘烨@ - ITeye技术网站 首页 资讯 精华 论坛 问答 博客 专栏 群组 更多 ▼ 招聘 搜索 您还未登录 ! 登录 注册 弘烨@ 博客 微博 相册 收藏 留言 关于我 hwy1782 Java class反编译后的代码还原 博客分类: J2SE 基础 JavaJVMJDK ? Java class 利用jad 反编译之后,偶尔回碰到一些不正常的代码,例如:label0 :_L1 MISSING_BLOCK_LABEL_30、JVM INSTR ret 7 、JVM INSTR tableswitch 1 3: default 269、 JVM INSTR monitorexit、JVM INSTR monitorenter,这些一般是由特殊的for循环、try catch finally语句块、synchronized语句反编译后产生的。 下面,就简单介绍一下,一些反编译后的特殊代码的还原规则。 本文在Jdk 1.6.0_20+jad 1.58g下测试。 1、普通的循环,原始 ? public void f1() { boolean flag = false; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { for (int i = 0; i < 10; i++) { flag = Boolean.getBoolean("sys"); if (flag) { System.exit(0); } } } } ?反编译后的代码 ? ? public void f1() { boolean flag = false; if(Boolean.getBoolean("sys")) { System.out.println("sys"); } else { for(int i = 0; i < 10; i++) { flag = Boolean.getBoolean("sys"); if(flag) System.exit(0); } } } ?2、反编译后代码变的很古怪,这是java原代码 ? public void f2() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { check: while (true) { for (int i = 0; i < list.length; i++) { if (list[i] == 2) { continue check; } else { break; } } } } } ?Java反编译后的代码,部分逻辑丢失。 ? public void f2() { int list[] = { 1, 2, 3, 4 }; if(Boolean.getBoolean("sys")) System.out.println("sys"); else do { int i = 0; if(i >= list.length || list[i] != 2); } while(true); } 就是比f2()多了一行System.out.println("list[i]");,反编译后也挺怪的。源码如下 public void f3() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { check: while (true) { for (int i = 0; i < list.length; i++) { System.out.println("list[i]"); if (list[i] == 2) { continue check; } else { break; } } } } } ?反编译后的代码: public void f3() { int list[] = { 1, 2, 3, 4 }; if(Boolean.getBoolean("sys")) System.out.println("sys"); else do { int i; do i = 0; while(i >= list.length); System.out.println("list[i]"); if(list[i] != 2); } while(true); } 4、 f2()中的break语言,移动了位置。源码如下 public void f4() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { check: while (true) { for (int i = 0; i < list.length; i++) { if (list[i] == 2) { continue check; } } break; } } } ?? 反编译后代码: public void f4() { int list[] = { 1, 2, 3, 4 }; int i; if(Boolean.getBoolean("sys")) System.out.println("sys"); else label0: do { for(i = 0; i < list.length; i++) if(list[i] == 2) continue label0; break; } while(true); }? ??5、就是比f4()多了一行System.out.println("list[i]");,反编译后相当怪的。源码如下:? public void f5() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { check: while (true) { for (int i = 0; i < list.length; i++) { System.out.println("list[i]"); if (list[i] == 2) { continue check; } } break; } } } ?反编译后比较晕的代码:? public void f5() { int list[] = { 1, 2, 3, 4 }; if(!Boolean.getBoolean("sys")) goto _L2; else goto _L1 _L1: System.out.println("sys"); goto _L3 _L2: int i = 0; goto _L4 _L6: System.out.println("list[i]"); if(list[i] != 2) goto _L5; else goto _L2 _L5: i++; _L4: if(i < list.length) goto _L6; else goto _L3 _L3: } ?? 6、就是比f5()多了一行System.exit(0);代码,但是差异确很大。源码如下: public void f6() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { check: while (true) { for (int i = 0; i < list.length; i++) { System.out.println("list[i]"); if (list[i] == 2) { continue check; } } System.exit(0); break; } } } ?反编译后代码,比f5()差异太大了。 public void f6() { int list[]; list = (new int[] { 1, 2, 3, 4 }); if(Boolean.getBoolean("sys")) { System.out.println("sys"); break MISSING_BLOCK_LABEL_75; } _L2: int i = 0; goto _L1 _L5: System.out.println("list[i]"); if(list[i] != 2) goto _L3; else goto _L2 _L3: i++; _L1: if(i < list.length) goto _L5; else goto _L4 _L4: System.exit(0); } ? ??7、差异就是f6()中的System.exit(0);移动了位置,但是差异确很大。源码如下:? public void f7() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { check: while (true) { for (int i = 0; i < list.length; i++) { System.out.println("list[i]"); if (list[i] == 2) { continue check; } } break; } System.exit(0); } } ?反编译后代码,比f6()差异太大了。 public void f7() { int list[]; list = (new int[] { 1, 2, 3, 4 }); if(Boolean.getBoolean("sys")) { System.out.println("sys"); break MISSING_BLOCK_LABEL_75; } _L2: int i = 0; goto _L1 _L5: System.out.println("list[i]"); if(list[i] != 2) goto _L3; else goto _L2 _L3: i++; _L1: if(i < list.length) goto _L5; else goto _L4 _L4: System.exit(0); } ?8、逻辑和f7比没有变,只是多了一些System.out.println()代码。 public void f8() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { System.out.println(":check while"); check: while (true) { System.out.println("for"); for (int i = 0; i < list.length; i++) { System.out.println("list[i]"); if (list[i] == 2) { continue check; } } System.out.println("break"); break; } System.out.println("exit(0)"); System.exit(0); } } ?反编译后的代码:和f7()比较一下,基本就可以确定反编译后的代码对应关系了。? public void f8() { int list[]; list = (new int[] { 1, 2, 3, 4 }); if(Boolean.getBoolean("sys")) { System.out.println("sys"); break MISSING_BLOCK_LABEL_107; } System.out.println(":check while"); _L2: int i; System.out.println("for"); i = 0; goto _L1 _L5: System.out.println("list[i]"); if(list[i] != 2) goto _L3; else goto _L2 _L3: i++; _L1: if(i < list.length) goto _L5; else goto _L4 _L4: System.out.println("break"); System.out.println("exit(0)"); System.exit(0); } ?9、逻辑和f8比没有变,只是多了一行System.out.println()代码,导致了反编译后的/* Loop/switch isn&apos;t completed */ public void f9() { int[] list = new int[] { 1, 2, 3, 4 }; if (Boolean.getBoolean("sys")) { System.out.println("sys"); } else { System.out.println(":check while"); check: while (true) { System.out.println("for"); for (int i = 0; i < list.length; i++) { System.out.println("list[i]"); if (list[i] == 2) { System.out.println("continue check"); continue check; } } System.out.println("break"); break; } System.out.println("exit(0)"); System.exit(0); } } } ?反编译后的代码: public void f9() { int list[] = { 1, 2, 3, 4 }; if(!Boolean.getBoolean("sys")) goto _L2; else goto _L1 _L1: System.out.println("sys"); goto _L3 _L2: System.out.println(":check while"); _L5: System.out.println("for"); for(int i = 0; i < list.length; i++) { System.out.println("list[i]"); if(list[i] != 2) continue; System.out.println("continue check"); continue; /* Loop/switch isn&apos;t completed */ } System.out.println("break"); System.out.println("exit(0)"); System.exit(0); _L3: return; if(true) goto _L5; else goto _L4 _L4: } } ? 分享到: SVN 项目的目录结构 | 数组中出现次数超过一半的数字 2011-02-17 14:15 浏览 948 评论(0) 分类:编程语言 相关推荐 评论 发表评论 您还没有登录,请您登录后再发表评论 hwy1782 浏览: 15312 次 性别: 来自: 杭州 最近访客 更多访客>> dylinshi126 csj24975 cxcco smartbigsea 文章分类 全部博客 (64) J2SE 基础 (20) 生活 (0) 笔试题 (5) 算法 (6) 开发工具 (7) web (3) 数据库 (4) linux (2) android (8) 架构 (1) 社区版块 我的资讯 (0) 我的论坛 (1) 我的问答 (0) 存档分类 2013-08 (1) 2013-05 (5) 2013-04 (8) 更多存档... 最新评论 润之哥: 额 值传递 和引用传递 很蛋疼啦 ~~~ Java中String类型的参数传递问题的解析 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。若作者同意转载,必须以超链接形式标明文章原始出处和作者。 &copy; 2003-2014 ITeye.com. All rights reserved. [ 京ICP证110151号 京公网安备110105010620 ]