Unity Mono Scripting Encryption

Source: Internet
Author: User
Tags dotnet file copy reflector

Encryption environment

Engine version: Unity3d 5.3.4 and later ( using mono instead of il2cpp)

Operating system: CentOS 6.2 (Final)

Encryption environment: Android, IOS (tentative)

Encrypted objects: C # source code (DLL file)

Decryption method: Libmono.so (Focus: Add decryption algorithm and recompile this file)

Encrypt the target ground

Anti-compilation tools such as. NET Reflector are not able to get the source code by recompiling the DLL

Precautions

The encryption algorithm of DLL is consistent with libmono.so decryption algorithm

Thinking analysis

Important: We need to recompile the libmono.so and join our decryption algorithm.

Preparing the Environment compilation system: Linux or Mac OS

My build Environment: CentOS 6.2 Final, recommended to be compiled in Linux or Mac OS libmono.so

Linux Install runtime git

You may need to get some runtimes through Git during the compilation process.

To see if Git is installed:git–version

CentOS7 Yum Install git

Https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

Other Package

Autoconf
Automake
Bison
Gcc
GetText
GLib >= 2.0
Libtool
Make
Perl

GLib >= 2.0 This has failed to install

CentOS installation Software

Under root permissions, install the software by using the following command:

Yum Install [Nginx] [PHP] [PHP-FPM] [MARIADB] [Mariadb-server] [MySQL] [Mysql-server] ...
Unity installs Android module

Make sure the Unity engine is installed, and that the Android module is installed, the Android SDK is installed and updated to ensure that you can pack the APK

Formal/test Engineering

Use Unity to create a cryptographic test project or a formal project to encrypt

Unity Mono

Unity Mono and native mono are somewhat different, so you need to go to GitHub to pull the Unity Mono Library

Https://github.com/Unity-Technologies/mono

Monobuildtools

Unity Mono Packaging Tool

Https://github.com/Unity-Technologies/monobuildtools

Android SDK tool/android6.0

I use Unity5.3.4 to pack the APK on Windows and need the Android SDK tool version for 23,android6.0, so please also prepare the environment first.

Android Packaging Tools

Android studio:http://www.androiddevtools.cn/or: 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

The NDK version of Android

View path:external/buildscripts/build_runtime_android.sh

https://github.com/Unity-Technologies/mono/blob/unity-5.3/external/buildscripts/build_runtime_android.sh

The required NDK version can be seen in the top half of the file, and I am in 2016-06-25 clone, which requires the NDK version to be r10e

ANDROID-NDK Download

Depending on the version of Android and Unity, the NDK version you need is different, and I'm taking 2016-06-25 clone's warehouse as an example, and need ndk-r10e

x64

Android-ndk-r10e-linux-x86_64.bin:http://pan.baidu.com/s/1ddaqnk1

x86

Android-ndk-r10e-linux-x86.bin:http://pan.baidu.com/s/1sjonerr

Setting Android NDK Environment variables

The Anti-compilation tool tests the results of the encryption. NET Anti-compilation tool

The primary cryptographic object is Assembly-csharp.dll, so you can prepare several. NET anti-compilation tools to test the encryption results

The following example. NET Anti-compilation tool

. NET reflector:http://www.red-gate.com/products/dotnet-development/dotnet-developer-bundle/

C-Language anti-compilation tool

If the libmono.so is also encrypted, then you need to prepare several C-language anti-compilation tools

The following example C-Language anti-compilation tool

Ida Pro

Official website: https://www.hex-rays.com/products/ida/

Reseller: http://xlsoft.com.cn/category/%E5%8F%8D%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7/

Libmono.so (decryption method) to encrypt C # DLLs

Encrypt the exported assets/bin/data/managed/Assembly-csharp.dll According to your own situation

Decrypting a DLL in so

Mono load DLL code files are located/mono/metadata/image.c

Mono_image_open_from_data_with_name

Open the image.c, find the mono_image_open_from_data_with_name method, write the decryption method here. This method is approximately 1807 lines

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; returnNULL; }     //decrypt the encrypted DLL here.    if(Strstr (Name, "Assembly-csharp.dll")! =NULL) {        //here is the decryption process, we are using the Xxtea encryption and decryption algorithm.     }    //.....    returnregister_image (image);}
Problems encountered Androidmanifest.xml Error

After Unity exports Android project, one line in Androidmainifest.xml will report error: android:debuggable= "false" , unrecognized.

Workaround: Http://stackoverflow.com/questions/24204140/android-error-when-i-set-androiddebuggable-false-or-true

CentOS Install software Error

Installing some software on CentOS: Errno [] No more mirrors to try

Make sure the system is connected to the network, enter the following command (function: Rebuild cache)

Yum Clean All
Yum Makecache

Linux installation Ndk.bin?

Info: Linux under Install jdk-(Bin version) http://blog.csdn.net/sonnet123/article/details/9290561

Installation steps

The following commands are run as root

1. Install ndk-file copy
#mkdir /usr//usr/ndk #CP /XXXX/ANDROID-NDK-R10E-LINUX-X86.BIN/USR/NDK
2. Install ndk-Install and configure environment variables

1./android-ndk-r10e-linux-x86.bin after successful terminal output everything is OK

3. Installation ndk-installed successfully
/etc/echo  $ANDROID _ndk_root/usr/ndk/android-ndk-r10r[[email protected] ndk]#
Tips to Ndk9?

See the changes to reference caption

./configure does not have that file or directory

View the Readme file

TAR.XZ Installation

Unzip tar.xz compressed files under Linux

Profile: http://blog.csdn.net/longerzone/article/details/8707118

Installing glib

I'm installing glib-2.48.1.

1./configure  2 Make make    Install

Here configure is mainly to configure and generate makefile files, make is mainly to compile the program, make install mainly for the installation of the compiled program

Profile: http://www.linuxfromscratch.org/blfs/view/svn/general/glib2.html

Installation glib-tips missing Libffi

I do not know if you notice that when configure, there is a lack of relevant libraries when the solution can be resolved using the library-devel , then this
What is Devel? Devel is a development package that is installed only when the program is developed. It contains header files, as well as the relevant libraries for development and
Help files, and so on. When some tools are installed, they will appear

Installation of glib: http://blog.chinaunix.net/uid-26126915-id-3368644.html

Installing GLib dependent libraries

Libffi

Download, unzip, execute./configure make makes install installation

Libpcre >=8.13

./configure--with-prce=/usr/local/prec/
TAR.BZ2 Installation

Command: TAR-XJVF xxx.tar.bz2 to extract, get the extracted directory before further installation

Other error 1. File format error

/bin/bash^m:bad Interpreter: No file or directory

Method Two: Use notepad++ to modify the UNIX format under Windows

Pkg_config_path Environment

If you configure Pkg_config_path

Linux Operational knowledge

To view the system version :

Lsb_release–a

To view the number of Linux system bits :

getconf Long_bit Output 32 is x86, output 64 is x64

to give the shell root privileges :

1. Enter Su 2. Enter the root password

Execute script: chmod hello.sh

File copy

CP [option] source file or directory destination file or directory

accessing shared Folders

1.virtual box set up shared folders

2. This step is to create the share directory under MNT, without creating

mkdir /mnt/share

Step 3, there are two ways

If you want to place the shared directory under Share, and MNT also creates the share directory:
#sudo mount-t vboxsf shared folder name/mnt/share, such as mine:

Mount -T vboxsf mono/mnt/share

You want to put it directly under the MNT:

#sudo mount-t vboxsf shared folder name/mnt, such as mine:

Mount -T vboxsf mono/mnt

4. You can see the shared content under the file system –mnt

CD Directory operation

After you log in as root, the default is within the current user folder, up to the file home directory: CD. /.. /

VirtualBox Virtual and host pasteboard sharing

1. Download the corresponding version of the Add-on toolkit from the VirtualBox website for installation

2. Load the toolkit iOS image in Linux to install

3. Virtual machines and hosts can share clipboard content

CentOS installation Software

centos6.x installation QQ2012

Can finally use the QQ under the CentOS!

Centos yum Update Software: http://jingyan.baidu.com/article/19020a0ac84c3d529d2842ee.html

CentOS installation software: https://www.centos.org/forums/viewtopic.php?t=871 find a category of software: Yum list *firefox*

Literature Information

Unity Auto Export Androidstudio Project

Perl language (*.pl file)

Perl is an explanatory language that can be used in Linux/unix systems. Can be understood as the same as bat under Windows.

    • *.pl is a library file for the Perl language, usually with require xx.pl , to load
    • *.PM is a module file for the Perl language, usually using the use module;
    • *.PLX is a script file in the Perl language

Run: ./path/File name (previous "./" means Run command)

End: Ctrl + C

Comments

Single line: #开头, with an exception the first line of the Perl program is also the # beginning

Multiple lines: =pod comment Multiple lines of code block =cut

Resources

Captain

Unity3d Encryption Assembly-csharp.dll (Android platform) full record: http://blog.csdn.net/huutu/article/details/50829828

Technical Life

unity3d-re-compiling the Mono cryptographic DLL

http://www.luzexi.com/unity3d/%E6%B8%B8%E6%88%8F%E6%9E%B6%E6%9E%84/%E5%89%8D%E7%AB%AF%E6%8A%80%E6%9C%AF/2015/ 04/11/unity3d-%e9%87%8d%e6%96%b0%e7%bc%96%e8%af%91mono%e5%8a%a0%e5%af%86dll.html

Rain Pine

Unity3d Research Institute of Android encrypted DLL with cracked DLL. So (81): http://www.xuanyusong.com/archives/3553

Other

Unity 3d scripting encryption scheme: http://www.cppcourse.com/u3d-encryption.html

Progress

is complete

    1. NDK Installation and Configuration complete
    2. Unity Mono Library clone to local

Encounter problems

    1. Install GTK card in Libffi version too low
My environment

Il2cpp

Subsequent projects are highly likely to use Il2cpp. In the case of il2cpp, there is no need for this set of encryption, because the package generated through Il2cpp does not have a DLL, but a binary file.

For more information on il2cpp, you can view Unity's official profile, or my previous article: http://www.cnblogs.com/zhaoqingqing/p/3842690.html

Unity Mono Scripting Encryption

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.