android java虚拟机拦截技术,[原创]Android Java虚拟机拦截技术分析

2013-10-16 17:34

Mark: "original" Android Java virtual machine to intercept technical analysis

Author: cockroaches. 1

Time: 2013-10-10, 21:44:03

Recent decompiled jinshan drug gangsters, analyze its advertising is how to implement interception function. According to the introduction of jinshan drug gangsters, USES the Java virtual machine to intercept technology, with a curious to study. In the process of check code, will see many hook Java classes, such as ActivityThread, ServiceManager, etc. In the compilation of source code, I mainly tracked about iphonesubinfo intercept service implementation. And test pass through the code and share achievements.

1. The Java virtual machine to intercept technology overall process.

1) first by ptrace injection so to the remote process, for example, jinshan is injected libksrootclient. So to the remote process.

2) in remote process call through ptrace_call libksrootclient in a static method, the method is mainly finished loading encapsulate Java function class jars, and call the class method in jars, finish the hook Java layer in the process of work. As in the loading of the jinshan drug gangsters jars: ksremote jar

2. The key technology

1) so injection

So the first step to intercept injection Java virtual machine technology, injection or not determines the success at the back of the interception function.

2) implement interception Java API function module, and export the jar package.

Such as mobile phone IMEI/reading if you want to monitor whether ismi, phone number and sim card number. Through source code analysis, access to the information need of TelephonyManager class related method, method of main is by getting iphonesubinfo service class provides functions. So if intercepted by iphonesubinfo service function, can successfully get application whether read equipment information.

In Java layer, access to services is by ServiceManager getService method of obtaining, analyzing getService method, this method will first query whether there is any service from sCache, if there is a service that is returned directly. Therefore, if the alteration of sCache iphonesubinfo ibinder references, can realize interception function.

3) through JNI in injection so dynamic loading jars, and implement the key classes of jars, complete Hook Java layer.

JNI dynamic loading jars principle can view the posts "Android JNI calling jar package".

About android intercept technology in summary:

1. The android API interceptor technology has two modes, one is to intercept C layer API, another kind is to intercept the Java layer API.

2. C layer intercept API

In C layer intercepts API interception is the most common research way libbinder. So the ioctl call. In binder communication, user space and kernel space need the ioctl system call, if the system calls, then the argument parsing, can achieve the function of lbe active defense. The premise is must be very familiar with binder mechanism and binder data transmission formats.

3. The Java virtual machine to intercept technology (Java layer intercept)

Java layer intercepts the need to realize the key method of interception, the way of intercepting the parameters on a large scale does not need to parse.

For example, I in the process of implement interception read imei, simply by intercepting directly returns false, where the Java API application access the imei become null.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值