引擎版本:Unity3D 5.3.4 及更高版本 (使用Mono而並不是IL2CPP)php
操做系統:CentOS 6.2(Final)html
加密環境:Android、IOS(暫定)mysql
加密對象:C#源代碼(dll文件)linux
解密方法:libmono.so (重點:加入解密算法並重編譯此文件)android
.NET Reflector等反編譯工具 沒法經過對dll反編譯獲得源碼ios
dll的加密算法和libmono.so解密算法一致nginx
重點:咱們須要對libmono.so重編譯,加入咱們的解密算法。git
個人編譯環境:centos 6.2 Final,建議在linux或mac os中編譯 libmono.sogithub
在編譯過程當中,可能須要經過git獲取某些運行庫。算法
查看是否安裝git:git –version
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
autoconf
automake
bison
gcc
gettext
glib >= 2.0
libtool
make
perl
glib >= 2.0 這個一直安裝失敗
在root權限下,經過如下命令來安裝軟件:
yum install [nginx][php][php-fpm][mariadb][mariadb-server][mysql][mysql-server]...
確保已安裝Unity引擎,而且Android模塊已安裝,Android SDK已安裝並更新,保證能夠打包APK
使用Unity建立一個加密測試項目或正式項目,用來用加密
unity的mono和原生mono有些不同,因此須要去github拉取unity的mono庫
https://github.com/Unity-Technologies/mono
unity mono打包工具
https://github.com/Unity-Technologies/monobuildtools
我使用Unity5.3.4在windows上打包apk,須要android sdk tool版本爲23,Android6.0,因此一樣請先準備好環境
Android Studio:http://www.androiddevtools.cn/ 或者:http://tools.android-studio.org/
Eclipse:https://marketplace.eclipse.org/content/android-development-tools-eclipse
Andmore - Eclipse Android Tooling:https://projects.eclipse.org/projects/tools.andmore
查看路徑:external/buildscripts/build_runtime_android.sh
在文件的上半部分就能夠看到須要的NDK版本,我在2016-06-25 clone的,須要的NDK版本爲r10e
根據android和unity的版本不一樣,須要的ndk版本也不一樣,我這兒以2016-06-25 clone的倉庫爲例,須要ndk-r10e
android-ndk-r10e-linux-x86_64.bin:http://pan.baidu.com/s/1dDAqnK1
android-ndk-r10e-linux-x86.bin:http://pan.baidu.com/s/1sjoneRr
設置android ndk環境變量
主要加密對象是Assembly-CSharp.dll,因此能夠準備幾款.Net反編譯工具來測試加密結果
下面舉例.net的反編譯工具
.NET Reflector:http://www.red-gate.com/products/dotnet-development/dotnet-developer-bundle/
若是對libmono.so也加密的話,那還須要準備幾款C語言反編譯工具
下面舉例C語言反編譯工具
ida pro
官網:https://www.hex-rays.com/products/ida/
代銷商:http://xlsoft.com.cn/category/%E5%8F%8D%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7/
根據本身的實際狀況,對導出的 assets/bin/Data/Managed/Assembly-CSharp.dll 進行加密
Mono加載dll的代碼的文件位於/mono/metadata/image.c
打開image.c,找到 mono_image_open_from_data_with_name 方法,把解密方法寫在這兒。此方法大概在1807行
MonoImage * mono_image_open_from_data_with_name (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, const char *name) { MonoCLIImageInfo *iinfo; MonoImage *image; char *datac; if (!data || !data_len) { if (status) *status = MONO_IMAGE_IMAGE_INVALID; return NULL; } //在這兒對加密過的dll進行解密 if (strstr(name, 「Assembly-CSharp.dll」) != NULL) { //這裏是解密過程,咱們採用的是xxtea加解密算法。 } //..... return register_image (image); }
Unity導出Android Project以後,AndroidMainifest.xml中有一行會報Error: android:debuggable="false" ,沒法識別。
解決辦法:http://stackoverflow.com/questions/24204140/android-error-when-i-set-androiddebuggable-false-or-true
在CentOS上安裝一些軟件時遇到:Errno 256] No more mirrors to try
確保系統已鏈接網絡,輸入如下命令(做用:重建緩存)
yum clean all
yum makecache
資料:Linux下安裝JDK-(bin版) http://blog.csdn.net/sonnet123/article/details/9290561
安裝步驟
如下命令都是ROOT身份運行
#mkdir /usr/ndk #cd /usr/ndk #cp /xxxx/android-ndk-r10e-linux-x86.bin /usr/ndk
1. ./android-ndk-r10e-linux-x86.bin 成功後終端輸出 Everything is OK
Everything is Ok [root@workstation ndk]# source /etc/bashrc [root@workstation ndk]# echo $ANDROID_NDK_ROOT /usr/ndk/android-ndk-r10r [root@workstation ndk]#
查看參考資料caption的修改
查看README文件
Linux下解壓tar.xz格式壓縮文件
資料:http://blog.csdn.net/longerzone/article/details/8707118
我安裝的是glib-2.48.1
1 ./configure 2 make 3 make install
這裏configure主要是配置並生成Makefile文件,make主要是對程序進行編譯,make install主要是對編譯好的程序進行安裝
資料:http://www.linuxfromscratch.org/blfs/view/svn/general/glib2.html
不知道你們注意到沒有,在configure時,出現缺乏相關庫時解決方法均可以使用 庫-devel 解決,那麼這個
devel是什麼呢?devel是個開發包,只有在開發程序時纔會安裝。裏面包含了頭文件、以及開發用到的相關庫和
幫助文件等等。通常安裝某些工具的時候就會出現
glib的安裝:http://blog.chinaunix.net/uid-26126915-id-3368644.html
libffi
下載,解壓,執行 ./configure make make install 進行安裝
libpcre >=8.13
./configure --with-prce=/usr/local/prec/
命令:tar -xjvf xxx.tar.bz2 來解壓,獲得解壓後的目錄再進一步安裝
/bin/bash^M: bad interpreter: 沒有那個文件或目錄
方法二:在windows下用Notepad++修改格式爲unix
若是配置 PKG_CONFIG_PATH
查看系統版本:
lsb_release –a
查看linux系統位數:
getconf LONG_BIT 輸出32則是x86,輸出64則是x64
給shell賦於root權限:
1. 輸入 su 2.輸入root密碼 回車
執行腳本:chmod 700 hello.sh
文件拷貝
cp [選項] 源文件或目錄 目標文件或目錄
1.virtual box設置共享文件夾
2. 這一步是在mnt下建立share目錄,可不建立
mkdir /mnt/share
步驟3,有兩種方法
若是你但願把共享目錄放在share下,而且mnt也建立 了share目錄:
#sudo mount -t vboxsf 共享文件夾名/mnt/share ,好比個人:
mount -t vboxsf mono/mnt/share
你但願直接放在mnt下:
#sudo mount -t vboxsf 共享文件夾名/mnt,好比個人:
mount -t vboxsf mono/mnt
4. 在 文件系統 – mnt 下就能夠看到共享內容了
以root用戶登陸以後,默認是在當前用戶文件夾內,往上跳到文件主目錄中:cd ../../
1. 從virtualbox官網下載對應版本的增長工具包,進行安裝
2. 在linux中加載工具包 ios鏡像,進行安裝
3. 虛擬機和主機能夠共享粘貼板內容了
Centos YUM更新軟件:http://jingyan.baidu.com/article/19020a0ac84c3d529d2842ee.html
centos安裝軟件:https://www.centos.org/forums/viewtopic.php?t=871 查找某一類軟件:yum list *Firefox*
perl是解釋性語言, 可用於linux/unix系統。能夠理解爲和windows下的bat同樣。
運行: ./路徑/文件名 (前面的「./」表示運行命令)
結束: ctrl + c
註釋
單行:#開頭,有個例外perl程序第一行也是#開頭
多行:=pod 註釋多行代碼塊 =cut
Captain
Unity3d 加密 Assembly-CSharp.dll (Android平臺) 全記錄:http://blog.csdn.net/huutu/article/details/50829828
技術人生
Unity3D-從新編譯Mono加密DLL
雨鬆
Unity3D研究院之Android加密DLL與破解DLL .SO(八十一):http://www.xuanyusong.com/archives/3553
其它
Unity 3d腳本加密方案:http://www.cppcourse.com/u3d-encryption.html
已完成
遇到問題
以後的項目很可能會使用IL2CPP。若是是IL2CPP的話,就無需這一套加密了,由於經過IL2CPP生成的包中並不存在dll,而是二進制文件。
更多關於IL2CPP的資料,能夠查看Unity官方的資料,或者我以前的文章:http://www.cnblogs.com/zhaoqingqing/p/3842690.html