script.py
2.2 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import file_utils
import os
import os.path
from xml.etree import ElementTree as ET
from xml.etree.ElementTree import SubElement
from xml.etree.ElementTree import Element
from xml.etree.ElementTree import ElementTree
import os
import os.path
import zipfile
import re
import subprocess
import platform
from xml.dom import minidom
import codecs
import sys
androidNS = 'http://schemas.android.com/apk/res/android'
def execute(channel, pluginInfo, decompileDir, packageName):
manifestFile = decompileDir + "/AndroidManifest.xml"
manifestFile = file_utils.getFullPath(manifestFile)
ET.register_namespace('android', androidNS)
key = '{' + androidNS + '}launchMode'
tree = ET.parse(manifestFile)
root = tree.getroot()
package = root.attrib.get('package')
applicationNode = root.find('application')
if applicationNode is None:
return 1
key = '{'+androidNS+'}name'
receiverNodeList = applicationNode.findall('receiver')
if receiverNodeList != None:
for node in receiverNodeList:
if node.attrib[key] == 'com.umeng.message.RegistrationReceiver':
intentNodeLst = node.findall('intent-filter')
if intentNodeLst is None:
break
for intentNode in intentNodeLst:
actionNodeList = intentNode.findall('action')
if actionNodeList is None:
break
for actionNode in actionNodeList:
if actionNode.attrib[key].endswith('intent.action.COMMAND'):
newVal = package + ".intent.action.COMMAND";
actionNode.set(key, newVal)
serviceNodeList = applicationNode.findall('service')
if serviceNodeList != None:
for node in serviceNodeList:
if node.attrib[key] == 'com.umeng.message.UmengService':
intentNodeLst = node.findall('intent-filter')
if intentNodeLst is None:
break
for intentNode in intentNodeLst:
actionNodeList = intentNode.findall('action')
if actionNodeList is None:
break
for actionNode in actionNodeList:
if actionNode.attrib[key].endswith('intent.action.START'):
newVal = package + '.intent.action.START'
actionNode.set(key, newVal)
if actionNode.attrib[key].endswith('intent.action.COCKROACH'):
newVal = package + '.intent.action.COCKROACH'
actionNode.set(key, newVal)
tree.write(manifestFile, 'UTF-8')
return 0