Breaking: get the source code, textures and models in games on Unity

Breaking: get the source code, textures and models in games on Unity

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 .assets and .resources. The most popular tool for viewing such files and extracting resources Unity Assets Explorer.

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 Windows Texture Viewer.



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 official website of the author on github. Also at the end of the article will be a link to download the program from the article.

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 — TYK

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: Assembly-CSharp.dll, Assembly-CSharp-firstpass.dll and Assembly-UnityScript.dll.

For decompiling and viewing the managed-code .NET libraries (which are our victims), there are quite convenient and free utility: IlSpy and dotPeek.

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 3D Ripper DX you can extract all this information and save in a format readable by 3D-editors (e.g. 3D Studio Max). Note that the program is not the easiest to handle — may have to consult the documentation.

Break Open PlayerPrefs

PlayerPrefs is a class from the standard library for Unity that allows you to save data in non-volatile memory device. It is often used by developers to store various settings, achievements, progress and other information about the game state. On Windows this data is stored in the registry at the following path: 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.

Conclusion

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


46 Views

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments


Do NOT follow this link or you will be banned from the site!
0
Would love your thoughts, please comment.x
()
x

Spelling error report

The following text will be sent to our editors: