-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintentPermissionParse.py
76 lines (52 loc) · 1.9 KB
/
intentPermissionParse.py
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
#!/usr/bin/env python
# coding=utf-8
import os
intentPermission_dict={}
originPath = "/home/chicho/Psout/PScout/results/jellybean_intentpermissions"
destPath = "/home/chicho/Psout/test.log"
f = open(originPath)
intentdict={}
for line in f.readlines():
intentInfo = line.split(" ")[0]
permission = line.split()[1]
valueList=[]
if intentInfo not in intentdict:
valueList.append(permission)
valueList.append(1)
intentdict[intentInfo]=valueList
else:
tmpValueList=intentdict[intentInfo]
tmpValueList[1]+=1
intentdict[intentInfo]=tmpValueList
cmd = '''grep -e {0} {1} >> intentPerMappingResult'''.format(intentInfo,destPath)
os.system(cmd)
print "The processing is running..."
f.close()
path = os.path.dirname(destPath)
intentFilePath = os.path.join(path,"intentPerMappingResult")
intentList=[]
newIntentDict={}
if os.path.exists(intentFilePath):
fint = open(intentFilePath)
for line in fint.readlines():
valueList=[]
intentInfo = line.split(":")[1].split(")")[0]
intentPermission = intentdict[intentInfo][0]
if intentInfo not in newIntentDict:
valueList.append(intentPermission)
valueList.append(1)
newIntentDict[intentInfo]=valueList
else:
tmpValueList = newIntentDict[intentInfo]
tmpValueList[1] += 1
newIntentDict[intentInfo]=tmpValueList
# intentList.append(intentInfo)
# uniqueIntent = set(intentList)
#for intent in uniqueIntent:
# if intent in intentdict:
# cmd = '''echo {0} {1} >> countIntentPermission'''.format(intent,intentdict[intent])
# os.system(cmd)
for intent in newIntentDict:
cmd = '''echo {0}, {1}, {2} >> countIntentPermission'''.format(intent,newIntentDict[intent][0],newIntentDict[intent][1])
os.system(cmd)
print "The Work is done!"