WifiInfo.getIpAddress

Better version (logs the IP address in human-readable form) of the same hook by A200K. Internal Wifi IP address restriction.

CollectionFif
GroupRead.Network
NameWifiInfo.getIpAddress
AuthorFif_
Version1
Updated (UTC)2018-03-14 23:07:31
Created (UTC)2018-03-14 23:07:31
Downloads1537
Class nameandroid.net.wifi.WifiInfo
Method namegetIpAddress
Parameter types
Return typeint
Min SDK1
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
Settings-
-- Fif.WifiInfo.getIpAddress is a Lua hooks designed to work with XPrivacyLua.
-- Copyright (C) 2018 Philippe Troin (Fif_ on XDA)

-- Fif.WifiInfo.getIpAddress 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.WifiInfo.getIpAddress 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 resultAcc = result
    local resb1 = math.floor(resultAcc / 256 / 256 / 256)
    resultAcc = resultAcc - resb1 * 256 * 256 * 256
    local resb2 = math.floor(resultAcc / 256 / 256)
    resultAcc = resultAcc - resb2 * 256 * 256
    local resb3 = math.floor(resultAcc / 256)
    local resb4 = math.floor(resultAcc - resb3 * 256)

    -- Assuming luaJ's ints are little-endian, which does not make sense
    -- but seems to be the case
    local fake, fakeStr, resultStr
    fake = 0x0100007F
    fakeStr = '127.0.0.1'
    resultStr = string.format('%d.%d.%d.%d', resb4, resb3, resb2, resb1)
    
    param:setResult(fake)
    return true, resultStr, fakeStr
end