Skip to content

Commit

Permalink
Merge pull request #144 from sunnamed434/dev
Browse files Browse the repository at this point in the history
Bump new version 0.18.0
  • Loading branch information
sunnamed434 committed Sep 2, 2023
2 parents 0cfdf3b + da7f393 commit dedbc7b
Show file tree
Hide file tree
Showing 29 changed files with 249 additions and 176 deletions.
1 change: 1 addition & 0 deletions BitMono.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
props\SharedProjectProps.props = props\SharedProjectProps.props
props\SharedPackages.props = props\SharedPackages.props
build.md = build.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D87066C4-1144-4BD8-96E9-9F4676001397}"
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

| Versions: |
|-------------------------------|
| [0.18.0-alpha](#0180-alpha33) |
| [0.16.2-alpha](#0162-alpha31) |
| [0.16.1-alpha](#0161-alpha30) |
| [0.16.0-alpha](#0160-alpha29) |
Expand All @@ -29,6 +30,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## 0.18.0-alpha.33
2023-09-02

### Added
- Add ForceObfuscation, ReferencesDirectoryName, OutputDirectoryName, and ClearCLI options in the obfuscation.json
- More detailed info how to build the solution
- .NET 6.0 Support

### Fixed
- BitMono drag and drop exception [#135](https://github.com/sunnamed434/BitMono/issues/135)
- First line of the CLI shows working directory [#137](https://github.com/sunnamed434/BitMono/issues/137)
- .NET 5 exceptions [#138](https://github.com/sunnamed434/BitMono/issues/138)

## 0.16.2-alpha.31
2023-07-19

Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<img src="https://raw.githubusercontent.com/sunnamed434/BitMono/main/resources/logo/BitMonoLogo.png" alt="BitMono logo" width="180" /><br>
Free open-source obfuscator for Mono<br>
Free open-source obfuscator that targetting Mono, and maybe whole .NET<br>
</p>

## BitMono
Expand All @@ -12,7 +12,7 @@
[![MIT License][image_license]][license]
[![BitMono Discord][image_bitmono_discord]][bitmono_discord]

BitMono is a free open-source C# obfuscator that in most cases works **only** with Mono - well known as a fork of .NET framework (which runs popular platforms such as Unity, etc), you can still use this for a whole .NET, but be careful that something working not as intentional, because the main target of the this project is Mono. Which uses **[AsmResolver][asmresolver]** for assembly manipulation (not a dnlib as you might already think). If you have any questions/issues please let me know **[there][bitmono_issues]**. You can install the latest version of BitMono **[here][bitmono_releases]**.
BitMono is a free open-source C# obfuscator that in most cases works **only** with Mono - well known as a fork of .NET framework (which runs popular platforms such as Unity, etc), you can still use this for a whole .NET, but be careful that something working not as intentional, because the main target of the this project is Mono (actually some protections don't work with Mono but work with .NET Core). Which uses **[AsmResolver][asmresolver]** for assembly manipulation (not a dnlib as you might already think). If you have any questions/issues please let me know **[there][bitmono_issues]**. You can install the latest version of BitMono **[here][bitmono_releases]**.

<p align="center">
<img src="https://raw.githubusercontent.com/sunnamed434/BitMono/main/resources/images/preview/before-after.png"
Expand Down Expand Up @@ -135,11 +135,22 @@ $ BitMono.CLI -f C:\specially_created_folder_for_obfuscation/your_app.exe -l C:\
Want more? Simply read the **[docs][bitmono_docs]**.

### Detailed build status
If you want to build the BitMono by your own - [click here for detailed info](https://raw.githubusercontent.com/sunnamed434/BitMono/main/build.md)

| Branch | AppVeyor |
|--------|-------------------------------------------------------------|
| main | [![Build status][image_appveyor_main]][appveyor_main_build] |
| dev | [![Build status][image_appveyor_dev]][appveyor_dev_build] |

### Supported Frameworks
Mono is supported obviously (some protections don't support Mono), however if you use BitMono for .NET (Core) or higher versions be careful because some protections won't work - you will be notified about that by BitMono when using not supported protections for yours running target framework.

| Framework | Version |
|----------------|---------|
| .NET (Core) | 6.0 |
| .NET Framework | 462 |
| netstandard | 2.0 |

Credits
-------
**[0x59R11][author_0x59r11]** for his acquaintance in big part of **[BitDotNet][bitdotnet_source]** that breaks files for mono executables!
Expand Down
20 changes: 20 additions & 0 deletions build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Build the BitMono
First of all, if you just need the compiled binaries simply install them [right here][releases] - open the dropdown button `Assets`, and select the CLI/GUI.zip/7z file

### Build the solution
Recommended to install tools via Visual Studio installer, otherwise you can install those tools directly via provided links down below or just searching for it by yourself.

- [.NET Framework 462][net462]
- [Visual Studio 2022][vs2022]/[JetBrains Rider 2023][rider2023] or newer to build the solution
- [.NET 6.0 (Core)][net6]

### Help
If you have any issues/questions freely ask them [here][issues], or contact via:
- Email: sunnamed434@proton.me

[net462]: https://dotnet.microsoft.com/en-us/download/dotnet-framework/net462
[vs2022]: https://visualstudio.microsoft.com/downloads/
[rider2023]: https://www.jetbrains.com/rider/download/#section=windows
[net6]: https://dotnet.microsoft.com/en-us/download/dotnet/6.0
[releases]: https://github.com/sunnamed434/BitMono/releases
[issues]: https://github.com/sunnamed434/BitMono/issues
Binary file added packages.txt
Binary file not shown.
7 changes: 4 additions & 3 deletions props/SharedProjectProps.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/sunnamed434/BitMono</PackageProjectUrl>
<PackageOwners>sunnamed434</PackageOwners>
<PackageVersion>0.16.2-alpha.31</PackageVersion>
<BitMonoVersion>0.18.0-alpha.33</BitMonoVersion>
<PackageVersion>$(BitMonoVersion)</PackageVersion>
<Version>$(BitMonoVersion)</Version>
<InformationalVersion>$(BitMonoVersion)</InformationalVersion>
<RepositoryUrl>https://github.com/sunnamed434/BitMono</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>sunnamed434</Authors>
<Version>0.16.2-alpha.31</Version>
<InformationalVersion>0.16.2-alpha.31</InformationalVersion>
<Company>BitMono</Company>
<Copyright>sunnamed434</Copyright>
<LangVersion>10</LangVersion>
Expand Down
10 changes: 1 addition & 9 deletions src/BitMono.API/BitMono.API.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0;net462</TargetFrameworks>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\props\SharedProjectProps.props" />
<Import Project="$(MSBuildThisFileDirectory)..\..\props\SharedPackages.props" />

<ItemGroup>
<PackageReference Include="Autofac" Version="6.5.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0-eap1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="NullGuard.Fody" Version="3.1.0" PrivateAssets="All" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/BitMono.API/Resolvers/CustomAttributeResolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public class CustomAttributeResolve
{
[AllowNull]
[NullGuard.AllowNull]
public Dictionary<string, object>? NamedValues { get; set; }
[AllowNull]
[NullGuard.AllowNull]
public List<object>? FixedValues { get; set; }
public CustomAttribute? Attribute { get; set; }
}
29 changes: 12 additions & 17 deletions src/BitMono.CLI/BitMono.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,33 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0;net462</TargetFrameworks>
<ApplicationIcon>BitMonoLogo.ico</ApplicationIcon>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\props\SharedProjectProps.props" />
<Import Project="$(MSBuildThisFileDirectory)..\..\props\SharedProjectProps.props"/>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
<PackageReference Include="Costura.Fody" Version="5.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0-eap1" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="NullGuard.Fody" Version="3.1.1" />
<PackageReference Include="Serilog" Version="3.0.0-dev-01862" />
<PackageReference Include="Serilog.Sinks.Map" Version="1.0.2" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="NullGuard.Fody" Version="3.1.1"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BitMono.API\BitMono.API.csproj" />
<ProjectReference Include="..\BitMono.Host\BitMono.Host.csproj" />
<ProjectReference Include="..\BitMono.Obfuscation\BitMono.Obfuscation.csproj" />
<ProjectReference Include="..\BitMono.Protections\BitMono.Protections.csproj" />
<ProjectReference Include="..\BitMono.Runtime\BitMono.Runtime.csproj" />
<ProjectReference Include="..\BitMono.Shared\BitMono.Shared.csproj" />
<ProjectReference Include="..\BitMono.Utilities\BitMono.Utilities.csproj" />
<ProjectReference Include="..\BitMono.API\BitMono.API.csproj"/>
<ProjectReference Include="..\BitMono.Host\BitMono.Host.csproj"/>
<ProjectReference Include="..\BitMono.Obfuscation\BitMono.Obfuscation.csproj"/>
<ProjectReference Include="..\BitMono.Protections\BitMono.Protections.csproj"/>
<ProjectReference Include="..\BitMono.Runtime\BitMono.Runtime.csproj"/>
<ProjectReference Include="..\BitMono.Shared\BitMono.Shared.csproj"/>
<ProjectReference Include="..\BitMono.Utilities\BitMono.Utilities.csproj"/>
</ItemGroup>

<ItemGroup>
<EditorConfigFiles Remove="C:\Me\Github\BitMono\src\BitMono.CLI\.editorconfig" />
<EditorConfigFiles Remove="C:\Me\Github\BitMono\src\BitMono.CLI\.editorconfig"/>
</ItemGroup>

</Project>
78 changes: 47 additions & 31 deletions src/BitMono.CLI/Modules/CLIObfuscationNeedsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
public class CLIObfuscationNeedsFactory
{
private readonly string[] _args;
private readonly ObfuscationSettings _obfuscationSettings;
private readonly ILogger _logger;

public CLIObfuscationNeedsFactory(string[] args, ILogger logger)
public CLIObfuscationNeedsFactory(string[] args, ObfuscationSettings obfuscationSettings, ILogger logger)
{
_args = args;
_obfuscationSettings = obfuscationSettings;
_logger = logger.ForContext<CLIObfuscationNeedsFactory>();
}

Expand Down Expand Up @@ -45,54 +47,68 @@ public ObfuscationNeeds Create()
}
}

string dependenciesDirectoryName;
string outputDirectoryName;
var fileBaseDirectory = Path.GetDirectoryName(fileName);
var dependenciesDirectoryName = Path.Combine(fileBaseDirectory, "libs");
if (Directory.Exists(dependenciesDirectoryName) == false)
if (_obfuscationSettings.ForceObfuscation)
{
var specifyingDependencies = true;
while (specifyingDependencies)
dependenciesDirectoryName = fileBaseDirectory;
outputDirectoryName = fileBaseDirectory;
}
else
{
outputDirectoryName = Path.Combine(fileBaseDirectory, _obfuscationSettings.OutputDirectoryName);
dependenciesDirectoryName = Path.Combine(fileBaseDirectory, _obfuscationSettings.ReferencesDirectoryName);
if (Directory.Exists(dependenciesDirectoryName) == false)
{
try
var specifyingDependencies = true;
while (specifyingDependencies)
{
if (Directory.Exists(dependenciesDirectoryName))
try
{
_logger.Information("Dependencies (libs) successfully found automatically: {0}!", dependenciesDirectoryName);
specifyingDependencies = false;
break;
}

_logger.Information("Please, specify dependencies (libs) path: ");
var newDependenciesDirectoryName = PathFormatterUtility.Format(Console.ReadLine());
if (string.IsNullOrWhiteSpace(newDependenciesDirectoryName) == false)
{
if (Directory.Exists(newDependenciesDirectoryName))
if (Directory.Exists(dependenciesDirectoryName))
{
dependenciesDirectoryName = newDependenciesDirectoryName;
_logger.Information("Dependencies (libs) successfully specified: {0}!", newDependenciesDirectoryName);
_logger.Information("Dependencies (libs) successfully found automatically: {0}!",
dependenciesDirectoryName);
specifyingDependencies = false;
break;
}

_logger.Information("Please, specify dependencies (libs) path: ");
var newDependenciesDirectoryName = PathFormatterUtility.Format(Console.ReadLine());
if (string.IsNullOrWhiteSpace(newDependenciesDirectoryName) == false)
{
if (Directory.Exists(newDependenciesDirectoryName))
{
dependenciesDirectoryName = newDependenciesDirectoryName;
_logger.Information("Dependencies (libs) successfully specified: {0}!",
newDependenciesDirectoryName);
specifyingDependencies = false;
}
else
{
_logger.Information("Libs directory doesn't exist, please, try again!");
}
}
else
{
_logger.Information("Libs directory doesn't exist, please, try again!");
_logger.Information("Unable to specify empty (libs), please, try again!");
}
}
else
catch (Exception ex)
{
_logger.Information("Unable to specify empty (libs), please, try again!");
_logger.Information("Something went wrong while specifying the dependencies (libs) path: " +
ex);
}
}
catch (Exception ex)
{
_logger.Information("Something went wrong while specifying the dependencies (libs) path: " + ex);
}
}
}
else
{
_logger.Information("Dependencies (libs) directory was automatically found in: {0}!", dependenciesDirectoryName);
else
{
_logger.Information("Dependencies (libs) directory was automatically found in: {0}!",
dependenciesDirectoryName);
}
}

var outputDirectoryName = Path.Combine(fileBaseDirectory, "output");
Directory.CreateDirectory(outputDirectoryName);
Directory.CreateDirectory(dependenciesDirectoryName);
return new ObfuscationNeeds
Expand Down
44 changes: 32 additions & 12 deletions src/BitMono.CLI/Modules/CLIOptionsObfuscationNeedsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ namespace BitMono.CLI.Modules;
public class CLIOptionsObfuscationNeedsFactory
{
private readonly string[] _args;
private readonly ObfuscationSettings _obfuscationSettings;
private readonly ILogger _logger;

public CLIOptionsObfuscationNeedsFactory(string[] args, ILogger logger)
public CLIOptionsObfuscationNeedsFactory(string[] args,
ObfuscationSettings obfuscationSettings, ILogger logger)
{
_args = args;
_obfuscationSettings = obfuscationSettings;
_logger = logger.ForContext<CLIOptionsObfuscationNeedsFactory>();
}

Expand All @@ -26,21 +29,38 @@ public CLIOptionsObfuscationNeedsFactory(string[] args, ILogger logger)
return null;
}
var options = parserResult.Value;
if (File.Exists(options.File) == false)
var filePath = PathFormatterUtility.Format(options.File!);
if (File.Exists(filePath) == false)
{
_logger.Fatal("File cannot be found, please, try again!");
return null;
}
var fileBaseDirectory = Path.GetDirectoryName(options.File);
var needs = new ObfuscationNeeds();
needs.FileName = options.File!;
needs.FileBaseDirectory = fileBaseDirectory;
needs.ReferencesDirectoryName = options.Libraries?.IsNullOrEmpty() == false
? options.Libraries
: Path.Combine(fileBaseDirectory, "libs");
needs.OutputPath = options.Output?.IsNullOrEmpty() == false
? options.Output
: Path.Combine(fileBaseDirectory, "output");
ObfuscationNeeds needs;
var fileBaseDirectory = Path.GetDirectoryName(filePath);
if (_obfuscationSettings.ForceObfuscation)
{
needs = new ObfuscationNeeds
{
FileName = filePath,
FileBaseDirectory = fileBaseDirectory,
ReferencesDirectoryName = fileBaseDirectory,
OutputPath = fileBaseDirectory
};
}
else
{
needs = new ObfuscationNeeds
{
FileName = filePath,
FileBaseDirectory = fileBaseDirectory,
ReferencesDirectoryName = options.Libraries?.IsNullOrEmpty() == false
? options.Libraries
: Path.Combine(fileBaseDirectory, _obfuscationSettings.ReferencesDirectoryName),
OutputPath = options.Output?.IsNullOrEmpty() == false
? options.Output
: Path.Combine(fileBaseDirectory, _obfuscationSettings.OutputDirectoryName)
};
}

Directory.CreateDirectory(needs.OutputPath);
Directory.CreateDirectory(needs.ReferencesDirectoryName);
Expand Down

0 comments on commit dedbc7b

Please sign in to comment.