本文转载自: https://www.zybuluo.com/oro-oro/note/145250

JebInstance可以通过getUI()方法来获得jeb.api.ui.JebUI

JebUI 下面有很多View,如AssemblyView, JavaView等等。

JebUI可以通过getView(View.Type viewtype)方法获得对应的View。 
具体类型在jeb.api.ui.View.Type中:

类型 说明
ASSEMBLY 反汇编界面
CLASS_HIERARCHY 类层级界面(左)
CONSOLE 控制台(下)
JAVA Java代码界面
MANIFEST 清单界面
NOTES 全局评论界面

在第3章解密的基础上,让JavaView界面自动刷新,显示解密字符串:

import jeb.api.IScript;
import jeb.api.JebInstance;
import jeb.api.ast.*;
import jeb.api.dex.Dex;
import jeb.api.dex.DexMethod;
import jeb.api.ui.JavaView;
import jeb.api.ui.JebUI;
import jeb.api.ui.View;
import java.util.ArrayList;
import java.util.List;
public class TestASTDecode implements IScript {
    public static final byte[] bytes = new byte[]{'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'};
    @Override
    public void run(JebInstance jebInstance) {
        JebUI ui = jebInstance.getUI();
        JavaView javaView = (JavaView) ui.getView(View.Type.JAVA);
        Dex dex = jebInstance.getDex();
        List<String> classSignatures = dex.getClassSignatures(true);
        Constant.Builder cstBuilder = new Constant.Builder(jebInstance);
        // 获得decode方法的sig
        int methodCount = dex.getMethodCount();
        String decodeMtdSig;
        for (int i = 0; i < methodCount; i++) {
            DexMethod dexMethod = dex.getMethod(i);
            int index = dexMethod.getIndex();
            decodeMtdSig = dex.getMethod(i).getSignature(true);
            if (decodeMtdSig.contains("Lcom/test/helloworld/MainActivity;->decode")) {
                // 找出所有使用了该方法的地方
                List<Integer> methodReferences = dex.getMethodReferences(index);
                for (Integer refIdx : methodReferences) {
                    DexMethod refDexMethod = dex.getMethod(refIdx);
                    // 找到AST中对应的Method
                    Method decompiledMethodTree = jebInstance.getDecompiledMethodTree(refDexMethod.getSignature(true));
                    // 拿到语句块,遍历所有语句
                    Block block = decompiledMethodTree.getBody();
                    int size = block.size();
                    for (int j = 0; j < size; j++) {
                        Statement statement = block.get(j);
                        jebInstance.print(statement.toString());
                        if (statement instanceof Call) {
                            Call call = (Call) statement;
                            Method method = call.getMethod();
                            jebInstance.print("Call : " + method.getSignature());
                            List<IElement> subElements = call.getSubElements();
                            for (IElement element : subElements) {
                                jebInstance.print("Sub Element : " + element.toString());
                                if (element instanceof Call) {
                                    Call c = (Call) element;
                                    Method m = c.getMethod();
                                    if (m.getSignature().equals(decodeMtdSig)) {
                                        jebInstance.print(">>> " + decodeMtdSig);
                                        List<IExpression> arguments = c.getArguments();
                                        ArrayList<Integer> arrayList = new ArrayList<Integer>();
                                        for (IExpression expression : arguments) {
                                            if (expression instanceof Constant) {
                                                arrayList.add(((Constant) expression).getInt());
                                            }
                                        }
                                        String str = decode(arrayList.get(0), arrayList.get(1));
                                        jebInstance.print("解密后的字符串 : " + str);
                                        // 将当前语句Call的子元素,替换为解密后的字符串
                                        call.replaceSubElement(element, cstBuilder.buildString(str));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        javaView.refresh();
    }
    String decode(int a, int b) {
        byte[] ab = new byte[]{bytes[a], bytes[b]};
        return new String(ab);
    }
}

[转载] 4. JebAPI 之 jeb.api.ui的更多相关文章

  1. [转载] 3. JebAPI 之 jeb.api.ast

    本文转载自: https://www.zybuluo.com/oro-oro/note/143651 0. 序 Jeb 本身是支持变量重命名的,所以,混淆了的变量名.类名可以修改. 实际上,它还可以做 ...

  2. [转载] 1. JebAPI 之 jeb.api

    本文转载自: https://www.zybuluo.com/oro-oro/note/142707 JEB API 官方地址:https://www.pnfsoftware.com/apidoc/  ...

  3. [转载] 2. JebAPI 之 jeb.api.dex

    本文转载自: https://www.zybuluo.com/oro-oro/note/142842 1. jeb.api.dex.Dex 这个类代表正在被JEB处理的DEX文件. 要想更好的了解这个 ...

  4. [转载] ZooKeeper的Java客户端API

    转载自 http://www.cnblogs.com/ggjucheng/p/3370359.html http://zookeeper.apache.org/doc/trunk/javaExampl ...

  5. [转载]Java 8 日期&时间 API

    Java 8 日期和时间 声明 本文转自http://www.journaldev.com/2800/java-8-date-localdate-localdatetime-instant,以mark ...

  6. 转载:21个免费的UI界面设计工具、资源及网站

    我们刚刚介绍了移动设计初探:触屏网页设计.本文将介绍一些UI界面与设计使用的元素.软件和网站.内容很丰富,适合用户体验设计师.界面设计师.产品设计师.JS前段开发.手机产品设计以及iPad和平板电脑产 ...

  7. (转载) ASP.NET(C#) Web Api 通过文件流下载文件到本地实例

    下载文件到本地是很多项目开发中需要实现的一个很简单的功能.说简单,是从具体的代码实现上来说的,.NET的文件下载方式有很多种,本示例给大家介绍的是ASP.NET Web Api方式返回HttpResp ...

  8. (转载)基于Unity~UGUI的简单UI框架(附UIFramework源码)

    此博客跟随siki老师的课程笔记生成,感谢siki老师的辛勤付出! 此框架功能较简单,适用于学习,可以很好的锻炼我们的设计思想 框架源码地址: UIFramework litjson.dll下载地址: ...

  9. (转载)Unity UGUI鼠标点击UI不受影响方法IsPointerOverGameObject

    这几天在做捕鱼达人游戏时发现,当鼠标点击UI时,炮台的子弹也会发射子弹,这样会影响用户体验. 然后网上百度了一波,发现在UGUI系统上,EventSystem提供了一些方法.那就是EventSyste ...

随机推荐

  1. Redis 初

    tcl8.6.1 $wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz $tar xzvf tcl8.6.1-src.tar.g ...

  2. 如何有效的使用C#读取文件

    如何有效的使用C#读取文件  你平时是怎么读取文件的?使用流读取.是的没错,C#给我们提供了非常强大的类库(又一次吹捧了.NET一番),里面封装了几乎所有我们可以想到的和我们没有想到的类,流是读取文件 ...

  3. Difference between applicationContext.xml and spring-servlet.xml in Spring Framework

    Question: Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will ...

  4. 大型博彩公司招聘 .net,DB,tester,android

    大型博彩公司招聘 .net,DB,tester,android,ios等. 等拿完年终奖的朋友,可以先发简历给我,先面试,年后上班. emai:sjchen1203@126.com 要求: 1. 全职 ...

  5. OAF_文件系列2_实现OAF导出CSV格式文件ExportButton(案例)

    20150727 Created By BaoXinjian

  6. 在Linux中永久设置Anaconda环境变量的方法

    [感谢:http://www.codesec.net/view/459539.html] 如果在安装Anaconda的过程中没有将安装路径添加到系统环境变量中,需要在安装后手工添加: 1.在终端输入$ ...

  7. WPF绑定数据源

    using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Comp ...

  8. 34. Convert Sorted List to Binary Search Tree && Convert Sorted Array to Binary Search Tree

    Convert Sorted List to Binary Search Tree OJ: https://oj.leetcode.com/problems/convert-sorted-list-t ...

  9. VPS及LNMP(一)

    1.试用了搬瓦工.interserver.天翼云.网安互联之后,分别写下感受: 前两个是美国服务器,天翼云是国内服务器,网安互联是香港主机. a.搬瓦工非常便宜,512M的1年9.99刀,但是用了之后 ...

  10. CultureInfo 类

    https://msdn.microsoft.com/zh-cn/library/system.globalization.cultureinfo(VS.80).aspx 区域性名称 区域性标识符 语 ...