HarmonyOS 鸿蒙Next 升级到后,har 开启了混淆,但在 ide 工具中的 oh_modules 能看到混淆后的代码,有什么方法可以加强源码保护

HarmonyOS 鸿蒙Next 升级到后,har 开启了混淆,但在 ide 工具中的 oh_modules 能看到混淆后的代码,有什么方法可以加强源码保护 在开发第三方库,采用了 har 的方式,也按照文档开启了对应的混淆配置。

-enable-property-obfuscation
-enable-string-property-obfuscation
-enable-filename-obfuscation
-compact

https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md

但是在一个空白工程通过线上集成这个 har 的时候,可以在 oh_modules 看到混淆后的代码,基本上格式化一下就能还原原本逻辑,有还有什么办法可以保护源码


更多关于HarmonyOS 鸿蒙Next 升级到后,har 开启了混淆,但在 ide 工具中的 oh_modules 能看到混淆后的代码,有什么方法可以加强源码保护的实战教程也可以访问 https://www.itying.com/category-93-b0.html

15 回复

更多关于HarmonyOS 鸿蒙Next 升级到后,har 开启了混淆,但在 ide 工具中的 oh_modules 能看到混淆后的代码,有什么方法可以加强源码保护的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


export class EventEmitter { private _events: any = {};

on(type: string, listener: Function) { if (this._events[type]) { this._events[type].push(listener); } else { this._events[type] = [listener]; } }

emit(type: string, …args: any[]) { if (this._events[type]) { this._events[type].forEach((listener: Function) => { listener(…args); }); } }

off(type: string, listener: Function) { if (this._events[type]) { this._events[type] = this._events[type].filter((l: Function) => { return l !== listener; }); } }

once(type: string, listener: Function) { const wrapper = (…args: any[]) => { listener(…args); this.off(type, wrapper); }; this.on(type, wrapper); }

removeAllListeners(type: string) { if (this._events[type]) { delete this._events[type]; } } }

请问该问题是否已经解决了呢,我开发的har增加规则后,新demo工程中可以看到har的源码。好像并没有被混淆

请问你解决了吗,我也是开发第三方SDK,也开启了

-enable-property-obfuscation
-enable-export-obfuscation
-enable-string-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-compact
-remove-log
-remove-comments 

但效果不大,格式化一下就能还原原本逻辑的;求解决方法???

华为后续会提供其他的加密方式,目前没办法,

这个混淆怎么开启的 怎么在混淆文件中增加选项 编译har后解压还是发现没混淆呢

项目名称

  • 项目状态: 已完成
  • 项目周期: 2023.01 - 2023.06
  • 项目描述: 这是一个示例项目,用于演示如何将HTML转换为Markdown。

团队成员

  • 张三
  • 李四
  • 王五

主要职责

  • 负责项目的需求分析和设计
  • 编写项目的核心代码
  • 完成项目的测试和上线工作

混淆文档:https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V4/obfuscation-0000001606787580-V4h

±/$%-+ 混淆配置:https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.mdh

±/$%-+ 在 obfuscation-rules.txt 文件里加上这些就行

  • enable-property-obfuscation
  • enable-string-property-obfuscation
  • enable-filename-obfuscation
  • compact

期待HarmonyOS能在未来带来更多创新的技术和理念。

这个IDE图片是新版IDE吗?

DevEco Studio NEXT Developer Preview2,

基本信息

  • 版本号: 2.2.0.202
  • API版本: 9
  • 深色代码主题: 开启
  • 图片:

开放给开发者了吗,

基本信息

<div>
    <p>这个API目前仅限内部使用,尚未对外开放。</p>
    <img src="" alt="图片">
</div>

去申请,

基本信息

  • 姓名: 张三
  • 年龄: 28
  • 职位: 开发工程师

在HarmonyOS鸿蒙Next中,har包开启了混淆后,虽然oh_modules目录中可以看到混淆后的代码,但仍有方法进一步保护源码。

  • 使用ProGuard或R8进行深度混淆:通过配置ProGuard或R8规则,进一步混淆类名、方法名和字段名,增加逆向工程难度。

  • 代码加密:对关键代码段进行加密处理,运行时解密执行。可以使用AES等加密算法,结合HarmonyOS的安全模块实现。

  • 动态加载:将部分核心逻辑代码编译为动态库(如.so文件),通过动态加载方式调用,减少源码暴露风险。

  • 代码分割与模块化:将敏感代码拆分为独立模块,单独打包和分发,降低整体代码的暴露范围。

  • 使用华为提供的安全增强功能:利用HarmonyOS的安全增强特性,如安全存储、安全启动等,保护关键数据和代码。

  • 代码签名与验证:对发布的代码进行签名,并在运行时验证签名,确保代码未被篡改。

  • 混淆资源文件:对资源文件(如布局文件、图片等)进行混淆或加密处理,增加逆向工程难度。

  • 使用NDK开发:将核心逻辑用C/C++编写,编译为本地库,减少Java/JS代码的暴露。

通过以上方法,可以有效加强源码保护,降低逆向工程风险。

回到顶部