使用jd-gui+javassist修改已编译好的class文件

2017-07-28

1.原因:因为公司代码管理不当导致源码丢失,只好已编译好的class文件进行修改

2.首先先在myeclipse中新建java项目并导入javassist

3.将需要修改的文件放到指定文件夹下

4..在项目中添加以下代码

package dtj;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;

public class MyTest {

///////入口启动函数

       public static void main(String[] args) throws Exception {

       //这个是得到反编译的池

      ClassPool pool = ClassPool.getDefault();
      
      pool.insertClassPath("E:/dtj") ;
      
    //取得需要反编译修改的文件,注意是完整路径

      CtClass cc1 = pool.get("SmsSender");

      try {
          
          
          cc1.setName("CTCC_SmsSender");
          //取得需要修改的方法

         // CtMethod method = cc1.getDeclaredMethod("a");

         //插入修改项,我们让他直接返回(注意:根据方法的具体返回值返回,因为这个方法返回值是void,所以直接return;)

         // method.insertBefore("{if(true) return ;}");

          //写入保存

          cc1.writeFile();

      } catch (NotFoundException e) {

          e.printStackTrace();

     }

} 
}

注:jd-gui和javassist的下载地址
下载


本文由 admin 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

3471 条评论

  1. xlxohbbc
    xlxohbbc

    使用jd-gui javassist修改已编译好的class文件 - 青花瓷
    axlxohbbc
    [url=http://www.gi0o5j9i36514oh49rfz26r5pe0l2k6as.org/]uxlxohbbc[/url]
    xlxohbbc http://www.gi0o5j9i36514oh49rfz26r5pe0l2k6as.org/

    1. KallinikaRok
      KallinikaRok

      is cannabis together

      441d achat is italie

      1. pqanielsddwsc
        pqanielsddwsc

        lbcyohprhkmq viagra testimonials viagra shelf life viagra free samples mexican pharmacy for erectile dysfunction and cialis
        viagra online sales
        http://dou46magadan.ru/user/bongomarch4/

    2. KallinikaRok
      KallinikaRok

      is verkaufte aus kanada

      441d at is daily soft tabs

      1. woaniellpjnqf
        woaniellpjnqf

        tmidywlprnpb low cost viagra canadian cialis] viagra pill brand cialis canadain paypal
        does generic viagra work
        http://www.agriverdesa.it/index.php?option=com_k2&view=itemlist&task=user&id=879358

    3. KallinikaRok
      KallinikaRok

      ff97 buy cialis cipla

      http://cialishhqq.com/ - get cialis toronto
      discount cialis

      precios cialis genrico

    4. KallinikaRok
      KallinikaRok

      is rezeptfrei online

      441d is jovene

    5. Kristianascied
      Kristianascied

      comprar is foro

      b5db is tablets prices in pk

      1. rcanielbumrwt
        rcanielbumrwt

        uciqysvvzbyx lowest price viagra viagra overnight viagra and high blood pressure price of cialis in canada
        viagra purchase

    6. Kristianascied
      Kristianascied

      is e cibo

      b5db is levitra is prices

    7. Gordianscied
      Gordianscied

      is tadalafil a at is

      be07 is to be

      1. ixhnry
        ixhnry

        4dnj9ns payday loan alternative
        http://loandayfastgo.com/ - installment loans for bad credit no payday loans
        payday loans in jacksonville fl
        best online payday loans direct lender payday loans oregon

    8. Gordianscied
      Gordianscied

      is 10 precio

      be07 is tadalafil a at is