安卓逆向:x红书水印去除Frida脚本和Xposed模块
文章介绍了一种通过Frida和Xposed技术去除小红书应用中文字和图片水印的方法,并提供了具体的脚本实现和模块下载链接。 2025-9-8 02:31:16 Author: www.freebuf.com(查看原文) 阅读量:3 收藏

freeBuf

主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

定位hook点

调研了常用的加水印方式,使用frida工具定位关键API:

  1. Bitmap.compress - 用于保存图片到磁盘
  2. Canvas.drawText - 添加文字水印
  3. Canvas.drawBitmap - 添加图像水印

Frida脚本实现

去除文字水印

通过hook Canvas.drawText方法,检测并替换包含"小红书"或"xhs"的文字内容为空字符串:

Canvas.drawText.overload("java.lang.String", "float", "float", "android.graphics.Paint").implementation = function(text, x, y, paint) {
    if (text.toLowerCase().includes("小红书") || text.toLowerCase().includes("xhs")) {
        return this.drawText('', x, y, paint);
    }
}

去除图片logo水印

定位到drawBitmap的重载方法,通过检测Bitmap尺寸判断是否为水印:

Canvas.drawBitmap.overload("android.graphics.Bitmap", "android.graphics.Rect", "android.graphics.Rect", "android.graphics.Paint").implementation = function(bitmap, src, dst, paint) {
    if (bitmap.getWidth() < 400 && bitmap.getHeight() < 150) {
        // 替换为透明Bitmap
        var transparent = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
        return this.drawBitmap(transparent, src, dst, paint);
    }
}

Xposed模块实现

将Frida脚本转换为Xposed模块,实现持久化去水印功能:

文字水印处理

private void hookCanvasDrawText() {
    for (Method method : Canvas.class.getDeclaredMethods()) {
        if (method.getName().equals("drawText") && method.getParameterTypes().length == 4) {
            XposedBridge.hookMethod(method, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) {
                    String text = (String) param.args[0];
                    if (text != null && (text.toLowerCase().contains("小红书") || text.toLowerCase().contains("xhs"))) {
                        param.args[0] = "";
                    }
                }
            });
        }
    }
}

图片水印处理

private void hookCanvasDrawBitmap() {
    for (Method method : Canvas.class.getDeclaredMethods()) {
        if (method.getName().equals("drawBitmap") && method.getParameterTypes().length == 4) {
            XposedBridge.hookMethod(method, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) {
                    Bitmap bmp = (Bitmap) param.args[0];
                    if (bmp.getWidth() < 400 && bmp.getHeight() < 150) {
                        Bitmap transparent = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Bitmap.Config.ARGB_8888);
                        param.args[0] = transparent;
                    }
                }
            });
        }
    }
}

完整代码和模块下载地址: https://github.com/SimpsonGet/XhsWatermarkRemove

免责声明

1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。

2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。

3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。

本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)


文章来源: https://www.freebuf.com/articles/web/447700.html
如有侵权请联系:admin#unsafe.sh