obfuz仓库只保留obfuz,将Samples、obfuz4hybridclr和DeobfuscatedStackTrace拆分为独立的仓库

1.x
walon 2025-06-02 09:48:44 +08:00
parent 1f74c8d65d
commit 39c9925cbc
614 changed files with 0 additions and 43222 deletions

View File

@ -1,37 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug | 描述问题**
A clear and concise description of what the bug is.
** Enviroment | 环境 **
- Unity Version: 202x.y.z
- com.code-philosophy.obfuz Version: 4.x.y
- Platform: Win 64 Standalone|Android|iOS| ...
**To Reproduce | 复制步骤 **
Please provide a reproduction project. Please try to reproduce this bug on the https://github.com/focus-creative-games/obfuz/tree/main/Samples/QuickStart. | 提供复现工程,请尽量在 https://github.com/focus-creative-games/obfuz/tree/main/Samples/QuickStart 项目上复现这个bug。
Steps to reproduce the behavior :
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior | 期望的结果**
A clear and concise description of what you expected to happen.
**Screenshots | 截图或者日志**
If applicable, add screenshots to help explain your problem.
**Additional context | 补充信息**
Add any other context about the problem here.

25
.gitignore vendored
View File

@ -1,25 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
**/Library/
**/Logs/
**/Temp/
**/Build-*/
**/Release-*/
**/Debug-*/
**/HybridCLRData/
**/.vs/
**/bin/
**/obj/
.vsconfig
**/UserSettings/
*.csproj
*.sln
packages-lock.json
/Samples/WorkWithHybridCLR/Assets/Obfuz/SymbolObfus/symbol-mapping.xml
/Samples/WorkWithHybridCLR/Assets/StreamingAssets/HotUpdate.dll.bytes

View File

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
</ItemGroup>
</Project>

View File

@ -1,24 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35931.197
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeobfuscateStackTrace", "DeobfuscateStackTrace.csproj", "{B7192F39-1EEA-4F31-885B-B606D700FC79}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B7192F39-1EEA-4F31-885B-B606D700FC79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7192F39-1EEA-4F31-885B-B606D700FC79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7192F39-1EEA-4F31-885B-B606D700FC79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7192F39-1EEA-4F31-885B-B606D700FC79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9F39E3ED-EF31-43DE-B085-0F7BF60844E8}
EndGlobalSection
EndGlobal

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2025 Code Philosophy(代码哲学)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,57 +0,0 @@
using CommandLine;
namespace DeobfuscateStackTrace
{
internal class Program
{
private class CommandOptions
{
[Option('m', "mappingFile", Required = true, HelpText = "mapping xml file")]
public string MappingFile { get; set; }
[Option('i', "input", Required = true, HelpText = "input obfuscated log file")]
public string InputFile { get; set; }
[Option('o', "output", Required = true, HelpText = "output deobfuscated log file")]
public string OutputFile { get; set; }
}
static void Main(string[] args)
{
CommandOptions opt = ParseArgs(args);
if (!File.Exists(opt.MappingFile))
{
Console.Error.WriteLine($"Mapping file {opt.MappingFile} not found");
Environment.Exit(1);
}
if (!File.Exists(opt.InputFile))
{
Console.Error.WriteLine($"Input file {opt.InputFile} not found");
Environment.Exit(1);
}
var reader = new SymbolMappingReader(opt.MappingFile);
StackTraceDeObfuscator.Convert(reader, opt.InputFile, opt.OutputFile);
}
private static CommandOptions ParseArgs(string[] args)
{
var helpWriter = new StringWriter();
var parser = new Parser(settings =>
{
settings.AllowMultiInstance = true;
settings.HelpWriter = helpWriter;
});
var result = parser.ParseArguments<CommandOptions>(args);
if (result.Tag == ParserResultType.NotParsed)
{
Console.Error.WriteLine(helpWriter.ToString());
Environment.Exit(1);
}
return ((Parsed<CommandOptions>)result).Value;
}
}
}

View File

@ -1,8 +0,0 @@
{
"profiles": {
"DeobfuscateStackTrace": {
"commandName": "Project",
"commandLineArgs": "-m ../../../mapping.xml -i ../../../obfuscated.log -o ../../../deobfuscated.log"
}
}
}

View File

@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeobfuscateStackTrace
{
public class StackTraceDeObfuscator
{
public static void Convert(SymbolMappingReader reader, string oldLogFile, string newLogFile)
{
var obfuscatedLines = File.ReadAllLines(oldLogFile, Encoding.UTF8);
var deObfuscatedLines = new List<string>();
bool logLineFound = false;
foreach (string line in obfuscatedLines)
{
if (TryConvertLine(line, reader, ref logLineFound, out var newLine))
{
deObfuscatedLines.Add(newLine);
}
else
{
deObfuscatedLines.Add(line);
}
}
File.WriteAllLines(newLogFile, deObfuscatedLines, Encoding.UTF8);
}
private static bool TryConvertLine(string line, SymbolMappingReader reader, ref bool logLineFound, out string deObfuscatedStackTrace)
{
deObfuscatedStackTrace = line;
if (string.IsNullOrEmpty(line))
{
logLineFound = false;
return false;
}
if (!logLineFound)
{
logLineFound = line.StartsWith("UnityEngine.DebugLogHandler:Internal_Log")
|| line.StartsWith("UnityEngine.DebugLogHandler:LogFormat")
|| line.StartsWith("UnityEngine.Logger:Log");
return false;
}
return reader.TryDeObfuscateStackTrace(line, out deObfuscatedStackTrace);
}
}
}

View File

@ -1,128 +0,0 @@
using System.Xml;
namespace DeobfuscateStackTrace
{
public class SymbolMappingReader
{
private readonly Dictionary<string, List<string>> _fullSignatureMapper = new Dictionary<string, List<string>>();
private readonly Dictionary<string, List<string>> _signatureWithParamsMapper = new Dictionary<string, List<string>>();
public SymbolMappingReader(string mappingFile)
{
LoadXmlMappingFile(mappingFile);
}
private void LoadXmlMappingFile(string mappingFile)
{
var doc = new XmlDocument();
doc.Load(mappingFile);
var root = doc.DocumentElement;
foreach (XmlNode node in root.ChildNodes)
{
if (!(node is XmlElement element))
{
continue;
}
LoadAssemblyMapping(element);
}
}
private void LoadAssemblyMapping(XmlElement ele)
{
if (ele.Name != "assembly")
{
throw new System.Exception($"Invalid node name: {ele.Name}. Expected 'assembly'.");
}
foreach (XmlNode node in ele.ChildNodes)
{
if (!(node is XmlElement element))
{
continue;
}
if (element.Name == "type")
{
LoadTypeMapping(element);
}
}
}
private void LoadTypeMapping(XmlElement ele)
{
foreach (XmlNode node in ele.ChildNodes)
{
if (!(node is XmlElement c))
{
continue;
}
if (node.Name == "method")
{
LoadMethodMapping(c);
}
}
}
private string GetMethodSignatureWithoutParams(string signature)
{
int index = signature.IndexOf('(');
if (index < 0)
{
return signature;
}
return signature.Substring(0, index);
}
private void LoadMethodMapping(XmlElement ele)
{
if (!ele.HasAttribute("oldStackTraceSignature"))
{
throw new System.Exception($"Invalid node name: {ele.Name}. attribute 'oldStackTraceSignature' missing.");
}
if (!ele.HasAttribute("newStackTraceSignature"))
{
throw new System.Exception($"Invalid node name: {ele.Name}. attribute 'newStackTraceSignature' missing.");
}
string oldStackTraceSignature = ele.Attributes["oldStackTraceSignature"].Value;
string newStackTraceSignature = ele.Attributes["newStackTraceSignature"].Value;
if (!_fullSignatureMapper.TryGetValue(newStackTraceSignature, out var oldFullSignatures))
{
oldFullSignatures = new List<string>();
_fullSignatureMapper[newStackTraceSignature] = oldFullSignatures;
}
oldFullSignatures.Add(oldStackTraceSignature);
string oldStackTraceSignatureWithoutParams = GetMethodSignatureWithoutParams(oldStackTraceSignature);
string newStackTraceSignatureWithoutParams = GetMethodSignatureWithoutParams(newStackTraceSignature);
if (!_signatureWithParamsMapper.TryGetValue(newStackTraceSignatureWithoutParams, out var oldSignaturesWithoutParams))
{
oldSignaturesWithoutParams = new List<string>();
_signatureWithParamsMapper[newStackTraceSignatureWithoutParams] = oldSignaturesWithoutParams;
}
oldSignaturesWithoutParams.Add(oldStackTraceSignatureWithoutParams);
}
public bool TryDeObfuscateStackTrace(string obfuscatedStackTraceLog, out string deObfuscatedStackTrace)
{
obfuscatedStackTraceLog = obfuscatedStackTraceLog.Trim();
if (_fullSignatureMapper.TryGetValue(obfuscatedStackTraceLog, out var oldFullSignatures))
{
deObfuscatedStackTrace = string.Join("|", oldFullSignatures);
return true;
}
string obfuscatedStackTraceSignatureWithoutParams = GetMethodSignatureWithoutParams(obfuscatedStackTraceLog);
if (_signatureWithParamsMapper.TryGetValue(obfuscatedStackTraceSignatureWithoutParams, out var oldSignaturesWithoutParams))
{
deObfuscatedStackTrace = obfuscatedStackTraceLog.Replace(obfuscatedStackTraceSignatureWithoutParams, string.Join("|", oldSignaturesWithoutParams));
return true;
}
deObfuscatedStackTrace = null;
return false;
}
}
}

View File

@ -1,17 +0,0 @@
test stack trace
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Obfus2.TestStackTrace:Stack3()
Obfus2.NestedClass`1:Stack2(TestStackTrace, Int32[], List`1, Banana)
Obfus2.TestStackTrace:Stack1(Int64, UInt64, Single, Double, String, Object)
Obfus2.TestStackTrace:Stack0(Byte, SByte, Int16, UInt16, Int32, UInt32)
Tests.TC_StackTrace:PrintStackTrace()
System.Reflection.RuntimeMethodInfo:InternalInvoke(Object, Object[], Exception&)
System.Reflection.RuntimeMethodInfo:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
SharpUnit.TestCase:Run(TestResult)
SharpUnit.TestSuite:Run(TestResult)
TestRunner:Run()
Bootstrap:Start()

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
test stack trace
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
F.g:A()
F.G:a(g, Int32[], List`1, Banana)
F.g:a(Int64, UInt64, Single, Double, String, Object)
F.g:b(Byte, SByte, Int16, UInt16, Int32, UInt32)
Tests.TC_StackTrace:PrintStackTrace()
System.Reflection.RuntimeMethodInfo:InternalInvoke(Object, Object[], Exception&)
System.Reflection.RuntimeMethodInfo:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
SharpUnit.TestCase:Run(TestResult)
SharpUnit.TestSuite:Run(TestResult)
TestRunner:Run()
Bootstrap:Start()

Some files were not shown because too many files have changed in this diff Show More