Skip to content

Commit

Permalink
Merge pull request #199 from sunnamed434/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
sunnamed434 authored Aug 25, 2024
2 parents e64e54d + 46bba8b commit 61cc6dd
Show file tree
Hide file tree
Showing 59 changed files with 429 additions and 202 deletions.
10 changes: 9 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ indent_style = space

[*.{proj,csproj,vbproj,props,targets,resx,vsixmanifest}]
indent_size = 2
indent_style = space
indent_style = space

[*.cs]
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0290
csharp_style_prefer_primary_constructors = false
dotnet_diagnostic.IDE0290.severity = none

# https://www.jetbrains.com/help/rider/ConvertToPrimaryConstructor.html
resharper_convert_to_primary_constructor_highlighting = none
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[![MIT License][image_license]][license]
[![BitMono Discord][image_bitmono_discord]][bitmono_discord]

BitMono is a free, open-source C# obfuscator designed mainly for Mono, a version of the .NET framework used by Unity and other platforms. You can use it with the full .NET framework, but some features might not work as expected. Some protections work with .NET Core but not Mono.
BitMono is a free, open-source C# obfuscator that was initially designed and intended mainly for Mono, however, now you're feel free to use it for any .NET app, but, be careful some protections work on .NET Framework, some on .NET, some on Mono, some on Unity only.

BitMono uses [AsmResolver][asmresolver] instead of dnlib for handling assemblies. If you have questions or issues, please let us know [here][bitmono_issues]. Download the latest version of BitMono [here][bitmono_releases].
BitMono uses [AsmResolver][asmresolver] instead of [dnlib][dnlib] (which we used in the past) for handling assemblies. If you have questions or issues, please let us know [here][bitmono_issues]. Download the latest version of BitMono [here][bitmono_releases].

You can also use BitMono as an engine to build custom obfuscators. It is built using dependency injection (DI) using Autofac and follows the latest C# best practices.

Expand Down Expand Up @@ -83,6 +83,16 @@ Read the **[docs][bitmono_docs]** to read protection, functionality, and more.

## Usage

### Download

Go and get [Latest BitMono Release][bitmono_latest_release] and download preferred archive file, and make sure to select the similar or same Target Framework of the app that you are going to protect, for example:

- Your Target File is for .NET 8 then use BitMono for .NET 8 `BitMono-v0.25.3+e64e54d3-CLI-net8.0-win-x64.zip`
- Your Target File is for .netstandard then use BitMono for .NET Framework or .NET 8 `BitMono-v0.25.3+e64e54d3-CLI-net8.0-win-x64.zip`
- Your Target File is .NET Framework then use BitMono for .NET Framework `BitMono-v0.25.3+e64e54d3-CLI-net462-win-x64.zip`

If you select wrong BitMono build you have a risk that your file going to be protected incorrectly, because you use different target framework build.

### Pre-Require

Set one of setting from `protections.json` to `true`.
Expand Down Expand Up @@ -188,6 +198,7 @@ Credits
[license]: https://github.com/sunnamed434/BitMono/blob/main/LICENSE
[previews]: https://github.com/sunnamed434/BitMono/blob/main/PREVIEWS.md
[asmresolver]: https://github.com/Washi1337/AsmResolver
[dnlib]: https://github.com/0xd4d/dnlib
[bitmono_issues]: https://github.com/sunnamed434/BitMono/issues
[bitmono_releases]: https://github.com/sunnamed434/BitMono/releases
[bitmono_docs]: https://bitmono.readthedocs.io/en/latest/
Expand All @@ -207,6 +218,7 @@ Credits
[author_kao_blog]: https://lifeinhex.com/
[author_drakonia]: https://github.com/dr4k0nia
[author_sunnamed434]: https://github.com/sunnamed434
[bitmono_latest_release]: https://github.com/sunnamed434/BitMono/releases/latest
[bitmono_discord]: https://discord.gg/sFDHd47St4

[troubleshooting]: https://github.com/sunnamed434/BitMono/blob/main/troubleshooting.md
Expand Down
15 changes: 15 additions & 0 deletions docs/source/developers/native-code.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Native Code
###########

If you want to use a native code in the protection you must do the following:


.. code-block:: csharp
[ConfigureForNativeCode] // Add this attribute on top of the protection class
public class CustomProtection : Protection
A good example is ``UnmanagedString`` protection. It uses native code to encrypt strings. You can find the source code in the ``UnmanagedString`` file.
This thing is so important to do, before actually it was automatically done before the obfuscation without any attributes, however we found that this might break an app, because it changes the architecture of the app, so we decided to make it optional.
23 changes: 12 additions & 11 deletions docs/source/developers/obfuscation-execution-order.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ BitMono uses its own obfuscation execution order which is good to be known, and
2. Output Information about BitMono (example, is it intended for .NET Core or Mono or .NET Framework, etc.) and running OS, etc.
3. Output Compatibility Issues in case of module is built for .NET Framework, but BitMono is running on .NET Core, or vice versa.
4. Sort Protections
5. Basic output information about Protections
6. Elapsed time counter
7. Resolve References
8. Expand Macros
10. Run Protection, PipelineProtection and child pipeline protections
5. Information about Protections
6. Configuration for Native Code
7. Elapsed time counter
8. Resolve References
9. Expand Macros
11. Run Protection, PipelineProtection and child pipeline protections


.. code-block:: csharp
Expand All @@ -21,16 +22,16 @@ BitMono uses its own obfuscation execution order which is good to be known, and
public class Pipeline : PipelineProtection
11. Optimize Macros
12. [ObfuscationAttribute] cleanup
13. Create PE Image
14. Write Module
15. Run Packers
12. Optimize Macros
13. [ObfuscationAttribute] cleanup
14 Create PE Image
15. Write Module
16. Run Packers
.. code-block:: csharp
public class Packer : PackerProtection
16. Output Elapsed Time since obfuscation
17. Output Elapsed Time since obfuscation
14 changes: 11 additions & 3 deletions docs/source/faq/unable-to-reference-after-protect.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Unable to reference after protect?
==================================
Unable to Reference After Protection
====================================

You're probably stuck on a problem, when you want to use your ``.dll`` after protection, you protect it via BitMono and try to reference it in IDE or whatever else, you're doing a bit wrong, you need to have an original copy and use it as a reference, and as output folder (i.e Release\...) drop there a protected version of your ``.dll``.
If you're having trouble referencing your ``.dll`` file after protecting it with BitMono, follow these steps:

1. **Keep an Original Copy**: Always keep an original, unprotected copy of your ``.dll`` file. This will be used as a reference in your IDE or other tools.

2. **Protect the DLL**: Use BitMono to protect your ``.dll`` file.

3. **Set Up Output Folder**: In your output folder (e.g., ``Release\...``), place the protected version of your ``.dll`` file.

By following these steps, you can ensure that your project references the original ``.dll`` while deploying the protected version.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Table of Contents:
developers/obfuscation-execution-order
developers/which-base-protection-select
developers/protection-runtime-moniker
developers/native-code
developers/do-not-resolve-members
developers/configuration

Expand Down
6 changes: 6 additions & 0 deletions docs/source/protections/antide4dot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ AntiDe4dot

How it works?
-------------

Protection adds multiple attributes of known obfuscators/protectors and as a result fools de4dot.

Protection Type
---------------

The protection type is `Protection`.


.. warning::

Expand Down
8 changes: 7 additions & 1 deletion docs/source/protections/antidebugbreakpoints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ AntiDebugBreakpoints

How it works?
-------------
Protection adds things in method bodies that check if from the last execution passed more than the const value, then as a result the program will be crashed.

Protection adds things in method bodies that check if from the last execution passed more than the const value, then as a result the program will be crashed.

Protection Type
---------------

The protection type is `Protection`.
6 changes: 6 additions & 0 deletions docs/source/protections/antidecompiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ AntiDecompiler

How it works?
-------------

Protection looks for a nested type in <Module> and sets non-public accessibility attributes, according to ECMA CIL standard nested types should always have one of them applied, but Mono doesn't care about this standard.

That means if someone will try to analyze the protected nested type, dnSpy will crash, however in a newer version, this exploit was fixed.

Protection Type
---------------

The protection type is `Packer`.


.. warning::

Expand Down
8 changes: 7 additions & 1 deletion docs/source/protections/antiildasm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ AntiILdasm

How it works?
-------------
Protection adds ``[SuppressIldasmAttribute]`` which prevents the Ildasm (IL Disassembler) from disassembling the protected file.

Protection adds ``[SuppressIldasmAttribute]`` which prevents the Ildasm (IL Disassembler) from disassembling the protected file.

Protection Type
---------------

The protection type is `Protection`.
7 changes: 6 additions & 1 deletion docs/source/protections/billionnops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ As a result when someone will try to analyze this method will cause a crashed dn
Cons
----

Be careful because this protection will increase a file size a lot, and a bigger file size will cause more questions by users, most of us when see a big file size think that this file is obfuscated.
Be careful because this protection will increase a file size a lot, and a bigger file size will cause more questions by users, most of us when see a big file size think that this file is obfuscated.

Protection Type
---------------

The protection type is `Protection`.
6 changes: 6 additions & 0 deletions docs/source/protections/bitdecompiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ BitDecompiler

How it works?
-------------

This protection works the same as BitDotnet protection, but with some fixes. However, since after Unity 2021 and higher it stopped working correctly and since many of users asked to figure something out we made this protection as a solution =)

Protection Type
---------------

The protection type is `Packer`.


.. warning::

Expand Down
6 changes: 6 additions & 0 deletions docs/source/protections/bitdotnet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ BitDotNet

How it works?
-------------

The protection uses dnlib exploit and modifies the file metadata (PE) to make it unrecognizable for dnSpy, as the result, at first sight, it will look like not a .NET file, for example, a C++ file.

Mono doesn't care about the thing which dnlib care about, and because of that it does what it does

Protection Type
---------------

The protection type is `Packer`.


.. warning::

Expand Down
6 changes: 6 additions & 0 deletions docs/source/protections/bitmethoddotnet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ BitMethodDotnet

How it works?
-------------

Protection adds invalid IL code in the file, as the result in the old dnSpy version it's going to be harder to see the C# code of the method body.

Protection Type
---------------

The protection type is `Protection`.


.. warning::

Expand Down
6 changes: 6 additions & 0 deletions docs/source/protections/bitmono.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ BitMono

How it works?
-------------

Protection modifies the file metadata (PE) to make it unrecognizable for decompilers or other tools such as Detect It Easy, as the result most of the tools will be fooled to think that this is an MS-DOS Executable as Detect It Easy does, decompilers will just not be able to open it up.

Mono doesn't care about the things which decompilers/tools care about, and because of that it does what it does.

Protection Type
---------------

The protection type is `Packer`.


.. warning::

Expand Down
8 changes: 7 additions & 1 deletion docs/source/protections/bittimedatestamp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ BitTimeDateStamp

How it works?
-------------
Protection modifies the file metadata (PE) and erases the TimeDateStamp, as the result no one will be able to know when this file was compiled.

Protection modifies the file metadata (PE) and erases the TimeDateStamp, as the result no one will be able to know when this file was compiled.

Protection Type
---------------

The protection type is `Packer`.
6 changes: 6 additions & 0 deletions docs/source/protections/calltocalli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ CallToCalli

How it works?
-------------

Protection replaces call opcode to calli and calls method by its function pointer.

Protection Type
---------------

The protection type is `Protection`.


.. warning::

Expand Down
8 changes: 7 additions & 1 deletion docs/source/protections/dotnethook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ DotNetHook

How it works?
-------------
Protection hooks methods, as a result, will call empty methods but, in fact, a completely different method will be called (the original one).

Protection hooks methods, as a result, will call empty methods but, in fact, a completely different method will be called (the original one).

Protection Type
---------------

The protection type is `Protection`.
8 changes: 7 additions & 1 deletion docs/source/protections/fullrenamer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ FullRenamer

How it works?
-------------

Protection renames types/methods/fields, however, ignores things such as reflection, Unity Methods (Update/FixedUpdate/LateUpdate, i.e all of them), overrides from Thanking (OV_methodName), and the most popular frameworks for plugin development in Unturned and Rust on GitHub - RocketMod, OpenMod, and rust-oxide-umod, you even could specify your methods/types to ignore.

If you want you can easily configure `criticals.json` to ignore strings and lot of stuff.

Be careful, because renamer is tricky protection, not always useful, and does not always work properly. But, if you configure BitMono correctly Renamer can be a great protection (I'm about big projects, not crackmes).
Be careful, because renamer is tricky protection, not always useful, and does not always work properly. But, if you configure BitMono correctly Renamer can be a great protection (I'm about big projects, not crackmes).

Protection Type
---------------

The protection type is `Protection`.
8 changes: 7 additions & 1 deletion docs/source/protections/nonamespaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ NoNamespaces

How it works?
-------------
Protection removes all namespaces.

Protection removes all namespaces.

Protection Type
---------------

The protection type is `Protection`.
8 changes: 7 additions & 1 deletion docs/source/protections/objectreturntype.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ ObjectReturnType

How it works?
-------------
Protection changes the nonvoid method return types to object return types.

Protection changes the nonvoid method return types to object return types.

Protection Type
---------------

The protection type is `Protection`.
6 changes: 6 additions & 0 deletions docs/source/protections/stringsencryption.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ StringsEncryption

How it works?
-------------

Protection encrypts strings using basic AES encryption, but not everyone like it because it makes the worse performance of application, but can be used with AntiDecompiler to crash dnSpy while analyzing the used class, also makes the RVA of the byte[] 0

Protection Type
---------------

The protection type is `Protection`.


.. warning::

Expand Down
Loading

0 comments on commit 61cc6dd

Please sign in to comment.