Last active
November 11, 2016 14:12
-
-
Save packmad/3e9f77d2de62a000e80e0a56e01cf944 to your computer and use it in GitHub Desktop.
Calculate most used but not dangerous Android permissions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
# https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous | |
group_dangerous = { | |
"CALENDAR": {"READ_CALENDAR", "WRITE_CALENDAR"}, | |
"CAMERA": {"CAMERA"}, | |
"CONTACTS": {"READ_CONTACTS", "WRITE_CONTACTS", "GET_ACCOUNTS"}, | |
"LOCATION": {"ACCESS_FINE_LOCATION", "ACCESS_COARSE_LOCATION"}, | |
"MICROPHONE": {"RECORD_AUDIO"}, | |
"PHONE": {"READ_PHONE_STATE", "CALL_PHONE", "READ_CALL_LOG", "WRITE_CALL_LOG", "ADD_VOICEMAIL", "USE_SIP", | |
"PROCESS_OUTGOING_CALLS"}, | |
"SENSORS": {"BODY_SENSORS"}, | |
"SMS": {"SEND_SMS", "RECEIVE_SMS", "READ_SMS", "RECEIVE_WAP_PUSH", "RECEIVE_MMS"}, | |
"STORAGE": {"READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"} | |
} | |
mu_malware = {"INTERNET", "READ_PHONE_STATE", "ACCESS_NETWORK_STATE", "WRITE_EXTERNAL_STORAGE", "SEND_SMS", | |
"ACCESS_WIFI_STATE", "RECEIVE_BOOT_COMPLETED", "ACCESS_COARSE_LOCATION", "RECEIVE_SMS", "WAKE_LOCK", | |
"READ_SMS", "VIBRATE", "ACCESS_FINE_LOCATION", "CHANGE_WIFI_STATE", "READ_CONTACTS"} | |
mu_gplay = {"INTERNET", "ACCESS_NETWORK_STATE", "WRITE_EXTERNAL_STORAGE", "ACCESS_WIFI_STATE", "WAKE_LOCK", | |
"READ_PHONE_STATE", "VIBRATE", "GET_ACCOUNTS", "ACCESS_COARSE_LOCATION", "READ_EXTERNAL_STORAGE", | |
"ACCESS_FINE_LOCATION", "RECEIVE_BOOT_COMPLETED", "CAMERA", "GET_TASKS", "READ_CONTACTS"} | |
mu_aptoide = {"INTERNET", "ACCESS_NETWORK_STATE", "WRITE_EXTERNAL_STORAGE", "WAKE_LOCK", "ACCESS_WIFI_STATE", | |
"READ_PHONE_STATE", "VIBRATE", "RECEIVE_BOOT_COMPLETED", "READ_EXTERNAL_STORAGE", "GET_ACCOUNTS", | |
"ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION", "GET_TASKS", "CAMERA", "READ_CONTACTS"} | |
mu_uptodown = {"INTERNET", "ACCESS_NETWORK_STATE", "WRITE_EXTERNAL_STORAGE", "WAKE_LOCK", "ACCESS_WIFI_STATE", | |
"READ_PHONE_STATE", "VIBRATE", "GET_ACCOUNTS", "READ_EXTERNAL_STORAGE", "ACCESS_COARSE_LOCATION", | |
"RECEIVE_BOOT_COMPLETED", "ACCESS_FINE_LOCATION", "CAMERA", "GET_TASKS", "READ_CONTACTS"} | |
mu = set().union(mu_malware).union(mu_gplay).union(mu_aptoide).union(mu_uptodown) | |
dangerous = {item for sub in list(itertools.chain(group_dangerous.values())) for item in sub} | |
mu_dangerous = mu.intersection(dangerous) | |
mu_not_dangerous = mu-dangerous | |
dangerous_not_mu = dangerous-mu | |
print("Most used: " + str(mu)) | |
print("Dangerous: " + str(dangerous)) | |
print("Most used and dangerous: " + str(mu_dangerous)) | |
print("Dangerous not most used: " + str(dangerous_not_mu)) | |
print("Most used not dangerous: " + str(mu_not_dangerous)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.