When it comes to software, the term “hacking” is often associated with piracy and copyright infringement. However, this article is a practical guide on hacking. Using tools and methods which will be discussed further, you’ll be able to check the protection of its own Unity game and learn how to protect it from hacking and theft of resources.
Many of the games created on the platform Unity not so secure as it seems. In this article, I offer hack the source code of the game Unity for their future plans.
Extracted the textures and shaders
Most of the resources Unity project files are packaged in a proprietary format extensions
.resources. The most popular tool for viewing such files and extracting resources
The program interface is not particularly convenient and it suffers from a few critical bugs. Regardless, the program is quite capable of removing most of the textures and shaders from the game. The resulting textures will be DDS format, which can be “read” using
With shaders, the situation is more complicated: they are already compiled and, as far as I know, solutions for automatic translation into readable format does not exist. However, this fact does not prevent to import and use the shaders in another Unity project. Don’t forget, however, that such “theft” violates copyright and constitutes an act of piracy.
The installation of the program dnSpy
dnSpy is a utility for decompiling of applications written in C# programming. The installation instructions can be found on
The files from the folder not to delete and not to move. Otherwise, the program will not work!
Finding the right files
In order to get the source code of the game downloaded it (can and Steam version of the game). Next we need to find her local files. To do this, go to ‘properties‘ >> ‘local files’ >> ‘browse local files‘. Next, you need to dig a little and find his daddy ‘Managed‘.
Make sure that the game is written in Unity!
In this folder there will be many files with the extension .dll. We only need 1 of them. Assembly-CSharp.dll
Work in dnSpy
To start, throw the file in dnSpy. Then you will see a similar picture.
You may not have certain files, they will appear with time.
Click on the arrow to the left of the name of our file. Then the same thing, only opened the eyes of the file. Get many files. All this code.
We only need the section titled “-“. Click on the arrow to the left. And see many files that have the source code. You can go through it and change such as the transparency of the walls or, for example, icons, characters and weapons.
In order to change something in the code you need to click on it RMB and choose “Change class (C#)”. Put yourself and click on “Compile” . Download link —
Break open the source code using IlSpy and dotPeek
For Windows builds of Unity compiles and saves the source code for all of the game scripts in the directory
Managed. We are interested in the following libraries:
This approach is particularly effective for our purpose: Unity very sparingly optimizes source code game scripts almost without changing its structure, and does not hide variable names. This makes it easy to read and understand the decompiled stuff.
Additional videos on the subject
The extracted 3D models
Three-dimensional models in the standard Unity build “scattered” on various resources, and some of them did, can be generated during the game. Instead of digging in the files, there is an interesting alternative to obtain the data on the geometry straight from the memory of the graphics accelerator.
When the game launched, all information about textures and patterns visible on the screen is in video memory. Utility
Break Open PlayerPrefs
HKEY_CURRENT_USERSoftware[company name][game name].
Using the standard utilities regedit you can easily modify any values PlayerPrefs, thereby modifying the configuration and status of the game.
Roughly speaking, in this article we learned how to change the game. If you rummage a little in C#, you can fix the game as if you downloaded the cheats. Being installed on the user device, the game actually reveals all its textures, models and source code. Decompile the game and steal resources — it is only a matter of time.
Source: telegra.ph and habr.com