`

反编译还原总结

 
阅读更多
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语句反编译后产生的。下面,就简单介绍一下,一些反编译后的特殊代码的还原规则。

异常  
 
下面的代码前提是类中有如下属性, 
Calendar cal = Calendar.getInstance();
 
1、Exceptioin的还原  
 
反编译后的代码如下: public boolean f1() { return cal.getTime().after(new Date());
Exception e;
e;
e.printStackTrace();
return false;
} 还原后的Java代码 public boolean f1() { try { return cal.getTime().after(new Date());
} catch (Exception e) { e.printStackTrace();
return false;
} } 

2、finally代码的还原 反编译后的Java代码如下: public boolean f2() { boolean flag = cal.getTime().after(new Date());
System.out.println("finally");
return flag;
Exception e;
e;
e.printStackTrace();
System.out.println("finally");
return false;
Exception exception;
exception;
System.out.println("finally");
throw exception;
} 还原后的代码如下: public boolean f2() { try { return cal.getTime().after(new Date());
} catch (Exception e) { e.printStackTrace();
return false;
} finally { System.out.println("finally");
} } 

3、MISSING_BLOCK_LABEL_的还原反编译后的代码 public Object f22() { Date date = cal.getTime();
System.out.println("finally");
return date;
Exception e;
e;
e.printStackTrace();
System.out.println("finally");
break MISSING_BLOCK_LABEL_45;
Exception exception;
exception;
System.out.println("finally");
throw exception;
return null;
} 还原后的Java代码 public Object f22() { try { return cal.getTime();
} catch (Exception e) { e.printStackTrace();
} finally { System.out.println("finally");
} return null;
} 

4、异常中:label的还原反编译后的代码 public String f4() throws Exception { label0: { try { Integer i = new Integer(1);
if(i.intValue() >
0) { System.out.println(i);
break label0;
} System.err.println(i);
} catch(Exception dae) { System.err.println(dae);
throw new RuntimeException(dae);
} return null;
} return "Hello";
} 注意,这个代码有点诡异,实际代码如下: public String f4() throws Exception { try { Integer i = new Integer(1);
if (i.intValue() >
0) { System.out.println(i);
} else { System.err.println(i);
return null;
} return "Hello";
} catch (Exception dae) { System.err.println(dae);
throw new RuntimeException(dae);
} } 

5、典型数据库操作代码还原反编译后代码 public HashMap f5() { Connection conn = null;
HashMap hashmap;
HashMap map = new HashMap();
Class.forName("");
conn = DriverManager.getConnection("jdbc:odbc:");
PreparedStatement pstmt = conn.prepareStatement("select * from table");
pstmt.setString(1, "param");
String columnVallue;
for(ResultSet rs = pstmt.executeQuery();
rs.next();
map.put(columnVallue, "")) columnVallue = rs.getString("column");
hashmap = map;
if(conn != null) try { conn.close();
} catch(SQLException sqlce) { sqlce.printStackTrace();
} return hashmap;
ClassNotFoundException cnfe;
cnfe;
cnfe.printStackTrace();
if(conn != null) try { conn.close();
} catch(SQLException sqlce) { sqlce.printStackTrace();
} break MISSING_BLOCK_LABEL_188;
SQLException sqle;
sqle;
sqle.printStackTrace();
if(conn != null) try { conn.close();
} catch(SQLException sqlce) { sqlce.printStackTrace();
} break MISSING_BLOCK_LABEL_188;
Exception exception;
exception;
if(conn != null) try { conn.close();
} catch(SQLException sqlce) { sqlce.printStackTrace();
} throw exception;
return null;
} 实际代码如下: public HashMap f5() { Connection conn = null;
try { HashMap map = new HashMap();
Class.forName("");
conn = DriverManager.getConnection("jdbc:odbc:");
PreparedStatement pstmt = conn.prepareStatement("select * from table");
pstmt.setString(1, "param");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) { String columnVallue = rs.getString("column");
map.put(columnVallue, "");
} return map;
} catch (ClassNotFoundException cnfe) { cnfe.printStackTrace();
} catch (SQLException sqle) { sqle.printStackTrace();
} finally { if (conn != null) { try { conn.close();
} catch (SQLException sqlce) { sqlce.printStackTrace();
} } } return null;
} 

6、两层异常嵌套代码还原反编译后的代码 public int f6() { int i = cal.getTime().compareTo(new Date());
System.out.println("finally");
return i;
Exception e1;
e1;
e1.printStackTrace();
System.out.println("finally");
return -1;
Exception e2;
e2;
e2.printStackTrace();
System.out.println("finally");
return -2;
Exception exception;
exception;
System.out.println("finally");
throw exception;
} 实际代码 public int f6() { try { try { return cal.getTime().compareTo(new Date());
} catch (Exception e1) { e1.printStackTrace();
return -1;
} } catch (Exception e2) { e2.printStackTrace();
return -2;
} finally { System.out.println("finally");
} } 

7、非常诡异的代码反编译后的代码 public int f7() { int i = cal.getTime().compareTo(new Date());
System.out.println("finally");
return i;
Exception e1;
e1;
e1.printStackTrace();
_L2: System.out.println("finally");
return -1;
Exception e2;
e2;
e2.printStackTrace();
if(true) goto _L2;
else goto _L1 _L1: Exception exception;
exception;
System.out.println("finally");
throw exception;
} 原始代码 public int f7() { try { try { return cal.getTime().compareTo(new Date());
} catch (Exception e1) { e1.printStackTrace();
return -1;
} } catch (Exception e2) { e2.printStackTrace();
return -1;
} finally { System.out.println("finally");
} } 
分享到:
评论

相关推荐

    关于JAD的反编译错误集

    (原创)经过一个工程后的研究总结,不过够你看的..

    微信小程序“反编译”实战(一):解包

    本实战教程将一步步告诉你如何“反编译”获得其它小程序的源代码,包括“解包”和“源码还原”两篇,主要参考了看雪论坛、V2EX、GitHub 等网站上的帖子、教程、工具,在此不胜感激,参考链接详见文章底部,以及加上...

    VMProtect的逆向分析和静态还原

    三、字节码反编译 (一)中间表示语言 (二)指令化简和优化 (三)转换汇编指令——树模式匹配 (四)归类映射寄存器 (五)转换汇编指令——动态规划 (六)寄存器染色 基本块内的寄存器轮转 基本块间的寄存器轮转...

    逆向工程源码

    6、还原java文件夹(项目中的类包)内容:将5中的com文件夹中的内容直接打开任意一个最下面的子文件,将其拖到我们之前下载好的反编译软件中 7、通过eclipse重新加载该项目,将反编译出来的每一个类按照相应的...

    《安天365安全研究》第二期.pdf

    2.11.1 使用 Reflector.v9.0.1.374 反编译 2.11.2 获取初始加密密码和密钥 2.12Intel AMT 固件密码绕过登录漏洞分析与实战 2.12.1 漏洞简介 2.12.2 攻击场景 2.12.3 漏洞利用原理 2.12.4 漏洞利用还原 2.12.5 kali ...

    Windows内核安全与驱动开发光盘源码

    10.2 具有还原功能的磁盘卷过滤驱动 168 10.2.1 简介 168 10.2.2 基本思想 169 10.3 驱动分析 169 10.3.1 DriverEntry函数 169 10.3.2 AddDevice函数 170 10.3.3 PnP请求的处理 174 10.3.4 Power请求的处理 ...

    Windows内核安全驱动开发(随书光盘)

    10.2 具有还原功能的磁盘卷过滤驱动 168 10.2.1 简介 168 10.2.2 基本思想 169 10.3 驱动分析 169 10.3.1 DriverEntry函数 169 10.3.2 AddDevice函数 170 10.3.3 PnP请求的处理 174 10.3.4 Power请求的处理 ...

    寒江独钓-Windows内核安全编程(高清完整版).part1

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    寒江独钓-Windows内核安全编程(高清完整版).part7

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    寒江独钓-Windows内核安全编程(高清完整版).part4

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    寒江独钓-Windows内核安全编程(高清完整版).part2

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    寒江独钓-Windows内核安全编程(高清完整版).part6

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    寒江独钓-Windows内核安全编程(高清完整版).part5

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    寒江独钓-Windows内核安全编程(高清完整版).part3

    6.2 具有还原功能的磁盘卷过滤驱动 129 6.2.1 简介 129 6.2.2 基本思想 130 6.3 驱动分析 130 6.3.1 DriverEntry函数 130 6.3.2 AddDevice函数 132 6.3.3 PnP请求的处理 136 6.3.4 Power请求的处理 140 6.3.5 ...

    RED HAT LINUX 6大全

    11.5.4 前区和反区必须保持同步 207 11.5.5 HUP信号和重启 207 11.5.6 IN-ADDR.ARPA域 207 11.5.7 主机命名方案 208 11.5.8 配置DNS客户:/etc/resolv.conf 208 11.5.9 DNS软件 208 11.6 DNS服务器配置文件 210 ...

Global site tag (gtag.js) - Google Analytics