30

[APP][XPOSED][7.0+] WeiJu2 - Scriptable Xposed Module

 2 years ago
source link: https://forum.xda-developers.com/t/app-xposed-7-0-weiju2-scriptable-xposed-module.4482585/page-2#post-88295947
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

[APP][XPOSED][7.0+] WeiJu2 - Scriptable Xposed Module

wanting2521

New member

Oct 1, 2022

File access causes me a lot of headache, and current implementation still have some flaw it.

Why would want load script from file?

ref: https://github.com/ikws4/WeiJu2/issues/7#issuecomment-1248109818

I have multiple devices and code on computer will be a lot faster than Android.

Currently I try to override function getAllCellInfo of TelephonyManager class.
But the return is a List<CellInfo>. I don't know how to write the return for a List. Could you help me, please? Both return=List and return=List<CellInfo> doesn't work

Code:
local TelephonyManager = import("android.telephony.TelephonyManager")
local List = import("java.util.List")

hook {
  class = TelephonyManager,
  returns = List,
  method = "getAllCellInfo",
  params = {
  },
  replace = function(this, params)
    return nil
  end,
}
Thank you in advance.

Great app !
Certainly, I will give a try.
I Love XPrivacyLua but it doesn't provide a full integration from Lua to Java.

I have two questions:
Can I set specific hooks to specific apps or all hooks are applied to all apps ?
Can I set variables on hooks and then set a different variable for each app ?

Last edited: Dec 8, 2022

zhipingne

Member

Mar 20, 2018

I have multiple devices and code on computer will be a lot faster than Android.

Currently I try to override function getAllCellInfo of TelephonyManager class.
But the return is a List<CellInfo>. I don't know how to write the return for a List. Could you help me, please? Both return=List and return=List<CellInfo> doesn't work
Code:
local TelephonyManager = import("android.telephony.TelephonyManager")
local List = import("java.util.List")

hook {
  class = TelephonyManager,
  returns = List,
  method = "getAllCellInfo",
  params = {
  },
  replace = function(this, params)
    return nil
  end,
}
Thank you in advance.
Try this one, If it doesn't work, could you paste the debug log?
Code:
local TelephonyManager = import("android.telephony.TelephonyManager")
local ArrayList = import("java.util.ArrayList")
local List = import("java.util.List")


hook {
  class = TelephonyManager,
  returns = List,
  method = "getAllCellInfo",
  replace = function(this, params)
    local ret = ArrayList()
    return ret
  end,
}

Reactions: wanting2521

zhipingne

Member

Mar 20, 2018

Can I set specific hooks to specific apps or all hooks are applied to all apps ?

For now, the workflow is you write a script for a specific app. But I am prepare to implement a "global app" feature (the script you write can be injected for all other apps).

Can I set variables on hooks and then set a different variable for each app ?

Yes, this is what the WeiJu2's package feature made for, you can import any script.
check them out on https://github.com/ikws4/WeiJu2-Scripts

wanting2521

New member

Oct 1, 2022

Try this one, If it doesn't work, could you paste the debug log?
Code:
local TelephonyManager = import("android.telephony.TelephonyManager")
local ArrayList = import("java.util.ArrayList")
local List = import("java.util.List")


hook {
  class = TelephonyManager,
  returns = List,
  method = "getAllCellInfo",
  replace = function(this, params)
    local ret = ArrayList()
    return ret
  end,
}

Thank you. It works after I change List to ArrayList

One more thing, Can I view or copy 'My Scripts' directly from Android Studio/computer, instead of editing directly from Weiju app?
I mean the path to 'My Scripts' on the device, so we can copy/paste the script?

zhipingne

Member

Mar 20, 2018

Thank you. It works after I change List to ArrayList

One more thing, Can I view or copy 'My Scripts' directly from Android Studio/computer, instead of editing directly from Weiju app?
I mean the path to 'My Scripts' on the device, so we can copy/paste the script?

Can or can't that depends you, for now the script are save inside a share preferences called `script_store`, and script are encoded in base64, you can take look at it.

Reactions: wanting2521

wanting2521

New member

Oct 1, 2022

Can or can't that depends you, for now the script are save inside a share preferences called `script_store`, and script are encoded in base64, you can take look at it.

Strangely, I check both path:
- data/data/io.ikws4.weiju
- /data/user_de/0/io.ikws4.weiju
But no shared_prefs folder there. where can it be, sir?

Attachments

  • Untitled.png

    Untitled.png
    36.8 KB · Views: 35

zhipingne

Member

Mar 20, 2018

Strangely, I check both path:
- data/data/io.ikws4.weiju
- /data/user_de/0/io.ikws4.weiju
But no shared_prefs folder there. where can it be, sir?
Oops, I recall that, the XSharedPreferences was store in a random path, tricky
github.com

New XSharedPreferences

LSPosed Framework. Contribute to LSPosed/LSPosed development by creating an account on GitHub.
github.com
To read the preference from the hooked app, you can simply use XSharedPreferences(String packageName) or XSharedPreferences(String packageName, String prefFileName) to retrieve the preference. Notice that you cannot use the XSharedPreferences(File prefFile) because the preference file is stored in a random directory.

zhipingne

Member

Mar 20, 2018

Strangely, I check both path:
- data/data/io.ikws4.weiju
- /data/user_de/0/io.ikws4.weiju
But no shared_prefs folder there. where can it be, sir?
try global search the file name. In my case, it was located at
Code:
/data/misc/b7076e05-6693-44af-990c-d5a46af38289/prefs/io.ikws4.weiju/script_store.xml

For now, the workflow is you write a script for a specific app. But I am prepare to implement a "global app" feature (the script you write can be injected for all other apps).


Yes, this is what the WeiJu2's package feature made for, you can import any script.
check them out on https://github.com/ikws4/WeiJu2-Scripts

Nice !
Definitely, global scripts are totally useful.

About package feature, why not some place/activity for setting each variable for each app, like XPrivacyLua Pro feature? Instead of opening and editting each script.

Attachments

  • Screenshot_2022-12-10-12-39-40-800_eu.faircode.xlua.pro.jpg

    Screenshot_2022-12-10-12-39-40-800_eu.faircode.xlua.pro.jpg
    96.1 KB · Views: 50
  • Screenshot_2022-12-10-12-39-50-253_eu.faircode.xlua.pro.jpg

    Screenshot_2022-12-10-12-39-50-253_eu.faircode.xlua.pro.jpg
    120.8 KB · Views: 48

zhipingne

Member

Mar 20, 2018

Nice !
Definitely, global scripts are totally useful.

About package feature, why not some place/activity for setting each variable for each app, like XPrivacyLua Pro feature? Instead of opening and editting each script.

Not a big fan of making these ui, I think using code to define the behaviors is much better way to manage configurations and it gives the user more flexibility.

Last edited: Dec 11, 2022

anuraag.neo

Senior Member

Aug 7, 2013

Can i hook android framework methods using this?

anuraag.neo

Senior Member

Aug 7, 2013

Maybe, I can write a convertor for this.

will you do this?

Can i hook android framework methods using this?

Yes.

Schroeder09

Senior Member

Nov 6, 2017 1,076

Google Pixel 7 Pro

Anyone having any interesting use case for this that they have been using? This looked really exciting when it came out. Idk enough about hooks to write them myself though.

zhipingne

Member

Mar 20, 2018

will you do this?

After some investigating, I found that it has many custom parameters and other stuff going on, so creating a complete compatible converter would be very difficult. Therefore, I probably won’t work on it, sorry.

Reactions: anuraag.neo

anuraag.neo

Senior Member

Aug 7, 2013

After some investigating, I found that it has many custom parameters and other stuff going on, so creating a complete compatible converter would be very difficult. Therefore, I probably won’t work on it, sorry.

ok but there is a hook which i wonder how to do.

Code:
      "className": "android.content.Intent",
      "methodName": "CREATOR:createFromParcel",
      "parameterTypes": [
        "android.os.Parcel"
      ],
      "returnType": "android.content.Intent",
It's hooking intent.

Another one
Code:
      "className": "android.content.ClipData",
      "methodName": "CREATOR:createFromParcel",
      "parameterTypes": [
        "android.os.Parcel"
      ],
      "returnType": "android.content.ClipData",

zhipingne

Member

Mar 20, 2018

ok but there is a hook which i wonder how to do.
Code:
      "className": "android.content.Intent",
      "methodName": "CREATOR:createFromParcel",
      "parameterTypes": [
        "android.os.Parcel"
      ],
      "returnType": "android.content.Intent",
It's hooking intent.

Another one
Code:
      "className": "android.content.ClipData",
      "methodName": "CREATOR:createFromParcel",
      "parameterTypes": [
        "android.os.Parcel"
      ],
      "returnType": "android.content.ClipData",
Code:
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")
local ClipData = import("android.content.ClipData")

hook {
  class = Intent.CREATOR:getClass(),
  returns = Intent,
  method = "createFromParcel",
  params = {
    Parcel
  },
  replace = function(this, params)
    print("replace Intent.CREATOR.createFromParcel")
    return Intent(params[1])
  end
}

hook {
  class = ClipData.CREATOR:getClass(),
  returns = ClipData,
  method = "createFromParcel",
  params = {
    Parcel
  },
  replace = function(this, params)
    print("replace ClipData.CREATOR.createFromParcel")
    return Intent(params[1])
  end
}
Refs:
github.com

XPrivacyLua/XLua.java at 85a1e498d5a9dbb902ca3d83e987ae6eec377d7a · M66B/XPrivacyLua

Really simple to use privacy manager for Android 6.0 Marshmallow and later - XPrivacyLua/XLua.java at 85a1e498d5a9dbb902ca3d83e987ae6eec377d7a · M66B/XPrivacyLua
github.com
github.com

XPrivacyLua/DEFINE.md at master · M66B/XPrivacyLua

Really simple to use privacy manager for Android 6.0 Marshmallow and later - XPrivacyLua/DEFINE.md at master · M66B/XPrivacyLua
github.com

anuraag.neo

Senior Member

Aug 7, 2013

Code:
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")
local ClipData = import("android.content.ClipData")

hook {
  class = Intent.CREATOR:getClass(),
  returns = Intent,
  method = "createFromParcel",
  params = {
    Parcel
  },
  replace = function(this, params)
    print("replace Intent.CREATOR.createFromParcel")
    return Intent(params[1])
  end
}

hook {
  class = ClipData.CREATOR:getClass(),
  returns = ClipData,
  method = "createFromParcel",
  params = {
    Parcel
  },
  replace = function(this, params)
    print("replace ClipData.CREATOR.createFromParcel")
    return Intent(params[1])
  end
}

Thanks for this but I'm still struggling to find Intent action. XprivicyLua has getResult() function which returns Intent.

I think below code will give me action?

Code:
Intent(params[1]):getAction()

Last edited: Yesterday at 11:14 PM

zhipingne

Member

Mar 20, 2018

Thanks for this but I'm still struggling to find Intent action. XprivicyLua has getResult() function which returns Intent.

I think below code will give me action?
Code:
Intent(params[1]):getAction()
Try this snippet, If any error please send to me.
Code:
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")

hook {
  class = Intent.CREATOR:getClass(),
  returns = Intent,
  method = "createFromParcel",
  params = {
    Parcel
  },
  replace = function(this, params)
    print("replace Intent.CREATOR.createFromParcel")
    local ret = Intent(params[1])
    print("action " .. ret:getAction())
    return ret
  end
}
Here maybe is what you want, but now WeiJu2 cannot read the method's original return value `ret' for now (this is a bug I'll fix it later)
Code:
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")

hook {
  class = Intent.CREATOR:getClass(),
  returns = Intent,
  method = "createFromParcel",
  params = {
    Parcel
  },
  --                                   Not Implemented: Should have access for original return value
  --                                                v
  after = function(this, params, ret)
    print("action " .. ret:getAction())
    return ret
  end
}

</div


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK