Unity加密

Unity的代码加密是一个有点麻烦的事情,相对iOS的IL2CPP,安卓里直接存放的dll很容易被ILSpy这种工具打开。网上有一些资料,如Unity3D研究院之Android加密DLL与破解DLL .SO,常见的思路都是修改mono源代码后重新编译;但是这样有一个麻烦的地方在于每次升级Unity版本之后都需要重新编译对应版本的libmono.so出来…

后来Unite 2016的时候和朋友聊天,学到了一个新思路——直接用Hook的方式来解密,这样就可以直接使用Unity自带的libmono.so解决问题~具体一点,使用了Cydia Substrate的API来劫持mono API

     
     
MSImageRef image = MSGetImageByName ( /* libmono.so */ );
if ( image == NULL ) return 1 ;
void * ptr = MSFindSymbol ( image , /* mono function */ );
if ( ptr == NULL ) return 2 ;
MSHookFunction ( ptr , ( void *)& oldPtr , ( void **)& newPtr );

由于非常简单就不展开解释了…反正就三个函数MSGetImageByNameMSFindSymbolMSHookFunction的事儿

至于怎么接入,网上也有不少资料,我主要参考的是Substrate - hooking C on Android。需要注意的是很多教程是介绍如何劫持别的App,需要root;但是我们劫持的是自己,所以不用那么麻烦。

最后再给个踩坑经验提示:Java那边必须显示、按顺序加载库,不然的话其实在绝大多数机型上依然能正常工作、但有些手机会crash。

     
     
public class Misc {
static {
System . loadLibrary ( "mono" );
System . loadLibrary ( "substrate" );
System . loadLibrary ( "soulgame" );
}
public static native int decrypt() ;
}

咳咳,最后的最后是必须注意的点:Android 7.0开始Hook方式将直接导致App崩溃 NDK Apps Linking to Platform Libraries

Starting in Android 7.0, the system prevents apps from dynamically linking against non-NDK libraries, which may cause your app to crash.

所以,我享受了一段时间不用每个版本编译mono之后也被逼回去了…当然你也不能说这个没有用啦,毕竟Android 7.0的占有率目前还是很低的(逃

更新 今天有朋友在群里遇到一个问题,有一个可能是使用了雨松MONO博客里的混淆方法导致的(依然是Android 7.0相关)。

     
     
dlopen failed : "libmono.so" . dynamic section header was not found
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
淘宝花钱买的最新版!需要的拿去! This asset obfuscates your code to make it harder for bad guys to reverse engineer your projects. Specifically designed for Unity, it seamlessly links in with its build process. The top priority of this package is to work straight out of the box with no extra steps required. While other obfuscators can stop a game from working, Beebyte's obfuscator looks for specific Unity related code that must be protected. The contents of your source files are unchanged, the obfuscation targets the compiled assembly. Features: - Supports IL2CPP - Supports Assembly Definition Files (Unity 2017.3+) - Removes Namespaces without any conflicts - Recognises Unity related code that must not be changed - Renames Classes (including MonoBehaviours) - Renames Methods - Renames Parameters - Renames Fields - Renames Properties - Renames Events - String literal obfuscation - Adds fake methods - Easy and extensive customisation using the Unity inspector window - Consistent name translations are possible across multiple builds and developers - Semantically secure cryptographic naming convention for renamed members The asset works for both Unity Free and Unity Pro version 4.2.0 onwards (including Unity 5 & 2017 & 2018). Build targets include Standalone, Android, iOS, WebGL, UWP. Other platforms are not guaranteed or supported but may become supported at a future date. IL2CPP builds are much harder to reverse engineer but strings and member information (class, method names etc) are visible in the global-metadata.dat file. Obfuscation will apply to this file adding further security. Why not complement your security with the Anti-Cheat Toolkit - a great third party asset. For more information about the Obfuscator, please see the FAQ
Unity是一款非常流行的跨平台游戏开发引擎,它可以在Windows操作系统上进行开发。关于Unity在Windows上的加密,以下是一个简要的介绍。 首先,Unity本身并不提供Windows加密功能。它主要用于游戏开发和可视化效果的创建,并不涉及底层操作系统的加密。但是,Unity可以与其他加密工具和技术一起使用,以实现Windows上的加密保护。 在Windows上,我们可以利用操作系统提供的加密功能来保护Unity应用程序的安全性。例如,Windows操作系统提供了BitLocker驱动器加密,它可以对整个硬盘驱动器进行加密保护,确保数据的安全性。 此外,我们还可以使用第三方的加密工具来加强Unity应用程序的保护。这些工具可以将Unity项目文件和可执行文件进行加密,使其难以逆向工程。通过使用这些工具,我们可以阻止未经授权的用户访问和修改Unity应用程序的内容。 除了使用加密工具,我们还可以使用数字签名来确保Unity应用程序的完整性。通过为应用程序和代码签名,我们可以验证其来源和完整性,防止被修改或篡改。 总而言之,Unity本身并不提供Windows加密功能,但我们可以利用操作系统的加密功能和第三方的加密工具来保护Unity应用程序的安全性。这些措施可以阻止未经授权的用户对应用程序进行访问、修改和逆向工程,提高应用程序的安全性和保护用户数据的机密性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值