SystemProperties.get/custom

This hook complements the built-in XPrivacyLua hooks of the same name. Instructions: 1. Download these two hooks: - SystemProperties.get/custom - SystemProperties.get.default/custom 2. Make sure that the Fif collection is enabled in XPL Pro. 3. Configure a property blacklist with XPrivacyLua Pro, under "Custom Values", "Property blacklist (prefixes)". List items are whitespace separated, and will match if they are a prefix of the requested property. For example, if the blacklist is "persist. net", all of persist.usb, persist.key, net.DNS and netif will be blocked. 4. For any app for which you want the hooks to apply: 4.a. Toggle the "Use tracking" category until it's fully enabled (red) in XPL. 4.b. Or, alternately, enable both SystemProperties.get/custom SystemProperties.get.default/custom hook in XPL Pro. Note that the builtin hooks SystemProperties.get/build, /operator, /serial, and /vendor, and their get.default counterparts (8 hooks total) can either complement the /custom hooks, or the /custom hooks can completely replace them. It is recommended to use the builtin SystemProperties.get/operator (and get.default/operator) for masking the operator as the built-in hooks return valid (but fake) operator ids and countries, while the /custom hooks would return completely invalid values. The builtin /build, /serial and /vendor .get and .get.default hooks can safely be replaced with this version, provided that you respectively configure the "Property blacklist (prefixes)" custom values with: - "ro.build." for replacing the builtin /build hooks. - "ro.serialno ro.boot.serialno" for replacing the builtin /serial hooks. - "ro.vendor." for replacing the builtin /vendor hooks. The /custom hooks will generate fake values using this heuristic: - If the original value looks like a number or hexadecimal number, the fake value will be a number of same magnitude (number of digits) but with all zeroes. Eg. 9138474 will become 0000000 and 8d8fe will become 00000. - Otherwise the string "Private" will be returned. Changelog: v5 - 2018-09-30 Actually set the fake value in the hook instead of nil. v4 - 2018-09-30 Expanded description field / documentation. Now the faked value is not nil (crashes Coc), but either a zeroed out number or the string "Private".

CollectionFif
GroupUse.Tracking
NameSystemProperties.get/custom
AuthorFif_
Version5
Updated (UTC)2018-10-01 05:47:23
Created (UTC)2018-02-23 01:27:29
Downloads1684
Class nameandroid.os.SystemProperties
Method nameget
Parameter typesjava.lang.String
Return typejava.lang.String
Min SDK1
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
SettingsProperty blacklist (prefixes)
-- Fif.SystemProperties.get_custom is a Lua hook designed to work with XPrivacyLua.
-- Copyright (C) 2018 Philippe Troin (Fif_ on XDA)

-- Fif.SystemProperties.get_custom is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.

-- Fif.SystemProperties.get_custom is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.

-- You should have received a copy of the GNU General Public License
-- along with XPrivacyLua.  If not, see <http://www.gnu.org/licenses/>.

function after(hook, param)
    local result = param:getResult()
    if result == nil then
        return false
    end

    local context = param:getApplicationContext()
    local BlacklistPropertyPrefixes = param:getValue('Fif.SystemProperties.get_custom.BlacklistPropertyPrefixes', context)

    if BlacklistPropertyPrefixes == nil then
        local blacklist = param:getSetting("Property blacklist (prefixes)")
        BlacklistPropertyPrefixes = {}
        if blacklist ~= nil then
            blacklist:gsub('[%S]+', function(x) table.insert(BlacklistPropertyPrefixes, x) end)
        end
        param:putValue('Fif.SystemProperties.get_custom.BlacklistPropertyPrefixes', BlacklistPropertyPrefixes, context)
        log('Property prefix blacklist: ' .. table.concat(BlacklistPropertyPrefixes, ', '))
    end

    local key = param:getArgument(0)
    local found = false
    local i, prefix
    for i, prefix in pairs(BlacklistPropertyPrefixes) do
        if string.sub(key, 1, string.len(prefix)) == prefix then
            found = true
            break
        end
    end

    if found then
        local fake
        if result:match('^[0-9a-fA-F]+$') then
            fake = string.rep('0', result:len())
        else
            fake = 'Private'
        end
        log('Deny ' .. key .. '=' .. result .. ' → ' .. fake)
        param:setResult(fake)
        return true, key .. '=' .. result, key .. '=' .. fake
    else
        log('Allow ' .. key .. '=' .. result)
        return false
    end
end