- 浏览: 118261 次
- 性别:
- 来自: 西安
文章分类
最新评论
-
wuruxiantu:
http://localhost:8080/blog/uplo ...
mvnForum 一个开源的BBS搭建过程 -
shansheng:
第一个for循环,没看出来原始的和反编译后的区别嘛
java class反编译后的代码还原 -
hhujsj:
顶 对我做的项目很有帮组!!!
J2EE应用:定时器 -
iRoger:
不错,写的很仔细,为什么没人顶呢
J2EE应用:定时器 -
rain16881:
很好很强大啊..边看你这..边看自己的..十分钟就搞好了一个难 ...
java class反编译后的代码还原
文章来源:http://blog.csdn.net/z3h/archive/2008/07/11/2640522.aspx
java class反编译后的代码还原(一)
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.4.2_08+jad 1.58f下测试。jad 1.5.8f可以到这里http://download.csdn.net/source/470540 下载。
第一部分、for、while循环
1、普通的循环,原始
view plaincopy to clipboardprint?
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);
}
}
}
}
反编译后的代码
view plaincopy to clipboardprint?
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原代码
view plaincopy to clipboardprint?
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反编译后的代码,部分逻辑丢失。
view plaincopy to clipboardprint?
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);
}
3、就是比f2()多了一行System.out.println("list[i]");,反编译后也挺怪的。源码如下:
view plaincopy to clipboardprint?
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;
}
}
}
}
}
反编译后的代码:
view plaincopy to clipboardprint?
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语言,移动了位置。源码如下:
view plaincopy to clipboardprint?
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;
}
}
}
反编译后代码:
view plaincopy to clipboardprint?
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]");,反编译后相当怪的。源码如下:
view plaincopy to clipboardprint?
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;
}
}
}
反编译后比较晕的代码:
view plaincopy to clipboardprint?
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);代码,但是差异确很大。源码如下:
view plaincopy to clipboardprint?
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()差异太大了。
view plaincopy to clipboardprint?
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);移动了位置,但是差异确很大。源码如下:
view plaincopy to clipboardprint?
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()差异太大了。
view plaincopy to clipboardprint?
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()代码。
view plaincopy to clipboardprint?
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()比较一下,基本就可以确定反编译后的代码对应关系了。
view plaincopy to clipboardprint?
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't completed */。
view plaincopy to clipboardprint?
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);
}
}
}
反编译后的代码:
view plaincopy to clipboardprint?
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't completed */
}
System.out.println("break");
System.out.println("exit(0)");
System.exit(0);
_L3:
return;
if(true) goto _L5; else goto _L4
_L4:
}
}
java class反编译后的代码还原(二)
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.4.2_08+jad 1.58f下测试。jad 1.5.8f可以到这里http://download.csdn.net/source/470540 下载。
第二部分、异常
下面的代码前提是类中有如下属性, Calendar cal = Calendar.getInstance();。
1、Exceptioin的还原 反编译后的代码如下:
view plaincopy to clipboardprint?
public boolean f1()
{
return cal.getTime().after(new Date());
Exception e;
e;
e.printStackTrace();
return false;
}
还原后的Java代码
view plaincopy to clipboardprint?
public boolean f1()
{
try
{
return cal.getTime().after(new Date());
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
2、finally代码的还原 反编译后的Java代码如下:
view plaincopy to clipboardprint?
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;
}
还原后的代码如下:
view plaincopy to clipboardprint?
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_的还原反编译后的代码
view plaincopy to clipboardprint?
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代码
view plaincopy to clipboardprint?
public Object f22()
{
try
{
return cal.getTime();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
System.out.println("finally");
}
return null;
}
4、异常中:label的还原反编译后的代码
view plaincopy to clipboardprint?
public String f4()
throws Exception
{
l0:
{
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";
}
注意,这个代码有点诡异,实际代码如下:
view plaincopy to clipboardprint?
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、典型数据库操作代码还原 反编译后代码
view plaincopy to clipboardprint?
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;
}
实际代码如下:
view plaincopy to clipboardprint?
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、两层异常嵌套代码还原 反编译后的代码
view plaincopy to clipboardprint?
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;
}
实际代码
view plaincopy to clipboardprint?
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、非常诡异的代码 反编译后的代码
view plaincopy to clipboardprint?
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;
}
原始代码
view plaincopy to clipboardprint?
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");
}
}
java class反编译后的代码还原(一)
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.4.2_08+jad 1.58f下测试。jad 1.5.8f可以到这里http://download.csdn.net/source/470540 下载。
第一部分、for、while循环
1、普通的循环,原始
view plaincopy to clipboardprint?
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);
}
}
}
}
反编译后的代码
view plaincopy to clipboardprint?
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原代码
view plaincopy to clipboardprint?
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反编译后的代码,部分逻辑丢失。
view plaincopy to clipboardprint?
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);
}
3、就是比f2()多了一行System.out.println("list[i]");,反编译后也挺怪的。源码如下:
view plaincopy to clipboardprint?
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;
}
}
}
}
}
反编译后的代码:
view plaincopy to clipboardprint?
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语言,移动了位置。源码如下:
view plaincopy to clipboardprint?
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;
}
}
}
反编译后代码:
view plaincopy to clipboardprint?
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]");,反编译后相当怪的。源码如下:
view plaincopy to clipboardprint?
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;
}
}
}
反编译后比较晕的代码:
view plaincopy to clipboardprint?
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);代码,但是差异确很大。源码如下:
view plaincopy to clipboardprint?
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()差异太大了。
view plaincopy to clipboardprint?
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);移动了位置,但是差异确很大。源码如下:
view plaincopy to clipboardprint?
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()差异太大了。
view plaincopy to clipboardprint?
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()代码。
view plaincopy to clipboardprint?
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()比较一下,基本就可以确定反编译后的代码对应关系了。
view plaincopy to clipboardprint?
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't completed */。
view plaincopy to clipboardprint?
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);
}
}
}
反编译后的代码:
view plaincopy to clipboardprint?
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't completed */
}
System.out.println("break");
System.out.println("exit(0)");
System.exit(0);
_L3:
return;
if(true) goto _L5; else goto _L4
_L4:
}
}
java class反编译后的代码还原(二)
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.4.2_08+jad 1.58f下测试。jad 1.5.8f可以到这里http://download.csdn.net/source/470540 下载。
第二部分、异常
下面的代码前提是类中有如下属性, Calendar cal = Calendar.getInstance();。
1、Exceptioin的还原 反编译后的代码如下:
view plaincopy to clipboardprint?
public boolean f1()
{
return cal.getTime().after(new Date());
Exception e;
e;
e.printStackTrace();
return false;
}
还原后的Java代码
view plaincopy to clipboardprint?
public boolean f1()
{
try
{
return cal.getTime().after(new Date());
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
2、finally代码的还原 反编译后的Java代码如下:
view plaincopy to clipboardprint?
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;
}
还原后的代码如下:
view plaincopy to clipboardprint?
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_的还原反编译后的代码
view plaincopy to clipboardprint?
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代码
view plaincopy to clipboardprint?
public Object f22()
{
try
{
return cal.getTime();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
System.out.println("finally");
}
return null;
}
4、异常中:label的还原反编译后的代码
view plaincopy to clipboardprint?
public String f4()
throws Exception
{
l0:
{
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";
}
注意,这个代码有点诡异,实际代码如下:
view plaincopy to clipboardprint?
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、典型数据库操作代码还原 反编译后代码
view plaincopy to clipboardprint?
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;
}
实际代码如下:
view plaincopy to clipboardprint?
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、两层异常嵌套代码还原 反编译后的代码
view plaincopy to clipboardprint?
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;
}
实际代码
view plaincopy to clipboardprint?
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、非常诡异的代码 反编译后的代码
view plaincopy to clipboardprint?
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;
}
原始代码
view plaincopy to clipboardprint?
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");
}
}
评论
4 楼
shansheng
2011-04-28
第一个for循环,没看出来原始的和反编译后的区别嘛
3 楼
rain16881
2009-02-12
很好很强大啊..边看你这..边看自己的..十分钟就搞好了一个难题
2 楼
rain16881
2009-02-12
goto也不难的..按他走一次就好了
你这个我看了也有启发
你这个我看了也有启发
1 楼
laith_li
2009-01-16
- System.out.println("finally");
发表评论
-
极点五笔的五笔拼音输入模式,很喜欢
2012-09-09 01:15 877下载附件: -
C++让计算机自动重启
2010-10-10 01:31 970转自:http://www.yuloo.com/jsjks/ ... -
VBA实例教程
2010-07-02 02:13 1316学习VBA -
GOOGLE版的金山
2010-06-29 22:14 802GOOGLE版的金山相当不错,界面漂亮,运行速度快,用户体验非 ... -
FTP主动模式及被动模式
2009-06-26 15:27 1924FTP主动模式及被动模式 ... -
CVSNT在Windows下的安装和使用
2009-06-17 15:54 1178CVSNT在Windows下的安装和 ... -
Dom4j的使用
2009-03-14 23:00 695文章来源:http://xhy0422.ite ... -
EXT学习资料
2008-12-04 12:32 1371无论你是Ext库的新手, ... -
Maven使用手册
2008-12-03 13:28 1412来自:http://www.jieesoft.com/ ... -
windows批处理中符号的作用
2008-12-03 13:27 1102发表时间: 2007-12-27 13:48 ... -
将Java的class文件转为EXE的八种方法
2008-12-03 13:26 872将Java的class文件转为EXE的八种方法 文章来源:ht ... -
log4j配置文件基本含义说明
2008-12-03 13:24 923log4j配置文件基本含义说明 文章来源:http://www ... -
Commons-logging + Log4j 入门指南
2008-12-03 13:23 1869一 :为什么同时使用commons-logging和Log4j ... -
国家语言代码i18n
2008-12-03 13:23 2526Locale 语言 国家 da_DK 丹麦语 丹麦 ... -
FTP上传,下载
2008-12-03 13:20 1133FTP上传,下载 来源:htt ... -
用JAVA访问共享文件系统
2008-12-03 13:19 1436在Microsoft 网 络 系 统 ... -
如何利用数据库控制Serv-U的用户
2008-12-03 13:18 1393如何利用数据库控制Serv-U的用户 作者:未知 文章来源 ... -
关于SAX,DOM,JAXP,JDOM,DOM4J的一些理解
2008-12-03 13:12 2287作者:renyangok 处出: ... -
Word模板的制作方法和内容定位识别技术
2008-12-03 13:03 5799blueski推荐 [2006-11-1] 出处:计算机与信息 ... -
java中通过jacob调用word方法
2008-12-03 13:01 1090java中通过jacob调用word方法 public st ...
相关推荐
JAVA反编译软件(可将class文件反编译为java文件)
java反编译工具(.class文件反编译成.java文件) 解压后点击exe文件打开工具,点击open菜单选择.class文件执行后即生成.java文件 一直在使用的,方便,系统维护必不可少
XJad是一款高效的Java源程序反编译软件,可以把.class文件还原成.java文件,精确度很高,内置Jad1.5.8e2,同时可处理多个*.class文件,也可以同时编译文件夹内的所有的CLASS文件,甚至可以处理*.jar文件;...
有时候,为了学习源码,我们希望将.java已经编译成.class的文件反编译为.java文件,如何还原为.java文件呢? 此款软件可以帮您将.class文件反编译为.java文件。 —好不好? ——谁用谁知道!
1、打开一个或者多个*.class文件,XJad反编译后,重命名为*.java文件, 保存至当前文件夹,并在编辑器中打开查看; 2、打开一个文件夹,XJad将该文件夹下所有*.class文件进行反编译,并保存至该文件夹下, 依据包...
1、打开一个或者多个*.class文件,XJad反编译后,重命名为*.java文件, 保存至当前文件夹,并在编辑器中打开查看; 2、打开一个文件夹,XJad将该文件夹下所有*.class文件进行反编译,并保存至该文件夹下, 依据包...
java class反编译后的代码还原常见的编译后代码以及还原代码
DJ Java Decompiler 是个反编译的工具,可以将编译过的CLASS文件编译还原成为Java原始文件,并且不需要额外安装JVM(Java Virtual Machine)或是Java SDK的工具模组即可使用。不单如此,DJJava Decompiler也兼具有...
JD-GUI 是一个用 C++ 开发的 Java 反编译工具,仅支持Windows平台。JD-GUI不需要安装,直接点击运行,可以反编译jar,class文件。
luyten是Procyon-Decompiler的GUI,是一款操作简单、功能实用的java反编译工具,软件支持*.JAR、*.zip、*.class等类型文件的反编译操作,还原度非常高,支持更多功能设置,如显式导入、类型、合成组件等等;...
JAVA 反编译工具 DJ DJ Java Decompiler是个反编译的工具,可以将编译过的CLASS文件编译还原成为Java原始文件,并且不需要额外安装JVM
把经过java文件编译后的可执行的class文件再反编译为java文件,因为经过编译的class文件是不可阅读的!但是由于java文件一般都不是单独运行的,会有类之间的相互调用,所以反编译工具反编译后只能大体上还原原来java文件...
当我们编写完成一个java类后,运行结果会得到一个class文件,这种二进制文件如果用普通记事本打开,就会出现各种乱码现象,令人十分头疼,当我们要查看.class文件的源代码时,可以通过反编译工具jd-gui实现。...
它支持Java applets,JAR和ZIP文件的反编译,从中还原出你所需要的源代码,之后你就可以通过Java编程工具中的Class浏览器查看,或进行相关操作。 Cavaj Java Decompiler是独立的Windows应用程序,即使没有安装Java...
1、打开一个或者多个*.class文件,XJad反编译后,重命名为*.java文件, 保存至当前文件夹,并在编辑器中打开查看; 2、打开一个文件夹,XJad将该文件夹下所有*.class文件进行反编译,并保存至该文件夹下, 依据包...
luyten是Procyon的GUI,是一款操作简单、功能实用的java反编译工具,软件支持*.JAR、*.zip、*.class等类型文件的反编译操作,还原度非常高,支持更多功能设置,如显式导入、类型、合成组件等等,用户可根据不同的...
此资源只包含一个工具, java反编译工具,将class还原成,java未编译文件。还原原始文件
经典的Java反编译工具,可以直接打开.class文件进行还原,需要的朋友下来看看