Android Xposed开发技巧
Xposed,大名鼎鼎得Xposed,是Android平台上最负盛名的一个框架。在这个框架下,我们可以加载很多插件App,这些插件App可以直接或间接操纵系统层面的东西,比如操纵一些本来只对系统厂商才open的功能(实际上是因为Android系统很多API是不公开的,而第三方APP又没有权限)。有了Xposed后,理论上我们的插件APP可以hook到系统任意一个Java进程(zygote,systemserver,systemui好不啦!)。
- 静态field变量
静态field变量sMoney的值的修改和获取,可以直接使用xposed提供的XposedHelpers类相关功能函数。具体操作可以类比以下示例代码片段:
Class clazz =XposedHelpers.findClass("com.example.inner_class_demo.demo",lpparam.classLoader);
XposedHelpers.setStaticObjectField(clazz,"sMoney",110);
Field sMoney = clazz.getDeclaredField("sMoney");
sMoney.setAccessible(true);
System.out.println(sMoney.get(null));
- 隐藏函数hidden_fun
主动调用隐藏函数hidden_fun(这一类函数是指触发条件比较苛刻的函数,但是我们又需要了解它的输入、输出的大致关系),需要通过clazz来新建实例,最后将此实例与函数名组装成XposedHelpers.callMethod()的实参需求形式。具体操作可以类比以下示例代码片段:
Class clazz =XposedHelpers.findClass("com.example.inner_class_demo.demo",lpparam.classLoader);
XposedHelpers.callMethod(constructor.newInstance(),"hidden_fun");
以上代码仅适用于存在无参构造函数的类,如果目标类没有无参构造函数,那就麻烦一点了,需要根据构造函数参数类型,反射寻找构造函数,接着才能类似上述操作。具体操作可以类比以下示例代码片段:
假设此时的构造函数仅有以下函数,即public demo(){}不存在的情形:
public demo(String str){...}
Class clazz =XposedHelpers.findClass("com.example.inner_class_demo.demo",lpparam.classLoader);
Constructor constructor = clazz.getConstructor(String.class);
XposedHelpers.callMethod(constructor.newInstance("..."),"hidden_fun");
- 内部类inner_class
内部类inner_class作为Android编程过程常见的一种编程方式,这里为了demo的全面,也将其列出。其实内部类整个处理过程与普通类极其相似,具体操作可以类比以下示例代码片段:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
XposedHelpers.findAndHookMethod("com.example.inner_class_demo.demo$inner_class",lpparam.classLoader,
"secret", String.class, boolean.class, new XC_MethodHook() {
protectedvoid beforeHookedMethod(MethodHookParam param) throws Throwable {
for (int i = 0; i < param.args.length; i++) {
XposedBridge.log(" argument is:" + param.args[i]);
}
int field_result = (int)XposedHelpers.getObjectField(param.thisObject,"pMoney");
XposedBridge.log(String.valueOf(field_result));
}
});
|
需要注意的是,这里打印目标函数参数列表的时候,用了XposedBridge.log()。这样的输出方式对日志的长度有限制,即长度不超过1024。特殊场合(比如:文件读取时,需要查看文件的内容)需要注意处理下,不然会出现截断的现象。
- 匿名内部类$inner
同内部类,一般是class_name$1之类,具体可以反编译目标程序查看下。常见的反编译工具,比如:apktool、jeb、baksmali均可以方便达到目的。
- 构造函数
构造函数demo()的处理,可以使用xposed提供的XposedHelpers类,具体操作可以类比以下示例代码片段:
Class clazz =XposedHelpers.findClass("com.example.inner_class_demo.demo",lpparam.classLoader);
XposedHelpers.findAndHookConstructor(clazz, new XC_MethodHook() {
...
});
需要注意的是,由于构造函数不同于普通函数,函数名不需要提供(因为与类名相同,xposed框架处理函数名问题)。
- 同时监控多函数
如果遇到某一类函数需要“批量”hook操作的时候,比如:需要同时监控多个构造函数、多个重载函数,我们此时不可能去挨个hook每个具体目标,那么应该怎么操作呢?我们可以这样来实现:
1
2
3
4
5
6
7
8
9
10
11
12
|
hookAllConstructors(clazz, new XC_MethodHook() {
...
});
hookAllMethods(clazz, new XC_MethodHook() {
...
});
|
hook重载函数时候,只需要忽略参数的具体类型即可。这种方式其实可以达到两种效果:1. 高效的处理函数重载问题 2.目标函数参数类型太复杂,自定义的类型太多。忽略参数类型,可以简化我们的hook工作。
- 替换方法
只要改变一下回调方式就行了,原来是用XC_MethodHook()回调函数,实现在调用方法前和方法后执行hook代码,而只要把这个回调函数变成XC_MethodReplacement()回调函数,就可以实现直接替换原方法的目的,那么只要在这个回调函数里不加任何代码,就可以实现调用原方法,而不执行其代码的目的。
attachBaseContext.classloader hook
- Multidex勾住技术
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
findAndHookMethod(Application.class, "attach", Context.class, newXC_MethodHook() {
@Override
protectedvoid afterHookedMethod(MethodHookParam param) throws Throwable {
// place your hooks here, it should work with lpparam.classLoader
findAndHookMethod(class, lpparam.classLoader, method, arg1, arg2, …new XC_MethodHook() {
@Override
protectedvoid beforeHookedMethod(MethodHookParam param)throws Throwable {
// this will be called before the clock was updated by
// the original method
Log.d("xposed", "劫持开始了~");
}
@Override
protectedvoid afterHookedMethod(MethodHookParam param)throws Throwable {
// this will be called after the clock was updated by
// the original method
}
});
}
});
|
- 加固APP的勾住
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
if (lpparam.packageName.equals("com.XX.XXbank")) {
XposedBridge.log("定位到hook程序");
XposedHelpers.findAndHookMethod("com.secneo.apkwrapper.ApplicationWrapper", lpparam.classLoader,
"attachBaseContext", Context.class, new XC_MethodHook() {
@Override
protectedvoid afterHookedMethod(MethodHookParam param) throwsThrowable {
// TODO Auto-generated method stub
super.afterHookedMethod(param);
Context Ctx = (Context) param.args[0];
ClassLoader Clz = Ctx.getClassLoader();
XposedHelpers.findAndHookMethod("com.iss.sdpersonalbank.util.Log", Clz, "d", String.class,
String.class, new XC_MethodHook() {
@Override
protectedvoid beforeHookedMethod(MethodHookParam param) throws Throwable {
// TODO Auto-generated method stub
super.afterHookedMethod(param);
String Str1 = (String) param.args[0];
String Str2 = (String) param.args[1];
Log.e(TAG, Str1 + ":" + Str2);
}
});
|
转载自网络
BennyTunty
wh0cd2454432 visit this link
Kennethcluts
wh0cd1003644 hctz no prescription sildenafil citrate tablets ip 100 mg arimidex
BrettApept
wh0cd1003644 alli tablets
BennyTunty
wh0cd1487240 prednisone buy toradol generic antabuse
Charlesdog
wh0cd1003644 lotrisone erythromycin online buy tadalafil online erythromycin atarax finasteride dutasteride can you buy viagra online legally inderal cialis cost vantin acyclovir seroquel for anxiety and depression stromectol more helpful hints
Kennethcluts
wh0cd1970836 for more info
Michaeljep
wh0cd2938028 zithromay cleocin hcl tadalis sx without prescription Tetracycline Sildenafil Zetia Cost buy serpina torsemide cleocin hcl 150 mg clomid 100mg 800 mg motrin tadalis
AaronSwire
wh0cd1970836 skelaxin ventolin inhaler 40 mg lisinopril 25 Mg Viagra Tretinoin
Charlesdog
wh0cd2938028 glucotrol xl 5mg generic cafergot tadalis sx generic estrace cream amitriptyline
Alfredoxilt
wh0cd2454432 discount viagra online citalopram 20mg buy cheap nolvadex generic for toradol
Michaeljep
wh0cd2454432 alli prescription singulair straterra order clomid alli Singulair
Michaeljep
wh0cd2454432 singulair for bronchitis 5mg citalopram Cleocin clomid medication crestor
BennyTunty
wh0cd1970836 where to buy cialis
BrettApept
wh0cd520048 Orlistat Alli Tetracycline celebrex generic torsemide alli pill
Kennethcluts
wh0cd1487240 cost cymbalta albuterol buy anafranil generic viagra metformin hydrochloride 500 mg
Michaeljep
wh0cd1003644 serpina ZETIA cleocin t tadalis sx sildenafil crestor serpina online tadalis sx advair for asthma Tetracycline Hydrochloride
Kennethcluts
wh0cd520048 toradol generic
BennyTunty
wh0cd1003644 website here
AaronSwire
wh0cd1487240 tamoxifen tricor Obagi Tretinoin Cream .05 gynecomastia nolvadex generic cialis 10mg
Charlesdog
wh0cd520048 clomid adalat online amitriptyline clindamycin 150mg read this generic nexium toradol toprol xl viagra doxycycline cipro online wellbutrin generic
Michaeljep
wh0cd2454432 cleocin t gel vpxl advair diskus online Alli Orlistat Capsules cleocin t gel GENERIC FOR ZETIA crestor rosuvastatin
Charlesdog
wh0cd2454432 colchicine triamterene hydrochlorothiazide generic crestor cymbalta
Alfredoxilt
wh0cd1970836 toradol viagra for women pink pill amlodipine hydrochlorothiazide
BennyTunty
wh0cd1487240 toradol online
Michaeljep
wh0cd1970836 Celexa Buy Serpina Cleocin clomid alli sale Cleocin tadalis full article crestor citalopram for hot flashes tetracycline pill generic tadalis celebrex 200 generic torsemide
Michaeljep
wh0cd1970836 tadalis sx cleocin vaginal suppository PREDNISOLONE 5 MG vpxl online singulair 10mg price Serpina Without Prescription cleocin gel for acne
Kennethcluts
wh0cd1003644 cephalexin wellbutrin
BrettApept
wh0cd36452 tadalis cleocin gel for acne
Kennethcluts
wh0cd36452 anafranil for anxiety sildenafil
Alfredoxilt
wh0cd2454432 proscar
Michaeljep
wh0cd520048 go here Serpina TADALIS SX motrin cost how much is strattera Citalopram tetracycline generic brand for singulair where can you buy zithromax generic tadalis
Charlesdog
wh0cd2938028 metformin clonidine vantin fluoxetine
AaronSwire
wh0cd1003644 prednisolone sodium aldactone paroxetine
BennyTunty
wh0cd520048 phenergan on line price of levitra
Charlesdog
wh0cd1970836 azithromycin 500 mg tablets
Charlesdog
wh0cd36452 elocon methylprednisolone as an example buy stromectol generic viagra mastercard valtrex tadalafil 20 mg propranolol losartan hydrochlorothiazide
Michaeljep
wh0cd1970836 celexa 40mg torsemide 10 mg tadalis sx cheap alli pills prednisolone buy online motrin 800 advair Zithromax generic motrin serpina without prescription paxil drug Tetracycline Zetia tadalis sx
Alfredoxilt
wh0cd1487240 valtrex buy sildenafil bentyl price where to buy keflex without prescription bentyl
BennyTunty
wh0cd1003644 silagra without prescription click nolvadex
Michaeljep
wh0cd1487240 Generic Brand For Singulair alli singulair headache tetracycline for acne cleocin t gel Prednisolone 5 Mg zithromax Celebrex clomid tablets cleocin antibiotic tadalis VPXL
Kennethcluts
wh0cd520048 sildenafil
Michaeljep
wh0cd1487240 strattera MOTRIN sildenafil crestor medication cleocin generic SINGULAIR 4MG Tadalis cleocin antibiotics generic tadalis alli diet pill recommended site cost of alli tetracycline generic for buspar
BrettApept
wh0cd2938028 paxil 10mg as explained here Celebrex Medication buy tetracycline online without prescription
Kennethcluts
wh0cd2938028 elimite online
AaronSwire
wh0cd2454432 explained here tadalafil methotrexate 2.5mg tablets
Charlesdog
wh0cd36452 aldactone over the counter click this link ANTABUSE 250 MG
Kennethcluts
wh0cd1487240 Viagra nolvadex Buy Paroxetine skelaxin cost Kamagra Gold
Michaeljep
wh0cd520048 accutane Prednisolone Medicine recommended site xenical ventolin zovirax 5 how can i get valtrex albenza Aldactone cialis professional 20 mg tadalafil BUY VIAGRA ONLINE WITH MASTERCARD
Kennethcluts
wh0cd2454432 ALDACTONE tamoxifen pills Lisinopril 40 Mg Tablets
Michaeljep
wh0cd1970836 GENERIC CLOZARIL Antabuse 250 Mg prednisolone sildenafil citrate tablets 100 mg mobic 7.5 mg tablets clozaril found here Prednisolone xenical paroxetine Dapoxetine ventolin with out prescription buy cialis online safely
Michaeljep
wh0cd1487240 albenza helpful hints how can i get valtrex cost of pyridium amantadine brand name Mobic Tablets KAMAGRA sildenafil citrate cephalexin furosemide medication
BrettApept
wh0cd1487240 cephalexin Paroxetine buy viagra online with mastercard skelaxin for menstrual cramps orlistat
Charlesdog
wh0cd520048 antabuse nolvadex dapoxetine usa albuterol sulfate
Michaeljep
wh0cd1003644 AMANTADINE FOR CONCUSSION Antabuse Generic Cialis viagra 25mg online vasotec tricor weight loss non prescription tretinoin antabuse 500mg xenical diet pills Tadalafil Best Price clozaril clozapine buy orlistat 120 mg
AaronSwire
wh0cd2454432 Sildenafil Citrate Tablets Ip 100 Mg
Charlesdog
wh0cd36452 25 mg viagra mobic medication keflex 500 more bonuses albuterol sulfate VALTREX amantadine for concussion prednisolone medicine Tricor keflex online Furosemide Over The Counter kamagra sildenafil citrate 100mg Pyridium
BennyTunty
wh0cd2938028 skelaxin 800 mg price
Alfredoxilt
wh0cd36452 tricor 160 mg resource cheap viagra overnight delivery skelaxin
BennyTunty
wh0cd1970836 skelaxin for fibromyalgia dapoxetine
Kennethcluts
wh0cd1003644 found here pyridium Cephalexin
Alfredoxilt
wh0cd36452 lisinopril kamagra online pharmacy Dapoxetine For Sale TRETINOIN CREAM 0.1
Michaeljep
wh0cd36452 prednisolone sod price of ventolin inhaler how can i get valtrex 25 mg viagra zanaflex for anxiety prednisolone ACCUTANE tretinoin gel 1 vasotec pyridium
Kennethcluts
wh0cd1970836 antabuse over the counter amantadine keflex medication prednisolone
BrettApept
wh0cd1003644 buy amantadine dapoxetine buy Generic Cialis
Charlesdog
wh0cd36452 Prednisolone Sod Lisinopril dapoxetine hydrochloride
Michaeljep
wh0cd1487240 paroxetine buy cialis pyridium for kidney stones keflex 500 tricor 145 generic mobic nolvadex tablets sildenafil over counter Tretinoin Cream how much is retin a Viagra 25mg mobic tadalafil 5 mg
Michaeljep
wh0cd1003644 tretinoin Tadalafil 5 Mg mobic click here keflex drug zanaflex
AaronSwire
wh0cd1970836 amantadine for brain injury VENTOLIN tadalafil tadalafil
AaronSwire
wh0cd1487240 tricor paroxetine hcl 40mg Albuterol Sulfate ALBENZA 200 MG skelaxin for menstrual cramps
AaronSwire
wh0cd1003644 tadalafil 5 mg Tadalafil Tablets 20 Mg mobic 7.5 mg cialis professional online
AaronSwire
wh0cd520048 pyridium ORLISTAT
AaronSwire
wh0cd36452 albenza over the counter tricor statin
AaronSwire
wh0cd2938028 generic paroxetine Cialis Soft 20mg
AaronSwire
wh0cd2454432 Sildenafil over the counter tretinoin Tadalafil Best Price
AaronSwire
wh0cd1970836 amantadine hcl tadalafil canada aciclovir
AaronSwire
wh0cd1487240 DAPOXETINE HCL Pyridium
AaronSwire
wh0cd1003644 aciclovir
AaronSwire
wh0cd520048 generic cialis 200mg Buy Viagra Online Mastercard mobic
AaronSwire
wh0cd36452 xenical tricor herbicide Buy Cialis Online With Mastercard VENTOLIN example
AaronSwire
wh0cd2938028 ventolin cephalexin generic cialis mobic 15mg tab
AaronSwire
wh0cd2454432 orlistat
AaronSwire
wh0cd1970836 acyclovir 800 Xenical 120 Mg For Sale Antabuse ventolin nebules
AaronSwire
wh0cd1487240 buy cialis online safely
AaronSwire
wh0cd1003644 tadalafil dapoxetine hcl
AaronSwire
wh0cd520048 Antabuse
AaronSwire
wh0cd36452 buy viagra online with mastercard amantadine for adhd Albenza 200mg 20 mg tadalafil Pyridium
AaronSwire
wh0cd2938028 ventolin discount
AaronSwire
wh0cd2454432 nolvadex
AaronSwire
wh0cd1970836 cheap viagra overnight delivery ANTABUSE 250 MG sildenafil retin a 0.05
AaronSwire
wh0cd1487240 tricor sildenafil 50
AaronSwire
wh0cd520048 Paroxetine Cr 12.5mg generic cialis soft tabs 20mg Viagra 100 discover more 25 Mg Viagra
AaronSwire
wh0cd36452 dapoxetine 60mg view over the counter tretinoin aldactone
AaronSwire
wh0cd2938028 Clozaril
AaronSwire
wh0cd2454432 antabuse tablets generic zanaflex prednisolone 20mg Tricor TRETINOIN CREAM
AaronSwire
wh0cd1970836 antabuse 500mg tretinoin online keflex medication click this link tretinoin
AaronSwire
wh0cd1487240 25 mg viagra clozaril clozapine valtrex
AaronSwire
wh0cd1003644 buy cialis Ventolin Inhaler clozaril clozapine tadalafil vasotec 2.5mg
AaronSwire
wh0cd520048 clozaril tadalafil GENERIC FOR TRICOR skelaxin cialis professional online
AaronSwire
wh0cd36452 mobic 15 mg tablets mobic 7.5 tablets
AaronSwire
wh0cd2938028 nolvadex for men Clozaril orlistat nolvadex tamoxifen buy dapoxetine usa
AaronSwire
wh0cd2454432 Sildenafil Citrate Orlistat clozaril obagi tretinoin cream .05 Antabuse
AaronSwire
wh0cd1970836 get more info xenical pyridium skelaxin muscle relaxer aciclovir
AaronSwire
wh0cd1487240 aldactone 100 mg 20 mg tadalafil where can i get cialis over the counter Sildenafil Citrate 100mg tricor
AaronSwire
wh0cd1003644 buy viagra online with mastercard Pyridium
AaronSwire
wh0cd520048 proscar 5 mg provera hydrochlorothiazide buspar
AaronSwire
wh0cd36452 effexor yasmin
AaronSwire
wh0cd2938028 sterapred buy cytotec pills z pack azithromycin
AaronSwire
wh0cd2454432 buy proscar online viagra ciprofloxacin 500mg cymbalta capsules triamterene
AaronSwire
wh0cd1970836 erythromycin cream
AaronSwire
wh0cd1487240 crestor cephalexin 500 buy phenergan online lisinopril pills
AaronSwire
wh0cd1003644 buy prednisone biaxin augmentin generic crestor buy indocin
AaronSwire
wh0cd520048 buy cialis order sertraline online ventolin inhaler non prescriptio effexor buy retin-a
AaronSwire
wh0cd36452 nexium
AaronSwire
wh0cd2938028 prednisone anafranil buy wellbutrin site
AaronSwire
wh0cd2454432 cheap advair crestor generic motilium suspension citalopram propecia
AaronSwire
wh0cd1970836 cipro 500mg dosage
AaronSwire
wh0cd1487240 albuterol for nebulizer keflex penicillin where to buy doxycycline online ciprofloxacin hcl 500 mg
AaronSwire
wh0cd1003644 citation buy diflucan viagra
AaronSwire
wh0cd520048 buy baclofen ciprofloxacin 500mg antibiotics buy elocon cream doxycycline buy methotrexate
AaronSwire
wh0cd36452 effexor lisinopril
AaronSwire
wh0cd2938028 plavix for sale neurontin adalat
AaronSwire
wh0cd2454432 paxil more information elimite generic vpxl
AaronSwire
wh0cd1970836 seroquel seroquel
AaronSwire
wh0cd1487240 elimite