{QUESTION} Hook systems UserAgent - Xposed General

Hi,
I trying to change user agent for all system, but
Code:
User-Agent: Dalvik/2.1.0 (Linux; U; Android 5.1.1; Nexus 6 Build/LMY47X)
saving. Can you say how i can hook method of superclass. Some userAgents don't changing by hooks getProp and changing build.prop
My trying to change
Code:
XposedHelpers.findAndHookMethod("java.net.URLConnection", sharePkgParam.classLoader, "setRequestProperty", String.class, String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== BEFORE HOOK ==== " + Arrays.toString(param.args));
if (param.args[0].equals("User-Agent")) {
param.args[1] = "XYZXYZXYZ";
}
}
});

This make a reboot system after 5-7 sec after system loading
Code:
XposedHelpers.findAndHookMethod(System.class, "getProperty", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== System BEFORE ==== " + Arrays.toString(param.args));
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== System AFTER ==== " + (String) param.getResult());
param.setResult("Dalvik/2.1.0 (Linux; U; Android 5.1.1; Nexus 5 Build/LMY47X)");
}
});
XposedHelpers.findAndHookMethod(Properties.class, "getProperty", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("--- Properties HOOK --- " + Arrays.toString(param.args));
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("--- Properties HOOK --- " + (String) param.getResult());
}
});

solved. Tnx to all xD
Code:
XposedHelpers.findAndHookMethod(System.class, "getProperty", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== System BEFORE ==== " + param.args[0]);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (param.args[0].toString().equals("http.agent")) {
XposedBridge.log("==== System AFTER ==== " + (String) param.getResult());
param.setResult("Dalvik/2.1.0 (Linux; U; Android 6.0.1; Nexus 5 Build/LMY47X)");
XposedBridge.log("==== System AFTER ==== " + (String) param.getResult());
}
}
});

Related

[Q] Hook android.util.Log methods

Hi, I followed the tutorial on github and tried to hook android.util.Log.i(String tag, String msg) method, but I always get a ClassNotFoundError.
I don't know what I did wrong, my code seems so simple.
Edit: I found the solution. The code below works correctly, the problem was in another part of my code.
Here is the code:
Code:
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable
{
XposedBridge.log("Package name: " + lpparam.packageName);
try
{
findAndHookMethod("android.util.Log", lpparam.classLoader, "i", String.class, String.class, new XC_MethodHook()
{
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable
{
//do something before
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable
{
//do something after
}
});
}
catch (XposedHelpers.ClassNotFoundError e)
{
XposedBridge.log("ClassNotFoundError");
}
catch (NoSuchMethodError e)
{
XposedBridge.log("NoSuchMethodError");
}
}
}
}

[Q] Problem: Xposed hook OpenGL ES ?

I'm trying to hook GLES API with Xposed. But met some problems. Xposed can work well when i use it for some other things except the GLES API.
The module:
...
public class Tutorial implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (lpparam.packageName.equals("android"))
{
XposedBridge.log("Mark !");
findAndHookMethod("android.opengl.GLES20", lpparam.classLoader, "glFinish", new XC_MethodHook() {
@override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("glFinish GLES20");
}
@override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("glFinish GLES20");
}
});
}
...​
And i wrote an app with some glFinish() calls in it. When i run the app, i can't get "glFinish GLES20" at the log file.
I can get "Mark !", and no error in the log file.
Can any one help me? Thanks!

How to hook static method

I want to modify some static field in android.os.Build, such as android.os.Build.BOARD, android.os.Build.DEVICE, android.os.Build.DISPLAY.
Then I tried to hook the static method 'getString(String s)' in android.os.Build .
Code:
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
XposedBridge.log(loadPackageParam.packageName + " -> load ");
Class build = XposedHelpers.findClass(Build.class.getName(), loadPackageParam.classLoader);
XposedHelpers.findAndHookMethod(build, "getString", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("before ->" + param.args[0]);
super.beforeHookedMethod(param);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("after ->" + param.args[0]);
super.afterHookedMethod(param);
}
});
I wrote
Code:
txvTxt = (TextView) findViewById(R.id.txvTxt);
txvTxt.setText(Build.DISPLAY);
in my activity, I could not see any before or after hook message.
Waiting online for any solution. 3Q

Hooking a method with a custom class array as argument

The code:
Code:
updateNotifications([Lcom/samsung/android/uniform/widget/notification/NotificationItem;)V
As you can see, I need an array of "NotificationItem"
But when I do this:
Code:
XposedHelpers.findAndHookMethod(NotiContainer, "updateNotifications", NotiItem[].class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
I get "unknown class NotiItem"
so yeah.. kinda confused.
I tried this too:
Code:
XposedHelpers.findAndHookMethod(NotiContainer, "updateNotifications", "[com.samsung.android.uniform.widget.notification.NotificationItem", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
But I get "ClassNotFound Exception: Invalid Name"
How the heck can I do this...
Solved using "com.samsung.android.uniform.widget.notification.NotificationItem[]" instead of "[com.samsung.android.uniform.widget.notification.NotificationItem" as the class name.

[Help] reflection method on pie hooks too slow!!! Am I missing something

I am on pie so obviously its EdXposed running.
I want to hook a method which is like
Code:
public void setSensorBrightness(int var1) {
Log.d(TAG, "setSensorBrightness: " + var1);
AODCommonSettingsUtils.setBrightnessSettingValue(var1);
this.mSensorBrightness = var1;
}
this original method is located in class "com.samsung.android.app.aodservice.manager.BrightnessManager" and a package name is "com.samsung.android.app.aodservice"
I use reflection as suggested in tutorial otherwise it throws no class found exception.
My code is
Code:
@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable
{
if (!lpparam.packageName.equals("com.samsung.android.app.aodservice"))
return;
XposedHelpers.findAndHookMethod(
"com.samsung.android.app.aodservice.manager.BrightnessManager",
lpparam.classLoader,
"setSensorBrightness",
"int",
new MethodHook());
}
protected static class MethodHook extends XC_MethodHook
{
@Override
protected void beforeHookedMethod(MethodHookParam param)
throws Throwable
{
int x =3;
param.args[0]=x;
Log.d("Brightness_hack :", "works");
}
@Override
public boolean equals(Object o)
{
if (o instanceof MethodHook)
{
return true;
}
return super.equals(o);
}
@Override
public int hashCode()
{
return ~MethodHook.class.hashCode() ^ 0xdeadbeef;
}
}
Now my problem is its tooooooo slow hooks in like 15-20 mins and returns no result.
Am I missing something???

Categories

Resources