├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── LICENSE ├── README.md ├── osu!decoder.sln └── osu!decoder ├── BinaryPatch.cs ├── CliOptions.cs ├── Constants.cs ├── FodyWeavers.xml ├── Processors ├── AssemblyDecoder.cs ├── AssemblyStringDecoder.cs ├── IProcessor.cs └── ReferenceUpdater.cs ├── Program.cs ├── Properties └── AssemblyInfo.cs ├── app.config └── osu!decoder.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | 154 | # Windows Azure Build Output 155 | csx/ 156 | *.build.csdef 157 | 158 | # Windows Store app package directory 159 | AppPackages/ 160 | 161 | # Visual Studio cache files 162 | # files ending in .cache can be ignored 163 | *.[Cc]ache 164 | # but keep track of directories ending in .cache 165 | !*.[Cc]ache/ 166 | 167 | # Others 168 | ClientBin/ 169 | [Ss]tyle[Cc]op.* 170 | ~$* 171 | *~ 172 | *.dbmdl 173 | *.dbproj.schemaview 174 | *.pfx 175 | *.publishsettings 176 | node_modules/ 177 | orleans.codegen.cs 178 | 179 | # RIA/Silverlight projects 180 | Generated_Code/ 181 | 182 | # Backup & report files from converting an old project file 183 | # to a newer Visual Studio version. Backup files are not needed, 184 | # because we have git ;-) 185 | _UpgradeReport_Files/ 186 | Backup*/ 187 | UpgradeLog*.XML 188 | UpgradeLog*.htm 189 | 190 | # SQL Server files 191 | *.mdf 192 | *.ldf 193 | 194 | # Business Intelligence projects 195 | *.rdl.data 196 | *.bim.layout 197 | *.bim_*.settings 198 | 199 | # Microsoft Fakes 200 | FakesAssemblies/ 201 | 202 | # Node.js Tools for Visual Studio 203 | .ntvs_analysis.dat 204 | 205 | # Visual Studio 6 build log 206 | *.plg 207 | 208 | # Visual Studio 6 workspace options file 209 | *.opt 210 | 211 | # Visual Studio LightSwitch build output 212 | **/*.HTMLClient/GeneratedArtifacts 213 | **/*.DesktopClient/GeneratedArtifacts 214 | **/*.DesktopClient/ModelManifest.xml 215 | **/*.Server/GeneratedArtifacts 216 | **/*.Server/ModelManifest.xml 217 | _Pvt_Extensions 218 | 219 | \.idea/ 220 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # This file is a template, and might need editing before it works on your project. 2 | # The following script will work for any project that can be built from command line by msbuild 3 | # It uses powershell shell executor, so you need to add the following line to your config.toml file 4 | # (located in gitlab-runner.exe directory): 5 | # shell = "powershell" 6 | # 7 | # The script is composed of 3 stages: build, test and deploy. 8 | # 9 | # The build stage restores NuGet packages and uses msbuild to build the exe and msi 10 | # One major issue you'll find is that you can't build msi projects from command line 11 | # if you use vdproj. There are workarounds building msi via devenv, but they rarely work 12 | # The best solution is migrating your vdproj projects to WiX, as it can be build directly 13 | # by msbuild. 14 | # 15 | # The test stage runs nunit from command line against Test project inside your solution 16 | # It also saves the resulting TestResult.xml file 17 | # 18 | # The deploy stage copies the exe and msi from build stage to a network drive 19 | # You need to have the network drive mapped as Local System user for gitlab-runner service to see it 20 | # The best way to persist the mapping is via a scheduled task (see: https://stackoverflow.com/a/7867064/1288473), 21 | # running the following batch command: net use P: \\x.x.x.x\Projects /u:your_user your_pass /persistent:yes 22 | 23 | 24 | # place project specific paths in variables to make the rest of the script more generic 25 | variables: 26 | EXE_RELEASE_FOLDER: 'YourApp\bin\Release' 27 | MSI_RELEASE_FOLDER: 'Setup\bin\Release' 28 | TEST_FOLDER: 'Tests\bin\Release' 29 | DEPLOY_FOLDER: 'P:\Projects\YourApp\Builds' 30 | 31 | NUGET_PATH: 'C:\NuGet\nuget.exe' 32 | MSBUILD_PATH: 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe' 33 | NUNIT_PATH: 'C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe' 34 | 35 | stages: 36 | - build 37 | - test 38 | - deploy 39 | 40 | build_job: 41 | stage: build 42 | only: 43 | - tags # the build process will only be started by git tag commits 44 | script: 45 | - '& "$env:NUGET_PATH" restore' # restore Nuget dependencies 46 | - '& "$env:MSBUILD_PATH" /p:Configuration=Release' # build the project 47 | artifacts: 48 | expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on 49 | paths: 50 | - '$env:EXE_RELEASE_FOLDER\YourApp.exe' # saving exe to copy to deploy folder 51 | - '$env:MSI_RELEASE_FOLDER\YourApp Setup.msi' # saving msi to copy to deploy folder 52 | - '$env:TEST_FOLDER\' # saving entire Test project so NUnit can run tests 53 | 54 | test_job: 55 | stage: test 56 | only: 57 | - tags 58 | script: 59 | - '& "$env:NUNIT_PATH" ".\$env:TEST_FOLDER\Tests.dll"' # running NUnit tests 60 | artifacts: 61 | expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on 62 | paths: 63 | - '.\TestResult.xml' # saving NUnit results to copy to deploy folder 64 | dependencies: 65 | - build_job 66 | 67 | deploy_job: 68 | stage: deploy 69 | only: 70 | - tags 71 | script: 72 | # Compose a folder for each release based on commit tag. 73 | # Assuming your tag is Rev1.0.0.1, and your last commit message is 'First commit' 74 | # the artifact files will be copied to: 75 | # P:\Projects\YourApp\Builds\Rev1.0.0.1 - First commit\ 76 | - '$commitSubject = git log -1 --pretty=%s' 77 | - '$deployFolder = $($env:DEPLOY_FOLDER) + "\" + $($env:CI_BUILD_TAG) + " - " + $commitSubject + "\"' 78 | 79 | # xcopy takes care of recursively creating required folders 80 | - 'xcopy /y ".\$env:EXE_RELEASE_FOLDER\YourApp.exe" "$deployFolder"' 81 | - 'xcopy /y ".\$env:MSI_RELEASE_FOLDER\YourApp Setup.msi" "$deployFolder"' 82 | - 'xcopy /y ".\TestResult.xml" "$deployFolder"' 83 | 84 | dependencies: 85 | - build_job 86 | - test_job 87 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "EazDecode"] 2 | path = EazDecode 3 | url = https://github.com/HoLLy-HaCKeR/EazDecode.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, HoLLy 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # osu!decoder 2 | Not affiliated with osu! or ppy Pty Ltd ;) 3 | 4 | ## What is this? 5 | This is a private tool I used to decrypt osu!'s symbol names, allowing me to view osu!'s code as if I got it from the original source. Since peppy changed his encryption key and it can no longer be considered public domain, I believe it is safe to publish this tool publicly. 6 | 7 | ## Usage 8 | It has a help menu, you can figure it out. You probably want to run your input through [EazFixer](https://github.com/HoLLy-HaCKeR/EazFixer) first. 9 | 10 | ## FAQ 11 | 12 | ### It doesn't work! 13 | As of 26/03/2019 (v3098), peppy has changed away from a (leaked) static encryption key used for encrypting symbol names. This tool will only work on osu! builds with a known encryption key. 14 | 15 | ### This looks decompiled! Did you even write this yourself?? 16 | You can tell from commit [3d15ab](https://github.com/HoLLy-HaCKeR/osu-decoder/commit/3d15ab56f221e7f005b3efe7adee5ea04f2a2db9) that the source in this repo started from a decompiled program. I was an idiot and just lost the original source a few years ago. 17 | -------------------------------------------------------------------------------- /osu!decoder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu!decoder", "osu!decoder\osu!decoder.csproj", "{7CDE3892-D6ED-4784-AC5C-560649D75F9A}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EazDecodeLib", "eazdecode\EazDecodeLib\EazDecodeLib.csproj", "{E4F62A91-08C4-451B-B8FD-6A5D951C7F7A}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7CDE3892-D6ED-4784-AC5C-560649D75F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {7CDE3892-D6ED-4784-AC5C-560649D75F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {7CDE3892-D6ED-4784-AC5C-560649D75F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {7CDE3892-D6ED-4784-AC5C-560649D75F9A}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {E4F62A91-08C4-451B-B8FD-6A5D951C7F7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {E4F62A91-08C4-451B-B8FD-6A5D951C7F7A}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {E4F62A91-08C4-451B-B8FD-6A5D951C7F7A}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {E4F62A91-08C4-451B-B8FD-6A5D951C7F7A}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {92FAA7E8-8C12-4E46-8CB3-DBE933213731} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /osu!decoder/BinaryPatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | using dnlib.DotNet.Emit; 6 | 7 | namespace osu_decoder_dnlib 8 | { 9 | internal class BinaryPatch 10 | { 11 | public static void PatchSignatureCheck(ModuleDefMD module) 12 | { 13 | bool found = false; 14 | foreach(TypeDef typeDef in module.Types.Where(a => a.Methods.Any(b => b.IsPinvokeImpl && b.ImplMap.Name == "WinVerifyTrust"))) 15 | { 16 | foreach (MethodDef methodDef in typeDef.Methods.Where(a => a.ReturnType.TypeName == "Boolean")) 17 | { 18 | Program.Verbose("Writing ret true to " + methodDef.FullName); 19 | methodDef.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldc_I4_1)); 20 | methodDef.Body.Instructions.Insert(1, new Instruction(OpCodes.Ret)); 21 | found = true; 22 | } 23 | } 24 | if (!found) 25 | Console.WriteLine("WARNING: did not write any changes."); 26 | } 27 | 28 | public static void PatchExecutableName(ModuleDefMD module) 29 | { 30 | try 31 | { 32 | var realMain = (MethodDef)module.EntryPoint.Body.Instructions[0].Operand; 33 | 34 | Program.Verbose("Patching name check in " + realMain.FullName); 35 | IList instructions = realMain.Body.Instructions; 36 | 37 | //Patch out all method name check instructions 38 | int index = instructions.IndexOf(instructions.Last(a => a.OpCode == OpCodes.Brfalse_S)); 39 | for (int i = -4; i < 10; i++) 40 | { 41 | instructions[i + index].OpCode = OpCodes.Nop; 42 | } 43 | } 44 | catch (Exception ex) 45 | { 46 | Console.WriteLine("Could not patch: " + ex.Message); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /osu!decoder/CliOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CommandLine; 3 | using CommandLine.Text; 4 | 5 | namespace osu_decoder_dnlib 6 | { 7 | internal class CliOptions 8 | { 9 | [ValueOption(0)] 10 | public string Input { get; set; } 11 | 12 | [Option('o', "output", HelpText = "Path of the output file")] 13 | public string Output { get; set; } 14 | 15 | [Option('v', "verbose", HelpText = "Prints more output.")] 16 | public bool Verbose { get; set; } 17 | 18 | [Option('d', "debug", HelpText = "Prints a lot more output, you should pipe this to a file.")] 19 | public bool Debug { get; set; } 20 | 21 | [Option('s', "sourcemap", HelpText = "Writes a file containing an original:decoded source map.")] 22 | public bool Sourcemap { get; set; } 23 | 24 | [Option('r', "dry-run", HelpText = "Do not write decoded executable to disk.")] 25 | public bool DryRun { get; set; } 26 | 27 | [Option('n', "no-types", HelpText = "Don't decrypt types, but strings")] 28 | public bool NoTypes { get; set; } 29 | 30 | [Option('p', "password", HelpText = "Specify a custom password")] 31 | public string Password { get; set; } = "recorderinthesandybridge"; 32 | 33 | [Option("exp-patch", HelpText = "Apply patch to remove signature and filename check", DefaultValue = true)] 34 | public bool ExperimentPatch { get; set; } 35 | 36 | [HelpOption] 37 | public string GetHelp() 38 | { 39 | HelpText helpText = new HelpText(); 40 | helpText.Heading = new HeadingInfo("osu!decoder", "v1.4"); 41 | helpText.Copyright = new CopyrightInfo("HoLLy/JustM3", 2017); 42 | helpText.AdditionalNewLineAfterOption = false; 43 | helpText.AddDashesToOption = true; 44 | helpText.MaximumDisplayWidth = Console.BufferWidth; 45 | helpText.AddPreOptionsLine("\nExample usage:"); 46 | helpText.AddPreOptionsLine("\t- osu!decoder osu!.exe"); 47 | helpText.AddPreOptionsLine("\t- osu!decoder osu!.exe -v -p updated_password -o c:/newosu!.exe"); 48 | helpText.AddOptions(this); 49 | helpText.AddPostOptionsLine("Please do not distribute. If you have this, it means I trust you :)"); 50 | return helpText; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /osu!decoder/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace osu_decoder_dnlib 5 | { 6 | internal static class Constants 7 | { 8 | public static readonly Regex RegexObfuscated = new Regex("^#=[a-zA-Z0-9_$]+={0,2}$", RegexOptions.Compiled); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /osu!decoder/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /osu!decoder/Processors/AssemblyDecoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | using EazDecodeLib; 6 | using static osu_decoder_dnlib.Constants; 7 | 8 | namespace osu_decoder_dnlib.Processors 9 | { 10 | internal class AssemblyDecoder : IProcessor 11 | { 12 | public Dictionary SrcMap; 13 | 14 | private readonly CryptoHelper _crypto; 15 | 16 | public AssemblyDecoder(CryptoHelper crypto) 17 | { 18 | _crypto = crypto; 19 | } 20 | 21 | public void Process(ModuleDef def) 22 | { 23 | SrcMap = new Dictionary(); 24 | 25 | DecodeRecursive(def.Types); 26 | } 27 | 28 | private void DecodeRecursive(IEnumerable members) 29 | { 30 | foreach (IFullName fullName in members) { 31 | switch (fullName) { 32 | case TypeDef t: 33 | DecodeSingle(t); 34 | 35 | foreach (GenericParam generic in t.GenericParameters) 36 | DecodeSingle(generic); 37 | 38 | DecodeRecursive(t.Events); 39 | DecodeRecursive(t.Fields); 40 | DecodeRecursive(t.Methods); 41 | DecodeRecursive(t.NestedTypes); 42 | DecodeRecursive(t.Properties); 43 | 44 | foreach (InterfaceImpl impl in t.Interfaces) 45 | DecodeSingle(impl.Interface); 46 | break; 47 | case MethodDef m: 48 | DecodeSingle(m); 49 | 50 | foreach (GenericParam generic in m.GenericParameters) 51 | DecodeSingle(generic); 52 | foreach (Parameter param in m.Parameters) 53 | DecodeSingle(param); 54 | break; 55 | case FieldDef _: 56 | case PropertyDef _: 57 | case EventDef _: 58 | DecodeSingle(fullName); 59 | break; 60 | default: 61 | Program.Verbose("Unhandled type: " + fullName.GetType()); 62 | DecodeSingle(fullName); 63 | break; 64 | } 65 | } 66 | } 67 | 68 | private void DecodeSingle(IFullName param) 69 | { 70 | if (!RegexObfuscated.IsMatch(param.Name)) return; 71 | 72 | string text = _crypto.Decrypt(param.Name); 73 | SrcMap[param.Name] = text; 74 | if (param is TypeDef typeDef && text.Contains('.')) { 75 | typeDef.Namespace = text.Substring(0, text.LastIndexOf('.')); 76 | typeDef.Name = text.Substring(text.LastIndexOf('.') + 1); 77 | } 78 | else if (param is TypeSpec spec) 79 | DecodeSingle(spec.ScopeType); 80 | else 81 | param.Name = text; 82 | } 83 | 84 | private void DecodeSingle(IVariable param) 85 | { 86 | if (!RegexObfuscated.IsMatch(param.Name)) return; 87 | 88 | string text = _crypto.Decrypt(param.Name); 89 | SrcMap[param.Name] = text; 90 | param.Name = text; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /osu!decoder/Processors/AssemblyStringDecoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | using EazDecodeLib; 6 | using static osu_decoder_dnlib.Constants; 7 | 8 | namespace osu_decoder_dnlib.Processors 9 | { 10 | internal class AssemblyStringDecoder : IProcessor 11 | { 12 | private readonly CryptoHelper _crypto; 13 | 14 | public AssemblyStringDecoder(CryptoHelper crypto) 15 | { 16 | _crypto = crypto; 17 | } 18 | 19 | public void Process(ModuleDef def) 20 | { 21 | UpdateRecursive(def.Types); 22 | } 23 | 24 | private void UpdateRecursive(IEnumerable members) 25 | { 26 | foreach (ITypeOrMethodDef def in members) 27 | { 28 | switch (def) 29 | { 30 | case TypeDef t: 31 | UpdateRecursive(t.Methods); 32 | UpdateRecursive(t.NestedTypes); 33 | break; 34 | case MethodDef m: 35 | UpdateSingle(m); 36 | break; 37 | } 38 | } 39 | } 40 | 41 | private void UpdateSingle(MethodDef method) 42 | { 43 | //Update calls to methods in method bodies 44 | if (!method.HasBody) return; 45 | foreach (Instruction i in method.Body.Instructions) 46 | { 47 | if (i.Operand == null || !(i.Operand is string s)) continue; 48 | 49 | i.Operand = RegexObfuscated.Replace(s, match => _crypto.Decrypt(match.Value)); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /osu!decoder/Processors/IProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using dnlib.DotNet; 7 | 8 | namespace osu_decoder_dnlib.Processors 9 | { 10 | internal interface IProcessor 11 | { 12 | void Process(ModuleDef def); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /osu!decoder/Processors/ReferenceUpdater.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | using static osu_decoder_dnlib.Constants; 6 | 7 | namespace osu_decoder_dnlib.Processors 8 | { 9 | internal class ReferenceUpdater : IProcessor 10 | { 11 | private readonly Dictionary _srcMap; 12 | 13 | public ReferenceUpdater(Dictionary srcMap) 14 | { 15 | _srcMap = srcMap; 16 | } 17 | 18 | public void Process(ModuleDef def) => UpdateRecursive(def.Types); 19 | 20 | private void UpdateRecursive(IEnumerable members) 21 | { 22 | foreach (ITypeOrMethodDef def in members) 23 | { 24 | switch (def) 25 | { 26 | case TypeDef t: 27 | UpdateRecursive(t.Methods); 28 | UpdateRecursive(t.NestedTypes); 29 | break; 30 | case MethodDef m: 31 | UpdateSingle(m); 32 | break; 33 | } 34 | } 35 | } 36 | 37 | private void UpdateSingle(MethodDef method) 38 | { 39 | //Update the Overrides for interface implementations 40 | foreach (MethodOverride methodOverride in method.Overrides) { 41 | var baseMethod = methodOverride.MethodDeclaration; 42 | 43 | if (RegexObfuscated.IsMatch(baseMethod.Name)) { 44 | baseMethod.Name = _srcMap[baseMethod.Name]; 45 | } 46 | } 47 | 48 | //Update calls to methods in method bodies 49 | if (!method.HasBody) return; 50 | foreach (Instruction i in method.Body.Instructions) { 51 | if (i.Operand == null || !(i.Operand is IFullName f)) continue; 52 | 53 | if (RegexObfuscated.IsMatch(f.Name)) { 54 | f.Name = _srcMap[f.Name]; 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /osu!decoder/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using CommandLine; 5 | using dnlib.DotNet; 6 | using EazDecodeLib; 7 | using osu_decoder_dnlib.Processors; 8 | 9 | namespace osu_decoder_dnlib 10 | { 11 | internal class Program 12 | { 13 | internal static CliOptions Options = new CliOptions(); 14 | 15 | private static void Main(string[] args) 16 | { 17 | if (!Parser.Default.ParseArguments(args, Options) || string.IsNullOrWhiteSpace(Options.Input)) 18 | { 19 | Console.WriteLine(Options.GetHelp()); 20 | return; 21 | } 22 | Verbose("Verbose output enabled."); 23 | 24 | string input = Options.Input; 25 | 26 | Console.WriteLine("Loading crypto..."); 27 | var crypto = new CryptoHelper(Program.Options.Password); 28 | 29 | Console.WriteLine("Loading assembly..."); 30 | ModuleDefMD moduleDefMD = ModuleDefMD.Load(input); 31 | 32 | Verbose("Total amount of types in root: " + moduleDefMD.Types.Count); 33 | 34 | Dictionary sourceMap = null; 35 | if (Options.ExperimentPatch) 36 | { 37 | Console.WriteLine("Patching Authenticode/WinVerifyTrust..."); 38 | BinaryPatch.PatchSignatureCheck(moduleDefMD); 39 | 40 | Console.WriteLine("Patching executable name check..."); 41 | BinaryPatch.PatchExecutableName(moduleDefMD); 42 | } 43 | 44 | if (!Options.NoTypes) 45 | { 46 | Console.WriteLine("Decrypting..."); 47 | var ass = new AssemblyDecoder(crypto); 48 | ass.Process(moduleDefMD); 49 | 50 | Console.WriteLine("Updating references..."); 51 | new ReferenceUpdater(sourceMap = ass.SrcMap).Process(moduleDefMD); 52 | } 53 | else 54 | { 55 | Console.WriteLine("Decrypting strings..."); 56 | new AssemblyStringDecoder(crypto).Process(moduleDefMD); 57 | 58 | } 59 | 60 | 61 | int periodIdx = input.LastIndexOf('.'); 62 | if (periodIdx == -1) 63 | periodIdx = input.Length; 64 | string fileOut = string.IsNullOrEmpty(Options.Output) 65 | ? input.Substring(0, periodIdx) + "-decrypted" + input.Substring(periodIdx) 66 | : Options.Output; 67 | 68 | if (Options.Sourcemap && sourceMap != null) 69 | { 70 | string srcmap = $"{fileOut}.srcmap"; 71 | Console.WriteLine("Writing sourcemap to " + srcmap); 72 | 73 | using (StreamWriter sw = new StreamWriter(srcmap)) 74 | foreach (var entry in sourceMap) 75 | sw.WriteLine($"{entry.Key}:{entry.Value}"); 76 | } 77 | 78 | if (!Options.DryRun) 79 | { 80 | Console.WriteLine("Writing new assembly..."); 81 | moduleDefMD.Write(fileOut); 82 | Console.WriteLine("Written to " + fileOut); 83 | } 84 | else 85 | { 86 | Console.WriteLine("Dry run, not writing new assembly to disk"); 87 | } 88 | } 89 | 90 | public static void Verbose(string input) 91 | { 92 | if (Options.Verbose || Options.Debug) 93 | Console.WriteLine("[v] " + input); 94 | } 95 | 96 | public static void Debug(string input) 97 | { 98 | if (Options.Debug) 99 | Console.WriteLine("[D] " + input); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /osu!decoder/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Runtime.Versioning; 7 | 8 | [assembly: AssemblyVersion("1.0.0.0")] 9 | [assembly: Guid("3f4b7f2f-5319-4bf2-b0c8-fe6f539fbf0e")] 10 | [assembly: ComVisible(false)] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCopyright("Copyright © HoLLy 2017")] 13 | [assembly: AssemblyProduct("osu!decoder dnlib")] 14 | [assembly: AssemblyCompany("HoLLy")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyTitle("osu!decoder")] 18 | #if DEBUG 19 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints 20 | | DebuggableAttribute.DebuggingModes.DisableOptimizations 21 | | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] 22 | #else 23 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 24 | #endif 25 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 26 | [assembly: CompilationRelaxations(8)] 27 | [assembly: AssemblyFileVersion("1.0.0.0")] 28 | -------------------------------------------------------------------------------- /osu!decoder/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /osu!decoder/osu!decoder.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7CDE3892-D6ED-4784-AC5C-560649D75F9A} 8 | Exe 9 | osu_decoder_dnlib 10 | osu!decoder 11 | v4.6.1 12 | 512 13 | osu_decoder_dnlib.Program 14 | 15 | 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | {e4f62a91-08c4-451b-b8fd-6a5d951c7f7a} 61 | EazDecodeLib 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | all 71 | runtime; build; native; contentfiles; analyzers; buildtransitive 72 | 73 | 74 | 75 | all 76 | runtime; build; native; contentfiles; analyzers; buildtransitive 77 | 78 | 79 | 80 | --------------------------------------------------------------------------------