-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathandroid 15 and up swd and awk permission.txt
132 lines (93 loc) · 5.53 KB
/
android 15 and up swd and awk permission.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
added permissions
sed -i -E 's/(ca.zgrs.clipper">)(.*)/\1<permission name="android.permission.READ_CLIPBOARD_IN_BACKGROUND" granted="true" flags="0" \/>\2/' /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
chmod 400 /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
chattr +i /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
pkill system_server
or reboot and after the reboot
sed -i -E 's/(ca.zgrs.clipper">)(.*)/\1<permission name="android.permission.READ_CLIPBOARD_IN_BACKGROUND" granted="true" flags="0" \/>\2/' /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml.new
chmod 400 /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml.new
chattr +i /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml.new
chattr -i /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
chmod 600 /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
pkg="ca.zgrs.clipper"
permission="android.permission.READ_CLIPBOARD_IN_BACKGROUND"
sed -i -E "s/(${pkg}\">)(.*)/\1<permission name=\"${permission}\" granted=\"true\" flags=\"0\" \/\>\2/" /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
pkg="com.termux"
permission="android.permission.INTERNET"
permission_status="revoke" # Set to "grant" or "revoke"
# Use sed with variables
if [ "$permission_status" == "grant" ]; then
sed -i -E "s/(${pkg}\">)(.*)/\1<permission name=\"${permission}\" granted=\"true\" flags=\"0\" \/\>\2/" /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
elif [ "$permission_status" == "revoke" ]; then
sed -i -E "s/(${pkg}\">)(.*)/\1<permission name=\"${permission}\" granted=\"false\" flags=\"0\" \/\>\2/" /data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
fi
revoke permissions
cd /data/misc_de/0/apexdata/com.android.permission/
awk -v RS="" -v ORS="" '{
content = $0
pos1 = index(content, "ca.zgrs.clipper")
if (pos1) {
substr_content = substr(content, pos1 + length("ca.zgrs.clipper"))
match(substr_content, /android\.permission\.READ_EXTERNAL_STORAGE"[[:space:]]*granted="true"/)
if (RSTART > 0) {
pos2 = pos1 + length("ca.zgrs.clipper") + RSTART - 1
new_content = substr(content, 1, pos2 - 1) \
"android.permission.READ_EXTERNAL_STORAGE\" granted=\"false\"" \
substr(content, pos2 + length("android.permission.READ_EXTERNAL_STORAGE\" granted=\"true\""))
print new_content > "runtime-permissions.xml.new"
}
}
}' runtime-permissions.xml
cp runtime-permissions.xml.new runtime-permissions.xml
cd /data/misc_de/0/apexdata/com.android.permission/
pkg="com.opera.mini.native"
permission="android.permission.INTERNET"
permission_status="revoke" # Set to "grant" or "revoke"
awk -v RS="" -v ORS="" -v pkg="$pkg" -v permission="$permission" -v status="$permission_status" '{
content = $0
pos1 = index(content, pkg)
if (pos1) {
substr_content = substr(content, pos1)
match_str = (status == "grant") ? "<permission name=\"" permission "\" granted=\"false\"" : "<permission name=\"" permission "\" granted=\"true\""
if (match(substr_content, match_str)) {
pos2 = RSTART + pos1 - 1
new_permission = (status == "grant") ? "<permission name=\"" permission "\" granted=\"true\" flags=\"0\" />" : "<permission name=\"" permission "\" granted=\"false\" flags=\"0\" />"
new_content = substr(content, 1, pos2 - 1) new_permission substr(content, pos2 + RLENGTH)
print new_content > "runtime-permissions.xml.new"
}
}
}' runtime-permissions.xml
cp runtime-permissions.xml.new runtime-permissions.xml
awk -v RS="" -v ORS="" '{
print "Original content: " $0
content = $0
# Find the first instance of "ca.zgrs.clipper"
pos1 = index(content, "ca.zgrs.clipper")
if (pos1 > 0) {
print "Found ca.zgrs.clipper at position: " pos1
pos1_end = pos1 + length("ca.zgrs.clipper")
substr_content = substr(content, pos1_end)
# Find the first instance of "package" after "ca.zgrs.clipper"
pos_package = index(substr_content, "package")
if (pos_package > 0) {
print "Found package at position: " (pos1_end + pos_package - 1)
substr_content = substr(substr_content, 1, pos_package - 1)
}
# Find the first instance of the target string within the truncated substring
match(substr_content, /android\.permission\.READ_EXTERNAL_STORAGE"[[:space:]]*granted="true"/)
if (RSTART > 0) {
pos2_start = pos1_end + RSTART - 1
pos2_end = pos2_start + RLENGTH - 1
print "Found android.permission.READ_EXTERNAL_STORAGE\" granted=\"true\" at position: " pos2_start "-" pos2_end
new_content = substr(content, 1, pos2_start - 1) \
"android.permission.READ_EXTERNAL_STORAGE\" granted=\"false\"" \
substr(content, pos2_end + 1)
print "Modified content: " new_content
print new_content > "s.xml"
} else {
print "Did not find android.permission.READ_EXTERNAL_STORAGE\" granted=\"true\" after ca.zgrs.clipper and before the first package"
}
} else {
print "Did not find ca.zgrs.clipper"
}
}' runtime-permissions.xml