Skip to content

Commit

Permalink
v1.42 update(add obfusfunc)
Browse files Browse the repository at this point in the history
  • Loading branch information
SummerofOrange committed Dec 9, 2022
1 parent a5300eb commit c196f1e
Show file tree
Hide file tree
Showing 33 changed files with 9,500 additions and 39 deletions.
2 changes: 2 additions & 0 deletions O&Z_IL2CPP_Security/JsonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ public class ObfusConfig
public int NumObfus { get; set; }
public int LocalVariables2Field { get; set; }
public int StrCrypter { get; set; }
public int Obfusfunc { get; set; }
}
public class JsonManager
{
public JsonIndex index;
public string path;
public static string origin = "ewogICAgImtleSI6MTE0NTE0LAogICAgIlZlcnNpb24iOiIyNC40IiwKICAgICIvLyI6IuaUr+aMgTI4IDI0LjQiLAogICAgIk9iZnVzIjoKICAgIHsKICAgICAgICAiQ29udHJvbEZsb3ciOjEsCiAgICAgICAgIk51bU9iZnVzIjoxLAogICAgICAgICJMb2NhbFZhcmlhYmxlczJGaWVsZCI6MSwKICAgICAgICAiU3RyQ3J5cHRlciI6MSwKICAgICAgICAiT2JmdXNmdW5jIjoxLAogICAgICAgICIvLyI6IjA95YWz6ZetIDE95byA5ZCvIiwKICAgICAgICAiLy8iOiJDb250cm9sRmxvd++8muaOp+WItua1geeoi+a3t+a3hiIsCiAgICAgICAgIi8vIjoiTnVtT2JmdXPvvJrmlbDlrZfmt7fmt4YiLAogICAgICAgICIvLyI6IkxvY2FsVmFyaWFibGVzMkZpZWxk77ya5bGA6YOo5Y+Y6YeP6L2s5o2i5Li65a2X5q61IiwKICAgICAgICAiLy8iOiJTdHJDcnlwdGVy77ya5a2X56ym5Liy5Yqg5a+GIiwKICAgICAgICAiLy8iOiJPYmZ1c2Z1bmPvvJroh6rlrprkuYnmt7fmt4bnsbvlkozmlrnms5XlkI3np7As5Y+v5Lul5Zyoa2V5ZnVuY+S4reiHquWumuS5iea3t+a3huaooeW8jyjlpoLnlKjliLDkuoblj43lsITnrYnnsbvlnospIgoKICAgIH0KfQ==";
public JsonManager(string _path)
{
path = _path;
Expand Down
29 changes: 14 additions & 15 deletions O&Z_IL2CPP_Security/Progarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@
Console.WriteLine("O&Z_IL2CPP_Security");
if (!File.Exists("Config.json"))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Config.json not found!");
Console.WriteLine("正在生成默认配置文件...");
JsonIndex index = new JsonIndex()
{
key = 114514,
Version = "24.4",
Obfus = new ObfusConfig()
{
ControlFlow = 1,
NumObfus = 1,
LocalVariables2Field = 1,
StrCrypter = 1
}
};
File.WriteAllText("Config.json", JsonMapper.ToJson(index));
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("正在生成默认配置文件...");
File.WriteAllBytes("Config.json", Convert.FromBase64String(JsonManager.origin));
if (File.Exists("Config.json")) Console.WriteLine("已重新生成默认配置文件...\nDone!");
Console.ForegroundColor = ConsoleColor.White;
}
if (args.Length == 0)
{
Expand Down Expand Up @@ -193,7 +184,10 @@ bool CheckMetadataFile()
}
void _Test()
{
Console.WriteLine(XXTEA.EncryptToBase64String("HelloWorld", "123456"));
AssemblyLoader loader = new AssemblyLoader(OpenFilePath);
ObfusFunc obfusFunc = new ObfusFunc(loader.Module);
obfusFunc.Excute();
loader.Save();
}
void CheckVersion()
{
Expand All @@ -220,6 +214,11 @@ void MonoObfus()
ControlFlow controlFlow = new ControlFlow(loader.Module);
controlFlow.Execute();
}
if (jsonManager.index.Obfus.Obfusfunc == 1)
{
ObfusFunc obfusFunc = new ObfusFunc(loader.Module);
obfusFunc.Excute();
}
if (jsonManager.index.Obfus.NumObfus == 1)
{
NumObfus numObfus = new NumObfus(loader.Module);
Expand Down
4 changes: 2 additions & 2 deletions O&Z_IL2CPP_Security/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
},
"Test": {
"commandName": "Project",
"commandLineArgs": "\"global-metadata.dat\" Test"
"commandLineArgs": "\"C:\\Users\\22864\\Desktop\\2019Testbuild\\O&Z_2019_4_32_f1_Data\\Managed\\Assembly-CSharp - 副本.dll\" Test"
},
"Generate": {
"commandName": "Project",
"commandLineArgs": "Generate"
},
"Obfus": {
"commandName": "Project",
"commandLineArgs": "\"C:\\Users\\22864\\Desktop\\END_AUTO V2\\END_Data\\Managed\\Assembly-CSharp.dll.bak\" MonoObfus"
"commandLineArgs": "\"C:\\Users\\22864\\Desktop\\2019Testbuild\\O&Z_2019_4_32_f1_Data\\Managed\\Assembly-CSharp - 副本.dll\" MonoObfus"
}
}
}
19 changes: 19 additions & 0 deletions O&Z_IL2CPP_Security/resource/Config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"key":114514,
"Version":"24.4",
"//":"支持28 24.4",
"Obfus":
{
"ControlFlow":1,
"NumObfus":1,
"LocalVariables2Field":1,
"StrCrypter":1,
"StrObfus":1,
"//":"0=关闭 1=开启",
"//":"ControlFlow:控制流程混淆",
"//":"NumObfus:数字混淆",
"//":"LocalVariables2Field:局部变量转换为字段",
"//":"StrCrypter:字符串加密",
"//":"StrObfus:方法加密混淆,可以在keyfunc中添加自定义需要排除的方法(如用到了反射等类型)"
}
}
126 changes: 126 additions & 0 deletions O&Z_IL2CPP_Security/resource/keyfunc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"ignoreMethod": [
"Awake",
"OnEnable",
"Start",
"FixedUpdate",
"Update",
"OnDisable",
"LateUpdate",
"Reset",
"OnValidate",
"FixedUpdate",
"OnTriggerEnter",
"OnTriggerEnter2D",
"OnTriggerExit",
"OnTriggerExit2D",
"OnTriggerStay2D",
"OnCollisionEnter",
"OnCollisionEnter2D",
"OnCollisionExit",
"OnCollisionExit2D",
"OnCollisionStay",
"OnCollisionStay2D",
"OnMouseDown",
"OnMouseDrag",
"OnMouseEnter",
"OnMouseExit",
"OnMouseOver",
"OnMouseUp",
"OnMouseUpAsButton",
"OnPreCull",
"OnBecameVisible",
"OnBecameInvisible",
"OnWillRenderObject",
"OnPreRender",
"OnRenderObject",
"OnPostRender",
"OnRenderImage",
"OnGUI",
"OnDrawGizmos",
"OnDrawGizmosSelected",
"OnApplicationFocus",
"OnApplicationPause",
"OnApplicationQuit",
"OnDisable",
"OnDestory",
"OnLevelWasLoaded",
"OnAnimatorIK",
"OnAnimatorMove",
"OnApplicationFocus",
"OnApplicationPause",
"OnApplicationQuit",
"OnAudioFilterRead",
"OnBecameInvisible",
"OnBecameVisible",
"OnConnectedToServer",
"OnControllerColliderHit",
"OnEnable",
"OnFailedToConnect",
"OnDisconnectedFromServer",
"OnDrawGizmos",
"OnDrawGizmosSelected",
"OnEnable",
"OnFailedToConnect",
"OnFailedToConnectToMasterServer",
"OnJointBreak",
"OnJointBreak2D",
"OnMasterServerEvent",
"OnNetworkInstantiate",
"OnParticleCollision",
"OnParticleSystemStopped",
"OnParticleTrigger",
"OnParticleUpdateJobScheduled",
"OnPlayerConnected",
"OnPlayerDisconnected",
"OnPostRender",
"OnPreCull",
"OnPreRender",
"OnRenderImage",
"OnRenderObject",
"OnSerializeNetworkView",
"OnServerInitialized",
"OnTransformChildrenChanged",
"OnTransformParentChanged",
"OnValidate",
"OnWillRenderObject",
"Reset",
"__",
"incontrol",
"stop",
"option",
"pausemanager",
"fallingrock",
"postfix",
"prefix",
"transpiler"
],
"ignoreField":[
"incontrol",
"enum",
"optional",
"__"
],
"//":"以上为默认忽略列表,默认包含全部的Unity关键方法,建议不要修改,以下为自定义忽略列表,可以根据需要自行添加(如果需要用到反射或者动态调用的方法,建议添加到这里))",

"//":"关于如何是使用自定义忽略列表,这里有几点建议",
"//":"1.在Unity中,GameObject或者prefabs初始绑定了脚本,则该脚本的类名不可混淆,方法名和字段名可以混淆",
"//":"2.在Unity中,GameObject或者prefabs初始没有绑定脚本,但是在代码中动态添加了脚本,则该脚本的类名、方法名和字段名都可以混淆",
"//":"3.如果该脚本中涉及到了UI的事件响应(如Button.OnClick),则该脚本的类名和该方法名都不可混淆,字段名可以混淆",
"//":"4.Unity的生命周期方法和回调方法不能混淆,上方的忽略列表包含了大多数常用的生命周期和回调方法,如果有遗漏,可以自行添加",
"//":"5.Unity中的Invoke等特殊方法所调用的函数方法不可混淆,同理协程类的方法也不可混淆,请自行添加到自定义忽略列表",
"//":"6.部分涉及反射类的代码不能混淆,如System.Reflection(GetField,GetMethod,Invoke等),请自行添加到自定义忽略列表",
"//":"7.Native层里直接调用C#或通过Unity内置API发送事件到C#的类和方法不可混淆(大多数在移动平台中)",
"//":"8.一些特殊插件对应的脚本不可混淆,例如xLua和与之绑定的C#脚本",


"//":"对于方法名的混淆采用的是白名单模式,即默认混淆,如果不需要混淆,可以添加到这里",
"customignoreMethod":[
],
"//":"对于字段名的混淆采用的是白名单模式,即默认混淆,如果不需要混淆,可以添加到这里",
"customignoreField":[
],
"//":"对于类名的混淆采用的是黑名单模式,即默认不混淆,如果需要混淆,可以添加到这里",
"customignoreClass":[
]
}
Loading

0 comments on commit c196f1e

Please sign in to comment.