├── README.md ├── SugarGuard.sln ├── SugarGuard ├── Main.Designer.cs ├── Main.cs ├── Main.resources ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.cs │ └── Resources.resources ├── Protector │ ├── Class │ │ ├── Constants │ │ │ ├── DynamicContext.cs │ │ │ ├── DynamicHelper.cs │ │ │ ├── DynamicMethods.cs │ │ │ ├── EncodedMethod.cs │ │ │ ├── ImportContext.cs │ │ │ └── Inject.cs │ │ ├── InjectHelper.cs │ │ ├── MutationHelper.cs │ │ ├── RandomHelper.cs │ │ └── SugarLib.cs │ ├── Enums │ │ ├── Protections.cs │ │ └── saveMode.cs │ ├── Protections │ │ ├── AntiDebug.cs │ │ ├── AntiDump.cs │ │ ├── CallConvertion.cs │ │ ├── Constants │ │ │ ├── Constants.cs │ │ │ └── PosConstants.cs │ │ ├── ControlFlow │ │ │ ├── BlockParser.cs │ │ │ ├── ControlFlow.cs │ │ │ ├── ControlFlowBlock.cs │ │ │ ├── ControlFlowBlockType.cs │ │ │ ├── ControlFlowGraph.cs │ │ │ ├── IPredicate.cs │ │ │ ├── ManglerBase.cs │ │ │ ├── Predicate.cs │ │ │ ├── SwitchMangler.cs │ │ │ └── Utils.cs │ │ ├── FakeAttributes.cs │ │ ├── InvalidOpcodes.cs │ │ ├── MethodHider.cs │ │ ├── Mutation │ │ │ ├── Calculator.cs │ │ │ ├── Mutation.cs │ │ │ └── Stages │ │ │ │ ├── IntsConversions.cs │ │ │ │ ├── IntsReplacer.cs │ │ │ │ ├── IntsToArray.cs │ │ │ │ ├── IntsToInitializeArray.cs │ │ │ │ ├── IntsToInliner.cs │ │ │ │ ├── IntsToMath.cs │ │ │ │ ├── IntsToMethodPointer.cs │ │ │ │ ├── IntsToRandom.cs │ │ │ │ ├── IntsToStackalloc.cs │ │ │ │ ├── LocalsToCustomLocal.cs │ │ │ │ └── MethodPreparation.cs │ │ ├── ReferenceProxy │ │ │ ├── Helper.cs │ │ │ └── ReferenceProxy.cs │ │ ├── Renamer.cs │ │ ├── Runtime │ │ │ ├── AntiDebug.cs │ │ │ ├── AntiDump.cs │ │ │ ├── ConstantsRuntime.cs │ │ │ └── MethodHider.cs │ │ └── WaterMark.cs │ └── Sugar.cs ├── SugarGuard.csproj ├── SugarGuard.ico └── app.manifest └── Suggar Guard ├── MaterialSkin.dll ├── SugarGuard.exe ├── dnlib.dll ├── dnlib.pdb └── dnlib.xml /README.md: -------------------------------------------------------------------------------- 1 | # Sugar Guard 2 | 3 | [Sugar Guard] Private .net obfuscator 4 | 5 | 6 | ![image](https://user-images.githubusercontent.com/66917888/151652519-12dafadd-291a-4223-b2fc-d1acf7f7ec52.png) 7 | 8 | -------------------------------------------------------------------------------- /SugarGuard.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SugarGuard", "SugarGuard\SugarGuard.csproj", "{96A2C21F-9D77-494C-8783-A6A5E0CB401F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {96A2C21F-9D77-494C-8783-A6A5E0CB401F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {96A2C21F-9D77-494C-8783-A6A5E0CB401F}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {96A2C21F-9D77-494C-8783-A6A5E0CB401F}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {96A2C21F-9D77-494C-8783-A6A5E0CB401F}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /SugarGuard/Main.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SugarGuard 2 | { 3 | // Token: 0x02000002 RID: 2 4 | public partial class Main : global::System.Windows.Forms.Form 5 | { 6 | // Token: 0x0600000B RID: 11 RVA: 0x00002210 File Offset: 0x00000410 7 | protected override void Dispose(bool disposing) 8 | { 9 | bool flag = disposing && this.components != null; 10 | if (flag) 11 | { 12 | this.components.Dispose(); 13 | } 14 | base.Dispose(disposing); 15 | } 16 | 17 | // Token: 0x0600000C RID: 12 RVA: 0x00002248 File Offset: 0x00000448 18 | private void InitializeComponent() 19 | { 20 | global::System.ComponentModel.ComponentResourceManager componentResourceManager = new global::System.ComponentModel.ComponentResourceManager(typeof(global::SugarGuard.Main)); 21 | this.Constants = new global::MaterialSkin.Controls.MaterialCheckBox(); 22 | this.Protect = new global::MaterialSkin.Controls.MaterialRaisedButton(); 23 | this.VM = new global::MaterialSkin.Controls.MaterialCheckBox(); 24 | this.ReferenceProxy = new global::MaterialSkin.Controls.MaterialCheckBox(); 25 | this.ControlFlow = new global::MaterialSkin.Controls.MaterialCheckBox(); 26 | this.InvalidOpcodes = new global::MaterialSkin.Controls.MaterialCheckBox(); 27 | this.Renamer = new global::MaterialSkin.Controls.MaterialCheckBox(); 28 | this.AntiDebug = new global::MaterialSkin.Controls.MaterialCheckBox(); 29 | this.AntiDump = new global::MaterialSkin.Controls.MaterialCheckBox(); 30 | this.FPath = new global::MaterialSkin.Controls.MaterialSingleLineTextField(); 31 | this.WaterMark = new global::MaterialSkin.Controls.MaterialCheckBox(); 32 | this.CallConvertion = new global::MaterialSkin.Controls.MaterialCheckBox(); 33 | this.pictureBox1 = new global::System.Windows.Forms.PictureBox(); 34 | this.Close = new global::System.Windows.Forms.PictureBox(); 35 | this.FakeAttributes = new global::MaterialSkin.Controls.MaterialCheckBox(); 36 | this.ReferenceOverload = new global::MaterialSkin.Controls.MaterialCheckBox(); 37 | this.Mutation = new global::MaterialSkin.Controls.MaterialCheckBox(); 38 | ((global::System.ComponentModel.ISupportInitialize)this.pictureBox1).BeginInit(); 39 | ((global::System.ComponentModel.ISupportInitialize)this.Close).BeginInit(); 40 | base.SuspendLayout(); 41 | this.Constants.AutoSize = true; 42 | this.Constants.Depth = 0; 43 | this.Constants.Font = new global::System.Drawing.Font("Roboto", 10f); 44 | this.Constants.Location = new global::System.Drawing.Point(15, 104); 45 | this.Constants.Margin = new global::System.Windows.Forms.Padding(0); 46 | this.Constants.MouseLocation = new global::System.Drawing.Point(-1, -1); 47 | this.Constants.MouseState = global::MaterialSkin.MouseState.HOVER; 48 | this.Constants.Name = "Constants"; 49 | this.Constants.Ripple = true; 50 | this.Constants.Size = new global::System.Drawing.Size(93, 30); 51 | this.Constants.TabIndex = 5; 52 | this.Constants.Text = "Constants"; 53 | this.Constants.UseVisualStyleBackColor = true; 54 | this.Protect.AutoSize = true; 55 | this.Protect.AutoSizeMode = global::System.Windows.Forms.AutoSizeMode.GrowAndShrink; 56 | this.Protect.Depth = 0; 57 | this.Protect.Icon = null; 58 | this.Protect.Location = new global::System.Drawing.Point(131, 297); 59 | this.Protect.MouseState = global::MaterialSkin.MouseState.HOVER; 60 | this.Protect.Name = "Protect"; 61 | this.Protect.Primary = true; 62 | this.Protect.Size = new global::System.Drawing.Size(81, 36); 63 | this.Protect.TabIndex = 7; 64 | this.Protect.Text = "Protect"; 65 | this.Protect.UseVisualStyleBackColor = true; 66 | this.Protect.Click += new global::System.EventHandler(this.Protect_Click); 67 | this.VM.AutoSize = true; 68 | this.VM.Depth = 0; 69 | this.VM.Font = new global::System.Drawing.Font("Roboto", 10f); 70 | this.VM.Location = new global::System.Drawing.Point(248, 301); 71 | this.VM.Margin = new global::System.Windows.Forms.Padding(0); 72 | this.VM.MouseLocation = new global::System.Drawing.Point(-1, -1); 73 | this.VM.MouseState = global::MaterialSkin.MouseState.HOVER; 74 | this.VM.Name = "VM"; 75 | this.VM.Ripple = true; 76 | this.VM.Size = new global::System.Drawing.Size(51, 30); 77 | this.VM.TabIndex = 9; 78 | this.VM.Text = "VM"; 79 | this.VM.UseVisualStyleBackColor = true; 80 | this.ReferenceProxy.AutoSize = true; 81 | this.ReferenceProxy.Depth = 0; 82 | this.ReferenceProxy.Font = new global::System.Drawing.Font("Roboto", 10f); 83 | this.ReferenceProxy.Location = new global::System.Drawing.Point(15, 164); 84 | this.ReferenceProxy.Margin = new global::System.Windows.Forms.Padding(0); 85 | this.ReferenceProxy.MouseLocation = new global::System.Drawing.Point(-1, -1); 86 | this.ReferenceProxy.MouseState = global::MaterialSkin.MouseState.HOVER; 87 | this.ReferenceProxy.Name = "ReferenceProxy"; 88 | this.ReferenceProxy.Ripple = true; 89 | this.ReferenceProxy.Size = new global::System.Drawing.Size(131, 30); 90 | this.ReferenceProxy.TabIndex = 10; 91 | this.ReferenceProxy.Text = "Reference Proxy"; 92 | this.ReferenceProxy.UseVisualStyleBackColor = true; 93 | this.ControlFlow.AutoSize = true; 94 | this.ControlFlow.Depth = 0; 95 | this.ControlFlow.Font = new global::System.Drawing.Font("Roboto", 10f); 96 | this.ControlFlow.Location = new global::System.Drawing.Point(15, 194); 97 | this.ControlFlow.Margin = new global::System.Windows.Forms.Padding(0); 98 | this.ControlFlow.MouseLocation = new global::System.Drawing.Point(-1, -1); 99 | this.ControlFlow.MouseState = global::MaterialSkin.MouseState.HOVER; 100 | this.ControlFlow.Name = "ControlFlow"; 101 | this.ControlFlow.Ripple = true; 102 | this.ControlFlow.Size = new global::System.Drawing.Size(108, 30); 103 | this.ControlFlow.TabIndex = 11; 104 | this.ControlFlow.Text = "Control Flow"; 105 | this.ControlFlow.UseVisualStyleBackColor = true; 106 | this.InvalidOpcodes.AutoSize = true; 107 | this.InvalidOpcodes.Depth = 0; 108 | this.InvalidOpcodes.Font = new global::System.Drawing.Font("Roboto", 10f); 109 | this.InvalidOpcodes.Location = new global::System.Drawing.Point(201, 164); 110 | this.InvalidOpcodes.Margin = new global::System.Windows.Forms.Padding(0); 111 | this.InvalidOpcodes.MouseLocation = new global::System.Drawing.Point(-1, -1); 112 | this.InvalidOpcodes.MouseState = global::MaterialSkin.MouseState.HOVER; 113 | this.InvalidOpcodes.Name = "InvalidOpcodes"; 114 | this.InvalidOpcodes.Ripple = true; 115 | this.InvalidOpcodes.Size = new global::System.Drawing.Size(128, 30); 116 | this.InvalidOpcodes.TabIndex = 12; 117 | this.InvalidOpcodes.Text = "Invalid Opcodes"; 118 | this.InvalidOpcodes.UseVisualStyleBackColor = true; 119 | this.Renamer.AutoSize = true; 120 | this.Renamer.Depth = 0; 121 | this.Renamer.Font = new global::System.Drawing.Font("Roboto", 10f); 122 | this.Renamer.Location = new global::System.Drawing.Point(201, 254); 123 | this.Renamer.Margin = new global::System.Windows.Forms.Padding(0); 124 | this.Renamer.MouseLocation = new global::System.Drawing.Point(-1, -1); 125 | this.Renamer.MouseState = global::MaterialSkin.MouseState.HOVER; 126 | this.Renamer.Name = "Renamer"; 127 | this.Renamer.Ripple = true; 128 | this.Renamer.Size = new global::System.Drawing.Size(85, 30); 129 | this.Renamer.TabIndex = 13; 130 | this.Renamer.Text = "Renamer"; 131 | this.Renamer.UseVisualStyleBackColor = true; 132 | this.AntiDebug.AutoSize = true; 133 | this.AntiDebug.Depth = 0; 134 | this.AntiDebug.Font = new global::System.Drawing.Font("Roboto", 10f); 135 | this.AntiDebug.Location = new global::System.Drawing.Point(201, 104); 136 | this.AntiDebug.Margin = new global::System.Windows.Forms.Padding(0); 137 | this.AntiDebug.MouseLocation = new global::System.Drawing.Point(-1, -1); 138 | this.AntiDebug.MouseState = global::MaterialSkin.MouseState.HOVER; 139 | this.AntiDebug.Name = "AntiDebug"; 140 | this.AntiDebug.Ripple = true; 141 | this.AntiDebug.Size = new global::System.Drawing.Size(98, 30); 142 | this.AntiDebug.TabIndex = 14; 143 | this.AntiDebug.Text = "Anti Debug"; 144 | this.AntiDebug.UseVisualStyleBackColor = true; 145 | this.AntiDump.AutoSize = true; 146 | this.AntiDump.Depth = 0; 147 | this.AntiDump.Font = new global::System.Drawing.Font("Roboto", 10f); 148 | this.AntiDump.Location = new global::System.Drawing.Point(201, 134); 149 | this.AntiDump.Margin = new global::System.Windows.Forms.Padding(0); 150 | this.AntiDump.MouseLocation = new global::System.Drawing.Point(-1, -1); 151 | this.AntiDump.MouseState = global::MaterialSkin.MouseState.HOVER; 152 | this.AntiDump.Name = "AntiDump"; 153 | this.AntiDump.Ripple = true; 154 | this.AntiDump.Size = new global::System.Drawing.Size(94, 30); 155 | this.AntiDump.TabIndex = 15; 156 | this.AntiDump.Text = "Anti Dump"; 157 | this.AntiDump.UseVisualStyleBackColor = true; 158 | this.FPath.Depth = 0; 159 | this.FPath.Hint = ""; 160 | this.FPath.Location = new global::System.Drawing.Point(12, 68); 161 | this.FPath.MaxLength = 32767; 162 | this.FPath.MouseState = global::MaterialSkin.MouseState.HOVER; 163 | this.FPath.Name = "FPath"; 164 | this.FPath.PasswordChar = '\0'; 165 | this.FPath.SelectedText = ""; 166 | this.FPath.SelectionLength = 0; 167 | this.FPath.SelectionStart = 0; 168 | this.FPath.Size = new global::System.Drawing.Size(318, 23); 169 | this.FPath.TabIndex = 17; 170 | this.FPath.TabStop = false; 171 | this.FPath.Text = "Drag and drop your assembly here."; 172 | this.FPath.UseSystemPasswordChar = false; 173 | this.FPath.Click += new global::System.EventHandler(this.FPath_Click); 174 | this.WaterMark.AutoSize = true; 175 | this.WaterMark.Depth = 0; 176 | this.WaterMark.Font = new global::System.Drawing.Font("Roboto", 10f); 177 | this.WaterMark.Location = new global::System.Drawing.Point(201, 194); 178 | this.WaterMark.Margin = new global::System.Windows.Forms.Padding(0); 179 | this.WaterMark.MouseLocation = new global::System.Drawing.Point(-1, -1); 180 | this.WaterMark.MouseState = global::MaterialSkin.MouseState.HOVER; 181 | this.WaterMark.Name = "WaterMark"; 182 | this.WaterMark.Ripple = true; 183 | this.WaterMark.Size = new global::System.Drawing.Size(101, 30); 184 | this.WaterMark.TabIndex = 20; 185 | this.WaterMark.Text = "Water Mark"; 186 | this.WaterMark.UseVisualStyleBackColor = true; 187 | this.CallConvertion.AutoSize = true; 188 | this.CallConvertion.Depth = 0; 189 | this.CallConvertion.Font = new global::System.Drawing.Font("Roboto", 10f); 190 | this.CallConvertion.Location = new global::System.Drawing.Point(15, 254); 191 | this.CallConvertion.Margin = new global::System.Windows.Forms.Padding(0); 192 | this.CallConvertion.MouseLocation = new global::System.Drawing.Point(-1, -1); 193 | this.CallConvertion.MouseState = global::MaterialSkin.MouseState.HOVER; 194 | this.CallConvertion.Name = "CallConvertion"; 195 | this.CallConvertion.Ripple = true; 196 | this.CallConvertion.Size = new global::System.Drawing.Size(124, 30); 197 | this.CallConvertion.TabIndex = 21; 198 | this.CallConvertion.Text = "Call Convertion"; 199 | this.CallConvertion.UseVisualStyleBackColor = true; 200 | this.pictureBox1.Image = global::SugarGuard.Properties.Resources.Logo; 201 | this.pictureBox1.Location = new global::System.Drawing.Point(12, 12); 202 | this.pictureBox1.Name = "pictureBox1"; 203 | this.pictureBox1.Size = new global::System.Drawing.Size(126, 44); 204 | this.pictureBox1.SizeMode = global::System.Windows.Forms.PictureBoxSizeMode.StretchImage; 205 | this.pictureBox1.TabIndex = 22; 206 | this.pictureBox1.TabStop = false; 207 | this.Close.Image = global::SugarGuard.Properties.Resources.Delete; 208 | this.Close.Location = new global::System.Drawing.Point(301, 19); 209 | this.Close.Name = "Close"; 210 | this.Close.Size = new global::System.Drawing.Size(29, 30); 211 | this.Close.SizeMode = global::System.Windows.Forms.PictureBoxSizeMode.CenterImage; 212 | this.Close.TabIndex = 4; 213 | this.Close.TabStop = false; 214 | this.Close.Click += new global::System.EventHandler(this.Close_Click); 215 | this.FakeAttributes.AutoSize = true; 216 | this.FakeAttributes.Depth = 0; 217 | this.FakeAttributes.Font = new global::System.Drawing.Font("Roboto", 10f); 218 | this.FakeAttributes.Location = new global::System.Drawing.Point(201, 224); 219 | this.FakeAttributes.Margin = new global::System.Windows.Forms.Padding(0); 220 | this.FakeAttributes.MouseLocation = new global::System.Drawing.Point(-1, -1); 221 | this.FakeAttributes.MouseState = global::MaterialSkin.MouseState.HOVER; 222 | this.FakeAttributes.Name = "FakeAttributes"; 223 | this.FakeAttributes.Ripple = true; 224 | this.FakeAttributes.Size = new global::System.Drawing.Size(124, 30); 225 | this.FakeAttributes.TabIndex = 23; 226 | this.FakeAttributes.Text = "Fake Attributes"; 227 | this.FakeAttributes.UseVisualStyleBackColor = true; 228 | this.ReferenceOverload.AutoSize = true; 229 | this.ReferenceOverload.Depth = 0; 230 | this.ReferenceOverload.Font = new global::System.Drawing.Font("Roboto", 10f); 231 | this.ReferenceOverload.Location = new global::System.Drawing.Point(15, 224); 232 | this.ReferenceOverload.Margin = new global::System.Windows.Forms.Padding(0); 233 | this.ReferenceOverload.MouseLocation = new global::System.Drawing.Point(-1, -1); 234 | this.ReferenceOverload.MouseState = global::MaterialSkin.MouseState.HOVER; 235 | this.ReferenceOverload.Name = "ReferenceOverload"; 236 | this.ReferenceOverload.Ripple = true; 237 | this.ReferenceOverload.Size = new global::System.Drawing.Size(151, 30); 238 | this.ReferenceOverload.TabIndex = 24; 239 | this.ReferenceOverload.Text = "Reference Overload"; 240 | this.ReferenceOverload.UseVisualStyleBackColor = true; 241 | this.Mutation.AutoSize = true; 242 | this.Mutation.Depth = 0; 243 | this.Mutation.Font = new global::System.Drawing.Font("Roboto", 10f); 244 | this.Mutation.Location = new global::System.Drawing.Point(15, 134); 245 | this.Mutation.Margin = new global::System.Windows.Forms.Padding(0); 246 | this.Mutation.MouseLocation = new global::System.Drawing.Point(-1, -1); 247 | this.Mutation.MouseState = global::MaterialSkin.MouseState.HOVER; 248 | this.Mutation.Name = "Mutation"; 249 | this.Mutation.Ripple = true; 250 | this.Mutation.Size = new global::System.Drawing.Size(85, 30); 251 | this.Mutation.TabIndex = 25; 252 | this.Mutation.Text = "Mutation"; 253 | this.Mutation.UseVisualStyleBackColor = true; 254 | base.AutoScaleDimensions = new global::System.Drawing.SizeF(6f, 13f); 255 | base.AutoScaleMode = global::System.Windows.Forms.AutoScaleMode.Font; 256 | this.BackColor = global::System.Drawing.Color.FromArgb(33, 33, 33); 257 | base.ClientSize = new global::System.Drawing.Size(342, 350); 258 | base.Controls.Add(this.Mutation); 259 | base.Controls.Add(this.ReferenceOverload); 260 | base.Controls.Add(this.FakeAttributes); 261 | base.Controls.Add(this.pictureBox1); 262 | base.Controls.Add(this.CallConvertion); 263 | base.Controls.Add(this.WaterMark); 264 | base.Controls.Add(this.FPath); 265 | base.Controls.Add(this.AntiDump); 266 | base.Controls.Add(this.AntiDebug); 267 | base.Controls.Add(this.Renamer); 268 | base.Controls.Add(this.InvalidOpcodes); 269 | base.Controls.Add(this.ControlFlow); 270 | base.Controls.Add(this.ReferenceProxy); 271 | base.Controls.Add(this.VM); 272 | base.Controls.Add(this.Protect); 273 | base.Controls.Add(this.Constants); 274 | base.Controls.Add(this.Close); 275 | base.FormBorderStyle = global::System.Windows.Forms.FormBorderStyle.None; 276 | base.Icon = (global::System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon"); 277 | base.Name = "Main"; 278 | base.Opacity = 0.9; 279 | base.StartPosition = global::System.Windows.Forms.FormStartPosition.CenterScreen; 280 | this.Text = "Form1"; 281 | base.DragDrop += new global::System.Windows.Forms.DragEventHandler(this.Main_DragDrop); 282 | base.DragEnter += new global::System.Windows.Forms.DragEventHandler(this.Main_DragEnter); 283 | base.MouseDown += new global::System.Windows.Forms.MouseEventHandler(this.Main_MouseDown); 284 | ((global::System.ComponentModel.ISupportInitialize)this.pictureBox1).EndInit(); 285 | ((global::System.ComponentModel.ISupportInitialize)this.Close).EndInit(); 286 | base.ResumeLayout(false); 287 | base.PerformLayout(); 288 | } 289 | 290 | // Token: 0x04000002 RID: 2 291 | private global::System.ComponentModel.IContainer components = null; 292 | 293 | // Token: 0x04000003 RID: 3 294 | private new global::System.Windows.Forms.PictureBox Close; 295 | 296 | // Token: 0x04000004 RID: 4 297 | private global::MaterialSkin.Controls.MaterialCheckBox Constants; 298 | 299 | // Token: 0x04000005 RID: 5 300 | private global::MaterialSkin.Controls.MaterialRaisedButton Protect; 301 | 302 | // Token: 0x04000006 RID: 6 303 | private global::MaterialSkin.Controls.MaterialCheckBox VM; 304 | 305 | // Token: 0x04000007 RID: 7 306 | private global::MaterialSkin.Controls.MaterialCheckBox ReferenceProxy; 307 | 308 | // Token: 0x04000008 RID: 8 309 | private global::MaterialSkin.Controls.MaterialCheckBox ControlFlow; 310 | 311 | // Token: 0x04000009 RID: 9 312 | private global::MaterialSkin.Controls.MaterialCheckBox InvalidOpcodes; 313 | 314 | // Token: 0x0400000A RID: 10 315 | private global::MaterialSkin.Controls.MaterialCheckBox Renamer; 316 | 317 | // Token: 0x0400000B RID: 11 318 | private global::MaterialSkin.Controls.MaterialCheckBox AntiDebug; 319 | 320 | // Token: 0x0400000C RID: 12 321 | private global::MaterialSkin.Controls.MaterialCheckBox AntiDump; 322 | 323 | // Token: 0x0400000D RID: 13 324 | private global::MaterialSkin.Controls.MaterialSingleLineTextField FPath; 325 | 326 | // Token: 0x0400000E RID: 14 327 | private global::MaterialSkin.Controls.MaterialCheckBox WaterMark; 328 | 329 | // Token: 0x0400000F RID: 15 330 | private global::MaterialSkin.Controls.MaterialCheckBox CallConvertion; 331 | 332 | // Token: 0x04000010 RID: 16 333 | private global::System.Windows.Forms.PictureBox pictureBox1; 334 | 335 | // Token: 0x04000011 RID: 17 336 | private global::MaterialSkin.Controls.MaterialCheckBox FakeAttributes; 337 | 338 | // Token: 0x04000012 RID: 18 339 | private global::MaterialSkin.Controls.MaterialCheckBox ReferenceOverload; 340 | 341 | // Token: 0x04000013 RID: 19 342 | private global::MaterialSkin.Controls.MaterialCheckBox Mutation; 343 | } 344 | } 345 | -------------------------------------------------------------------------------- /SugarGuard/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Runtime.InteropServices; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | using MaterialSkin; 9 | using MaterialSkin.Controls; 10 | using SugarGuard.Properties; 11 | using SugarGuard.Protector; 12 | using SugarGuard.Protector.Enums; 13 | 14 | namespace SugarGuard 15 | { 16 | // Token: 0x02000002 RID: 2 17 | public partial class Main : Form 18 | { 19 | // Token: 0x06000001 RID: 1 20 | [DllImport("Gdi32.dll")] 21 | private static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse); 22 | 23 | // Token: 0x06000002 RID: 2 24 | [DllImport("user32.dll")] 25 | public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); 26 | 27 | // Token: 0x06000003 RID: 3 28 | [DllImport("user32.dll")] 29 | public static extern bool ReleaseCapture(); 30 | 31 | // Token: 0x06000004 RID: 4 RVA: 0x00002050 File Offset: 0x00000250 32 | public Main() 33 | { 34 | this.InitializeComponent(); 35 | MaterialSkinManager instance = MaterialSkinManager.Instance; 36 | instance.Theme = MaterialSkinManager.Themes.DARK; 37 | instance.ColorScheme = new ColorScheme(Primary.Pink600, Primary.Pink600, Primary.Pink600, Accent.Pink400, TextShade.WHITE); 38 | base.Region = Region.FromHrgn(Main.CreateRoundRectRgn(0, 0, base.Width, base.Height, 5, 5)); 39 | Control.CheckForIllegalCrossThreadCalls = false; 40 | this.AllowDrop = true; 41 | } 42 | 43 | // Token: 0x06000005 RID: 5 RVA: 0x000020E4 File Offset: 0x000002E4 44 | private void Main_DragDrop(object sender, DragEventArgs e) 45 | { 46 | string[] array = (string[])e.Data.GetData(DataFormats.FileDrop); 47 | foreach (string target in array) 48 | { 49 | this.Target = target; 50 | } 51 | this.FPath.Text = Path.GetFileName(this.Target); 52 | } 53 | 54 | // Token: 0x06000006 RID: 6 RVA: 0x0000213C File Offset: 0x0000033C 55 | private void Main_DragEnter(object sender, DragEventArgs e) 56 | { 57 | bool dataPresent = e.Data.GetDataPresent(DataFormats.FileDrop); 58 | if (dataPresent) 59 | { 60 | e.Effect = DragDropEffects.Copy; 61 | } 62 | } 63 | 64 | // Token: 0x06000007 RID: 7 RVA: 0x00002168 File Offset: 0x00000368 65 | private void Main_MouseDown(object sender, MouseEventArgs e) 66 | { 67 | bool flag = e.Button == MouseButtons.Left; 68 | if (flag) 69 | { 70 | Main.ReleaseCapture(); 71 | Main.SendMessage(base.Handle, 161, 2, 0); 72 | } 73 | } 74 | 75 | // Token: 0x06000008 RID: 8 RVA: 0x000021A2 File Offset: 0x000003A2 76 | private void Close_Click(object sender, EventArgs e) 77 | { 78 | Application.Exit(); 79 | } 80 | 81 | // Token: 0x06000009 RID: 9 RVA: 0x000021AB File Offset: 0x000003AB 82 | private void Protect_Click(object sender, EventArgs e) 83 | { 84 | new Task(delegate() 85 | { 86 | Sugar sugar = new Sugar(this.Target); 87 | bool @checked = this.VM.Checked; 88 | if (@checked) 89 | { 90 | sugar.protections.Add(Protections.VM); 91 | } 92 | bool checked2 = this.CallConvertion.Checked; 93 | if (checked2) 94 | { 95 | sugar.protections.Add(Protections.CallConvertion); 96 | } 97 | bool checked3 = this.AntiDebug.Checked; 98 | if (checked3) 99 | { 100 | sugar.protections.Add(Protections.AntiDebug); 101 | } 102 | bool checked4 = this.AntiDump.Checked; 103 | if (checked4) 104 | { 105 | sugar.protections.Add(Protections.AntiDump); 106 | } 107 | bool checked5 = this.Constants.Checked; 108 | if (checked5) 109 | { 110 | sugar.protections.Add(Protections.Constants); 111 | sugar.protections.Add(Protections.PosConstants); 112 | } 113 | bool checked6 = this.Mutation.Checked; 114 | if (checked6) 115 | { 116 | sugar.protections.Add(Protections.Mutation); 117 | } 118 | bool checked7 = this.ControlFlow.Checked; 119 | if (checked7) 120 | { 121 | sugar.protections.Add(Protections.ControlFlow); 122 | } 123 | bool checked8 = this.ReferenceProxy.Checked; 124 | if (checked8) 125 | { 126 | sugar.protections.Add(Protections.ReferenceProxy); 127 | } 128 | bool checked9 = this.InvalidOpcodes.Checked; 129 | if (checked9) 130 | { 131 | sugar.protections.Add(Protections.InvalidOpcodes); 132 | } 133 | bool checked10 = this.Renamer.Checked; 134 | if (checked10) 135 | { 136 | sugar.protections.Add(Protections.Renamer); 137 | } 138 | bool checked11 = this.FakeAttributes.Checked; 139 | if (checked11) 140 | { 141 | sugar.protections.Add(Protections.FakeAttributes); 142 | } 143 | bool checked12 = this.WaterMark.Checked; 144 | if (checked12) 145 | { 146 | sugar.protections.Add(Protections.WaterMark); 147 | } 148 | sugar.Protect(); 149 | sugar.Save(); 150 | Console.Beep(500, 500); 151 | }).Start(); 152 | } 153 | 154 | // Token: 0x0600000A RID: 10 RVA: 0x000021C8 File Offset: 0x000003C8 155 | private void FPath_Click(object sender, EventArgs e) 156 | { 157 | OpenFileDialog openFileDialog = new OpenFileDialog(); 158 | bool flag = openFileDialog.ShowDialog() == DialogResult.OK; 159 | if (flag) 160 | { 161 | this.FPath.Text = openFileDialog.FileName; 162 | this.Target = this.FPath.Text; 163 | } 164 | } 165 | 166 | // Token: 0x04000001 RID: 1 167 | private string Target = string.Empty; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /SugarGuard/Main.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/SugarGuard/Main.resources -------------------------------------------------------------------------------- /SugarGuard/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace SugarGuard 5 | { 6 | // Token: 0x02000003 RID: 3 7 | internal class Program 8 | { 9 | // Token: 0x0600000E RID: 14 RVA: 0x00003549 File Offset: 0x00001749 10 | [STAThread] 11 | private static void Main(string[] args) 12 | { 13 | Application.EnableVisualStyles(); 14 | Application.Run(new Main()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SugarGuard/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 | using System.Security; 8 | using System.Security.Permissions; 9 | 10 | [assembly: AssemblyVersion("1.0.0.0")] 11 | [assembly: AssemblyTitle("SugarGuard")] 12 | [assembly: AssemblyDescription("")] 13 | [assembly: AssemblyConfiguration("")] 14 | [assembly: AssemblyCompany("")] 15 | [assembly: AssemblyProduct("SugarGuard")] 16 | [assembly: AssemblyCopyright("Copyright © 2020")] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: ComVisible(false)] 19 | [assembly: Guid("5dc9d4b0-249b-4f38-91f0-938580537d9d")] 20 | [assembly: AssemblyFileVersion("1.0.0.0")] 21 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 22 | -------------------------------------------------------------------------------- /SugarGuard/Properties/Resources.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom.Compiler; 3 | using System.ComponentModel; 4 | using System.Diagnostics; 5 | using System.Drawing; 6 | using System.Globalization; 7 | using System.Resources; 8 | using System.Runtime.CompilerServices; 9 | 10 | namespace SugarGuard.Properties 11 | { 12 | // Token: 0x02000038 RID: 56 13 | [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 14 | [DebuggerNonUserCode] 15 | [CompilerGenerated] 16 | internal class Resources 17 | { 18 | // Token: 0x06000127 RID: 295 RVA: 0x0000E2D8 File Offset: 0x0000C4D8 19 | internal Resources() 20 | { 21 | } 22 | 23 | // Token: 0x17000023 RID: 35 24 | // (get) Token: 0x06000128 RID: 296 RVA: 0x0000E2E4 File Offset: 0x0000C4E4 25 | [EditorBrowsable(EditorBrowsableState.Advanced)] 26 | internal static ResourceManager ResourceManager 27 | { 28 | get 29 | { 30 | bool flag = Resources.resourceMan == null; 31 | if (flag) 32 | { 33 | ResourceManager resourceManager = new ResourceManager("SugarGuard.Properties.Resources", typeof(Resources).Assembly); 34 | Resources.resourceMan = resourceManager; 35 | } 36 | return Resources.resourceMan; 37 | } 38 | } 39 | 40 | // Token: 0x17000024 RID: 36 41 | // (get) Token: 0x06000129 RID: 297 RVA: 0x0000E32C File Offset: 0x0000C52C 42 | // (set) Token: 0x0600012A RID: 298 RVA: 0x0000E343 File Offset: 0x0000C543 43 | [EditorBrowsable(EditorBrowsableState.Advanced)] 44 | internal static CultureInfo Culture 45 | { 46 | get 47 | { 48 | return Resources.resourceCulture; 49 | } 50 | set 51 | { 52 | Resources.resourceCulture = value; 53 | } 54 | } 55 | 56 | // Token: 0x17000025 RID: 37 57 | // (get) Token: 0x0600012B RID: 299 RVA: 0x0000E34C File Offset: 0x0000C54C 58 | internal static Bitmap Delete 59 | { 60 | get 61 | { 62 | object @object = Resources.ResourceManager.GetObject("Delete", Resources.resourceCulture); 63 | return (Bitmap)@object; 64 | } 65 | } 66 | 67 | // Token: 0x17000026 RID: 38 68 | // (get) Token: 0x0600012C RID: 300 RVA: 0x0000E37C File Offset: 0x0000C57C 69 | internal static Bitmap Logo 70 | { 71 | get 72 | { 73 | object @object = Resources.ResourceManager.GetObject("Logo", Resources.resourceCulture); 74 | return (Bitmap)@object; 75 | } 76 | } 77 | 78 | // Token: 0x04000079 RID: 121 79 | private static ResourceManager resourceMan; 80 | 81 | // Token: 0x0400007A RID: 122 82 | private static CultureInfo resourceCulture; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /SugarGuard/Properties/Resources.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/SugarGuard/Properties/Resources.resources -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/Constants/DynamicContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Reflection.Emit; 6 | using dnlib.DotNet; 7 | using dnlib.DotNet.Emit; 8 | 9 | namespace SugarGuard.Protector.Class.Constants 10 | { 11 | // Token: 0x02000034 RID: 52 12 | public class DynamicContext : ImportContext 13 | { 14 | // Token: 0x0600010E RID: 270 RVA: 0x0000DA39 File Offset: 0x0000BC39 15 | public DynamicContext(ModuleDef module) : base(module) 16 | { 17 | this.LocalRefs = new Dictionary(); 18 | this.BranchRefs = new Dictionary(); 19 | this.ExceptionHandlers = new List(); 20 | } 21 | 22 | // Token: 0x0600010F RID: 271 RVA: 0x0000DA68 File Offset: 0x0000BC68 23 | public override void Initialize() 24 | { 25 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(ILGenerator))); 26 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(DynamicMethod))); 27 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(LocalBuilder))); 28 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(Type))); 29 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(MethodInfo))); 30 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(Label))); 31 | base.AddTypeImport(base.Module.ImportAsTypeSig(typeof(object))); 32 | base.AddRefImport(base.Module.Import(typeof(Type).GetMethod("GetTypeFromHandle", new Type[] 33 | { 34 | typeof(RuntimeTypeHandle) 35 | }))); 36 | base.AddRefImport(base.Module.Import(typeof(DynamicMethod).GetConstructor(new Type[] 37 | { 38 | typeof(string), 39 | typeof(System.Reflection.MethodAttributes), 40 | typeof(CallingConventions), 41 | typeof(Type), 42 | typeof(Type[]), 43 | typeof(Type), 44 | typeof(bool) 45 | }))); 46 | base.AddRefImport(base.Module.Import(typeof(DynamicMethod).GetMethod("GetILGenerator", new Type[0]))); 47 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("DeclareLocal", new Type[] 48 | { 49 | typeof(Type) 50 | }))); 51 | base.AddRefImport(base.Module.Import(typeof(Type).GetMethod("get_Module"))); 52 | base.AddRefImport(base.Module.Import(typeof(MethodBase).GetMethod("Invoke", new Type[] 53 | { 54 | typeof(object), 55 | typeof(object[]) 56 | }))); 57 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("DefineLabel"))); 58 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("MarkLabel", new Type[] 59 | { 60 | typeof(Label) 61 | }))); 62 | base.AddRefImport(base.Module.Import(typeof(MethodInfo).GetMethod("GetBaseDefinition"))); 63 | base.AddRefImport(base.Module.Import(typeof(Type).GetMethod("GetField", new Type[] 64 | { 65 | typeof(string), 66 | typeof(BindingFlags) 67 | }))); 68 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("BeginExceptionBlock"))); 69 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("BeginCatchBlock", new Type[] 70 | { 71 | typeof(Type) 72 | }))); 73 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("BeginExceptFilterBlock"))); 74 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("BeginFinallyBlock"))); 75 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("BeginFaultBlock"))); 76 | base.AddRefImport(base.Module.Import(typeof(ILGenerator).GetMethod("EndExceptionBlock"))); 77 | } 78 | 79 | // Token: 0x06000110 RID: 272 RVA: 0x0000DE88 File Offset: 0x0000C088 80 | public bool IsBranchTarget(Instruction instruction, out Local label) 81 | { 82 | label = this.BranchRefs.FirstOrDefault((KeyValuePair x) => (Instruction)x.Key.Operand == instruction).Value; 83 | return label != null; 84 | } 85 | 86 | // Token: 0x06000111 RID: 273 RVA: 0x0000DED0 File Offset: 0x0000C0D0 87 | public bool IsExceptionStart(Instruction instruction) 88 | { 89 | return this.ExceptionHandlers.FirstOrDefault((dnlib.DotNet.Emit.ExceptionHandler x) => x.TryStart == instruction) != null; 90 | } 91 | 92 | // Token: 0x06000112 RID: 274 RVA: 0x0000DF0C File Offset: 0x0000C10C 93 | public bool IsExceptionEnd(Instruction instruction) 94 | { 95 | return this.ExceptionHandlers.FirstOrDefault((dnlib.DotNet.Emit.ExceptionHandler x) => x.HandlerEnd == instruction) != null; 96 | } 97 | 98 | // Token: 0x06000113 RID: 275 RVA: 0x0000DF48 File Offset: 0x0000C148 99 | public bool IsHandlerStart(Instruction instruction, out MemberRef beginMethod, out dnlib.DotNet.Emit.ExceptionHandler ex) 100 | { 101 | ex = this.ExceptionHandlers.FirstOrDefault((dnlib.DotNet.Emit.ExceptionHandler x) => x.HandlerStart == instruction); 102 | beginMethod = null; 103 | bool flag = ex == null; 104 | bool result; 105 | if (flag) 106 | { 107 | result = false; 108 | } 109 | else 110 | { 111 | string name = (ex.HandlerType == ExceptionHandlerType.Filter) ? this.FormatName("ExceptFilter") : this.FormatName(ex.HandlerType.ToString()); 112 | beginMethod = base.GetRefImport(name); 113 | result = true; 114 | } 115 | return result; 116 | } 117 | 118 | // Token: 0x06000114 RID: 276 RVA: 0x0000DFCC File Offset: 0x0000C1CC 119 | private string FormatName(string handlerName) 120 | { 121 | return "Begin" + handlerName + "Block"; 122 | } 123 | 124 | // Token: 0x0400006C RID: 108 125 | public Dictionary BranchRefs; 126 | 127 | // Token: 0x0400006D RID: 109 128 | public Dictionary LocalRefs; 129 | 130 | // Token: 0x0400006E RID: 110 131 | public List ExceptionHandlers; 132 | 133 | // Token: 0x0400006F RID: 111 134 | public Instruction Branch; 135 | 136 | // Token: 0x04000070 RID: 112 137 | public Local ILGenerator; 138 | 139 | // Token: 0x04000071 RID: 113 140 | public Local DynamicMethod; 141 | 142 | // Token: 0x04000072 RID: 114 143 | public Local MethodInfo; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/Constants/DynamicMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Reflection.Emit; 5 | 6 | namespace SugarGuard.Protector.Class.Constants 7 | { 8 | // Token: 0x02000036 RID: 54 9 | internal static class DynamicMethods 10 | { 11 | // Token: 0x0600011D RID: 285 RVA: 0x0000E0C0 File Offset: 0x0000C2C0 12 | internal static MethodInfo GetCreatedMethodInfo(DynamicMethod method) 13 | { 14 | bool flag = DynamicMethods._methods == null; 15 | if (flag) 16 | { 17 | DynamicMethods._methods = new Dictionary(); 18 | } 19 | bool flag2 = DynamicMethods._methods.ContainsKey(method.Name); 20 | MethodInfo result; 21 | if (flag2) 22 | { 23 | result = DynamicMethods._methods[method.Name]; 24 | } 25 | else 26 | { 27 | result = null; 28 | } 29 | return result; 30 | } 31 | 32 | // Token: 0x0600011E RID: 286 RVA: 0x0000E110 File Offset: 0x0000C310 33 | internal static void SetMethodInfo(DynamicMethod method, MethodInfo methodInfo) 34 | { 35 | bool flag = !DynamicMethods._methods.ContainsKey(method.Name); 36 | if (flag) 37 | { 38 | DynamicMethods._methods.Add(method.Name, methodInfo); 39 | } 40 | else 41 | { 42 | DynamicMethods._methods[method.Name] = methodInfo; 43 | } 44 | } 45 | 46 | // Token: 0x0600011F RID: 287 RVA: 0x0000E15C File Offset: 0x0000C35C 47 | internal static MethodInfo GetMethod(Type ownerType, string name, Type[] parameters) 48 | { 49 | MethodInfo methodInfo = ownerType.GetMethod(name, parameters); 50 | bool flag = methodInfo == null; 51 | if (flag) 52 | { 53 | foreach (MethodInfo methodInfo2 in ownerType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) 54 | { 55 | bool flag2 = methodInfo2.Name == name && DynamicMethods.HasSameParamSig(parameters, methodInfo2.GetParameters()); 56 | if (flag2) 57 | { 58 | methodInfo = methodInfo2; 59 | break; 60 | } 61 | } 62 | } 63 | bool isGenericMethod = methodInfo.IsGenericMethod; 64 | MethodInfo result; 65 | if (isGenericMethod) 66 | { 67 | result = methodInfo.GetGenericMethodDefinition(); 68 | } 69 | else 70 | { 71 | result = methodInfo; 72 | } 73 | return result; 74 | } 75 | 76 | // Token: 0x06000120 RID: 288 RVA: 0x0000E1E8 File Offset: 0x0000C3E8 77 | internal static ConstructorInfo GetConstructor(Type ownerType, Type[] parameters) 78 | { 79 | ConstructorInfo constructorInfo = ownerType.GetConstructor(parameters); 80 | bool flag = constructorInfo == null; 81 | if (flag) 82 | { 83 | foreach (ConstructorInfo constructorInfo2 in ownerType.GetConstructors()) 84 | { 85 | bool flag2 = DynamicMethods.HasSameParamSig(parameters, constructorInfo2.GetParameters()); 86 | if (flag2) 87 | { 88 | constructorInfo = constructorInfo2; 89 | break; 90 | } 91 | } 92 | } 93 | return constructorInfo; 94 | } 95 | 96 | // Token: 0x06000121 RID: 289 RVA: 0x0000E248 File Offset: 0x0000C448 97 | private static bool HasSameParamSig(Type[] fParameters, ParameterInfo[] sParameters) 98 | { 99 | bool flag = fParameters.Length != sParameters.Length; 100 | bool result; 101 | if (flag) 102 | { 103 | result = false; 104 | } 105 | else 106 | { 107 | for (int i = 0; i < fParameters.Length; i++) 108 | { 109 | bool flag2 = fParameters[i] != sParameters[i].ParameterType; 110 | if (flag2) 111 | { 112 | return false; 113 | } 114 | } 115 | result = true; 116 | } 117 | return result; 118 | } 119 | 120 | // Token: 0x04000076 RID: 118 121 | private static Dictionary _methods; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/Constants/EncodedMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | 4 | namespace SugarGuard.Protector.Class.Constants 5 | { 6 | // Token: 0x02000037 RID: 55 7 | public class EncodedMethod 8 | { 9 | // Token: 0x17000021 RID: 33 10 | // (get) Token: 0x06000122 RID: 290 RVA: 0x0000E29C File Offset: 0x0000C49C 11 | // (set) Token: 0x06000123 RID: 291 RVA: 0x0000E2A4 File Offset: 0x0000C4A4 12 | public MethodDef eMethod { get; private set; } 13 | 14 | // Token: 0x17000022 RID: 34 15 | // (get) Token: 0x06000124 RID: 292 RVA: 0x0000E2AD File Offset: 0x0000C4AD 16 | // (set) Token: 0x06000125 RID: 293 RVA: 0x0000E2B5 File Offset: 0x0000C4B5 17 | public int eNum { get; private set; } 18 | 19 | // Token: 0x06000126 RID: 294 RVA: 0x0000E2BE File Offset: 0x0000C4BE 20 | public EncodedMethod(MethodDef method, int num) 21 | { 22 | this.eMethod = method; 23 | this.eNum = num; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/Constants/ImportContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | 6 | namespace SugarGuard.Protector.Class.Constants 7 | { 8 | // Token: 0x02000035 RID: 53 9 | public abstract class ImportContext 10 | { 11 | // Token: 0x17000020 RID: 32 12 | // (get) Token: 0x06000115 RID: 277 RVA: 0x0000DFEE File Offset: 0x0000C1EE 13 | // (set) Token: 0x06000116 RID: 278 RVA: 0x0000DFF6 File Offset: 0x0000C1F6 14 | public ModuleDef Module { get; private set; } 15 | 16 | // Token: 0x06000117 RID: 279 RVA: 0x0000DFFF File Offset: 0x0000C1FF 17 | public ImportContext(ModuleDef module) 18 | { 19 | this.Module = module; 20 | } 21 | 22 | // Token: 0x06000118 RID: 280 23 | public abstract void Initialize(); 24 | 25 | // Token: 0x06000119 RID: 281 RVA: 0x0000E027 File Offset: 0x0000C227 26 | public void AddRefImport(IMemberRef mRef) 27 | { 28 | this.importedRefs.Add(mRef); 29 | } 30 | 31 | // Token: 0x0600011A RID: 282 RVA: 0x0000E037 File Offset: 0x0000C237 32 | public void AddTypeImport(IType type) 33 | { 34 | this.importedTypes.Add(type); 35 | } 36 | 37 | // Token: 0x0600011B RID: 283 RVA: 0x0000E048 File Offset: 0x0000C248 38 | public T GetRefImport(string name) 39 | { 40 | return (T)((object)this.importedRefs.FirstOrDefault((IMemberRef x) => x.Name == name)); 41 | } 42 | 43 | // Token: 0x0600011C RID: 284 RVA: 0x0000E084 File Offset: 0x0000C284 44 | public T GetTypeImport(string name) 45 | { 46 | return (T)((object)this.importedTypes.FirstOrDefault((IType x) => x.Name == name)); 47 | } 48 | 49 | // Token: 0x04000073 RID: 115 50 | private List importedRefs = new List(); 51 | 52 | // Token: 0x04000074 RID: 116 53 | private List importedTypes = new List(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/Constants/Inject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | 5 | namespace SugarGuard.Protector.Class.Constants 6 | { 7 | // Token: 0x02000033 RID: 51 8 | internal class Inject 9 | { 10 | // Token: 0x0600010C RID: 268 RVA: 0x0000D94C File Offset: 0x0000BB4C 11 | public DynamicContext Execute(SugarLib context, ModuleDef moduleDef) 12 | { 13 | Inject.allMethods = new Dictionary(); 14 | ModuleDefMD moduleDefMD = ModuleDefMD.Load(typeof(DynamicMethods).Module); 15 | TypeDef typeDef = moduleDefMD.ResolveTypeDef(MDToken.ToRID(typeof(DynamicMethods).MetadataToken)); 16 | IEnumerable enumerable = InjectHelper.Inject(typeDef, moduleDef.GlobalType, moduleDef); 17 | DynamicContext dynamicContext = new DynamicContext(moduleDef); 18 | foreach (IDnlibDef dnlibDef in enumerable) 19 | { 20 | MethodDef methodDef = dnlibDef as MethodDef; 21 | bool flag = methodDef != null; 22 | if (flag) 23 | { 24 | dynamicContext.AddRefImport(methodDef); 25 | Inject.allMethods.Add(methodDef.Name, methodDef); 26 | } 27 | } 28 | dynamicContext.Initialize(); 29 | return dynamicContext; 30 | } 31 | 32 | // Token: 0x0400006B RID: 107 33 | public static Dictionary allMethods; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/InjectHelper.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 SugarGuard.Protector.Class 8 | { 9 | // Token: 0x0200002E RID: 46 10 | public static class InjectHelper 11 | { 12 | // Token: 0x060000D1 RID: 209 RVA: 0x0000B544 File Offset: 0x00009744 13 | private static TypeDefUser Clone(TypeDef origin) 14 | { 15 | TypeDefUser typeDefUser = new TypeDefUser(origin.Namespace, origin.Name); 16 | typeDefUser.Attributes = origin.Attributes; 17 | bool flag = origin.ClassLayout != null; 18 | if (flag) 19 | { 20 | typeDefUser.ClassLayout = new ClassLayoutUser(origin.ClassLayout.PackingSize, origin.ClassSize); 21 | } 22 | foreach (GenericParam genericParam in origin.GenericParameters) 23 | { 24 | typeDefUser.GenericParameters.Add(new GenericParamUser(genericParam.Number, genericParam.Flags, "-")); 25 | } 26 | return typeDefUser; 27 | } 28 | 29 | // Token: 0x060000D2 RID: 210 RVA: 0x0000B604 File Offset: 0x00009804 30 | private static MethodDefUser Clone(MethodDef origin) 31 | { 32 | MethodDefUser methodDefUser = new MethodDefUser(origin.Name, null, origin.ImplAttributes, origin.Attributes); 33 | foreach (GenericParam genericParam in origin.GenericParameters) 34 | { 35 | methodDefUser.GenericParameters.Add(new GenericParamUser(genericParam.Number, genericParam.Flags, "-")); 36 | } 37 | return methodDefUser; 38 | } 39 | 40 | // Token: 0x060000D3 RID: 211 RVA: 0x0000B694 File Offset: 0x00009894 41 | private static FieldDefUser Clone(FieldDef origin) 42 | { 43 | return new FieldDefUser(origin.Name, null, origin.Attributes); 44 | } 45 | 46 | // Token: 0x060000D4 RID: 212 RVA: 0x0000B6BC File Offset: 0x000098BC 47 | private static TypeDef PopulateContext(TypeDef typeDef, InjectHelper.InjectContext ctx) 48 | { 49 | IDnlibDef dnlibDef; 50 | bool flag = !ctx.map.TryGetValue(typeDef, out dnlibDef); 51 | TypeDef typeDef2; 52 | if (flag) 53 | { 54 | typeDef2 = InjectHelper.Clone(typeDef); 55 | ctx.map[typeDef] = typeDef2; 56 | } 57 | else 58 | { 59 | typeDef2 = (TypeDef)dnlibDef; 60 | } 61 | foreach (TypeDef typeDef3 in typeDef.NestedTypes) 62 | { 63 | typeDef2.NestedTypes.Add(InjectHelper.PopulateContext(typeDef3, ctx)); 64 | } 65 | foreach (MethodDef methodDef in typeDef.Methods) 66 | { 67 | typeDef2.Methods.Add((MethodDef)(ctx.map[methodDef] = InjectHelper.Clone(methodDef))); 68 | } 69 | foreach (FieldDef fieldDef in typeDef.Fields) 70 | { 71 | typeDef2.Fields.Add((FieldDef)(ctx.map[fieldDef] = InjectHelper.Clone(fieldDef))); 72 | } 73 | return typeDef2; 74 | } 75 | 76 | // Token: 0x060000D5 RID: 213 RVA: 0x0000B828 File Offset: 0x00009A28 77 | private static void CopyTypeDef(TypeDef typeDef, InjectHelper.InjectContext ctx) 78 | { 79 | TypeDef typeDef2 = (TypeDef)ctx.map[typeDef]; 80 | typeDef2.BaseType = ctx.Importer.Import(typeDef.BaseType); 81 | foreach (InterfaceImpl interfaceImpl in typeDef.Interfaces) 82 | { 83 | typeDef2.Interfaces.Add(new InterfaceImplUser(ctx.Importer.Import(interfaceImpl.Interface))); 84 | } 85 | } 86 | 87 | // Token: 0x060000D6 RID: 214 RVA: 0x0000B8C4 File Offset: 0x00009AC4 88 | private static void CopyMethodDef(MethodDef methodDef, InjectHelper.InjectContext ctx) 89 | { 90 | MethodDef methodDef2 = (MethodDef)ctx.map[methodDef]; 91 | methodDef2.Signature = ctx.Importer.Import(methodDef.Signature); 92 | methodDef2.Parameters.UpdateParameterTypes(); 93 | bool flag = methodDef.ImplMap != null; 94 | if (flag) 95 | { 96 | methodDef2.ImplMap = new ImplMapUser(new ModuleRefUser(ctx.TargetModule, methodDef.ImplMap.Module.Name), methodDef.ImplMap.Name, methodDef.ImplMap.Attributes); 97 | } 98 | foreach (CustomAttribute customAttribute in methodDef.CustomAttributes) 99 | { 100 | methodDef2.CustomAttributes.Add(new CustomAttribute((ICustomAttributeType)ctx.Importer.Import(customAttribute.Constructor))); 101 | } 102 | bool hasBody = methodDef.HasBody; 103 | if (hasBody) 104 | { 105 | methodDef2.Body = new CilBody(methodDef.Body.InitLocals, new List(), new List(), new List()); 106 | methodDef2.Body.MaxStack = methodDef.Body.MaxStack; 107 | Dictionary bodyMap = new Dictionary(); 108 | foreach (Local local in methodDef.Body.Variables) 109 | { 110 | Local local2 = new Local(ctx.Importer.Import(local.Type)); 111 | methodDef2.Body.Variables.Add(local2); 112 | local2.Name = local.Name; 113 | bodyMap[local] = local2; 114 | } 115 | foreach (Instruction instruction in methodDef.Body.Instructions) 116 | { 117 | Instruction instruction2 = new Instruction(instruction.OpCode, instruction.Operand); 118 | instruction2.SequencePoint = instruction.SequencePoint; 119 | bool flag2 = instruction2.Operand is IType; 120 | if (flag2) 121 | { 122 | instruction2.Operand = ctx.Importer.Import((IType)instruction2.Operand); 123 | } 124 | else 125 | { 126 | bool flag3 = instruction2.Operand is IMethod; 127 | if (flag3) 128 | { 129 | instruction2.Operand = ctx.Importer.Import((IMethod)instruction2.Operand); 130 | } 131 | else 132 | { 133 | bool flag4 = instruction2.Operand is IField; 134 | if (flag4) 135 | { 136 | instruction2.Operand = ctx.Importer.Import((IField)instruction2.Operand); 137 | } 138 | } 139 | } 140 | methodDef2.Body.Instructions.Add(instruction2); 141 | bodyMap[instruction] = instruction2; 142 | } 143 | Func <>9__0; 144 | foreach (Instruction instruction3 in methodDef2.Body.Instructions) 145 | { 146 | bool flag5 = instruction3.Operand != null && bodyMap.ContainsKey(instruction3.Operand); 147 | if (flag5) 148 | { 149 | instruction3.Operand = bodyMap[instruction3.Operand]; 150 | } 151 | else 152 | { 153 | bool flag6 = instruction3.Operand is Instruction[]; 154 | if (flag6) 155 | { 156 | Instruction instruction4 = instruction3; 157 | IEnumerable source = (Instruction[])instruction3.Operand; 158 | Func selector; 159 | if ((selector = <>9__0) == null) 160 | { 161 | selector = (<>9__0 = ((Instruction target) => (Instruction)bodyMap[target])); 162 | } 163 | instruction4.Operand = source.Select(selector).ToArray(); 164 | } 165 | } 166 | } 167 | foreach (ExceptionHandler exceptionHandler in methodDef.Body.ExceptionHandlers) 168 | { 169 | methodDef2.Body.ExceptionHandlers.Add(new ExceptionHandler(exceptionHandler.HandlerType) 170 | { 171 | CatchType = ((exceptionHandler.CatchType == null) ? null : ctx.Importer.Import(exceptionHandler.CatchType)), 172 | TryStart = (Instruction)bodyMap[exceptionHandler.TryStart], 173 | TryEnd = (Instruction)bodyMap[exceptionHandler.TryEnd], 174 | HandlerStart = (Instruction)bodyMap[exceptionHandler.HandlerStart], 175 | HandlerEnd = (Instruction)bodyMap[exceptionHandler.HandlerEnd], 176 | FilterStart = ((exceptionHandler.FilterStart == null) ? null : ((Instruction)bodyMap[exceptionHandler.FilterStart])) 177 | }); 178 | } 179 | methodDef2.Body.SimplifyMacros(methodDef2.Parameters); 180 | } 181 | } 182 | 183 | // Token: 0x060000D7 RID: 215 RVA: 0x0000BE4C File Offset: 0x0000A04C 184 | private static void CopyFieldDef(FieldDef fieldDef, InjectHelper.InjectContext ctx) 185 | { 186 | FieldDef fieldDef2 = (FieldDef)ctx.map[fieldDef]; 187 | fieldDef2.Signature = ctx.Importer.Import(fieldDef.Signature); 188 | } 189 | 190 | // Token: 0x060000D8 RID: 216 RVA: 0x0000BE88 File Offset: 0x0000A088 191 | private static void Copy(TypeDef typeDef, InjectHelper.InjectContext ctx, bool copySelf) 192 | { 193 | if (copySelf) 194 | { 195 | InjectHelper.CopyTypeDef(typeDef, ctx); 196 | } 197 | foreach (TypeDef typeDef2 in typeDef.NestedTypes) 198 | { 199 | InjectHelper.Copy(typeDef2, ctx, true); 200 | } 201 | foreach (MethodDef methodDef in typeDef.Methods) 202 | { 203 | InjectHelper.CopyMethodDef(methodDef, ctx); 204 | } 205 | foreach (FieldDef fieldDef in typeDef.Fields) 206 | { 207 | InjectHelper.CopyFieldDef(fieldDef, ctx); 208 | } 209 | } 210 | 211 | // Token: 0x060000D9 RID: 217 RVA: 0x0000BF70 File Offset: 0x0000A170 212 | public static TypeDef Inject(TypeDef typeDef, ModuleDef target) 213 | { 214 | InjectHelper.InjectContext injectContext = new InjectHelper.InjectContext(typeDef.Module, target); 215 | InjectHelper.PopulateContext(typeDef, injectContext); 216 | InjectHelper.Copy(typeDef, injectContext, true); 217 | return (TypeDef)injectContext.map[typeDef]; 218 | } 219 | 220 | // Token: 0x060000DA RID: 218 RVA: 0x0000BFB4 File Offset: 0x0000A1B4 221 | public static MethodDef Inject(MethodDef methodDef, ModuleDef target) 222 | { 223 | InjectHelper.InjectContext injectContext = new InjectHelper.InjectContext(methodDef.Module, target); 224 | injectContext.map[methodDef] = InjectHelper.Clone(methodDef); 225 | InjectHelper.CopyMethodDef(methodDef, injectContext); 226 | return (MethodDef)injectContext.map[methodDef]; 227 | } 228 | 229 | // Token: 0x060000DB RID: 219 RVA: 0x0000C000 File Offset: 0x0000A200 230 | public static IEnumerable Inject(TypeDef typeDef, TypeDef newType, ModuleDef target) 231 | { 232 | InjectHelper.InjectContext injectContext = new InjectHelper.InjectContext(typeDef.Module, target); 233 | injectContext.map[typeDef] = newType; 234 | InjectHelper.PopulateContext(typeDef, injectContext); 235 | InjectHelper.Copy(typeDef, injectContext, false); 236 | return injectContext.map.Values.Except(new TypeDef[] 237 | { 238 | newType 239 | }); 240 | } 241 | 242 | // Token: 0x0200004F RID: 79 243 | private class InjectContext : ImportMapper 244 | { 245 | // Token: 0x0600017E RID: 382 RVA: 0x0000F11C File Offset: 0x0000D31C 246 | public InjectContext(ModuleDef module, ModuleDef target) 247 | { 248 | this.OriginModule = module; 249 | this.TargetModule = target; 250 | this.importer = new Importer(target, ImporterOptions.TryToUseTypeDefs, default(GenericParamContext), this); 251 | } 252 | 253 | // Token: 0x1700002D RID: 45 254 | // (get) Token: 0x0600017F RID: 383 RVA: 0x0000F164 File Offset: 0x0000D364 255 | public Importer Importer 256 | { 257 | get 258 | { 259 | return this.importer; 260 | } 261 | } 262 | 263 | // Token: 0x06000180 RID: 384 RVA: 0x0000F17C File Offset: 0x0000D37C 264 | public override ITypeDefOrRef Map(ITypeDefOrRef typeDefOrRef) 265 | { 266 | TypeDef typeDef = typeDefOrRef as TypeDef; 267 | bool flag = typeDef != null; 268 | if (flag) 269 | { 270 | bool flag2 = this.map.ContainsKey(typeDef); 271 | if (flag2) 272 | { 273 | return (TypeDef)this.map[typeDef]; 274 | } 275 | } 276 | return null; 277 | } 278 | 279 | // Token: 0x06000181 RID: 385 RVA: 0x0000F1C4 File Offset: 0x0000D3C4 280 | public override IMethod Map(MethodDef methodDef) 281 | { 282 | bool flag = this.map.ContainsKey(methodDef); 283 | IMethod result; 284 | if (flag) 285 | { 286 | result = (MethodDef)this.map[methodDef]; 287 | } 288 | else 289 | { 290 | result = null; 291 | } 292 | return result; 293 | } 294 | 295 | // Token: 0x06000182 RID: 386 RVA: 0x0000F1FC File Offset: 0x0000D3FC 296 | public override IField Map(FieldDef fieldDef) 297 | { 298 | bool flag = this.map.ContainsKey(fieldDef); 299 | IField result; 300 | if (flag) 301 | { 302 | result = (FieldDef)this.map[fieldDef]; 303 | } 304 | else 305 | { 306 | result = null; 307 | } 308 | return result; 309 | } 310 | 311 | // Token: 0x040000AF RID: 175 312 | public readonly Dictionary map = new Dictionary(); 313 | 314 | // Token: 0x040000B0 RID: 176 315 | public readonly ModuleDef OriginModule; 316 | 317 | // Token: 0x040000B1 RID: 177 318 | public readonly ModuleDef TargetModule; 319 | 320 | // Token: 0x040000B2 RID: 178 321 | private readonly Importer importer; 322 | } 323 | } 324 | } 325 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/MutationHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | 6 | namespace SugarGuard.Protector.Class 7 | { 8 | // Token: 0x0200002F RID: 47 9 | public class MutationHelper 10 | { 11 | // Token: 0x060000DC RID: 220 RVA: 0x0000C058 File Offset: 0x0000A258 12 | public static bool CanObfuscate(IList instructions, int i) 13 | { 14 | bool flag = instructions[i + 1].GetOperand() != null; 15 | if (flag) 16 | { 17 | bool flag2 = instructions[i + 1].Operand.ToString().Contains("bool"); 18 | if (flag2) 19 | { 20 | return false; 21 | } 22 | } 23 | bool flag3 = instructions[i + 1].GetOpCode() == OpCodes.Newobj; 24 | bool result; 25 | if (flag3) 26 | { 27 | result = false; 28 | } 29 | else 30 | { 31 | bool flag4 = instructions[i].GetLdcI4Value() == 0 || instructions[i].GetLdcI4Value() == 1; 32 | result = !flag4; 33 | } 34 | return result; 35 | } 36 | 37 | // Token: 0x060000DD RID: 221 RVA: 0x0000C0EC File Offset: 0x0000A2EC 38 | public static List ParseMethod(MethodDef method) 39 | { 40 | List list = new List(); 41 | List list2 = new List(method.Body.Instructions); 42 | MutationHelper.Block block = new MutationHelper.Block(); 43 | int num = 0; 44 | int num2 = 0; 45 | block.Number = num; 46 | block.Instructions.Add(Instruction.Create(OpCodes.Nop)); 47 | list.Add(block); 48 | block = new MutationHelper.Block(); 49 | Stack stack = new Stack(); 50 | foreach (Instruction instruction in method.Body.Instructions) 51 | { 52 | foreach (ExceptionHandler exceptionHandler in method.Body.ExceptionHandlers) 53 | { 54 | bool flag = exceptionHandler.HandlerStart == instruction || exceptionHandler.TryStart == instruction || exceptionHandler.FilterStart == instruction; 55 | if (flag) 56 | { 57 | stack.Push(exceptionHandler); 58 | } 59 | } 60 | foreach (ExceptionHandler exceptionHandler2 in method.Body.ExceptionHandlers) 61 | { 62 | bool flag2 = exceptionHandler2.HandlerEnd == instruction || exceptionHandler2.TryEnd == instruction; 63 | if (flag2) 64 | { 65 | stack.Pop(); 66 | } 67 | } 68 | int num3; 69 | int num4; 70 | instruction.CalculateStackUsage(out num3, out num4); 71 | block.Instructions.Add(instruction); 72 | num2 += num3 - num4; 73 | bool flag3 = num3 == 0; 74 | if (flag3) 75 | { 76 | bool flag4 = instruction.OpCode != OpCodes.Nop; 77 | if (flag4) 78 | { 79 | bool flag5 = (num2 == 0 || instruction.OpCode == OpCodes.Ret) && stack.Count == 0; 80 | if (flag5) 81 | { 82 | num = (block.Number = num + 1); 83 | list.Add(block); 84 | block = new MutationHelper.Block(); 85 | } 86 | } 87 | } 88 | } 89 | return list; 90 | } 91 | 92 | // Token: 0x02000051 RID: 81 93 | public class Block 94 | { 95 | // Token: 0x06000185 RID: 389 RVA: 0x0000F24F File Offset: 0x0000D44F 96 | public Block() 97 | { 98 | this.Instructions = new List(); 99 | } 100 | 101 | // Token: 0x1700002E RID: 46 102 | // (get) Token: 0x06000186 RID: 390 RVA: 0x0000F265 File Offset: 0x0000D465 103 | // (set) Token: 0x06000187 RID: 391 RVA: 0x0000F26D File Offset: 0x0000D46D 104 | public List Instructions { get; set; } 105 | 106 | // Token: 0x1700002F RID: 47 107 | // (get) Token: 0x06000188 RID: 392 RVA: 0x0000F276 File Offset: 0x0000D476 108 | // (set) Token: 0x06000189 RID: 393 RVA: 0x0000F27E File Offset: 0x0000D47E 109 | public int Number { get; set; } 110 | 111 | // Token: 0x17000030 RID: 48 112 | // (get) Token: 0x0600018A RID: 394 RVA: 0x0000F287 File Offset: 0x0000D487 113 | // (set) Token: 0x0600018B RID: 395 RVA: 0x0000F28F File Offset: 0x0000D48F 114 | public int Next { get; set; } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/RandomHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SugarGuard.Protector.Class 4 | { 5 | // Token: 0x02000030 RID: 48 6 | public class RandomHelper 7 | { 8 | // Token: 0x060000DF RID: 223 RVA: 0x0000C344 File Offset: 0x0000A544 9 | public RandomHelper(int Seed) 10 | { 11 | int num = (Seed == int.MinValue) ? int.MaxValue : Math.Abs(Seed); 12 | int num2 = 161803398 - num; 13 | this.SeedArray[55] = num2; 14 | int num3 = 1; 15 | for (int i = 1; i < 55; i++) 16 | { 17 | int num4 = 21 * i % 55; 18 | this.SeedArray[num4] = num3; 19 | num3 = num2 - num3; 20 | bool flag = num3 < 0; 21 | if (flag) 22 | { 23 | num3 += int.MaxValue; 24 | } 25 | num2 = this.SeedArray[num4]; 26 | } 27 | for (int j = 1; j < 5; j++) 28 | { 29 | for (int k = 1; k < 56; k++) 30 | { 31 | this.SeedArray[k] -= this.SeedArray[1 + (k + 30) % 55]; 32 | bool flag2 = this.SeedArray[k] < 0; 33 | if (flag2) 34 | { 35 | this.SeedArray[k] += int.MaxValue; 36 | } 37 | } 38 | } 39 | this.inext = 0; 40 | this.inextp = 21; 41 | Seed = 1; 42 | } 43 | 44 | // Token: 0x060000E0 RID: 224 RVA: 0x0000C46C File Offset: 0x0000A66C 45 | public double InternalSample() 46 | { 47 | int num = this.inext = 0; 48 | int num2 = this.inextp = 21; 49 | bool flag = ++num >= 56; 50 | if (flag) 51 | { 52 | num = 1; 53 | } 54 | bool flag2 = ++num2 >= 56; 55 | if (flag2) 56 | { 57 | num2 = 1; 58 | } 59 | int num3 = this.SeedArray[num] - this.SeedArray[num2]; 60 | bool flag3 = num3 == int.MaxValue; 61 | if (flag3) 62 | { 63 | num3--; 64 | } 65 | bool flag4 = num3 < 0; 66 | if (flag4) 67 | { 68 | num3 += int.MaxValue; 69 | } 70 | this.SeedArray[num] = num3; 71 | this.inext = num; 72 | this.inextp = num2; 73 | return (double)num3; 74 | } 75 | 76 | // Token: 0x04000059 RID: 89 77 | private int inext; 78 | 79 | // Token: 0x0400005A RID: 90 80 | private int inextp; 81 | 82 | // Token: 0x0400005B RID: 91 83 | private int[] SeedArray = new int[56]; 84 | 85 | // Token: 0x0400005C RID: 92 86 | private const int MBIG = 2147483647; 87 | 88 | // Token: 0x0400005D RID: 93 89 | private const int MSEED = 161803398; 90 | 91 | // Token: 0x0400005E RID: 94 92 | private const int MZ = 0; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Class/SugarLib.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Writer; 5 | using SugarGuard.Protector.Enums; 6 | 7 | namespace SugarGuard.Protector.Class 8 | { 9 | // Token: 0x02000031 RID: 49 10 | public class SugarLib 11 | { 12 | // Token: 0x17000014 RID: 20 13 | // (get) Token: 0x060000E1 RID: 225 RVA: 0x0000C50E File Offset: 0x0000A70E 14 | // (set) Token: 0x060000E2 RID: 226 RVA: 0x0000C516 File Offset: 0x0000A716 15 | public string filePath { get; private set; } 16 | 17 | // Token: 0x17000015 RID: 21 18 | // (get) Token: 0x060000E3 RID: 227 RVA: 0x0000C51F File Offset: 0x0000A71F 19 | // (set) Token: 0x060000E4 RID: 228 RVA: 0x0000C527 File Offset: 0x0000A727 20 | public AssemblyDef assembly { get; private set; } 21 | 22 | // Token: 0x17000016 RID: 22 23 | // (get) Token: 0x060000E5 RID: 229 RVA: 0x0000C530 File Offset: 0x0000A730 24 | // (set) Token: 0x060000E6 RID: 230 RVA: 0x0000C538 File Offset: 0x0000A738 25 | public ModuleDef moduleDef { get; private set; } 26 | 27 | // Token: 0x17000017 RID: 23 28 | // (get) Token: 0x060000E7 RID: 231 RVA: 0x0000C541 File Offset: 0x0000A741 29 | // (set) Token: 0x060000E8 RID: 232 RVA: 0x0000C549 File Offset: 0x0000A749 30 | public TypeDef globalType { get; private set; } 31 | 32 | // Token: 0x17000018 RID: 24 33 | // (get) Token: 0x060000E9 RID: 233 RVA: 0x0000C552 File Offset: 0x0000A752 34 | // (set) Token: 0x060000EA RID: 234 RVA: 0x0000C55A File Offset: 0x0000A75A 35 | public MethodDef ctor { get; private set; } 36 | 37 | // Token: 0x17000019 RID: 25 38 | // (get) Token: 0x060000EB RID: 235 RVA: 0x0000C563 File Offset: 0x0000A763 39 | // (set) Token: 0x060000EC RID: 236 RVA: 0x0000C56B File Offset: 0x0000A76B 40 | public NativeModuleWriterOptions nativeModuleWriterOptions { get; private set; } 41 | 42 | // Token: 0x1700001A RID: 26 43 | // (get) Token: 0x060000ED RID: 237 RVA: 0x0000C574 File Offset: 0x0000A774 44 | // (set) Token: 0x060000EE RID: 238 RVA: 0x0000C57C File Offset: 0x0000A77C 45 | public ModuleWriterOptions moduleWriterOptions { get; private set; } 46 | 47 | // Token: 0x1700001B RID: 27 48 | // (get) Token: 0x060000EF RID: 239 RVA: 0x0000C585 File Offset: 0x0000A785 49 | // (set) Token: 0x060000F0 RID: 240 RVA: 0x0000C58D File Offset: 0x0000A78D 50 | public bool noThrowInstance { get; set; } 51 | 52 | // Token: 0x060000F1 RID: 241 RVA: 0x0000C598 File Offset: 0x0000A798 53 | public SugarLib(string file) 54 | { 55 | this.filePath = file; 56 | this.assembly = AssemblyDef.Load(file, null); 57 | this.moduleDef = this.assembly.ManifestModule; 58 | this.globalType = this.assembly.ManifestModule.GlobalType; 59 | this.ctor = this.assembly.ManifestModule.GlobalType.FindOrCreateStaticConstructor(); 60 | this.noThrowInstance = false; 61 | this.nativeModuleWriterOptions = new NativeModuleWriterOptions(this.moduleDef as ModuleDefMD, true) 62 | { 63 | MetadataLogger = DummyLogger.NoThrowInstance 64 | }; 65 | this.moduleWriterOptions = new ModuleWriterOptions(this.moduleDef) 66 | { 67 | MetadataLogger = DummyLogger.NoThrowInstance 68 | }; 69 | } 70 | 71 | // Token: 0x060000F2 RID: 242 RVA: 0x0000C652 File Offset: 0x0000A852 72 | private void Listener() 73 | { 74 | } 75 | 76 | // Token: 0x060000F3 RID: 243 RVA: 0x0000C658 File Offset: 0x0000A858 77 | private string NewName() 78 | { 79 | return string.Concat(new string[] 80 | { 81 | Path.GetDirectoryName(this.filePath), 82 | "//", 83 | Path.GetFileNameWithoutExtension(this.filePath), 84 | "_Sugary", 85 | Path.GetExtension(this.filePath) 86 | }); 87 | } 88 | 89 | // Token: 0x060000F4 RID: 244 RVA: 0x0000C6B0 File Offset: 0x0000A8B0 90 | public void buildASM(saveMode mode) 91 | { 92 | bool flag = mode == saveMode.Normal; 93 | if (flag) 94 | { 95 | this.moduleWriterOptions.MetadataOptions.Flags = (MetadataFlags.AlwaysCreateGuidHeap | MetadataFlags.AlwaysCreateStringsHeap | MetadataFlags.AlwaysCreateUSHeap | MetadataFlags.AlwaysCreateBlobHeap); 96 | this.moduleDef.Write(this.NewName(), this.moduleWriterOptions); 97 | } 98 | else 99 | { 100 | bool flag2 = mode == saveMode.x86; 101 | if (flag2) 102 | { 103 | this.nativeModuleWriterOptions.MetadataOptions.Flags = (MetadataFlags.AlwaysCreateGuidHeap | MetadataFlags.AlwaysCreateStringsHeap | MetadataFlags.AlwaysCreateUSHeap | MetadataFlags.AlwaysCreateBlobHeap); 104 | (this.moduleDef as ModuleDefMD).NativeWrite(this.NewName(), this.nativeModuleWriterOptions); 105 | } 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Enums/Protections.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SugarGuard.Protector.Enums 4 | { 5 | // Token: 0x0200002D RID: 45 6 | public enum Protections 7 | { 8 | // Token: 0x0400004A RID: 74 9 | Constants, 10 | // Token: 0x0400004B RID: 75 11 | PosConstants, 12 | // Token: 0x0400004C RID: 76 13 | VM, 14 | // Token: 0x0400004D RID: 77 15 | ReferenceProxy, 16 | // Token: 0x0400004E RID: 78 17 | ControlFlow, 18 | // Token: 0x0400004F RID: 79 19 | InvalidOpcodes, 20 | // Token: 0x04000050 RID: 80 21 | Renamer, 22 | // Token: 0x04000051 RID: 81 23 | AntiDebug, 24 | // Token: 0x04000052 RID: 82 25 | AntiDump, 26 | // Token: 0x04000053 RID: 83 27 | ReferenceOverload, 28 | // Token: 0x04000054 RID: 84 29 | WaterMark, 30 | // Token: 0x04000055 RID: 85 31 | CallConvertion, 32 | // Token: 0x04000056 RID: 86 33 | FakeAttributes, 34 | // Token: 0x04000057 RID: 87 35 | MethodHider, 36 | // Token: 0x04000058 RID: 88 37 | Mutation 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Enums/saveMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SugarGuard.Protector.Enums 4 | { 5 | // Token: 0x0200002C RID: 44 6 | public enum saveMode 7 | { 8 | // Token: 0x04000047 RID: 71 9 | Normal, 10 | // Token: 0x04000048 RID: 72 11 | x86 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/AntiDebug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | using dnlib.DotNet.Emit; 6 | using SugarGuard.Protector.Class; 7 | using SugarGuard.Protector.Protections.Runtime; 8 | 9 | namespace SugarGuard.Protector.Protections 10 | { 11 | // Token: 0x02000006 RID: 6 12 | public class AntiDebug 13 | { 14 | // Token: 0x06000017 RID: 23 RVA: 0x0000381B File Offset: 0x00001A1B 15 | public AntiDebug(SugarLib lib) 16 | { 17 | this.Main(lib); 18 | } 19 | 20 | // Token: 0x06000018 RID: 24 RVA: 0x0000382C File Offset: 0x00001A2C 21 | private void Main(SugarLib lib) 22 | { 23 | ModuleDef moduleDef = lib.moduleDef; 24 | ModuleDefMD moduleDefMD = ModuleDefMD.Load(typeof(AntiDebug).Module); 25 | TypeDef typeDef = moduleDefMD.ResolveTypeDef(MDToken.ToRID(typeof(AntiDebug).MetadataToken)); 26 | IEnumerable source = InjectHelper.Inject(typeDef, moduleDef.EntryPoint.DeclaringType, moduleDef); 27 | MethodDef method2 = (MethodDef)source.Single((IDnlibDef method) => method.Name == "Initialize"); 28 | MethodDef entryPoint = moduleDef.EntryPoint; 29 | entryPoint.Body.Instructions.Insert(0, OpCodes.Call.ToInstruction(method2)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/AntiDump.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | using dnlib.DotNet.Emit; 6 | using SugarGuard.Protector.Class; 7 | using SugarGuard.Protector.Protections.Runtime; 8 | 9 | namespace SugarGuard.Protector.Protections 10 | { 11 | // Token: 0x02000005 RID: 5 12 | public class AntiDump 13 | { 14 | // Token: 0x06000015 RID: 21 RVA: 0x0000375C File Offset: 0x0000195C 15 | public AntiDump(SugarLib lib) 16 | { 17 | this.Main(lib); 18 | } 19 | 20 | // Token: 0x06000016 RID: 22 RVA: 0x00003770 File Offset: 0x00001970 21 | private void Main(SugarLib lib) 22 | { 23 | ModuleDef moduleDef = lib.moduleDef; 24 | ModuleDefMD moduleDefMD = ModuleDefMD.Load(typeof(AntiDump).Module); 25 | TypeDef typeDef = moduleDefMD.ResolveTypeDef(MDToken.ToRID(typeof(AntiDump).MetadataToken)); 26 | IEnumerable source = InjectHelper.Inject(typeDef, moduleDef.GlobalType, moduleDef); 27 | MethodDef method2 = (MethodDef)source.Single((IDnlibDef method) => method.Name == "AntiDumpInj"); 28 | MethodDef methodDef = moduleDef.GlobalType.FindStaticConstructor(); 29 | methodDef.Body.Instructions.Insert(0, OpCodes.Call.ToInstruction(method2)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/CallConvertion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using dnlib.DotNet; 6 | using dnlib.DotNet.Emit; 7 | using SugarGuard.Protector.Class; 8 | 9 | namespace SugarGuard.Protector.Protections 10 | { 11 | // Token: 0x02000008 RID: 8 12 | public class CallConvertion 13 | { 14 | // Token: 0x0600001B RID: 27 RVA: 0x00003B0C File Offset: 0x00001D0C 15 | public CallConvertion(SugarLib lib) 16 | { 17 | this.Main(lib); 18 | } 19 | 20 | // Token: 0x0600001C RID: 28 RVA: 0x00003B20 File Offset: 0x00001D20 21 | private void Main(SugarLib lib) 22 | { 23 | Local local = new Local(lib.ctor.Module.ImportAsTypeSig(typeof(Module))); 24 | lib.ctor.Body.Variables.Add(local); 25 | FieldDef fieldDef = new FieldDefUser(Renamer.InvisibleName, new FieldSig(lib.moduleDef.ImportAsTypeSig(typeof(IntPtr[]))), dnlib.DotNet.FieldAttributes.FamANDAssem | dnlib.DotNet.FieldAttributes.Family | dnlib.DotNet.FieldAttributes.Static); 26 | lib.moduleDef.GlobalType.Fields.Add(fieldDef); 27 | List list = new List 28 | { 29 | OpCodes.Ldtoken.ToInstruction(lib.moduleDef.GlobalType), 30 | OpCodes.Call.ToInstruction(lib.moduleDef.Import(typeof(Type).GetMethod("GetTypeFromHandle", new Type[] 31 | { 32 | typeof(RuntimeTypeHandle) 33 | }))), 34 | OpCodes.Callvirt.ToInstruction(lib.moduleDef.Import(typeof(Type).GetMethod("get_Module"))), 35 | OpCodes.Stloc.ToInstruction(local), 36 | OpCodes.Ldc_I4.ToInstruction(666), 37 | OpCodes.Newarr.ToInstruction(lib.moduleDef.CorLibTypes.IntPtr), 38 | OpCodes.Stsfld.ToInstruction(fieldDef) 39 | }; 40 | Dictionary dictionary = new Dictionary(); 41 | int num = 0; 42 | foreach (TypeDef typeDef in lib.moduleDef.Types.ToArray()) 43 | { 44 | foreach (MethodDef methodDef in typeDef.Methods.ToArray()) 45 | { 46 | bool isConstructor = methodDef.IsConstructor; 47 | if (!isConstructor) 48 | { 49 | bool flag = methodDef.Body == null; 50 | if (!flag) 51 | { 52 | bool flag2 = methodDef.HasBody && methodDef.Body.HasInstructions && !methodDef.IsConstructor && !methodDef.DeclaringType.IsGlobalModuleType; 53 | if (flag2) 54 | { 55 | IList instructions = methodDef.Body.Instructions; 56 | int k = 0; 57 | while (k < instructions.Count()) 58 | { 59 | MemberRef memberRef; 60 | bool flag3; 61 | if (instructions[k].OpCode == OpCodes.Call || instructions[k].OpCode == OpCodes.Callvirt) 62 | { 63 | memberRef = (instructions[k].Operand as MemberRef); 64 | flag3 = (memberRef != null); 65 | } 66 | else 67 | { 68 | flag3 = false; 69 | } 70 | bool flag4 = flag3; 71 | if (flag4) 72 | { 73 | bool hasThis = memberRef.HasThis; 74 | if (!hasThis) 75 | { 76 | int key = memberRef.MDToken.ToInt32(); 77 | bool flag5 = !dictionary.ContainsKey(key); 78 | if (flag5) 79 | { 80 | list.Add(OpCodes.Ldsfld.ToInstruction(fieldDef)); 81 | list.Add(OpCodes.Ldc_I4.ToInstruction(num)); 82 | list.Add(OpCodes.Ldftn.ToInstruction(memberRef)); 83 | list.Add(OpCodes.Stelem_I.ToInstruction()); 84 | list.Add(OpCodes.Nop.ToInstruction()); 85 | instructions[k].OpCode = OpCodes.Ldsfld; 86 | instructions[k].Operand = fieldDef; 87 | instructions.Insert(++k, Instruction.Create(OpCodes.Ldc_I4, num)); 88 | instructions.Insert(++k, Instruction.Create(OpCodes.Ldelem_I)); 89 | instructions.Insert(++k, Instruction.Create(OpCodes.Calli, memberRef.MethodSig)); 90 | dictionary.Add(key, num); 91 | num++; 92 | } 93 | else 94 | { 95 | int value; 96 | dictionary.TryGetValue(key, out value); 97 | instructions[k].OpCode = OpCodes.Ldsfld; 98 | instructions[k].Operand = fieldDef; 99 | instructions.Insert(++k, Instruction.Create(OpCodes.Ldc_I4, value)); 100 | instructions.Insert(++k, Instruction.Create(OpCodes.Ldelem_I)); 101 | instructions.Insert(++k, Instruction.Create(OpCodes.Calli, memberRef.MethodSig)); 102 | } 103 | } 104 | } 105 | IL_430: 106 | k++; 107 | continue; 108 | goto IL_430; 109 | } 110 | } 111 | } 112 | } 113 | } 114 | } 115 | list[4].OpCode = OpCodes.Ldc_I4; 116 | list[4].Operand = num; 117 | for (int l = 0; l < list.Count; l++) 118 | { 119 | lib.ctor.Body.Instructions.Insert(l, list[l]); 120 | } 121 | } 122 | 123 | // Token: 0x0600001D RID: 29 RVA: 0x00003FFC File Offset: 0x000021FC 124 | public static bool IsDelegate(TypeDef type) 125 | { 126 | bool flag = type.BaseType == null; 127 | bool result; 128 | if (flag) 129 | { 130 | result = false; 131 | } 132 | else 133 | { 134 | string fullName = type.BaseType.FullName; 135 | result = (fullName == "System.Delegate" || fullName == "System.MulticastDelegate"); 136 | } 137 | return result; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Constants/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | using dnlib.DotNet.Emit; 6 | using SugarGuard.Protector.Class; 7 | using SugarGuard.Protector.Class.Constants; 8 | using SugarGuard.Protector.Protections.Runtime; 9 | 10 | namespace SugarGuard.Protector.Protections.Constants 11 | { 12 | // Token: 0x0200002A RID: 42 13 | public class Constants 14 | { 15 | // Token: 0x060000C5 RID: 197 RVA: 0x0000A9B4 File Offset: 0x00008BB4 16 | public Constants(SugarLib lib) 17 | { 18 | Constants.encodedMethods = new List(); 19 | this.Main(lib); 20 | } 21 | 22 | // Token: 0x060000C6 RID: 198 RVA: 0x0000A9D0 File Offset: 0x00008BD0 23 | private void Main(SugarLib lib) 24 | { 25 | ModuleDef moduleDef = lib.moduleDef; 26 | int[] array = this.GenerateArray(); 27 | string invisibleName = Renamer.InvisibleName; 28 | FieldDefUser fieldDefUser = new FieldDefUser(invisibleName, new FieldSig(moduleDef.ImportAsTypeSig(typeof(int[]))), FieldAttributes.FamANDAssem | FieldAttributes.Family | FieldAttributes.Static); 29 | moduleDef.GlobalType.Fields.Add(fieldDefUser); 30 | this.InjectArray(array, lib.ctor, fieldDefUser); 31 | MethodDef methodDef = this.InjectDecryptor(lib); 32 | methodDef = this.ModifyDecryptor(methodDef, fieldDefUser); 33 | foreach (TypeDef typeDef in moduleDef.Types) 34 | { 35 | bool isGlobalModuleType = typeDef.IsGlobalModuleType; 36 | if (!isGlobalModuleType) 37 | { 38 | foreach (MethodDef methodDef2 in typeDef.Methods) 39 | { 40 | bool flag = !methodDef2.HasBody || !methodDef2.Body.HasInstructions; 41 | if (!flag) 42 | { 43 | bool flag2 = !this.hasStrings(methodDef2); 44 | if (!flag2) 45 | { 46 | for (int i = 0; i < methodDef2.Body.Instructions.Count; i++) 47 | { 48 | bool flag3 = methodDef2.Body.Instructions[i].OpCode == OpCodes.Ldstr; 49 | if (flag3) 50 | { 51 | Local local = new Local(methodDef2.Module.ImportAsTypeSig(typeof(string))); 52 | methodDef2.Body.Variables.Add(local); 53 | string s = methodDef2.Body.Instructions[i].Operand.ToString(); 54 | methodDef2.Body.Instructions[i].OpCode = OpCodes.Ldloc; 55 | methodDef2.Body.Instructions[i].Operand = local; 56 | methodDef2.Body.Instructions.Insert(0, OpCodes.Ldstr.ToInstruction(s)); 57 | methodDef2.Body.Instructions.Insert(1, OpCodes.Stloc_S.ToInstruction(local)); 58 | i += 2; 59 | } 60 | } 61 | int num = Constants.rnd.Next(100, 500); 62 | Constants.encodedMethods.Add(new EncodedMethod(methodDef2, num)); 63 | MethodDef methodDef3 = moduleDef.GlobalType.FindOrCreateStaticConstructor(); 64 | Local local2 = new Local(moduleDef.ImportAsTypeSig(typeof(RuntimeMethodHandle))); 65 | methodDef3.Body.Variables.Add(local2); 66 | methodDef3.Body.Instructions.Insert(0, OpCodes.Ldtoken.ToInstruction(methodDef2)); 67 | methodDef3.Body.Instructions.Insert(1, OpCodes.Stloc.ToInstruction(local2)); 68 | for (int j = 0; j < methodDef2.Body.Instructions.Count; j++) 69 | { 70 | bool flag4 = methodDef2.Body.Instructions[j].OpCode == OpCodes.Ldstr; 71 | if (flag4) 72 | { 73 | string s2 = methodDef2.Body.Instructions[j].Operand.ToString(); 74 | int num2 = Constants.rnd.Next(10, 50); 75 | string s3 = this.EncodeString(s2, num2 + num, array); 76 | FieldDefUser fieldDefUser2 = new FieldDefUser(Renamer.GenerateName(), new FieldSig(moduleDef.ImportAsTypeSig(typeof(string))), FieldAttributes.FamANDAssem | FieldAttributes.Family | FieldAttributes.Static); 77 | moduleDef.GlobalType.Fields.Add(fieldDefUser2); 78 | int num3 = methodDef3.Body.Instructions.Count - 1; 79 | methodDef3.Body.Instructions.Insert(num3, OpCodes.Ldstr.ToInstruction(s3)); 80 | methodDef3.Body.Instructions.Insert(++num3, OpCodes.Ldc_I4.ToInstruction(num2)); 81 | methodDef3.Body.Instructions.Insert(++num3, OpCodes.Ldloc.ToInstruction(local2)); 82 | methodDef3.Body.Instructions.Insert(++num3, OpCodes.Call.ToInstruction(methodDef)); 83 | methodDef3.Body.Instructions.Insert(num3 + 1, OpCodes.Stsfld.ToInstruction(fieldDefUser2)); 84 | methodDef2.Body.Instructions[j] = OpCodes.Ldsfld.ToInstruction(fieldDefUser2); 85 | methodDef2.Body.SimplifyBranches(); 86 | methodDef2.Body.OptimizeBranches(); 87 | } 88 | } 89 | } 90 | } 91 | } 92 | } 93 | } 94 | } 95 | 96 | // Token: 0x060000C7 RID: 199 RVA: 0x0000AED4 File Offset: 0x000090D4 97 | private string EncodeString(string s, int realkey, int[] array) 98 | { 99 | for (int i = 0; i < array.Length; i++) 100 | { 101 | realkey += array[i]; 102 | } 103 | char[] array2 = new char[s.Length]; 104 | for (int j = 0; j < s.Length; j++) 105 | { 106 | array2[j] = (char)((int)s[j] ^ realkey); 107 | } 108 | return new string(array2); 109 | } 110 | 111 | // Token: 0x060000C8 RID: 200 RVA: 0x0000AF3C File Offset: 0x0000913C 112 | private int[] GenerateArray() 113 | { 114 | int[] array = new int[Constants.rnd.Next(10, 50)]; 115 | for (int i = 0; i < array.Length; i++) 116 | { 117 | array[i] = Constants.rnd.Next(100, 500); 118 | } 119 | return array; 120 | } 121 | 122 | // Token: 0x060000C9 RID: 201 RVA: 0x0000AF8C File Offset: 0x0000918C 123 | private void InjectArray(int[] array, MethodDef cctor, FieldDef arrayField) 124 | { 125 | bool flag = Constants.rnd.Next(0, 3) == 1; 126 | if (flag) 127 | { 128 | List list = new List 129 | { 130 | OpCodes.Ldc_I4.ToInstruction(array.Length), 131 | OpCodes.Newarr.ToInstruction(cctor.Module.CorLibTypes.Int32), 132 | OpCodes.Stsfld.ToInstruction(arrayField) 133 | }; 134 | for (int i = 0; i < array.Length; i++) 135 | { 136 | list.Add(OpCodes.Ldsfld.ToInstruction(arrayField)); 137 | list.Add(OpCodes.Ldc_I4.ToInstruction(i)); 138 | list.Add(OpCodes.Ldc_I4.ToInstruction(array[i])); 139 | list.Add(OpCodes.Stelem_I4.ToInstruction()); 140 | list.Add(OpCodes.Nop.ToInstruction()); 141 | } 142 | for (int j = 0; j < list.Count; j++) 143 | { 144 | cctor.Body.Instructions.Insert(j, list[j]); 145 | } 146 | } 147 | else 148 | { 149 | List list2 = new List 150 | { 151 | OpCodes.Ldc_I4.ToInstruction(array.Length), 152 | OpCodes.Newarr.ToInstruction(cctor.Module.CorLibTypes.Int32), 153 | OpCodes.Dup.ToInstruction() 154 | }; 155 | for (int k = 0; k < array.Length; k++) 156 | { 157 | list2.Add(OpCodes.Ldc_I4.ToInstruction(k)); 158 | list2.Add(OpCodes.Ldc_I4.ToInstruction(array[k])); 159 | list2.Add(OpCodes.Stelem_I4.ToInstruction()); 160 | bool flag2 = k != array.Length - 1; 161 | if (flag2) 162 | { 163 | list2.Add(OpCodes.Dup.ToInstruction()); 164 | } 165 | } 166 | list2.Add(OpCodes.Stsfld.ToInstruction(arrayField)); 167 | for (int l = 0; l < list2.Count; l++) 168 | { 169 | cctor.Body.Instructions.Insert(l, list2[l]); 170 | } 171 | } 172 | } 173 | 174 | // Token: 0x060000CA RID: 202 RVA: 0x0000B1C0 File Offset: 0x000093C0 175 | private MethodDef InjectDecryptor(SugarLib lib) 176 | { 177 | ModuleDefMD moduleDefMD = ModuleDefMD.Load(typeof(ConstantsRuntime).Module); 178 | TypeDef typeDef = moduleDefMD.ResolveTypeDef(MDToken.ToRID(typeof(ConstantsRuntime).MetadataToken)); 179 | IEnumerable enumerable = InjectHelper.Inject(typeDef, lib.globalType, lib.moduleDef); 180 | MethodDef result = (MethodDef)enumerable.Single((IDnlibDef method) => method.Name == "Decrypt"); 181 | foreach (IDnlibDef dnlibDef in enumerable) 182 | { 183 | dnlibDef.Name = Constants.GenerateName(); 184 | } 185 | return result; 186 | } 187 | 188 | // Token: 0x060000CB RID: 203 RVA: 0x0000B294 File Offset: 0x00009494 189 | public static string GenerateName() 190 | { 191 | return new string((from s in Enumerable.Repeat("あいうえおかきくけこがぎぐげごさしすせそざじずぜアイウエオクザタツワルムパリピンプペヲポ", 10) 192 | select s[Constants.rnd.Next(s.Length)]).ToArray()); 193 | } 194 | 195 | // Token: 0x060000CC RID: 204 RVA: 0x0000B2E0 File Offset: 0x000094E0 196 | private MethodDef ModifyDecryptor(MethodDef dec, FieldDef field) 197 | { 198 | for (int i = 0; i < dec.Body.Instructions.Count; i++) 199 | { 200 | bool flag = dec.Body.Instructions[i].OpCode == OpCodes.Ldsfld; 201 | if (flag) 202 | { 203 | dec.Body.Instructions[i].OpCode = OpCodes.Ldsfld; 204 | dec.Body.Instructions[i].Operand = field; 205 | } 206 | } 207 | return dec; 208 | } 209 | 210 | // Token: 0x060000CD RID: 205 RVA: 0x0000B36C File Offset: 0x0000956C 211 | private bool hasStrings(MethodDef method) 212 | { 213 | foreach (Instruction instruction in method.Body.Instructions) 214 | { 215 | bool flag = instruction.OpCode == OpCodes.Ldstr; 216 | if (flag) 217 | { 218 | return true; 219 | } 220 | } 221 | return false; 222 | } 223 | 224 | // Token: 0x04000044 RID: 68 225 | public static List encodedMethods; 226 | 227 | // Token: 0x04000045 RID: 69 228 | public static Random rnd = new Random(); 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Constants/PosConstants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | using SugarGuard.Protector.Class; 6 | using SugarGuard.Protector.Class.Constants; 7 | 8 | namespace SugarGuard.Protector.Protections.Constants 9 | { 10 | // Token: 0x0200002B RID: 43 11 | public class PosConstants 12 | { 13 | // Token: 0x060000CF RID: 207 RVA: 0x0000B3E4 File Offset: 0x000095E4 14 | public PosConstants(SugarLib lib) 15 | { 16 | this.Main(lib); 17 | } 18 | 19 | // Token: 0x060000D0 RID: 208 RVA: 0x0000B3F8 File Offset: 0x000095F8 20 | private void Main(SugarLib lib) 21 | { 22 | foreach (TypeDef typeDef in lib.moduleDef.Types) 23 | { 24 | foreach (MethodDef methodDef in typeDef.Methods) 25 | { 26 | List encodedMethods = Constants.encodedMethods; 27 | foreach (EncodedMethod encodedMethod in encodedMethods) 28 | { 29 | bool flag = encodedMethod.eMethod == methodDef; 30 | if (flag) 31 | { 32 | methodDef.Body.Instructions.Add(OpCodes.Ldstr.ToInstruction(encodedMethod.eNum.ToString())); 33 | methodDef.Body.Instructions.Add(OpCodes.Pop.ToInstruction()); 34 | methodDef.Body.Instructions.Add(OpCodes.Ret.ToInstruction()); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/BlockParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using dnlib.DotNet.Emit; 7 | 8 | namespace SugarGuard.Protector.Protections.ControlFlow 9 | { 10 | // Token: 0x02000021 RID: 33 11 | internal static class BlockParser 12 | { 13 | // Token: 0x0600009A RID: 154 RVA: 0x00008798 File Offset: 0x00006998 14 | public static BlockParser.ScopeBlock ParseBody(CilBody body) 15 | { 16 | Dictionary> dictionary = new Dictionary>(); 17 | foreach (ExceptionHandler exceptionHandler in body.ExceptionHandlers) 18 | { 19 | BlockParser.ScopeBlock item = new BlockParser.ScopeBlock(BlockParser.BlockType.Try, exceptionHandler); 20 | BlockParser.BlockType type = BlockParser.BlockType.Handler; 21 | bool flag = exceptionHandler.HandlerType == ExceptionHandlerType.Finally; 22 | if (flag) 23 | { 24 | type = BlockParser.BlockType.Finally; 25 | } 26 | else 27 | { 28 | bool flag2 = exceptionHandler.HandlerType == ExceptionHandlerType.Fault; 29 | if (flag2) 30 | { 31 | type = BlockParser.BlockType.Fault; 32 | } 33 | } 34 | BlockParser.ScopeBlock item2 = new BlockParser.ScopeBlock(type, exceptionHandler); 35 | bool flag3 = exceptionHandler.FilterStart != null; 36 | if (flag3) 37 | { 38 | BlockParser.ScopeBlock item3 = new BlockParser.ScopeBlock(BlockParser.BlockType.Filter, exceptionHandler); 39 | dictionary[exceptionHandler] = Tuple.Create(item, item2, item3); 40 | } 41 | else 42 | { 43 | dictionary[exceptionHandler] = Tuple.Create(item, item2, null); 44 | } 45 | } 46 | BlockParser.ScopeBlock scopeBlock = new BlockParser.ScopeBlock(BlockParser.BlockType.Normal, null); 47 | Stack stack = new Stack(); 48 | stack.Push(scopeBlock); 49 | foreach (Instruction instruction in body.Instructions) 50 | { 51 | foreach (ExceptionHandler exceptionHandler2 in body.ExceptionHandlers) 52 | { 53 | Tuple tuple = dictionary[exceptionHandler2]; 54 | bool flag4 = instruction == exceptionHandler2.TryEnd; 55 | if (flag4) 56 | { 57 | stack.Pop(); 58 | } 59 | bool flag5 = instruction == exceptionHandler2.HandlerEnd; 60 | if (flag5) 61 | { 62 | stack.Pop(); 63 | } 64 | bool flag6 = exceptionHandler2.FilterStart != null && instruction == exceptionHandler2.HandlerStart; 65 | if (flag6) 66 | { 67 | Debug.Assert(stack.Peek().Type == BlockParser.BlockType.Filter); 68 | stack.Pop(); 69 | } 70 | } 71 | foreach (ExceptionHandler exceptionHandler3 in body.ExceptionHandlers.Reverse()) 72 | { 73 | Tuple tuple2 = dictionary[exceptionHandler3]; 74 | BlockParser.ScopeBlock scopeBlock2 = (stack.Count > 0) ? stack.Peek() : null; 75 | bool flag7 = instruction == exceptionHandler3.TryStart; 76 | if (flag7) 77 | { 78 | bool flag8 = scopeBlock2 != null; 79 | if (flag8) 80 | { 81 | scopeBlock2.Children.Add(tuple2.Item1); 82 | } 83 | stack.Push(tuple2.Item1); 84 | } 85 | bool flag9 = instruction == exceptionHandler3.HandlerStart; 86 | if (flag9) 87 | { 88 | bool flag10 = scopeBlock2 != null; 89 | if (flag10) 90 | { 91 | scopeBlock2.Children.Add(tuple2.Item2); 92 | } 93 | stack.Push(tuple2.Item2); 94 | } 95 | bool flag11 = instruction == exceptionHandler3.FilterStart; 96 | if (flag11) 97 | { 98 | bool flag12 = scopeBlock2 != null; 99 | if (flag12) 100 | { 101 | scopeBlock2.Children.Add(tuple2.Item3); 102 | } 103 | stack.Push(tuple2.Item3); 104 | } 105 | } 106 | BlockParser.ScopeBlock scopeBlock3 = stack.Peek(); 107 | BlockParser.InstrBlock instrBlock = scopeBlock3.Children.LastOrDefault() as BlockParser.InstrBlock; 108 | bool flag13 = instrBlock == null; 109 | if (flag13) 110 | { 111 | scopeBlock3.Children.Add(instrBlock = new BlockParser.InstrBlock()); 112 | } 113 | instrBlock.Instructions.Add(instruction); 114 | } 115 | foreach (ExceptionHandler exceptionHandler4 in body.ExceptionHandlers) 116 | { 117 | bool flag14 = exceptionHandler4.TryEnd == null; 118 | if (flag14) 119 | { 120 | stack.Pop(); 121 | } 122 | bool flag15 = exceptionHandler4.HandlerEnd == null; 123 | if (flag15) 124 | { 125 | stack.Pop(); 126 | } 127 | } 128 | Debug.Assert(stack.Count == 1); 129 | return scopeBlock; 130 | } 131 | 132 | // Token: 0x02000043 RID: 67 133 | internal abstract class BlockBase 134 | { 135 | // Token: 0x0600014C RID: 332 RVA: 0x0000E46B File Offset: 0x0000C66B 136 | public BlockBase(BlockParser.BlockType type) 137 | { 138 | this.Type = type; 139 | } 140 | 141 | // Token: 0x17000027 RID: 39 142 | // (get) Token: 0x0600014D RID: 333 RVA: 0x0000E47D File Offset: 0x0000C67D 143 | // (set) Token: 0x0600014E RID: 334 RVA: 0x0000E485 File Offset: 0x0000C685 144 | public BlockParser.BlockType Type { get; private set; } 145 | 146 | // Token: 0x0600014F RID: 335 147 | public abstract void ToBody(CilBody body); 148 | } 149 | 150 | // Token: 0x02000044 RID: 68 151 | internal enum BlockType 152 | { 153 | // Token: 0x04000088 RID: 136 154 | Normal, 155 | // Token: 0x04000089 RID: 137 156 | Try, 157 | // Token: 0x0400008A RID: 138 158 | Handler, 159 | // Token: 0x0400008B RID: 139 160 | Finally, 161 | // Token: 0x0400008C RID: 140 162 | Filter, 163 | // Token: 0x0400008D RID: 141 164 | Fault 165 | } 166 | 167 | // Token: 0x02000045 RID: 69 168 | internal class ScopeBlock : BlockParser.BlockBase 169 | { 170 | // Token: 0x06000150 RID: 336 RVA: 0x0000E48E File Offset: 0x0000C68E 171 | public ScopeBlock(BlockParser.BlockType type, ExceptionHandler handler) : base(type) 172 | { 173 | this.Handler = handler; 174 | this.Children = new List(); 175 | } 176 | 177 | // Token: 0x17000028 RID: 40 178 | // (get) Token: 0x06000151 RID: 337 RVA: 0x0000E4AD File Offset: 0x0000C6AD 179 | // (set) Token: 0x06000152 RID: 338 RVA: 0x0000E4B5 File Offset: 0x0000C6B5 180 | public ExceptionHandler Handler { get; private set; } 181 | 182 | // Token: 0x17000029 RID: 41 183 | // (get) Token: 0x06000153 RID: 339 RVA: 0x0000E4BE File Offset: 0x0000C6BE 184 | // (set) Token: 0x06000154 RID: 340 RVA: 0x0000E4C6 File Offset: 0x0000C6C6 185 | public List Children { get; set; } 186 | 187 | // Token: 0x06000155 RID: 341 RVA: 0x0000E4D0 File Offset: 0x0000C6D0 188 | public override string ToString() 189 | { 190 | StringBuilder stringBuilder = new StringBuilder(); 191 | bool flag = base.Type == BlockParser.BlockType.Try; 192 | if (flag) 193 | { 194 | stringBuilder.Append("try "); 195 | } 196 | else 197 | { 198 | bool flag2 = base.Type == BlockParser.BlockType.Handler; 199 | if (flag2) 200 | { 201 | stringBuilder.Append("handler "); 202 | } 203 | else 204 | { 205 | bool flag3 = base.Type == BlockParser.BlockType.Finally; 206 | if (flag3) 207 | { 208 | stringBuilder.Append("finally "); 209 | } 210 | else 211 | { 212 | bool flag4 = base.Type == BlockParser.BlockType.Fault; 213 | if (flag4) 214 | { 215 | stringBuilder.Append("fault "); 216 | } 217 | } 218 | } 219 | } 220 | stringBuilder.AppendLine("{"); 221 | foreach (BlockParser.BlockBase value in this.Children) 222 | { 223 | stringBuilder.Append(value); 224 | } 225 | stringBuilder.AppendLine("}"); 226 | return stringBuilder.ToString(); 227 | } 228 | 229 | // Token: 0x06000156 RID: 342 RVA: 0x0000E5C0 File Offset: 0x0000C7C0 230 | public Instruction GetFirstInstr() 231 | { 232 | BlockParser.BlockBase blockBase = this.Children.First(); 233 | bool flag = blockBase is BlockParser.ScopeBlock; 234 | Instruction result; 235 | if (flag) 236 | { 237 | result = ((BlockParser.ScopeBlock)blockBase).GetFirstInstr(); 238 | } 239 | else 240 | { 241 | result = ((BlockParser.InstrBlock)blockBase).Instructions.First(); 242 | } 243 | return result; 244 | } 245 | 246 | // Token: 0x06000157 RID: 343 RVA: 0x0000E60C File Offset: 0x0000C80C 247 | public Instruction GetLastInstr() 248 | { 249 | BlockParser.BlockBase blockBase = this.Children.Last(); 250 | bool flag = blockBase is BlockParser.ScopeBlock; 251 | Instruction result; 252 | if (flag) 253 | { 254 | result = ((BlockParser.ScopeBlock)blockBase).GetLastInstr(); 255 | } 256 | else 257 | { 258 | result = ((BlockParser.InstrBlock)blockBase).Instructions.Last(); 259 | } 260 | return result; 261 | } 262 | 263 | // Token: 0x06000158 RID: 344 RVA: 0x0000E658 File Offset: 0x0000C858 264 | public override void ToBody(CilBody body) 265 | { 266 | bool flag = base.Type > BlockParser.BlockType.Normal; 267 | if (flag) 268 | { 269 | bool flag2 = base.Type == BlockParser.BlockType.Try; 270 | if (flag2) 271 | { 272 | this.Handler.TryStart = this.GetFirstInstr(); 273 | this.Handler.TryEnd = this.GetLastInstr(); 274 | } 275 | else 276 | { 277 | bool flag3 = base.Type == BlockParser.BlockType.Filter; 278 | if (flag3) 279 | { 280 | this.Handler.FilterStart = this.GetFirstInstr(); 281 | } 282 | else 283 | { 284 | this.Handler.HandlerStart = this.GetFirstInstr(); 285 | this.Handler.HandlerEnd = this.GetLastInstr(); 286 | } 287 | } 288 | } 289 | foreach (BlockParser.BlockBase blockBase in this.Children) 290 | { 291 | blockBase.ToBody(body); 292 | } 293 | } 294 | } 295 | 296 | // Token: 0x02000046 RID: 70 297 | internal class InstrBlock : BlockParser.BlockBase 298 | { 299 | // Token: 0x06000159 RID: 345 RVA: 0x0000E73C File Offset: 0x0000C93C 300 | public InstrBlock() : base(BlockParser.BlockType.Normal) 301 | { 302 | this.Instructions = new List(); 303 | } 304 | 305 | // Token: 0x1700002A RID: 42 306 | // (get) Token: 0x0600015A RID: 346 RVA: 0x0000E753 File Offset: 0x0000C953 307 | // (set) Token: 0x0600015B RID: 347 RVA: 0x0000E75B File Offset: 0x0000C95B 308 | public List Instructions { get; set; } 309 | 310 | // Token: 0x0600015C RID: 348 RVA: 0x0000E764 File Offset: 0x0000C964 311 | public override string ToString() 312 | { 313 | StringBuilder stringBuilder = new StringBuilder(); 314 | foreach (Instruction instruction in this.Instructions) 315 | { 316 | stringBuilder.AppendLine(instruction.ToString()); 317 | } 318 | return stringBuilder.ToString(); 319 | } 320 | 321 | // Token: 0x0600015D RID: 349 RVA: 0x0000E7D0 File Offset: 0x0000C9D0 322 | public override void ToBody(CilBody body) 323 | { 324 | foreach (Instruction item in this.Instructions) 325 | { 326 | body.Instructions.Add(item); 327 | } 328 | } 329 | } 330 | } 331 | } 332 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/ControlFlow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | using dnlib.DotNet.Pdb; 6 | using SugarGuard.Protector.Class; 7 | 8 | namespace SugarGuard.Protector.Protections.ControlFlow 9 | { 10 | // Token: 0x02000020 RID: 32 11 | public class ControlFlow 12 | { 13 | // Token: 0x06000098 RID: 152 RVA: 0x0000850E File Offset: 0x0000670E 14 | public ControlFlow(SugarLib lib) 15 | { 16 | this.Main(lib); 17 | } 18 | 19 | // Token: 0x06000099 RID: 153 RVA: 0x00008520 File Offset: 0x00006720 20 | private void Main(SugarLib lib) 21 | { 22 | foreach (TypeDef typeDef in lib.moduleDef.Types) 23 | { 24 | foreach (MethodDef methodDef in typeDef.Methods) 25 | { 26 | bool flag = !methodDef.HasBody || !methodDef.Body.HasInstructions; 27 | if (!flag) 28 | { 29 | bool flag2 = methodDef.ReturnType != null; 30 | if (flag2) 31 | { 32 | CilBody body = methodDef.Body; 33 | body.SimplifyBranches(); 34 | BlockParser.ScopeBlock scopeBlock = BlockParser.ParseBody(body); 35 | new SwitchMangler().Mangle(body, scopeBlock, lib, methodDef, methodDef.ReturnType); 36 | body.Instructions.Clear(); 37 | scopeBlock.ToBody(body); 38 | bool flag3 = body.PdbMethod != null; 39 | if (flag3) 40 | { 41 | body.PdbMethod = new PdbMethod 42 | { 43 | Scope = new PdbScope 44 | { 45 | Start = body.Instructions.First(), 46 | End = body.Instructions.Last() 47 | } 48 | }; 49 | } 50 | methodDef.CustomDebugInfos.RemoveWhere((PdbCustomDebugInfo cdi) => cdi is PdbStateMachineHoistedLocalScopesCustomDebugInfo); 51 | foreach (ExceptionHandler exceptionHandler in body.ExceptionHandlers) 52 | { 53 | int num = body.Instructions.IndexOf(exceptionHandler.TryEnd) + 1; 54 | exceptionHandler.TryEnd = ((num < body.Instructions.Count) ? body.Instructions[num] : null); 55 | num = body.Instructions.IndexOf(exceptionHandler.HandlerEnd) + 1; 56 | exceptionHandler.HandlerEnd = ((num < body.Instructions.Count) ? body.Instructions[num] : null); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/ControlFlowBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet.Emit; 5 | 6 | namespace SugarGuard.Protector.Protections.ControlFlow 7 | { 8 | // Token: 0x02000024 RID: 36 9 | public class ControlFlowBlock 10 | { 11 | // Token: 0x060000A7 RID: 167 RVA: 0x000093B0 File Offset: 0x000075B0 12 | internal ControlFlowBlock(int id, ControlFlowBlockType type, Instruction header, Instruction footer) 13 | { 14 | this.Id = id; 15 | this.Type = type; 16 | this.Header = header; 17 | this.Footer = footer; 18 | this.Sources = new List(); 19 | this.Targets = new List(); 20 | } 21 | 22 | // Token: 0x17000011 RID: 17 23 | // (get) Token: 0x060000A8 RID: 168 RVA: 0x000093EF File Offset: 0x000075EF 24 | // (set) Token: 0x060000A9 RID: 169 RVA: 0x000093F7 File Offset: 0x000075F7 25 | public IList Sources { get; private set; } 26 | 27 | // Token: 0x17000012 RID: 18 28 | // (get) Token: 0x060000AA RID: 170 RVA: 0x00009400 File Offset: 0x00007600 29 | // (set) Token: 0x060000AB RID: 171 RVA: 0x00009408 File Offset: 0x00007608 30 | public IList Targets { get; private set; } 31 | 32 | // Token: 0x060000AC RID: 172 RVA: 0x00009414 File Offset: 0x00007614 33 | public override string ToString() 34 | { 35 | return string.Format("Block {0} => {1} {2}", this.Id, this.Type, string.Join(", ", (from block in this.Targets 36 | select block.Id.ToString()).ToArray())); 37 | } 38 | 39 | // Token: 0x04000039 RID: 57 40 | public readonly Instruction Footer; 41 | 42 | // Token: 0x0400003A RID: 58 43 | public readonly Instruction Header; 44 | 45 | // Token: 0x0400003B RID: 59 46 | public readonly int Id; 47 | 48 | // Token: 0x0400003C RID: 60 49 | public readonly ControlFlowBlockType Type; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/ControlFlowBlockType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SugarGuard.Protector.Protections.ControlFlow 4 | { 5 | // Token: 0x02000023 RID: 35 6 | [Flags] 7 | public enum ControlFlowBlockType 8 | { 9 | // Token: 0x04000036 RID: 54 10 | Normal = 0, 11 | // Token: 0x04000037 RID: 55 12 | Entry = 1, 13 | // Token: 0x04000038 RID: 56 14 | Exit = 2 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/ControlFlowGraph.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using dnlib.DotNet.Emit; 5 | 6 | namespace SugarGuard.Protector.Protections.ControlFlow 7 | { 8 | // Token: 0x02000022 RID: 34 9 | public class ControlFlowGraph : IEnumerable, IEnumerable 10 | { 11 | // Token: 0x0600009B RID: 155 RVA: 0x00008BB8 File Offset: 0x00006DB8 12 | private ControlFlowGraph(CilBody body) 13 | { 14 | this.body = body; 15 | this.instrBlocks = new int[body.Instructions.Count]; 16 | this.blocks = new List(); 17 | this.indexMap = new Dictionary(); 18 | for (int i = 0; i < body.Instructions.Count; i++) 19 | { 20 | this.indexMap.Add(body.Instructions[i], i); 21 | } 22 | } 23 | 24 | // Token: 0x1700000E RID: 14 25 | // (get) Token: 0x0600009C RID: 156 RVA: 0x00008C34 File Offset: 0x00006E34 26 | public int Count 27 | { 28 | get 29 | { 30 | return this.blocks.Count; 31 | } 32 | } 33 | 34 | // Token: 0x1700000F RID: 15 35 | public ControlFlowBlock this[int id] 36 | { 37 | get 38 | { 39 | return this.blocks[id]; 40 | } 41 | } 42 | 43 | // Token: 0x17000010 RID: 16 44 | // (get) Token: 0x0600009E RID: 158 RVA: 0x00008C74 File Offset: 0x00006E74 45 | public CilBody Body 46 | { 47 | get 48 | { 49 | return this.body; 50 | } 51 | } 52 | 53 | // Token: 0x0600009F RID: 159 RVA: 0x00008C8C File Offset: 0x00006E8C 54 | IEnumerator IEnumerable.GetEnumerator() 55 | { 56 | return this.blocks.GetEnumerator(); 57 | } 58 | 59 | // Token: 0x060000A0 RID: 160 RVA: 0x00008CB0 File Offset: 0x00006EB0 60 | IEnumerator IEnumerable.GetEnumerator() 61 | { 62 | return this.blocks.GetEnumerator(); 63 | } 64 | 65 | // Token: 0x060000A1 RID: 161 RVA: 0x00008CD4 File Offset: 0x00006ED4 66 | public ControlFlowBlock GetContainingBlock(int instrIndex) 67 | { 68 | return this.blocks[this.instrBlocks[instrIndex]]; 69 | } 70 | 71 | // Token: 0x060000A2 RID: 162 RVA: 0x00008CFC File Offset: 0x00006EFC 72 | public int IndexOf(Instruction instr) 73 | { 74 | return this.indexMap[instr]; 75 | } 76 | 77 | // Token: 0x060000A3 RID: 163 RVA: 0x00008D1C File Offset: 0x00006F1C 78 | private void PopulateBlockHeaders(HashSet blockHeaders, HashSet entryHeaders) 79 | { 80 | for (int i = 0; i < this.body.Instructions.Count; i++) 81 | { 82 | Instruction instruction = this.body.Instructions[i]; 83 | bool flag = instruction.Operand is Instruction; 84 | if (flag) 85 | { 86 | blockHeaders.Add((Instruction)instruction.Operand); 87 | bool flag2 = i + 1 < this.body.Instructions.Count; 88 | if (flag2) 89 | { 90 | blockHeaders.Add(this.body.Instructions[i + 1]); 91 | } 92 | } 93 | else 94 | { 95 | bool flag3 = instruction.Operand is Instruction[]; 96 | if (flag3) 97 | { 98 | foreach (Instruction item in (Instruction[])instruction.Operand) 99 | { 100 | blockHeaders.Add(item); 101 | } 102 | bool flag4 = i + 1 < this.body.Instructions.Count; 103 | if (flag4) 104 | { 105 | blockHeaders.Add(this.body.Instructions[i + 1]); 106 | } 107 | } 108 | else 109 | { 110 | bool flag5 = (instruction.OpCode.FlowControl == FlowControl.Throw || instruction.OpCode.FlowControl == FlowControl.Return) && i + 1 < this.body.Instructions.Count; 111 | if (flag5) 112 | { 113 | blockHeaders.Add(this.body.Instructions[i + 1]); 114 | } 115 | } 116 | } 117 | } 118 | blockHeaders.Add(this.body.Instructions[0]); 119 | foreach (ExceptionHandler exceptionHandler in this.body.ExceptionHandlers) 120 | { 121 | blockHeaders.Add(exceptionHandler.TryStart); 122 | blockHeaders.Add(exceptionHandler.HandlerStart); 123 | blockHeaders.Add(exceptionHandler.FilterStart); 124 | entryHeaders.Add(exceptionHandler.HandlerStart); 125 | entryHeaders.Add(exceptionHandler.FilterStart); 126 | } 127 | } 128 | 129 | // Token: 0x060000A4 RID: 164 RVA: 0x00008F40 File Offset: 0x00007140 130 | private void SplitBlocks(HashSet blockHeaders, HashSet entryHeaders) 131 | { 132 | int num = 0; 133 | int num2 = -1; 134 | Instruction instruction = null; 135 | for (int i = 0; i < this.body.Instructions.Count; i++) 136 | { 137 | Instruction instruction2 = this.body.Instructions[i]; 138 | bool flag = blockHeaders.Contains(instruction2); 139 | if (flag) 140 | { 141 | bool flag2 = instruction != null; 142 | if (flag2) 143 | { 144 | Instruction instruction3 = this.body.Instructions[i - 1]; 145 | ControlFlowBlockType controlFlowBlockType = ControlFlowBlockType.Normal; 146 | bool flag3 = entryHeaders.Contains(instruction) || instruction == this.body.Instructions[0]; 147 | if (flag3) 148 | { 149 | controlFlowBlockType |= ControlFlowBlockType.Entry; 150 | } 151 | bool flag4 = instruction3.OpCode.FlowControl == FlowControl.Return || instruction3.OpCode.FlowControl == FlowControl.Throw; 152 | if (flag4) 153 | { 154 | controlFlowBlockType |= ControlFlowBlockType.Exit; 155 | } 156 | this.blocks.Add(new ControlFlowBlock(num2, controlFlowBlockType, instruction, instruction3)); 157 | } 158 | num2 = num++; 159 | instruction = instruction2; 160 | } 161 | this.instrBlocks[i] = num2; 162 | } 163 | bool flag5 = this.blocks.Count == 0 || this.blocks[this.blocks.Count - 1].Id != num2; 164 | if (flag5) 165 | { 166 | Instruction instruction4 = this.body.Instructions[this.body.Instructions.Count - 1]; 167 | ControlFlowBlockType controlFlowBlockType2 = ControlFlowBlockType.Normal; 168 | bool flag6 = entryHeaders.Contains(instruction) || instruction == this.body.Instructions[0]; 169 | if (flag6) 170 | { 171 | controlFlowBlockType2 |= ControlFlowBlockType.Entry; 172 | } 173 | bool flag7 = instruction4.OpCode.FlowControl == FlowControl.Return || instruction4.OpCode.FlowControl == FlowControl.Throw; 174 | if (flag7) 175 | { 176 | controlFlowBlockType2 |= ControlFlowBlockType.Exit; 177 | } 178 | this.blocks.Add(new ControlFlowBlock(num2, controlFlowBlockType2, instruction, instruction4)); 179 | } 180 | } 181 | 182 | // Token: 0x060000A5 RID: 165 RVA: 0x00009124 File Offset: 0x00007324 183 | private void LinkBlocks() 184 | { 185 | for (int i = 0; i < this.body.Instructions.Count; i++) 186 | { 187 | Instruction instruction = this.body.Instructions[i]; 188 | bool flag = instruction.Operand is Instruction; 189 | if (flag) 190 | { 191 | ControlFlowBlock controlFlowBlock = this.blocks[this.instrBlocks[i]]; 192 | ControlFlowBlock controlFlowBlock2 = this.blocks[this.instrBlocks[this.indexMap[(Instruction)instruction.Operand]]]; 193 | controlFlowBlock2.Sources.Add(controlFlowBlock); 194 | controlFlowBlock.Targets.Add(controlFlowBlock2); 195 | } 196 | else 197 | { 198 | bool flag2 = instruction.Operand is Instruction[]; 199 | if (flag2) 200 | { 201 | foreach (Instruction key in (Instruction[])instruction.Operand) 202 | { 203 | ControlFlowBlock controlFlowBlock3 = this.blocks[this.instrBlocks[i]]; 204 | ControlFlowBlock controlFlowBlock4 = this.blocks[this.instrBlocks[this.indexMap[key]]]; 205 | controlFlowBlock4.Sources.Add(controlFlowBlock3); 206 | controlFlowBlock3.Targets.Add(controlFlowBlock4); 207 | } 208 | } 209 | } 210 | } 211 | for (int k = 0; k < this.blocks.Count; k++) 212 | { 213 | bool flag3 = this.blocks[k].Footer.OpCode.FlowControl != FlowControl.Branch && this.blocks[k].Footer.OpCode.FlowControl != FlowControl.Return && this.blocks[k].Footer.OpCode.FlowControl != FlowControl.Throw; 214 | if (flag3) 215 | { 216 | this.blocks[k].Targets.Add(this.blocks[k + 1]); 217 | this.blocks[k + 1].Sources.Add(this.blocks[k]); 218 | } 219 | } 220 | } 221 | 222 | // Token: 0x060000A6 RID: 166 RVA: 0x00009358 File Offset: 0x00007558 223 | public static ControlFlowGraph Construct(CilBody body) 224 | { 225 | ControlFlowGraph controlFlowGraph = new ControlFlowGraph(body); 226 | bool flag = body.Instructions.Count == 0; 227 | ControlFlowGraph result; 228 | if (flag) 229 | { 230 | result = controlFlowGraph; 231 | } 232 | else 233 | { 234 | HashSet blockHeaders = new HashSet(); 235 | HashSet entryHeaders = new HashSet(); 236 | controlFlowGraph.PopulateBlockHeaders(blockHeaders, entryHeaders); 237 | controlFlowGraph.SplitBlocks(blockHeaders, entryHeaders); 238 | controlFlowGraph.LinkBlocks(); 239 | result = controlFlowGraph; 240 | } 241 | return result; 242 | } 243 | 244 | // Token: 0x04000031 RID: 49 245 | private readonly List blocks; 246 | 247 | // Token: 0x04000032 RID: 50 248 | private readonly CilBody body; 249 | 250 | // Token: 0x04000033 RID: 51 251 | private readonly int[] instrBlocks; 252 | 253 | // Token: 0x04000034 RID: 52 254 | private readonly Dictionary indexMap; 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/IPredicate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet.Emit; 4 | 5 | namespace SugarGuard.Protector.Protections.ControlFlow 6 | { 7 | // Token: 0x02000026 RID: 38 8 | internal interface IPredicate 9 | { 10 | // Token: 0x060000B0 RID: 176 11 | void Init(CilBody body); 12 | 13 | // Token: 0x060000B1 RID: 177 14 | void EmitSwitchLoad(IList instrs); 15 | 16 | // Token: 0x060000B2 RID: 178 17 | int GetSwitchKey(int key); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/ManglerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | using SugarGuard.Protector.Class; 6 | 7 | namespace SugarGuard.Protector.Protections.ControlFlow 8 | { 9 | // Token: 0x02000025 RID: 37 10 | internal abstract class ManglerBase 11 | { 12 | // Token: 0x060000AD RID: 173 RVA: 0x0000947F File Offset: 0x0000767F 13 | protected static IEnumerable GetAllBlocks(BlockParser.ScopeBlock scope) 14 | { 15 | foreach (BlockParser.BlockBase child in scope.Children) 16 | { 17 | bool flag = child is BlockParser.InstrBlock; 18 | if (flag) 19 | { 20 | yield return (BlockParser.InstrBlock)child; 21 | } 22 | else 23 | { 24 | foreach (BlockParser.InstrBlock block in ManglerBase.GetAllBlocks((BlockParser.ScopeBlock)child)) 25 | { 26 | yield return block; 27 | block = null; 28 | } 29 | IEnumerator enumerator2 = null; 30 | } 31 | child = null; 32 | } 33 | List.Enumerator enumerator = default(List.Enumerator); 34 | yield break; 35 | yield break; 36 | } 37 | 38 | // Token: 0x060000AE RID: 174 39 | public abstract void Mangle(CilBody body, BlockParser.ScopeBlock root, SugarLib ctx, MethodDef method, TypeSig retType); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/Predicate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet.Emit; 4 | using SugarGuard.Protector.Class; 5 | 6 | namespace SugarGuard.Protector.Protections.ControlFlow 7 | { 8 | // Token: 0x02000027 RID: 39 9 | internal class Predicate : IPredicate 10 | { 11 | // Token: 0x060000B3 RID: 179 RVA: 0x00009498 File Offset: 0x00007698 12 | public Predicate(SugarLib ctx) 13 | { 14 | this.ctx = ctx; 15 | } 16 | 17 | // Token: 0x060000B4 RID: 180 RVA: 0x000094AC File Offset: 0x000076AC 18 | public void Init(CilBody body) 19 | { 20 | bool flag = this.inited; 21 | if (!flag) 22 | { 23 | this.xorKey = new Random().Next(); 24 | this.inited = true; 25 | } 26 | } 27 | 28 | // Token: 0x060000B5 RID: 181 RVA: 0x000094DD File Offset: 0x000076DD 29 | public void EmitSwitchLoad(IList instrs) 30 | { 31 | instrs.Add(Instruction.Create(OpCodes.Ldc_I4, this.xorKey)); 32 | instrs.Add(Instruction.Create(OpCodes.Xor)); 33 | } 34 | 35 | // Token: 0x060000B6 RID: 182 RVA: 0x00009508 File Offset: 0x00007708 36 | public int GetSwitchKey(int key) 37 | { 38 | return key ^ this.xorKey; 39 | } 40 | 41 | // Token: 0x0400003F RID: 63 42 | private readonly SugarLib ctx; 43 | 44 | // Token: 0x04000040 RID: 64 45 | private bool inited; 46 | 47 | // Token: 0x04000041 RID: 65 48 | private int xorKey; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ControlFlow/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SugarGuard.Protector.Protections.ControlFlow 5 | { 6 | // Token: 0x02000029 RID: 41 7 | public static class Utils 8 | { 9 | // Token: 0x060000C3 RID: 195 RVA: 0x0000A91C File Offset: 0x00008B1C 10 | public static void AddListEntry(this IDictionary> self, TKey key, TValue value) 11 | { 12 | bool flag = key == null; 13 | if (flag) 14 | { 15 | throw new ArgumentNullException("key"); 16 | } 17 | List list; 18 | bool flag2 = !self.TryGetValue(key, out list); 19 | if (flag2) 20 | { 21 | list = (self[key] = new List()); 22 | } 23 | list.Add(value); 24 | } 25 | 26 | // Token: 0x060000C4 RID: 196 RVA: 0x0000A96C File Offset: 0x00008B6C 27 | public static IList RemoveWhere(this IList self, Predicate match) 28 | { 29 | for (int i = self.Count - 1; i >= 0; i--) 30 | { 31 | bool flag = match(self[i]); 32 | if (flag) 33 | { 34 | self.RemoveAt(i); 35 | } 36 | } 37 | return self; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/FakeAttributes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using SugarGuard.Protector.Class; 5 | 6 | namespace SugarGuard.Protector.Protections 7 | { 8 | // Token: 0x02000007 RID: 7 9 | public class FakeAttributes 10 | { 11 | // Token: 0x06000019 RID: 25 RVA: 0x000038D7 File Offset: 0x00001AD7 12 | public FakeAttributes(SugarLib lib) 13 | { 14 | this.Main(lib); 15 | } 16 | 17 | // Token: 0x0600001A RID: 26 RVA: 0x000038E8 File Offset: 0x00001AE8 18 | private void Main(SugarLib lib) 19 | { 20 | ModuleDef moduleDef = lib.moduleDef; 21 | List list = new List 22 | { 23 | "Borland.Vcl.Types", 24 | "Borland.Eco.Interfaces", 25 | "();\t", 26 | "BabelObfuscatorAttribute", 27 | "ZYXDNGuarder", 28 | "DotfuscatorAttribute", 29 | "YanoAttribute", 30 | "Reactor", 31 | "EMyPID_8234_", 32 | "ObfuscatedByAgileDotNetAttribute", 33 | "ObfuscatedByGoliath", 34 | "CheckRuntime", 35 | "ObfuscatedByCliSecureAttribute", 36 | "____KILL", 37 | "CodeWallTrialVersion", 38 | "Sixxpack", 39 | "Microsoft.VisualBasic", 40 | "nsnet", 41 | "ConfusedByAttribute", 42 | "Macrobject.Obfuscator", 43 | "Protected_By_Attribute'00'NETSpider.Attribute", 44 | "CryptoObfuscator.ProtectedWithCryptoObfuscatorAttribute", 45 | "Xenocode.Client.Attributes.AssemblyAttributes.ProcessedByXenocode", 46 | "NineRays.Obfuscator.Evaluation", 47 | "SecureTeam.Attributes.ObfuscatedByAgileDotNetAttribute", 48 | "SmartAssembly.Attributes.PoweredByAttribute", 49 | "Sugary", 50 | "Form", 51 | "Program" 52 | }; 53 | foreach (string s in list) 54 | { 55 | TypeDef typeDef = new TypeDefUser("SugarGuard.Attributes", s, moduleDef.Import(typeof(Attribute))); 56 | typeDef.Attributes = TypeAttributes.NotPublic; 57 | lib.moduleDef.Types.Add(typeDef); 58 | } 59 | TypeDef typeDef2 = lib.moduleDef.Types[new Random().Next(0, moduleDef.Types.Count)]; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/InvalidOpcodes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | using SugarGuard.Protector.Class; 5 | 6 | namespace SugarGuard.Protector.Protections 7 | { 8 | // Token: 0x02000009 RID: 9 9 | public class InvalidOpcodes 10 | { 11 | // Token: 0x0600001E RID: 30 RVA: 0x00004046 File Offset: 0x00002246 12 | public InvalidOpcodes(SugarLib lib) 13 | { 14 | this.Main(lib); 15 | } 16 | 17 | // Token: 0x0600001F RID: 31 RVA: 0x00004058 File Offset: 0x00002258 18 | private void Main(SugarLib lib) 19 | { 20 | foreach (TypeDef typeDef in lib.moduleDef.GetTypes()) 21 | { 22 | foreach (MethodDef methodDef in typeDef.Methods) 23 | { 24 | bool flag = !methodDef.HasBody || !methodDef.Body.HasInstructions; 25 | if (!flag) 26 | { 27 | methodDef.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Box, methodDef.Module.Import(typeof(Math)))); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/MethodHider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using dnlib.DotNet; 5 | using dnlib.DotNet.Emit; 6 | using SugarGuard.Protector.Class; 7 | using SugarGuard.Protector.Protections.Runtime; 8 | 9 | namespace SugarGuard.Protector.Protections 10 | { 11 | // Token: 0x0200000A RID: 10 12 | public class MethodHider 13 | { 14 | // Token: 0x06000020 RID: 32 RVA: 0x0000413C File Offset: 0x0000233C 15 | public MethodHider(SugarLib lib) 16 | { 17 | this.Main(lib); 18 | } 19 | 20 | // Token: 0x06000021 RID: 33 RVA: 0x00004150 File Offset: 0x00002350 21 | private void Main(SugarLib lib) 22 | { 23 | ModuleDef moduleDef = lib.moduleDef; 24 | ModuleDefMD moduleDefMD = ModuleDefMD.Load(typeof(AntiDump).Module); 25 | TypeDef typeDef = moduleDefMD.ResolveTypeDef(MDToken.ToRID(typeof(MethodHider).MetadataToken)); 26 | IEnumerable source = InjectHelper.Inject(typeDef, moduleDef.GlobalType, moduleDef); 27 | MethodDef method2 = (MethodDef)source.Single((IDnlibDef method) => method.Name == "MethodHiderInj"); 28 | foreach (TypeDef typeDef2 in moduleDef.GetTypes()) 29 | { 30 | bool isGlobalModuleType = typeDef2.IsGlobalModuleType; 31 | if (!isGlobalModuleType) 32 | { 33 | foreach (MethodDef methodDef in typeDef2.Methods) 34 | { 35 | bool flag = !methodDef.HasBody || !methodDef.Body.HasInstructions; 36 | if (!flag) 37 | { 38 | int i = 0; 39 | while (i < methodDef.Body.Instructions.Count) 40 | { 41 | bool flag2 = methodDef.Body.Instructions[i].OpCode == OpCodes.Call; 42 | if (flag2) 43 | { 44 | bool flag3 = methodDef.Body.Instructions[i].Operand is MethodDef; 45 | if (flag3) 46 | { 47 | try 48 | { 49 | bool flag4 = methodDef.Name != "CopyAll"; 50 | if (!flag4) 51 | { 52 | MethodDef methodDef2 = (MethodDef)methodDef.Body.Instructions[i].Operand; 53 | bool flag5 = methodDef2.Parameters.Count == 0; 54 | if (!flag5) 55 | { 56 | bool flag6 = methodDef2.DeclaringType == moduleDef.Import(typeof(void)); 57 | if (!flag6) 58 | { 59 | bool isConstructor = methodDef2.IsConstructor; 60 | if (!isConstructor) 61 | { 62 | bool flag7 = !methodDef2.IsStatic; 63 | if (!flag7) 64 | { 65 | int num = 1; 66 | Local local = new Local(moduleDef.ImportAsTypeSig(typeof(object[]))); 67 | methodDef.Body.Variables.Add(local); 68 | methodDef.Body.Instructions.Insert(i + num, OpCodes.Ldc_I4.ToInstruction(methodDef2.Parameters.Count)); 69 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Newarr.ToInstruction(moduleDef.CorLibTypes.Object)); 70 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Dup.ToInstruction()); 71 | for (int j = 0; j < methodDef2.Parameters.Count; j++) 72 | { 73 | bool flag8 = methodDef.Body.Instructions[i - j - 1].OpCode == OpCodes.Call; 74 | if (flag8) 75 | { 76 | methodDef.Body.Instructions.RemoveAt(i + num); 77 | methodDef.Body.Instructions.RemoveAt(i + --num); 78 | methodDef.Body.Instructions.RemoveAt(i + --num); 79 | break; 80 | } 81 | bool flag9 = methodDef.Body.Instructions[i - j - 1].OpCode == OpCodes.Nop; 82 | if (!flag9) 83 | { 84 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Ldc_I4.ToInstruction(j)); 85 | methodDef.Body.Instructions.Insert(i + ++num, methodDef.Body.Instructions[i - j - 1]); 86 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Stelem_Ref.ToInstruction()); 87 | bool flag10 = methodDef2.Parameters.Count - 1 != j; 88 | if (flag10) 89 | { 90 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Dup.ToInstruction()); 91 | } 92 | } 93 | } 94 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Ldc_I4.ToInstruction(methodDef2.MDToken.ToInt32())); 95 | methodDef.Body.Instructions.Insert(i + ++num, OpCodes.Call.ToInstruction(method2)); 96 | i += num + 1; 97 | break; 98 | } 99 | } 100 | } 101 | } 102 | } 103 | } 104 | catch 105 | { 106 | } 107 | } 108 | } 109 | IL_4A0: 110 | i++; 111 | continue; 112 | goto IL_4A0; 113 | } 114 | } 115 | } 116 | } 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Calculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet.Emit; 3 | 4 | namespace SugarGuard.Protector.Protections.Mutation 5 | { 6 | // Token: 0x02000014 RID: 20 7 | public class Calculator 8 | { 9 | // Token: 0x06000048 RID: 72 RVA: 0x00005CA8 File Offset: 0x00003EA8 10 | public Calculator(int value, int value2) 11 | { 12 | this.result = this.Calculate(value, value2); 13 | } 14 | 15 | // Token: 0x06000049 RID: 73 RVA: 0x00005CD0 File Offset: 0x00003ED0 16 | public int getResult() 17 | { 18 | return this.result; 19 | } 20 | 21 | // Token: 0x0600004A RID: 74 RVA: 0x00005CE8 File Offset: 0x00003EE8 22 | public OpCode getOpCode() 23 | { 24 | return this.cOpCode; 25 | } 26 | 27 | // Token: 0x0600004B RID: 75 RVA: 0x00005D00 File Offset: 0x00003F00 28 | private int Calculate(int num, int num2) 29 | { 30 | int num3 = 0; 31 | switch (Calculator.rnd.Next(0, 3)) 32 | { 33 | case 0: 34 | num3 = num + num2; 35 | this.cOpCode = OpCodes.Sub; 36 | break; 37 | case 1: 38 | num3 = (num ^ num2); 39 | this.cOpCode = OpCodes.Xor; 40 | break; 41 | case 2: 42 | num3 = num - num2; 43 | this.cOpCode = OpCodes.Add; 44 | break; 45 | } 46 | return num3; 47 | } 48 | 49 | // Token: 0x0400001A RID: 26 50 | public static Random rnd = new Random(); 51 | 52 | // Token: 0x0400001B RID: 27 53 | private OpCode cOpCode = null; 54 | 55 | // Token: 0x0400001C RID: 28 56 | private int result = 0; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Mutation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using SugarGuard.Protector.Class; 4 | using SugarGuard.Protector.Protections.Mutation.Stages; 5 | 6 | namespace SugarGuard.Protector.Protections.Mutation 7 | { 8 | // Token: 0x02000013 RID: 19 9 | public class Mutation 10 | { 11 | // Token: 0x06000044 RID: 68 RVA: 0x00005A82 File Offset: 0x00003C82 12 | public Mutation(SugarLib lib) 13 | { 14 | this.Phase(lib); 15 | } 16 | 17 | // Token: 0x06000045 RID: 69 RVA: 0x00005A94 File Offset: 0x00003C94 18 | public void Phase(SugarLib lib) 19 | { 20 | ModuleDef moduleDef = lib.moduleDef; 21 | foreach (TypeDef typeDef in moduleDef.GetTypes()) 22 | { 23 | bool isGlobalModuleType = typeDef.IsGlobalModuleType; 24 | if (!isGlobalModuleType) 25 | { 26 | foreach (MethodDef methodDef in typeDef.Methods) 27 | { 28 | bool flag = !this.canMutateMethod(methodDef); 29 | if (!flag) 30 | { 31 | new MethodPreparation(methodDef).Execute(); 32 | IntsToInliner intsToInliner = new IntsToInliner(methodDef); 33 | IntsToArray intsToArray = new IntsToArray(methodDef); 34 | IntsToStackalloc intsToStackalloc = new IntsToStackalloc(methodDef); 35 | IntsToMath intsToMath = new IntsToMath(methodDef); 36 | LocalsToCustomLocal localsToCustomLocal = new LocalsToCustomLocal(methodDef); 37 | IntsToRandom intsToRandom = new IntsToRandom(methodDef); 38 | for (int i = 0; i < methodDef.Body.Instructions.Count; i++) 39 | { 40 | bool flag2 = methodDef.Body.Instructions[i].IsLdcI4() && MutationHelper.CanObfuscate(methodDef.Body.Instructions, i); 41 | if (flag2) 42 | { 43 | switch (Mutation.rnd.Next(0, 5)) 44 | { 45 | case 1: 46 | intsToMath.Execute(ref i); 47 | break; 48 | case 2: 49 | localsToCustomLocal.Execute(ref i); 50 | break; 51 | case 3: 52 | intsToRandom.Execute(ref i); 53 | break; 54 | case 4: 55 | intsToStackalloc.Execute(ref i); 56 | break; 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | // Token: 0x06000046 RID: 70 RVA: 0x00005C74 File Offset: 0x00003E74 67 | public bool canMutateMethod(MethodDef method) 68 | { 69 | return method.HasBody && method.Body.HasInstructions; 70 | } 71 | 72 | // Token: 0x04000019 RID: 25 73 | private static Random rnd = new Random(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsConversions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | 5 | namespace SugarGuard.Protector.Protections.Mutation.Stages 6 | { 7 | // Token: 0x02000015 RID: 21 8 | public class IntsConversions 9 | { 10 | // Token: 0x17000003 RID: 3 11 | // (get) Token: 0x0600004D RID: 77 RVA: 0x00005D7B File Offset: 0x00003F7B 12 | // (set) Token: 0x0600004E RID: 78 RVA: 0x00005D83 File Offset: 0x00003F83 13 | private MethodDef Method { get; set; } 14 | 15 | // Token: 0x0600004F RID: 79 RVA: 0x00005D8C File Offset: 0x00003F8C 16 | public IntsConversions(MethodDef method) 17 | { 18 | this.Method = method; 19 | } 20 | 21 | // Token: 0x06000050 RID: 80 RVA: 0x00005DA0 File Offset: 0x00003FA0 22 | public void Execute() 23 | { 24 | int i = 0; 25 | while (i < this.Method.Body.Instructions.Count) 26 | { 27 | bool flag = this.Method.Body.Instructions[i].IsLdcI4(); 28 | if (flag) 29 | { 30 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 31 | bool flag2 = ldcI4Value < 10 && ldcI4Value > 0; 32 | if (flag2) 33 | { 34 | this.ConvToStrLen(ref i); 35 | } 36 | else 37 | { 38 | this.ConvToIntPtr(ref i); 39 | } 40 | } 41 | IL_69: 42 | i++; 43 | continue; 44 | goto IL_69; 45 | } 46 | } 47 | 48 | // Token: 0x06000051 RID: 81 RVA: 0x00005E3C File Offset: 0x0000403C 49 | private bool HasEmptyTypes() 50 | { 51 | for (int i = 0; i < this.Method.Body.Instructions.Count; i++) 52 | { 53 | bool flag = this.Method.Body.Instructions[i].IsLdcI4(); 54 | if (flag) 55 | { 56 | bool flag2 = this.Method.Body.Instructions[i].GetLdcI4Value() < 1; 57 | if (flag2) 58 | { 59 | return true; 60 | } 61 | } 62 | } 63 | return false; 64 | } 65 | 66 | // Token: 0x06000052 RID: 82 RVA: 0x00005EBC File Offset: 0x000040BC 67 | private void ConvToIntPtr(ref int i) 68 | { 69 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 70 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 71 | this.Method.Body.Instructions[i].Operand = ldcI4Value; 72 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Call.ToInstruction(this.Method.Module.Import(typeof(IntPtr).GetMethod("op_Explicit", new Type[] 73 | { 74 | typeof(int) 75 | })))); 76 | this.Method.Body.Instructions.Insert(i + 2, Instruction.Create(OpCodes.Conv_Ovf_I4)); 77 | i += 2; 78 | } 79 | 80 | // Token: 0x06000053 RID: 83 RVA: 0x00005FB0 File Offset: 0x000041B0 81 | private void ConvToStrLen(ref int i) 82 | { 83 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 84 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldstr; 85 | this.Method.Body.Instructions[i].Operand = this.RandomString(ldcI4Value); 86 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldlen.ToInstruction()); 87 | i++; 88 | } 89 | 90 | // Token: 0x06000054 RID: 84 RVA: 0x0000604C File Offset: 0x0000424C 91 | private string RandomString(int len) 92 | { 93 | string text = "abcdefghijklmnopqrstuvwxyz1234567890"; 94 | string text2 = ""; 95 | for (int i = 0; i < len; i++) 96 | { 97 | text2 += text[IntsConversions.rnd.Next(0, text.Length)].ToString(); 98 | } 99 | return text2; 100 | } 101 | 102 | // Token: 0x0400001E RID: 30 103 | private static Random rnd = new Random(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsReplacer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | 6 | namespace SugarGuard.Protector.Protections.Mutation.Stages 7 | { 8 | // Token: 0x02000016 RID: 22 9 | public class IntsReplacer 10 | { 11 | // Token: 0x17000004 RID: 4 12 | // (get) Token: 0x06000056 RID: 86 RVA: 0x000060B1 File Offset: 0x000042B1 13 | // (set) Token: 0x06000057 RID: 87 RVA: 0x000060B9 File Offset: 0x000042B9 14 | public MethodDef Method { get; set; } 15 | 16 | // Token: 0x06000058 RID: 88 RVA: 0x000060C2 File Offset: 0x000042C2 17 | public IntsReplacer(MethodDef method) 18 | { 19 | this.Method = method; 20 | } 21 | 22 | // Token: 0x06000059 RID: 89 RVA: 0x000060D4 File Offset: 0x000042D4 23 | public void Execute() 24 | { 25 | MethodImplAttributes implFlags = MethodImplAttributes.IL; 26 | MethodAttributes flags = MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig; 27 | MethodDefUser methodDefUser = new MethodDefUser(Renamer.InvisibleName, MethodSig.CreateStatic(this.Method.Module.CorLibTypes.Int32, this.Method.Module.CorLibTypes.Double), implFlags, flags) 28 | { 29 | Body = new CilBody() 30 | }; 31 | methodDefUser.Body.Instructions.Add(OpCodes.Ldarg_0.ToInstruction()); 32 | methodDefUser.Body.Instructions.Add(OpCodes.Call.ToInstruction(this.Method.Module.Import(typeof(Math).GetMethod("Sqrt", new Type[] 33 | { 34 | typeof(double) 35 | })))); 36 | methodDefUser.Body.Instructions.Add(OpCodes.Conv_I4.ToInstruction()); 37 | methodDefUser.Body.Instructions.Add(OpCodes.Ret.ToInstruction()); 38 | this.Method.Module.GlobalType.Methods.Add(methodDefUser); 39 | for (int i = 0; i < this.Method.Body.Instructions.Count; i++) 40 | { 41 | bool flag = this.Method.Body.Instructions[i].IsLdcI4(); 42 | if (flag) 43 | { 44 | this.MathReplacer(methodDefUser, ref i); 45 | } 46 | } 47 | } 48 | 49 | // Token: 0x0600005A RID: 90 RVA: 0x0000624C File Offset: 0x0000444C 50 | public void MathReplacer(MethodDef method, ref int i) 51 | { 52 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 53 | double num = (double)ldcI4Value * (double)ldcI4Value; 54 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_R8; 55 | this.Method.Body.Instructions[i].Operand = num; 56 | IList instructions = this.Method.Body.Instructions; 57 | int num2 = i + 1; 58 | i = num2; 59 | instructions.Insert(num2, OpCodes.Call.ToInstruction(method)); 60 | i++; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | 5 | namespace SugarGuard.Protector.Protections.Mutation.Stages 6 | { 7 | // Token: 0x02000017 RID: 23 8 | public class IntsToArray 9 | { 10 | // Token: 0x17000005 RID: 5 11 | // (get) Token: 0x0600005B RID: 91 RVA: 0x000062F0 File Offset: 0x000044F0 12 | // (set) Token: 0x0600005C RID: 92 RVA: 0x000062F8 File Offset: 0x000044F8 13 | public MethodDef method { get; set; } 14 | 15 | // Token: 0x0600005D RID: 93 RVA: 0x00006301 File Offset: 0x00004501 16 | public IntsToArray(MethodDef method) 17 | { 18 | this.method = method; 19 | } 20 | 21 | // Token: 0x0600005E RID: 94 RVA: 0x00006314 File Offset: 0x00004514 22 | public void Execute(int i, int start) 23 | { 24 | Local local = new Local(this.method.Module.ImportAsTypeSig(typeof(int[]))); 25 | this.method.Body.Variables.Add(local); 26 | int ldcI4Value = this.method.Body.Instructions[i].GetLdcI4Value(); 27 | this.method.Body.Instructions[i].OpCode = OpCodes.Ldloc_S; 28 | this.method.Body.Instructions[i].Operand = local; 29 | this.method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4_0.ToInstruction()); 30 | this.method.Body.Instructions.Insert(i + 2, OpCodes.Ldelem_I4.ToInstruction()); 31 | this.method.Body.Instructions.Insert(start, OpCodes.Ldc_I4_1.ToInstruction()); 32 | this.method.Body.Instructions.Insert(++start, OpCodes.Newarr.ToInstruction(this.method.Module.CorLibTypes.Int32)); 33 | this.method.Body.Instructions.Insert(++start, OpCodes.Dup.ToInstruction()); 34 | this.method.Body.Instructions.Insert(++start, OpCodes.Ldc_I4_0.ToInstruction()); 35 | this.method.Body.Instructions.Insert(++start, OpCodes.Ldc_I4.ToInstruction(ldcI4Value)); 36 | this.method.Body.Instructions.Insert(++start, OpCodes.Stelem_I4.ToInstruction()); 37 | this.method.Body.Instructions.Insert(++start, OpCodes.Stloc_S.ToInstruction(local)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToInitializeArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | 6 | namespace SugarGuard.Protector.Protections.Mutation.Stages 7 | { 8 | // Token: 0x02000018 RID: 24 9 | public class IntsToInitializeArray 10 | { 11 | // Token: 0x17000006 RID: 6 12 | // (get) Token: 0x0600005F RID: 95 RVA: 0x00006513 File Offset: 0x00004713 13 | // (set) Token: 0x06000060 RID: 96 RVA: 0x0000651B File Offset: 0x0000471B 14 | private MethodDef method { get; set; } 15 | 16 | // Token: 0x06000061 RID: 97 RVA: 0x00006524 File Offset: 0x00004724 17 | public IntsToInitializeArray(MethodDef method) 18 | { 19 | this.method = method; 20 | } 21 | 22 | // Token: 0x06000062 RID: 98 RVA: 0x00006538 File Offset: 0x00004738 23 | public void Execute() 24 | { 25 | bool flag = this.method.Name != "button1_Click"; 26 | if (!flag) 27 | { 28 | ITypeDefOrRef baseType = this.method.Module.ImportAsTypeSig(typeof(ValueType)).ToTypeDefOrRef(); 29 | TypeDef typeDef = new TypeDefUser("'__StaticArrayInitTypeSize=24'", baseType); 30 | typeDef.Attributes |= (TypeAttributes.ExplicitLayout | TypeAttributes.Sealed); 31 | typeDef.ClassLayout = new ClassLayoutUser(1, 24U); 32 | this.method.Module.Types.Add(typeDef); 33 | FieldDef fieldDef = new FieldDefUser("'$$method0x6000003-1'", new FieldSig(typeDef.ToTypeSig(true)), FieldAttributes.FieldAccessMask | FieldAttributes.Static | FieldAttributes.HasFieldRVA) 34 | { 35 | InitialValue = new byte[] 36 | { 37 | 1, 38 | 0, 39 | 0, 40 | 0, 41 | 2, 42 | 0, 43 | 0, 44 | 0, 45 | 3, 46 | 0, 47 | 0, 48 | 0, 49 | 4, 50 | 0, 51 | 0, 52 | 0, 53 | 5, 54 | 0, 55 | 0, 56 | 0, 57 | 6, 58 | 0, 59 | 0, 60 | 0 61 | } 62 | }; 63 | this.method.Module.GlobalType.Fields.Add(fieldDef); 64 | int num = 0; 65 | Local local = new Local(this.method.Module.ImportAsTypeSig(typeof(int[]))); 66 | this.method.Body.Variables.Add(local); 67 | this.method.Body.Instructions.Insert(num, OpCodes.Ldc_I4_6.ToInstruction()); 68 | this.method.Body.Instructions.Insert(++num, OpCodes.Newarr.ToInstruction(this.method.Module.CorLibTypes.Int32)); 69 | this.method.Body.Instructions.Insert(++num, OpCodes.Dup.ToInstruction()); 70 | this.method.Body.Instructions.Insert(++num, OpCodes.Ldtoken.ToInstruction(fieldDef)); 71 | this.method.Body.Instructions.Insert(++num, OpCodes.Call.ToInstruction(this.method.Module.Import(typeof(RuntimeHelpers).GetMethod("InitializeArray", new Type[] 72 | { 73 | typeof(Array), 74 | typeof(RuntimeFieldHandle) 75 | })))); 76 | this.method.Body.Instructions.Insert(num + 1, OpCodes.Stloc_S.ToInstruction(local)); 77 | this.method.Body.UpdateInstructionOffsets(); 78 | this.method.Body.OptimizeBranches(); 79 | this.method.Body.OptimizeMacros(); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToInliner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | 5 | namespace SugarGuard.Protector.Protections.Mutation.Stages 6 | { 7 | // Token: 0x02000019 RID: 25 8 | public class IntsToInliner 9 | { 10 | // Token: 0x17000007 RID: 7 11 | // (get) Token: 0x06000063 RID: 99 RVA: 0x000067CF File Offset: 0x000049CF 12 | // (set) Token: 0x06000064 RID: 100 RVA: 0x000067D7 File Offset: 0x000049D7 13 | public MethodDef method { get; set; } 14 | 15 | // Token: 0x06000065 RID: 101 RVA: 0x000067E0 File Offset: 0x000049E0 16 | public IntsToInliner(MethodDef method) 17 | { 18 | this.method = method; 19 | } 20 | 21 | // Token: 0x06000066 RID: 102 RVA: 0x000067F4 File Offset: 0x000049F4 22 | public void Execute(int i, int start) 23 | { 24 | Local local = new Local(this.method.Module.ImportAsTypeSig(typeof(int))); 25 | this.method.Body.Variables.Add(local); 26 | int ldcI4Value = this.method.Body.Instructions[i].GetLdcI4Value(); 27 | this.method.Body.Instructions[i].OpCode = OpCodes.Ldloc; 28 | this.method.Body.Instructions[i].Operand = local; 29 | Instruction instruction = OpCodes.Nop.ToInstruction(); 30 | this.method.Body.Instructions.Insert(start, Instruction.CreateLdcI4(IntsToInliner.rnd.Next(100, 500))); 31 | this.method.Body.Instructions.Insert(++start, Instruction.Create(OpCodes.Stloc, local)); 32 | this.method.Body.Instructions.Insert(++start, Instruction.CreateLdcI4(IntsToInliner.rnd.Next(1000, 5000))); 33 | this.method.Body.Instructions.Insert(++start, Instruction.Create(OpCodes.Ldloc, local)); 34 | this.method.Body.Instructions.Insert(++start, Instruction.Create(OpCodes.Ceq)); 35 | this.method.Body.Instructions.Insert(++start, Instruction.Create(OpCodes.Brtrue, instruction)); 36 | this.method.Body.Instructions.Insert(++start, Instruction.CreateLdcI4(ldcI4Value)); 37 | this.method.Body.Instructions.Insert(++start, Instruction.Create(OpCodes.Stloc, local)); 38 | this.method.Body.Instructions.Insert(++start, instruction); 39 | } 40 | 41 | // Token: 0x04000023 RID: 35 42 | private static Random rnd = new Random(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToMath.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | 6 | namespace SugarGuard.Protector.Protections.Mutation.Stages 7 | { 8 | // Token: 0x0200001A RID: 26 9 | public class IntsToMath 10 | { 11 | // Token: 0x17000008 RID: 8 12 | // (get) Token: 0x06000068 RID: 104 RVA: 0x00006A0B File Offset: 0x00004C0B 13 | // (set) Token: 0x06000069 RID: 105 RVA: 0x00006A13 File Offset: 0x00004C13 14 | private MethodDef Method { get; set; } 15 | 16 | // Token: 0x0600006A RID: 106 RVA: 0x00006A1C File Offset: 0x00004C1C 17 | public IntsToMath(MethodDef method) 18 | { 19 | this.Method = method; 20 | } 21 | 22 | // Token: 0x0600006B RID: 107 RVA: 0x00006A30 File Offset: 0x00004C30 23 | public void Execute(ref int i) 24 | { 25 | switch (IntsToMath.rnd.Next(0, 7)) 26 | { 27 | case 0: 28 | this.Neg(ref i); 29 | break; 30 | case 1: 31 | this.Not(ref i); 32 | break; 33 | case 2: 34 | this.Shr(ref i); 35 | break; 36 | case 3: 37 | this.Shl(ref i); 38 | break; 39 | case 4: 40 | this.Or(ref i); 41 | break; 42 | case 5: 43 | this.Rem(ref i); 44 | break; 45 | case 6: 46 | this.ConditionalMath(ref i); 47 | break; 48 | case 7: 49 | this.Add(ref i); 50 | break; 51 | case 8: 52 | this.Sub(ref i); 53 | break; 54 | case 9: 55 | this.Xor(ref i); 56 | break; 57 | } 58 | } 59 | 60 | // Token: 0x0600006C RID: 108 RVA: 0x00006AE4 File Offset: 0x00004CE4 61 | private void Add(ref int i) 62 | { 63 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 64 | int num = IntsToMath.rnd.Next(10000, 50000); 65 | int num2 = ldcI4Value - num; 66 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 67 | this.Method.Body.Instructions[i].Operand = num2; 68 | IList instructions = this.Method.Body.Instructions; 69 | int num3 = i + 1; 70 | i = num3; 71 | instructions.Insert(num3, OpCodes.Ldc_I4.ToInstruction(num)); 72 | IList instructions2 = this.Method.Body.Instructions; 73 | num3 = i + 1; 74 | i = num3; 75 | instructions2.Insert(num3, OpCodes.Add.ToInstruction()); 76 | } 77 | 78 | // Token: 0x0600006D RID: 109 RVA: 0x00006BC0 File Offset: 0x00004DC0 79 | private void Xor(ref int i) 80 | { 81 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 82 | int num = IntsToMath.rnd.Next(10000, 50000); 83 | int num2 = ldcI4Value ^ num; 84 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 85 | this.Method.Body.Instructions[i].Operand = num2; 86 | IList instructions = this.Method.Body.Instructions; 87 | int num3 = i + 1; 88 | i = num3; 89 | instructions.Insert(num3, OpCodes.Ldc_I4.ToInstruction(num)); 90 | IList instructions2 = this.Method.Body.Instructions; 91 | num3 = i + 1; 92 | i = num3; 93 | instructions2.Insert(num3, OpCodes.Xor.ToInstruction()); 94 | } 95 | 96 | // Token: 0x0600006E RID: 110 RVA: 0x00006C9C File Offset: 0x00004E9C 97 | private void Sub(ref int i) 98 | { 99 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 100 | int num = IntsToMath.rnd.Next(10000, 50000); 101 | int num2 = ldcI4Value + num; 102 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 103 | this.Method.Body.Instructions[i].Operand = num2; 104 | IList instructions = this.Method.Body.Instructions; 105 | int num3 = i + 1; 106 | i = num3; 107 | instructions.Insert(num3, OpCodes.Ldc_I4.ToInstruction(num)); 108 | IList instructions2 = this.Method.Body.Instructions; 109 | num3 = i + 1; 110 | i = num3; 111 | instructions2.Insert(num3, OpCodes.Sub.ToInstruction()); 112 | } 113 | 114 | // Token: 0x0600006F RID: 111 RVA: 0x00006D78 File Offset: 0x00004F78 115 | private void Neg(ref int i) 116 | { 117 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 118 | int num = IntsToMath.rnd.Next(10000, 50000); 119 | int value = -num; 120 | Calculator calculator = new Calculator(ldcI4Value, value); 121 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 122 | this.Method.Body.Instructions[i].Operand = calculator.getResult(); 123 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4.ToInstruction(num)); 124 | this.Method.Body.Instructions.Insert(i + 2, OpCodes.Neg.ToInstruction()); 125 | this.Method.Body.Instructions.Insert(i + 3, calculator.getOpCode().ToInstruction()); 126 | i += 3; 127 | } 128 | 129 | // Token: 0x06000070 RID: 112 RVA: 0x00006E80 File Offset: 0x00005080 130 | private void Rem(ref int i) 131 | { 132 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 133 | int num = IntsToMath.rnd.Next(10000, 50000); 134 | int num2 = IntsToMath.rnd.Next(10000, 50000); 135 | int value = num2 % num; 136 | Calculator calculator = new Calculator(ldcI4Value, value); 137 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 138 | this.Method.Body.Instructions[i].Operand = calculator.getResult(); 139 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4.ToInstruction(num2)); 140 | this.Method.Body.Instructions.Insert(i + 2, OpCodes.Ldc_I4.ToInstruction(num)); 141 | this.Method.Body.Instructions.Insert(i + 3, OpCodes.Rem.ToInstruction()); 142 | this.Method.Body.Instructions.Insert(i + 4, calculator.getOpCode().ToInstruction()); 143 | i += 4; 144 | } 145 | 146 | // Token: 0x06000071 RID: 113 RVA: 0x00006FC8 File Offset: 0x000051C8 147 | private void Not(ref int i) 148 | { 149 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 150 | int num = IntsToMath.rnd.Next(10000, 50000); 151 | int value = ~num; 152 | Calculator calculator = new Calculator(ldcI4Value, value); 153 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 154 | this.Method.Body.Instructions[i].Operand = calculator.getResult(); 155 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4.ToInstruction(num)); 156 | this.Method.Body.Instructions.Insert(i + 2, OpCodes.Not.ToInstruction()); 157 | this.Method.Body.Instructions.Insert(i + 3, calculator.getOpCode().ToInstruction()); 158 | i += 3; 159 | } 160 | 161 | // Token: 0x06000072 RID: 114 RVA: 0x000070D0 File Offset: 0x000052D0 162 | private void Shl(ref int i) 163 | { 164 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 165 | int num = IntsToMath.rnd.Next(10000, 50000); 166 | int num2 = IntsToMath.rnd.Next(10000, 50000); 167 | int value = num2 << num; 168 | Calculator calculator = new Calculator(ldcI4Value, value); 169 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 170 | this.Method.Body.Instructions[i].Operand = calculator.getResult(); 171 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4.ToInstruction(num2)); 172 | this.Method.Body.Instructions.Insert(i + 2, OpCodes.Ldc_I4.ToInstruction(num)); 173 | this.Method.Body.Instructions.Insert(i + 3, OpCodes.Shl.ToInstruction()); 174 | this.Method.Body.Instructions.Insert(i + 4, calculator.getOpCode().ToInstruction()); 175 | i += 4; 176 | } 177 | 178 | // Token: 0x06000073 RID: 115 RVA: 0x00007218 File Offset: 0x00005418 179 | private void Or(ref int i) 180 | { 181 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 182 | int num = IntsToMath.rnd.Next(10000, 50000); 183 | int num2 = IntsToMath.rnd.Next(10000, 50000); 184 | int value = num2 | num; 185 | Calculator calculator = new Calculator(ldcI4Value, value); 186 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 187 | this.Method.Body.Instructions[i].Operand = calculator.getResult(); 188 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4.ToInstruction(num2)); 189 | this.Method.Body.Instructions.Insert(i + 2, OpCodes.Ldc_I4.ToInstruction(num)); 190 | this.Method.Body.Instructions.Insert(i + 3, OpCodes.Or.ToInstruction()); 191 | this.Method.Body.Instructions.Insert(i + 4, calculator.getOpCode().ToInstruction()); 192 | i += 4; 193 | } 194 | 195 | // Token: 0x06000074 RID: 116 RVA: 0x00007360 File Offset: 0x00005560 196 | private void Shr(ref int i) 197 | { 198 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 199 | int num = IntsToMath.rnd.Next(10000, 50000); 200 | int num2 = IntsToMath.rnd.Next(10000, 50000); 201 | int value = num2 >> num; 202 | Calculator calculator = new Calculator(ldcI4Value, value); 203 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldc_I4; 204 | this.Method.Body.Instructions[i].Operand = calculator.getResult(); 205 | this.Method.Body.Instructions.Insert(i + 1, OpCodes.Ldc_I4.ToInstruction(num2)); 206 | this.Method.Body.Instructions.Insert(i + 2, OpCodes.Ldc_I4.ToInstruction(num)); 207 | this.Method.Body.Instructions.Insert(i + 3, OpCodes.Shr.ToInstruction()); 208 | this.Method.Body.Instructions.Insert(i + 4, calculator.getOpCode().ToInstruction()); 209 | i += 4; 210 | } 211 | 212 | // Token: 0x06000075 RID: 117 RVA: 0x000074A8 File Offset: 0x000056A8 213 | private void ConditionalMath(ref int i) 214 | { 215 | Instruction instruction = this.Method.Body.Instructions[i]; 216 | Local local = new Local(this.Method.Module.ImportAsTypeSig(typeof(int))); 217 | int ldcI4Value = instruction.GetLdcI4Value(); 218 | int num = IntsToMath.rnd.Next(); 219 | int num2 = IntsToMath.rnd.Next(); 220 | bool flag = num > num2; 221 | int value; 222 | int value2; 223 | if (flag) 224 | { 225 | value = ldcI4Value; 226 | value2 = ldcI4Value + ldcI4Value / 3; 227 | } 228 | else 229 | { 230 | value2 = ldcI4Value; 231 | value = ldcI4Value + ldcI4Value / 3; 232 | } 233 | this.Method.Body.Variables.Add(local); 234 | instruction.OpCode = OpCodes.Ldc_I4; 235 | instruction.Operand = num2; 236 | this.Method.Body.Instructions.Insert(i + 1, Instruction.Create(OpCodes.Ldc_I4, num)); 237 | this.Method.Body.Instructions.Insert(i + 2, Instruction.Create(OpCodes.Nop)); 238 | this.Method.Body.Instructions.Insert(i + 3, Instruction.Create(OpCodes.Ldc_I4, value)); 239 | this.Method.Body.Instructions.Insert(i + 4, Instruction.Create(OpCodes.Nop)); 240 | this.Method.Body.Instructions.Insert(i + 5, Instruction.Create(OpCodes.Ldc_I4, value2)); 241 | this.Method.Body.Instructions.Insert(i + 6, Instruction.Create(OpCodes.Stloc, local)); 242 | this.Method.Body.Instructions.Insert(i + 7, Instruction.Create(OpCodes.Ldloc, local)); 243 | this.Method.Body.Instructions[i + 2].OpCode = OpCodes.Bgt_S; 244 | this.Method.Body.Instructions[i + 2].Operand = this.Method.Body.Instructions[i + 5]; 245 | this.Method.Body.Instructions[i + 4].OpCode = OpCodes.Br_S; 246 | this.Method.Body.Instructions[i + 4].Operand = this.Method.Body.Instructions[i + 6]; 247 | i += 7; 248 | } 249 | 250 | // Token: 0x04000025 RID: 37 251 | private static Random rnd = new Random(); 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToMethodPointer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | 4 | namespace SugarGuard.Protector.Protections.Mutation.Stages 5 | { 6 | // Token: 0x0200001B RID: 27 7 | public class IntsToMethodPointer 8 | { 9 | // Token: 0x17000009 RID: 9 10 | // (get) Token: 0x06000077 RID: 119 RVA: 0x00007729 File Offset: 0x00005929 11 | // (set) Token: 0x06000078 RID: 120 RVA: 0x00007731 File Offset: 0x00005931 12 | private MethodDef method { get; set; } 13 | 14 | // Token: 0x06000079 RID: 121 RVA: 0x0000773A File Offset: 0x0000593A 15 | public IntsToMethodPointer(MethodDef method) 16 | { 17 | this.method = method; 18 | } 19 | 20 | // Token: 0x0600007A RID: 122 RVA: 0x0000774C File Offset: 0x0000594C 21 | public void Execute() 22 | { 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToRandom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using dnlib.DotNet; 4 | using dnlib.DotNet.Emit; 5 | using SugarGuard.Protector.Class; 6 | 7 | namespace SugarGuard.Protector.Protections.Mutation.Stages 8 | { 9 | // Token: 0x0200001C RID: 28 10 | public class IntsToRandom 11 | { 12 | // Token: 0x1700000A RID: 10 13 | // (get) Token: 0x0600007B RID: 123 RVA: 0x0000774F File Offset: 0x0000594F 14 | // (set) Token: 0x0600007C RID: 124 RVA: 0x00007757 File Offset: 0x00005957 15 | private MethodDef method { get; set; } 16 | 17 | // Token: 0x0600007D RID: 125 RVA: 0x00007760 File Offset: 0x00005960 18 | public IntsToRandom(MethodDef method) 19 | { 20 | this.method = method; 21 | } 22 | 23 | // Token: 0x0600007E RID: 126 RVA: 0x00007774 File Offset: 0x00005974 24 | public void Execute(ref int i) 25 | { 26 | int ldcI4Value = this.method.Body.Instructions[i].GetLdcI4Value(); 27 | int num = IntsToRandom.rnd.Next(1, int.MaxValue); 28 | int num2 = this.randomAssist(num, ldcI4Value); 29 | bool flag = num2 == 0; 30 | if (!flag) 31 | { 32 | this.method.Body.Instructions[i] = OpCodes.Ldc_I4.ToInstruction(num); 33 | IList instructions = this.method.Body.Instructions; 34 | int num3 = i + 1; 35 | i = num3; 36 | instructions.Insert(num3, OpCodes.Newobj.ToInstruction(this.method.Module.Import(typeof(Random).GetConstructor(new Type[] 37 | { 38 | typeof(int) 39 | })))); 40 | IList instructions2 = this.method.Body.Instructions; 41 | num3 = i + 1; 42 | i = num3; 43 | instructions2.Insert(num3, OpCodes.Ldc_I4.ToInstruction(num2)); 44 | IList instructions3 = this.method.Body.Instructions; 45 | num3 = i + 1; 46 | i = num3; 47 | instructions3.Insert(num3, OpCodes.Callvirt.ToInstruction(this.method.Module.Import(typeof(Random).GetMethod("Next", new Type[] 48 | { 49 | typeof(int) 50 | })))); 51 | } 52 | } 53 | 54 | // Token: 0x0600007F RID: 127 RVA: 0x000078D8 File Offset: 0x00005AD8 55 | private int randomAssist(int seed, int returnValue) 56 | { 57 | RandomHelper randomHelper = new RandomHelper(seed); 58 | int num = (int)Math.Round((double)returnValue / (randomHelper.InternalSample() * 4.656612875245797E-10)); 59 | bool flag = num < 0; 60 | int result; 61 | if (flag) 62 | { 63 | result = 0; 64 | } 65 | else 66 | { 67 | bool flag2 = new Random(seed).Next(num) == returnValue; 68 | if (flag2) 69 | { 70 | result = num; 71 | } 72 | else 73 | { 74 | bool flag3 = new Random(seed).Next(num + 1) == returnValue; 75 | if (flag3) 76 | { 77 | result = num + 1; 78 | } 79 | else 80 | { 81 | result = 0; 82 | } 83 | } 84 | } 85 | return result; 86 | } 87 | 88 | // Token: 0x04000028 RID: 40 89 | public static Random rnd = new Random(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/IntsToStackalloc.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 SugarGuard.Protector.Protections.Mutation.Stages 8 | { 9 | // Token: 0x0200001D RID: 29 10 | internal class IntsToStackalloc 11 | { 12 | // Token: 0x1700000B RID: 11 13 | // (get) Token: 0x06000081 RID: 129 RVA: 0x0000795A File Offset: 0x00005B5A 14 | // (set) Token: 0x06000082 RID: 130 RVA: 0x00007962 File Offset: 0x00005B62 15 | private MethodDef method { get; set; } 16 | 17 | // Token: 0x06000083 RID: 131 RVA: 0x0000796B File Offset: 0x00005B6B 18 | public IntsToStackalloc(MethodDef method) 19 | { 20 | this.method = method; 21 | this.Create(); 22 | } 23 | 24 | // Token: 0x06000084 RID: 132 RVA: 0x00007998 File Offset: 0x00005B98 25 | public unsafe void Create() 26 | { 27 | this.local = new Local(this.method.Module.Import(typeof(int*)).ToTypeSig(true)); 28 | this.method.Body.Variables.Add(this.local); 29 | this.toInject.Add(OpCodes.Ldc_I4.ToInstruction(4)); 30 | this.toInject.Add(OpCodes.Conv_U.ToInstruction()); 31 | this.toInject.Add(OpCodes.Localloc.ToInstruction()); 32 | } 33 | 34 | // Token: 0x06000085 RID: 133 RVA: 0x00007A30 File Offset: 0x00005C30 35 | public void Execute(ref int i) 36 | { 37 | int ldcI4Value = this.method.Body.Instructions[i].GetLdcI4Value(); 38 | this.toInject.Add(OpCodes.Dup.ToInstruction()); 39 | this.toInject.Add(OpCodes.Ldc_I4.ToInstruction(this.offset * 4)); 40 | this.toInject.Add(OpCodes.Add.ToInstruction()); 41 | this.toInject.Add(OpCodes.Ldc_I4.ToInstruction(ldcI4Value)); 42 | this.toInject.Add(OpCodes.Stind_I4.ToInstruction()); 43 | this.method.Body.Instructions[i] = OpCodes.Ldloc_S.ToInstruction(this.local); 44 | IList instructions = this.method.Body.Instructions; 45 | int num = i + 1; 46 | i = num; 47 | int index = num; 48 | OpCode ldc_I = OpCodes.Ldc_I4; 49 | num = this.offset; 50 | this.offset = num + 1; 51 | instructions.Insert(index, ldc_I.ToInstruction(num * 4)); 52 | IList instructions2 = this.method.Body.Instructions; 53 | num = i + 1; 54 | i = num; 55 | instructions2.Insert(num, OpCodes.Add.ToInstruction()); 56 | IList instructions3 = this.method.Body.Instructions; 57 | num = i + 1; 58 | i = num; 59 | instructions3.Insert(num, OpCodes.Ldind_I4.ToInstruction()); 60 | } 61 | 62 | // Token: 0x06000086 RID: 134 RVA: 0x00007B88 File Offset: 0x00005D88 63 | public void Inject() 64 | { 65 | int num = this.offset * 4; 66 | bool flag = num != 0; 67 | if (flag) 68 | { 69 | this.toInject[0] = OpCodes.Ldc_I4.ToInstruction(num); 70 | bool flag2 = this.toInject.Last().OpCode == OpCodes.Dup; 71 | if (flag2) 72 | { 73 | this.toInject.RemoveAt(this.toInject.Count - 1); 74 | } 75 | this.toInject.Add(OpCodes.Stloc_S.ToInstruction(this.local)); 76 | for (int i = 0; i < this.toInject.Count; i++) 77 | { 78 | this.method.Body.Instructions.Insert(i, this.toInject[i]); 79 | } 80 | } 81 | } 82 | 83 | // Token: 0x0400002A RID: 42 84 | private Local local; 85 | 86 | // Token: 0x0400002B RID: 43 87 | private List toInject = new List(); 88 | 89 | // Token: 0x0400002C RID: 44 90 | private int offset = 0; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/LocalsToCustomLocal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | 5 | namespace SugarGuard.Protector.Protections.Mutation.Stages 6 | { 7 | // Token: 0x0200001E RID: 30 8 | public class LocalsToCustomLocal 9 | { 10 | // Token: 0x1700000C RID: 12 11 | // (get) Token: 0x06000087 RID: 135 RVA: 0x00007C57 File Offset: 0x00005E57 12 | // (set) Token: 0x06000088 RID: 136 RVA: 0x00007C5F File Offset: 0x00005E5F 13 | private MethodDef method { get; set; } 14 | 15 | // Token: 0x06000089 RID: 137 RVA: 0x00007C68 File Offset: 0x00005E68 16 | public LocalsToCustomLocal(MethodDef method) 17 | { 18 | this.method = method; 19 | } 20 | 21 | // Token: 0x0600008A RID: 138 RVA: 0x00007C7C File Offset: 0x00005E7C 22 | public void Execute(ref int i) 23 | { 24 | int num = LocalsToCustomLocal.rnd.Next(0, 2); 25 | int num2 = num; 26 | if (num2 != 0) 27 | { 28 | if (num2 == 1) 29 | { 30 | this.RefLocal(ref i); 31 | } 32 | } 33 | else 34 | { 35 | this.PointerLocal(ref i); 36 | } 37 | } 38 | 39 | // Token: 0x0600008B RID: 139 RVA: 0x00007CB8 File Offset: 0x00005EB8 40 | public void RefLocal(ref int i) 41 | { 42 | Local local = new Local(this.method.Module.ImportAsTypeSig(typeof(int))); 43 | this.method.Body.Variables.Add(local); 44 | int ldcI4Value = this.method.Body.Instructions[i].GetLdcI4Value(); 45 | this.method.Body.Instructions[i].OpCode = OpCodes.Ldloc_S; 46 | this.method.Body.Instructions[i].Operand = local; 47 | this.method.Body.Instructions.Insert(0, OpCodes.Ldc_I4.ToInstruction(LocalsToCustomLocal.rnd.Next(100, 200))); 48 | this.method.Body.Instructions.Insert(1, OpCodes.Stloc_S.ToInstruction(local)); 49 | this.method.Body.Instructions.Insert(2, OpCodes.Ldloca_S.ToInstruction(local)); 50 | this.method.Body.Instructions.Insert(3, OpCodes.Mkrefany.ToInstruction(this.method.Module.CorLibTypes.Int32)); 51 | this.method.Body.Instructions.Insert(4, OpCodes.Refanyval.ToInstruction(this.method.Module.CorLibTypes.Int32)); 52 | this.method.Body.Instructions.Insert(5, OpCodes.Ldc_I4.ToInstruction(ldcI4Value)); 53 | this.method.Body.Instructions.Insert(6, OpCodes.Stind_I4.ToInstruction()); 54 | i += 7; 55 | } 56 | 57 | // Token: 0x0600008C RID: 140 RVA: 0x00007E84 File Offset: 0x00006084 58 | public unsafe void PointerLocal(ref int i) 59 | { 60 | int ldcI4Value = this.method.Body.Instructions[i].GetLdcI4Value(); 61 | Local local = new Local(this.method.Module.ImportAsTypeSig(typeof(int))); 62 | Local local2 = new Local(this.method.Module.ImportAsTypeSig(typeof(int*))); 63 | this.method.Body.Variables.Add(local); 64 | this.method.Body.Variables.Add(local2); 65 | this.method.Body.Instructions[i] = OpCodes.Ldloc_S.ToInstruction(local); 66 | this.method.Body.Instructions.Insert(0, OpCodes.Ldc_I4.ToInstruction(LocalsToCustomLocal.rnd.Next())); 67 | this.method.Body.Instructions.Insert(1, OpCodes.Stloc_S.ToInstruction(local)); 68 | this.method.Body.Instructions.Insert(2, OpCodes.Ldloca_S.ToInstruction(local)); 69 | this.method.Body.Instructions.Insert(3, OpCodes.Conv_U.ToInstruction()); 70 | this.method.Body.Instructions.Insert(4, OpCodes.Stloc_S.ToInstruction(local2)); 71 | this.method.Body.Instructions.Insert(5, OpCodes.Ldloc_S.ToInstruction(local2)); 72 | this.method.Body.Instructions.Insert(6, OpCodes.Ldc_I4.ToInstruction(ldcI4Value)); 73 | this.method.Body.Instructions.Insert(7, OpCodes.Stind_I4.ToInstruction()); 74 | i += 8; 75 | } 76 | 77 | // Token: 0x0400002E RID: 46 78 | private static Random rnd = new Random(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Mutation/Stages/MethodPreparation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | using SugarGuard.Protector.Class; 5 | 6 | namespace SugarGuard.Protector.Protections.Mutation.Stages 7 | { 8 | // Token: 0x0200001F RID: 31 9 | public class MethodPreparation 10 | { 11 | // Token: 0x1700000D RID: 13 12 | // (get) Token: 0x0600008E RID: 142 RVA: 0x00008069 File Offset: 0x00006269 13 | // (set) Token: 0x0600008F RID: 143 RVA: 0x00008071 File Offset: 0x00006271 14 | private MethodDef Method { get; set; } 15 | 16 | // Token: 0x06000090 RID: 144 RVA: 0x0000807A File Offset: 0x0000627A 17 | public MethodPreparation(MethodDef method) 18 | { 19 | this.Method = method; 20 | } 21 | 22 | // Token: 0x06000091 RID: 145 RVA: 0x0000808C File Offset: 0x0000628C 23 | public void Execute() 24 | { 25 | bool flag = this.hasInts(); 26 | if (flag) 27 | { 28 | this.Ints(); 29 | } 30 | } 31 | 32 | // Token: 0x06000092 RID: 146 RVA: 0x000080B0 File Offset: 0x000062B0 33 | private bool hasInts() 34 | { 35 | for (int i = 0; i < this.Method.Body.Instructions.Count; i++) 36 | { 37 | bool flag = this.Method.Body.Instructions[i].IsLdcI4(); 38 | if (flag) 39 | { 40 | return true; 41 | } 42 | } 43 | return false; 44 | } 45 | 46 | // Token: 0x06000093 RID: 147 RVA: 0x0000810C File Offset: 0x0000630C 47 | private void Ints() 48 | { 49 | for (int i = 0; i < this.Method.Body.Instructions.Count; i++) 50 | { 51 | bool flag = this.Method.Body.Instructions[i].IsLdcI4() && MutationHelper.CanObfuscate(this.Method.Body.Instructions, i); 52 | if (flag) 53 | { 54 | switch (MethodPreparation.rnd.Next(0, 10)) 55 | { 56 | case 1: 57 | this.ConvToField(ref i); 58 | break; 59 | case 2: 60 | this.ConvToLocal(ref i); 61 | break; 62 | case 3: 63 | this.ConvToFieldModule(ref i); 64 | break; 65 | } 66 | } 67 | } 68 | } 69 | 70 | // Token: 0x06000094 RID: 148 RVA: 0x000081D0 File Offset: 0x000063D0 71 | private void ConvToField(ref int i) 72 | { 73 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 74 | FieldDef fieldDef = new FieldDefUser(Renamer.InvisibleName, new FieldSig(this.Method.Module.CorLibTypes.Int32), FieldAttributes.FamANDAssem | FieldAttributes.Family | FieldAttributes.Static); 75 | this.Method.DeclaringType.Fields.Add(fieldDef); 76 | this.Method.Body.Instructions.Insert(0, Instruction.CreateLdcI4(ldcI4Value)); 77 | this.Method.Body.Instructions.Insert(1, Instruction.Create(OpCodes.Stsfld, fieldDef)); 78 | i += 2; 79 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldsfld; 80 | this.Method.Body.Instructions[i].Operand = fieldDef; 81 | } 82 | 83 | // Token: 0x06000095 RID: 149 RVA: 0x000082C4 File Offset: 0x000064C4 84 | private void ConvToFieldModule(ref int i) 85 | { 86 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 87 | MethodDef methodDef = this.Method.Module.GlobalType.FindOrCreateStaticConstructor(); 88 | FieldDef fieldDef = new FieldDefUser(Renamer.InvisibleName, new FieldSig(this.Method.Module.CorLibTypes.Int32), FieldAttributes.FamANDAssem | FieldAttributes.Family | FieldAttributes.Static); 89 | this.Method.Module.GlobalType.Fields.Add(fieldDef); 90 | methodDef.Body.Instructions.Insert(0, OpCodes.Ldc_I4.ToInstruction(MethodPreparation.rnd.Next())); 91 | methodDef.Body.Instructions.Insert(1, OpCodes.Stsfld.ToInstruction(fieldDef)); 92 | this.Method.Body.Instructions.Insert(0, OpCodes.Ldc_I4.ToInstruction(ldcI4Value)); 93 | this.Method.Body.Instructions.Insert(1, OpCodes.Stsfld.ToInstruction(fieldDef)); 94 | i += 2; 95 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldsfld; 96 | this.Method.Body.Instructions[i].Operand = fieldDef; 97 | } 98 | 99 | // Token: 0x06000096 RID: 150 RVA: 0x00008418 File Offset: 0x00006618 100 | private void ConvToLocal(ref int i) 101 | { 102 | int ldcI4Value = this.Method.Body.Instructions[i].GetLdcI4Value(); 103 | Local local = new Local(this.Method.Module.ImportAsTypeSig(typeof(int))); 104 | this.Method.Body.Variables.Add(local); 105 | this.Method.Body.Instructions[i].OpCode = OpCodes.Ldloc_S; 106 | this.Method.Body.Instructions[i].Operand = local; 107 | this.Method.Body.Instructions.Insert(0, OpCodes.Ldc_I4.ToInstruction(ldcI4Value)); 108 | this.Method.Body.Instructions.Insert(1, OpCodes.Stloc_S.ToInstruction(local)); 109 | i += 2; 110 | } 111 | 112 | // Token: 0x04000030 RID: 48 113 | private static Random rnd = new Random(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ReferenceProxy/Helper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using dnlib.DotNet; 3 | using dnlib.DotNet.Emit; 4 | 5 | namespace SugarGuard.Protector.Protections.ReferenceProxy 6 | { 7 | // Token: 0x02000012 RID: 18 8 | internal class Helper 9 | { 10 | // Token: 0x06000040 RID: 64 RVA: 0x000056F4 File Offset: 0x000038F4 11 | public MethodDef GenerateMethod(TypeDef declaringType, object targetMethod, bool hasThis = false, bool isVoid = false) 12 | { 13 | MemberRef memberRef = (MemberRef)targetMethod; 14 | MethodDef methodDef = new MethodDefUser(Renamer.InvisibleName, MethodSig.CreateStatic(memberRef.ReturnType), MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Static); 15 | methodDef.Body = new CilBody(); 16 | if (hasThis) 17 | { 18 | methodDef.MethodSig.Params.Add(declaringType.Module.Import(declaringType.ToTypeSig(true))); 19 | } 20 | foreach (TypeSig item in memberRef.MethodSig.Params) 21 | { 22 | methodDef.MethodSig.Params.Add(item); 23 | } 24 | methodDef.Parameters.UpdateParameterTypes(); 25 | foreach (Parameter parameter in methodDef.Parameters) 26 | { 27 | methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg, parameter)); 28 | } 29 | methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Call, memberRef)); 30 | methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); 31 | return methodDef; 32 | } 33 | 34 | // Token: 0x06000041 RID: 65 RVA: 0x00005854 File Offset: 0x00003A54 35 | public MethodDef GenerateMethod(IMethod targetMethod, MethodDef md) 36 | { 37 | MethodDef methodDef = new MethodDefUser(Renamer.InvisibleName, MethodSig.CreateStatic(md.Module.Import(targetMethod.DeclaringType.ToTypeSig(true))), MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Static); 38 | methodDef.ImplAttributes = MethodImplAttributes.IL; 39 | methodDef.IsHideBySig = true; 40 | methodDef.Body = new CilBody(); 41 | for (int i = 0; i < targetMethod.MethodSig.Params.Count; i++) 42 | { 43 | methodDef.ParamDefs.Add(new ParamDefUser(Renamer.InvisibleName, (ushort)(i + 1))); 44 | methodDef.MethodSig.Params.Add(targetMethod.MethodSig.Params[i]); 45 | } 46 | methodDef.Parameters.UpdateParameterTypes(); 47 | for (int j = 0; j < methodDef.Parameters.Count; j++) 48 | { 49 | Parameter operand = methodDef.Parameters[j]; 50 | methodDef.Body.Instructions.Add(new Instruction(OpCodes.Ldarg, operand)); 51 | } 52 | methodDef.Body.Instructions.Add(new Instruction(OpCodes.Newobj, targetMethod)); 53 | methodDef.Body.Instructions.Add(new Instruction(OpCodes.Ret)); 54 | return methodDef; 55 | } 56 | 57 | // Token: 0x06000042 RID: 66 RVA: 0x000059A4 File Offset: 0x00003BA4 58 | public MethodDef GenerateMethod(FieldDef targetField, MethodDef md) 59 | { 60 | MethodDef methodDef = new MethodDefUser(Renamer.InvisibleName, MethodSig.CreateStatic(md.Module.Import(targetField.FieldType)), MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Static); 61 | methodDef.Body = new CilBody(); 62 | TypeDef declaringType = md.DeclaringType; 63 | methodDef.MethodSig.Params.Add(md.Module.Import(declaringType).ToTypeSig(true)); 64 | methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg_0)); 65 | methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldfld, targetField)); 66 | methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); 67 | md.DeclaringType.Methods.Add(methodDef); 68 | return methodDef; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/ReferenceProxy/ReferenceProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using dnlib.DotNet; 6 | using dnlib.DotNet.Emit; 7 | using SugarGuard.Protector.Class; 8 | 9 | namespace SugarGuard.Protector.Protections.ReferenceProxy 10 | { 11 | // Token: 0x02000011 RID: 17 12 | public class ReferenceProxy 13 | { 14 | // Token: 0x0600003C RID: 60 RVA: 0x0000518D File Offset: 0x0000338D 15 | public ReferenceProxy(SugarLib lib) 16 | { 17 | this.Main(lib); 18 | } 19 | 20 | // Token: 0x0600003D RID: 61 RVA: 0x000051AC File Offset: 0x000033AC 21 | private static bool canObfuscate(MethodDef methodDef) 22 | { 23 | bool flag = !methodDef.HasBody; 24 | bool result; 25 | if (flag) 26 | { 27 | result = false; 28 | } 29 | else 30 | { 31 | bool flag2 = !methodDef.Body.HasInstructions; 32 | if (flag2) 33 | { 34 | result = false; 35 | } 36 | else 37 | { 38 | bool isGlobalModuleType = methodDef.DeclaringType.IsGlobalModuleType; 39 | result = !isGlobalModuleType; 40 | } 41 | } 42 | return result; 43 | } 44 | 45 | // Token: 0x0600003E RID: 62 RVA: 0x000051FC File Offset: 0x000033FC 46 | private void Main(SugarLib lib) 47 | { 48 | Helper helper = new Helper(); 49 | ReferenceProxy.
g__fixProxy|3_0(lib.moduleDef); 50 | foreach (TypeDef typeDef in lib.moduleDef.Types.ToArray()) 51 | { 52 | foreach (MethodDef methodDef in typeDef.Methods.ToArray()) 53 | { 54 | bool flag = this.usedMethods.Contains(methodDef); 55 | if (!flag) 56 | { 57 | bool flag2 = ReferenceProxy.canObfuscate(methodDef); 58 | if (flag2) 59 | { 60 | Instruction[] array3 = methodDef.Body.Instructions.ToArray(); 61 | int k = 0; 62 | while (k < array3.Length) 63 | { 64 | Instruction instruction = array3[k]; 65 | bool flag3 = instruction.OpCode == OpCodes.Newobj; 66 | if (flag3) 67 | { 68 | IMethodDefOrRef methodDefOrRef = instruction.Operand as IMethodDefOrRef; 69 | bool isMethodSpec = methodDefOrRef.IsMethodSpec; 70 | if (!isMethodSpec) 71 | { 72 | bool flag4 = methodDefOrRef == null; 73 | if (!flag4) 74 | { 75 | MethodDef methodDef2 = helper.GenerateMethod(methodDefOrRef, methodDef); 76 | bool flag5 = methodDef2 == null; 77 | if (!flag5) 78 | { 79 | methodDef.DeclaringType.Methods.Add(methodDef2); 80 | this.usedMethods.Add(methodDef2); 81 | instruction.OpCode = OpCodes.Call; 82 | instruction.Operand = methodDef2; 83 | this.usedMethods.Add(methodDef2); 84 | } 85 | } 86 | } 87 | } 88 | else 89 | { 90 | bool flag6 = instruction.OpCode == OpCodes.Stfld; 91 | if (flag6) 92 | { 93 | FieldDef fieldDef = instruction.Operand as FieldDef; 94 | bool flag7 = fieldDef == null; 95 | if (!flag7) 96 | { 97 | CilBody cilBody = new CilBody(); 98 | cilBody.Instructions.Add(OpCodes.Nop.ToInstruction()); 99 | cilBody.Instructions.Add(OpCodes.Ldarg_0.ToInstruction()); 100 | cilBody.Instructions.Add(OpCodes.Ldarg_1.ToInstruction()); 101 | cilBody.Instructions.Add(OpCodes.Stfld.ToInstruction(fieldDef)); 102 | cilBody.Instructions.Add(OpCodes.Ret.ToInstruction()); 103 | MethodSig methodSig = MethodSig.CreateInstance(lib.moduleDef.CorLibTypes.Void, fieldDef.FieldSig.GetFieldType()); 104 | methodSig.HasThis = true; 105 | MethodDefUser methodDefUser = new MethodDefUser(Renamer.InvisibleName, methodSig) 106 | { 107 | Body = cilBody, 108 | IsHideBySig = true 109 | }; 110 | this.usedMethods.Add(methodDefUser); 111 | methodDef.DeclaringType.Methods.Add(methodDefUser); 112 | instruction.Operand = methodDefUser; 113 | instruction.OpCode = OpCodes.Call; 114 | } 115 | } 116 | else 117 | { 118 | bool flag8 = instruction.OpCode == OpCodes.Ldfld; 119 | if (flag8) 120 | { 121 | FieldDef fieldDef2 = instruction.Operand as FieldDef; 122 | bool flag9 = fieldDef2 == null; 123 | if (!flag9) 124 | { 125 | MethodDef methodDef3 = helper.GenerateMethod(fieldDef2, methodDef); 126 | instruction.OpCode = OpCodes.Call; 127 | instruction.Operand = methodDef3; 128 | this.usedMethods.Add(methodDef3); 129 | } 130 | } 131 | else 132 | { 133 | bool flag10 = instruction.OpCode == OpCodes.Call; 134 | if (flag10) 135 | { 136 | bool flag11 = instruction.Operand is MemberRef; 137 | if (flag11) 138 | { 139 | MemberRef memberRef = (MemberRef)instruction.Operand; 140 | bool flag12 = !memberRef.FullName.Contains("Collections.Generic") && !memberRef.Name.Contains("ToString") && !memberRef.FullName.Contains("Thread::Start"); 141 | if (flag12) 142 | { 143 | MethodDef methodDef4 = helper.GenerateMethod(typeDef, memberRef, memberRef.HasThis, memberRef.FullName.StartsWith("System.Void")); 144 | bool flag13 = methodDef4 != null; 145 | if (flag13) 146 | { 147 | this.usedMethods.Add(methodDef4); 148 | typeDef.Methods.Add(methodDef4); 149 | instruction.Operand = methodDef4; 150 | methodDef4.Body.Instructions.Add(new Instruction(OpCodes.Ret)); 151 | } 152 | } 153 | } 154 | } 155 | } 156 | } 157 | } 158 | IL_3EB: 159 | k++; 160 | continue; 161 | goto IL_3EB; 162 | } 163 | } 164 | } 165 | } 166 | } 167 | } 168 | 169 | // Token: 0x0600003F RID: 63 RVA: 0x00005628 File Offset: 0x00003828 170 | [CompilerGenerated] 171 | internal static void
g__fixProxy|3_0(ModuleDef moduleDef) 172 | { 173 | AssemblyResolver assemblyResolver = new AssemblyResolver(); 174 | ModuleContext moduleContext = new ModuleContext(assemblyResolver); 175 | assemblyResolver.DefaultModuleContext = moduleContext; 176 | assemblyResolver.EnableTypeDefCache = true; 177 | List list = moduleDef.GetAssemblyRefs().ToList(); 178 | moduleDef.Context = moduleContext; 179 | foreach (AssemblyRef assemblyRef in list) 180 | { 181 | bool flag = assemblyRef == null; 182 | bool flag2 = !flag; 183 | if (flag2) 184 | { 185 | AssemblyDef assemblyDef = assemblyResolver.Resolve(assemblyRef.FullName, moduleDef); 186 | bool flag3 = assemblyDef == null; 187 | bool flag4 = !flag3; 188 | if (flag4) 189 | { 190 | ((AssemblyResolver)moduleDef.Context.AssemblyResolver).AddToCache(assemblyDef); 191 | } 192 | } 193 | } 194 | } 195 | 196 | // Token: 0x04000018 RID: 24 197 | private List usedMethods = new List(); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Renamer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using dnlib.DotNet; 4 | using SugarGuard.Protector.Class; 5 | 6 | namespace SugarGuard.Protector.Protections 7 | { 8 | // Token: 0x0200000B RID: 11 9 | public class Renamer 10 | { 11 | // Token: 0x06000022 RID: 34 RVA: 0x000046A8 File Offset: 0x000028A8 12 | public Renamer(SugarLib lib) 13 | { 14 | this.Main(lib); 15 | } 16 | 17 | // Token: 0x17000002 RID: 2 18 | // (get) Token: 0x06000023 RID: 35 RVA: 0x000046BC File Offset: 0x000028BC 19 | public static string InvisibleName 20 | { 21 | get 22 | { 23 | return string.Format("<{0}>Sugar{1}", Renamer.GenerateName(), "Guard.ツ"); 24 | } 25 | } 26 | 27 | // Token: 0x06000024 RID: 36 RVA: 0x000046E4 File Offset: 0x000028E4 28 | private void Main(SugarLib lib) 29 | { 30 | string text = null; 31 | foreach (ModuleDef moduleDef in lib.assembly.Modules) 32 | { 33 | foreach (TypeDef typeDef in moduleDef.Types) 34 | { 35 | bool isPublic = typeDef.IsPublic; 36 | if (isPublic) 37 | { 38 | text = typeDef.Name; 39 | } 40 | bool flag = Renamer.CanRename(typeDef); 41 | if (flag) 42 | { 43 | foreach (MethodDef methodDef in typeDef.Methods) 44 | { 45 | bool flag2 = Renamer.CanRename(methodDef); 46 | if (flag2) 47 | { 48 | TypeRef typeRef = lib.moduleDef.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "CompilerGeneratedAttribute"); 49 | MemberRefUser ctor = new MemberRefUser(lib.moduleDef, ".ctor", MethodSig.CreateInstance(lib.moduleDef.Import(typeof(void)).ToTypeSig(true)), typeRef); 50 | CustomAttribute item = new CustomAttribute(ctor); 51 | methodDef.CustomAttributes.Add(item); 52 | methodDef.Name = Renamer.InvisibleName; 53 | } 54 | foreach (Parameter parameter in methodDef.Parameters) 55 | { 56 | parameter.Name = Renamer.InvisibleName; 57 | } 58 | } 59 | } 60 | foreach (FieldDef fieldDef in typeDef.Fields) 61 | { 62 | bool flag3 = Renamer.CanRename(fieldDef); 63 | if (flag3) 64 | { 65 | fieldDef.Name = Renamer.InvisibleName; 66 | } 67 | } 68 | foreach (EventDef eventDef in typeDef.Events) 69 | { 70 | bool flag4 = Renamer.CanRename(eventDef); 71 | if (flag4) 72 | { 73 | eventDef.Name = Renamer.InvisibleName; 74 | } 75 | } 76 | bool isPublic2 = typeDef.IsPublic; 77 | if (isPublic2) 78 | { 79 | foreach (Resource resource in lib.moduleDef.Resources) 80 | { 81 | bool flag5 = resource.Name.Contains(text); 82 | if (flag5) 83 | { 84 | resource.Name = resource.Name.Replace(text, typeDef.Name); 85 | } 86 | } 87 | } 88 | } 89 | } 90 | } 91 | 92 | // Token: 0x06000025 RID: 37 RVA: 0x00004A64 File Offset: 0x00002C64 93 | public static string GenerateName() 94 | { 95 | return new string((from s in Enumerable.Repeat("あいうえおかきくけこがぎぐげごさしすせそざじずぜアイウエオクザタツワルムパリピンプペヲポ", 10) 96 | select s[Renamer.rnd.Next(s.Length)]).ToArray()); 97 | } 98 | 99 | // Token: 0x06000026 RID: 38 RVA: 0x00004AB0 File Offset: 0x00002CB0 100 | private static bool CanRename(TypeDef type) 101 | { 102 | bool isGlobalModuleType = type.IsGlobalModuleType; 103 | bool result; 104 | if (isGlobalModuleType) 105 | { 106 | result = false; 107 | } 108 | else 109 | { 110 | try 111 | { 112 | bool flag = type.Namespace.Contains("My"); 113 | if (flag) 114 | { 115 | return false; 116 | } 117 | } 118 | catch 119 | { 120 | } 121 | bool flag2 = type.Interfaces.Count > 0; 122 | if (flag2) 123 | { 124 | result = false; 125 | } 126 | else 127 | { 128 | bool isSpecialName = type.IsSpecialName; 129 | if (isSpecialName) 130 | { 131 | result = false; 132 | } 133 | else 134 | { 135 | bool isRuntimeSpecialName = type.IsRuntimeSpecialName; 136 | if (isRuntimeSpecialName) 137 | { 138 | result = false; 139 | } 140 | else 141 | { 142 | bool flag3 = type.Name.Contains("Sugar"); 143 | result = !flag3; 144 | } 145 | } 146 | } 147 | } 148 | return result; 149 | } 150 | 151 | // Token: 0x06000027 RID: 39 RVA: 0x00004B54 File Offset: 0x00002D54 152 | private static bool CanRename(MethodDef method) 153 | { 154 | bool isConstructor = method.IsConstructor; 155 | bool result; 156 | if (isConstructor) 157 | { 158 | result = false; 159 | } 160 | else 161 | { 162 | bool isForwarder = method.DeclaringType.IsForwarder; 163 | if (isForwarder) 164 | { 165 | result = false; 166 | } 167 | else 168 | { 169 | bool isFamily = method.IsFamily; 170 | if (isFamily) 171 | { 172 | result = false; 173 | } 174 | else 175 | { 176 | bool flag = method.IsConstructor || method.IsStaticConstructor; 177 | if (flag) 178 | { 179 | result = false; 180 | } 181 | else 182 | { 183 | bool isRuntimeSpecialName = method.IsRuntimeSpecialName; 184 | if (isRuntimeSpecialName) 185 | { 186 | result = false; 187 | } 188 | else 189 | { 190 | bool isForwarder2 = method.DeclaringType.IsForwarder; 191 | if (isForwarder2) 192 | { 193 | result = false; 194 | } 195 | else 196 | { 197 | bool isGlobalModuleType = method.DeclaringType.IsGlobalModuleType; 198 | if (isGlobalModuleType) 199 | { 200 | result = false; 201 | } 202 | else 203 | { 204 | bool flag2 = method.Name.Contains("Sugar"); 205 | result = !flag2; 206 | } 207 | } 208 | } 209 | } 210 | } 211 | } 212 | } 213 | return result; 214 | } 215 | 216 | // Token: 0x06000028 RID: 40 RVA: 0x00004C0C File Offset: 0x00002E0C 217 | private static bool CanRename(FieldDef field) 218 | { 219 | bool flag = field.IsLiteral && field.DeclaringType.IsEnum; 220 | bool result; 221 | if (flag) 222 | { 223 | result = false; 224 | } 225 | else 226 | { 227 | bool isForwarder = field.DeclaringType.IsForwarder; 228 | if (isForwarder) 229 | { 230 | result = false; 231 | } 232 | else 233 | { 234 | bool isRuntimeSpecialName = field.IsRuntimeSpecialName; 235 | if (isRuntimeSpecialName) 236 | { 237 | result = false; 238 | } 239 | else 240 | { 241 | bool flag2 = field.IsLiteral && field.DeclaringType.IsEnum; 242 | if (flag2) 243 | { 244 | result = false; 245 | } 246 | else 247 | { 248 | bool flag3 = field.Name.Contains("Sugar"); 249 | result = !flag3; 250 | } 251 | } 252 | } 253 | } 254 | return result; 255 | } 256 | 257 | // Token: 0x06000029 RID: 41 RVA: 0x00004C98 File Offset: 0x00002E98 258 | private static bool CanRename(EventDef ev) 259 | { 260 | bool isForwarder = ev.DeclaringType.IsForwarder; 261 | bool result; 262 | if (isForwarder) 263 | { 264 | result = false; 265 | } 266 | else 267 | { 268 | bool isRuntimeSpecialName = ev.IsRuntimeSpecialName; 269 | result = !isRuntimeSpecialName; 270 | } 271 | return result; 272 | } 273 | 274 | // Token: 0x04000016 RID: 22 275 | private static Random rnd = new Random(); 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Runtime/AntiDebug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | namespace SugarGuard.Protector.Protections.Runtime 7 | { 8 | // Token: 0x0200000D RID: 13 9 | internal static class AntiDebug 10 | { 11 | // Token: 0x0600002D RID: 45 12 | [DllImport("kernel32.dll")] 13 | internal static extern int CloseHandle(IntPtr hModule); 14 | 15 | // Token: 0x0600002E RID: 46 16 | [DllImport("kernel32.dll")] 17 | internal static extern IntPtr OpenProcess(uint hModule, int procName, uint procId); 18 | 19 | // Token: 0x0600002F RID: 47 20 | [DllImport("kernel32.dll")] 21 | internal static extern uint GetCurrentProcessId(); 22 | 23 | // Token: 0x06000030 RID: 48 24 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 25 | internal static extern IntPtr LoadLibrary(string hModule); 26 | 27 | // Token: 0x06000031 RID: 49 28 | [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] 29 | internal static extern AntiDebug.GetProcA GetProcAddress(IntPtr hModule, string procName); 30 | 31 | // Token: 0x06000032 RID: 50 32 | [DllImport("kernel32.dll", CharSet = CharSet.Ansi, EntryPoint = "GetProcAddress")] 33 | internal static extern AntiDebug.GetProcA2 GetProcAddress_2(IntPtr hModule, string procName); 34 | 35 | // Token: 0x06000033 RID: 51 36 | [DllImport("kernel32.dll", CharSet = CharSet.Ansi, EntryPoint = "GetProcAddress")] 37 | internal static extern AntiDebug.GetProcA3 GetProcAddress_3(IntPtr hModule, string procName); 38 | 39 | // Token: 0x06000034 RID: 52 40 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 41 | internal static extern int GetClassName(IntPtr hModule, StringBuilder procName, int procId); 42 | 43 | // Token: 0x06000035 RID: 53 RVA: 0x00004D18 File Offset: 0x00002F18 44 | internal static string SplitMenuItem(IntPtr hModule) 45 | { 46 | StringBuilder stringBuilder = new StringBuilder(260); 47 | AntiDebug.GetClassName(hModule, stringBuilder, stringBuilder.Capacity); 48 | return stringBuilder.ToString(); 49 | } 50 | 51 | // Token: 0x06000036 RID: 54 RVA: 0x00004D4C File Offset: 0x00002F4C 52 | private static void Initialize() 53 | { 54 | bool flag = AntiDebug.Detected(); 55 | if (flag) 56 | { 57 | throw new Exception(string.Format("Debugger was found! - This software cannot be executed under the debugger.", Array.Empty())); 58 | } 59 | } 60 | 61 | // Token: 0x06000037 RID: 55 RVA: 0x00004D78 File Offset: 0x00002F78 62 | internal static bool Detected() 63 | { 64 | try 65 | { 66 | IntPtr hModule = AntiDebug.LoadLibrary("kernel32.dll"); 67 | bool isAttached = Debugger.IsAttached; 68 | if (isAttached) 69 | { 70 | return true; 71 | } 72 | AntiDebug.GetProcA procAddress = AntiDebug.GetProcAddress(hModule, "IsDebuggerPresent"); 73 | bool flag = procAddress != null && procAddress() != 0; 74 | if (flag) 75 | { 76 | return true; 77 | } 78 | IntPtr intPtr = AntiDebug.OpenProcess(1024U, 0, AntiDebug.GetCurrentProcessId()); 79 | bool flag2 = intPtr != IntPtr.Zero; 80 | if (flag2) 81 | { 82 | try 83 | { 84 | AntiDebug.GetProcA2 procAddress_ = AntiDebug.GetProcAddress_2(hModule, "CheckRemoteDebuggerPresent"); 85 | bool flag3 = procAddress_ != null; 86 | if (flag3) 87 | { 88 | int num = 0; 89 | bool flag4 = procAddress_(intPtr, ref num) != 0; 90 | if (flag4) 91 | { 92 | bool flag5 = num != 0; 93 | if (flag5) 94 | { 95 | return true; 96 | } 97 | } 98 | } 99 | } 100 | finally 101 | { 102 | AntiDebug.CloseHandle(intPtr); 103 | } 104 | } 105 | bool flag6 = false; 106 | try 107 | { 108 | AntiDebug.CloseHandle(new IntPtr(305419896)); 109 | } 110 | catch 111 | { 112 | flag6 = true; 113 | } 114 | bool flag7 = flag6; 115 | if (flag7) 116 | { 117 | return true; 118 | } 119 | } 120 | catch 121 | { 122 | } 123 | return false; 124 | } 125 | 126 | // Token: 0x0200003E RID: 62 127 | // (Invoke) Token: 0x0600013A RID: 314 128 | internal delegate int GetProcA(); 129 | 130 | // Token: 0x0200003F RID: 63 131 | // (Invoke) Token: 0x0600013E RID: 318 132 | internal delegate int GetProcA2(IntPtr hProcess, ref int pbDebuggerPresent); 133 | 134 | // Token: 0x02000040 RID: 64 135 | // (Invoke) Token: 0x06000142 RID: 322 136 | internal delegate int WL(IntPtr wnd, IntPtr lParam); 137 | 138 | // Token: 0x02000041 RID: 65 139 | // (Invoke) Token: 0x06000146 RID: 326 140 | internal delegate int GetProcA3(AntiDebug.WL lpEnumFunc, IntPtr lParam); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Runtime/AntiDump.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace SugarGuard.Protector.Protections.Runtime 6 | { 7 | // Token: 0x0200000E RID: 14 8 | internal static class AntiDump 9 | { 10 | // Token: 0x06000038 RID: 56 11 | [DllImport("kernel32.dll")] 12 | private unsafe static extern bool VirtualProtect(byte* lpAddress, int dwSize, uint flNewProtect, out uint lpflOldProtect); 13 | 14 | // Token: 0x06000039 RID: 57 RVA: 0x00004EA0 File Offset: 0x000030A0 15 | private unsafe static void AntiDumpInj() 16 | { 17 | Module module = typeof(AntiDump).Module; 18 | byte* ptr = (byte*)((void*)Marshal.GetHINSTANCE(module)); 19 | byte* ptr2 = ptr + 60; 20 | ptr2 = ptr + *(uint*)ptr2; 21 | ptr2 += 6; 22 | ushort num = *(ushort*)ptr2; 23 | ptr2 += 14; 24 | ushort num2 = *(ushort*)ptr2; 25 | ptr2 = ptr2 + 4 + num2; 26 | byte* ptr3 = stackalloc byte[(UIntPtr)11]; 27 | uint num3; 28 | AntiDump.VirtualProtect(ptr2 - 16, 8, 64U, out num3); 29 | *(int*)(ptr2 - 12) = 0; 30 | byte* ptr4 = ptr + *(uint*)(ptr2 - 16); 31 | *(int*)(ptr2 - 16) = 0; 32 | AntiDump.VirtualProtect(ptr4, 72, 64U, out num3); 33 | byte* ptr5 = ptr + *(uint*)(ptr4 + 8); 34 | *(int*)ptr4 = 0; 35 | *(int*)(ptr4 + 4) = 0; 36 | *(int*)(ptr4 + (IntPtr)2 * 4) = 0; 37 | *(int*)(ptr4 + (IntPtr)3 * 4) = 0; 38 | AntiDump.VirtualProtect(ptr5, 4, 64U, out num3); 39 | *(int*)ptr5 = 0; 40 | for (int i = 0; i < (int)num; i++) 41 | { 42 | AntiDump.VirtualProtect(ptr2, 8, 64U, out num3); 43 | Marshal.Copy(new byte[8], 0, (IntPtr)((void*)ptr2), 8); 44 | ptr2 += 40; 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Runtime/ConstantsRuntime.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Reflection; 4 | 5 | namespace SugarGuard.Protector.Protections.Runtime 6 | { 7 | // Token: 0x0200000F RID: 15 8 | public static class ConstantsRuntime 9 | { 10 | // Token: 0x0600003A RID: 58 RVA: 0x00004FA4 File Offset: 0x000031A4 11 | public static string Decrypt(string s, int key, RuntimeMethodHandle runtimeMethodHandle) 12 | { 13 | StackTrace stackTrace = new StackTrace(); 14 | MethodBase method = ((stackTrace != null) ? stackTrace.GetFrame(1) : null).GetMethod(); 15 | bool flag = method != null; 16 | if (flag) 17 | { 18 | bool flag2 = method.Name == "InvokeMethod"; 19 | if (!flag2) 20 | { 21 | byte[] array = new byte[4]; 22 | bool flag3 = method.MethodHandle == runtimeMethodHandle || method.Name == ".cctor"; 23 | if (flag3) 24 | { 25 | array = MethodBase.GetMethodFromHandle(runtimeMethodHandle).GetMethodBody().GetILAsByteArray(); 26 | } 27 | bool value = runtimeMethodHandle.Value == method.MethodHandle.Value || method.Name == ".cctor"; 28 | int num = array.Length - Convert.ToInt32(value) * 6; 29 | int metadataToken = (int)array[num++] | (int)array[num++] << 8 | (int)array[num++] << 16 | (int)array[num++] << 24; 30 | int num2 = Convert.ToInt32(method.Module.ResolveString(metadataToken)); 31 | key += num2; 32 | int[] array2 = ConstantsRuntime.tempField; 33 | for (int i = 0; i < array2.Length; i++) 34 | { 35 | key += array2[i]; 36 | } 37 | char[] array3 = new char[s.Length]; 38 | for (int j = 0; j < s.Length; j++) 39 | { 40 | array3[j] = (char)((int)s[j] ^ key); 41 | } 42 | return new string(array3); 43 | } 44 | } 45 | return method.Name; 46 | } 47 | 48 | // Token: 0x04000017 RID: 23 49 | public static int[] tempField; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/Runtime/MethodHider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace SugarGuard.Protector.Protections.Runtime 6 | { 7 | // Token: 0x02000010 RID: 16 8 | internal static class MethodHider 9 | { 10 | // Token: 0x0600003B RID: 59 RVA: 0x00005140 File Offset: 0x00003340 11 | public static void MethodHiderInj(object[] parameters, int token) 12 | { 13 | parameters.Reverse(); 14 | Assembly executingAssembly = Assembly.GetExecutingAssembly(); 15 | Assembly callingAssembly = Assembly.GetCallingAssembly(); 16 | bool flag = executingAssembly == callingAssembly; 17 | if (flag) 18 | { 19 | Module manifestModule = executingAssembly.ManifestModule; 20 | MethodInfo methodInfo = (MethodInfo)manifestModule.ResolveMethod(token); 21 | methodInfo.Invoke(null, parameters); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Protections/WaterMark.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SugarGuard.Protector.Class; 3 | 4 | namespace SugarGuard.Protector.Protections 5 | { 6 | // Token: 0x0200000C RID: 12 7 | public class WaterMark 8 | { 9 | // Token: 0x0600002B RID: 43 RVA: 0x00004CD8 File Offset: 0x00002ED8 10 | public WaterMark(SugarLib lib) 11 | { 12 | this.Main(lib); 13 | } 14 | 15 | // Token: 0x0600002C RID: 44 RVA: 0x00004CE9 File Offset: 0x00002EE9 16 | private void Main(SugarLib lib) 17 | { 18 | lib.assembly.Name = "[Ϩ] Sugar Guard"; 19 | lib.moduleDef.Name = "[ッ] Sugary"; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SugarGuard/Protector/Sugar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using SugarGuard.Protector.Class; 4 | using SugarGuard.Protector.Enums; 5 | using SugarGuard.Protector.Protections; 6 | using SugarGuard.Protector.Protections.Constants; 7 | using SugarGuard.Protector.Protections.ControlFlow; 8 | using SugarGuard.Protector.Protections.Mutation; 9 | using SugarGuard.Protector.Protections.ReferenceProxy; 10 | 11 | namespace SugarGuard.Protector 12 | { 13 | // Token: 0x02000004 RID: 4 14 | public class Sugar 15 | { 16 | // Token: 0x17000001 RID: 1 17 | // (get) Token: 0x06000010 RID: 16 RVA: 0x00003566 File Offset: 0x00001766 18 | // (set) Token: 0x06000011 RID: 17 RVA: 0x0000356E File Offset: 0x0000176E 19 | private SugarLib lib { get; set; } 20 | 21 | // Token: 0x06000012 RID: 18 RVA: 0x00003577 File Offset: 0x00001777 22 | public Sugar(string filePath) 23 | { 24 | this.lib = new SugarLib(filePath); 25 | } 26 | 27 | // Token: 0x06000013 RID: 19 RVA: 0x0000359C File Offset: 0x0000179C 28 | public void Protect() 29 | { 30 | foreach (Protections protections in this.protections) 31 | { 32 | bool flag = protections == Protections.CallConvertion; 33 | if (flag) 34 | { 35 | new CallConvertion(this.lib); 36 | } 37 | bool flag2 = protections == Protections.Constants; 38 | if (flag2) 39 | { 40 | new Constants(this.lib); 41 | } 42 | bool flag3 = protections == Protections.VM; 43 | if (flag3) 44 | { 45 | bool flag4 = protections == Protections.ReferenceProxy; 46 | if (flag4) 47 | { 48 | new ReferenceProxy(this.lib); 49 | } 50 | } 51 | bool flag5 = protections == Protections.ControlFlow; 52 | if (flag5) 53 | { 54 | new ControlFlow(this.lib); 55 | } 56 | bool flag6 = protections == Protections.InvalidOpcodes; 57 | if (flag6) 58 | { 59 | new InvalidOpcodes(this.lib); 60 | } 61 | bool flag7 = protections == Protections.AntiDump; 62 | if (flag7) 63 | { 64 | new AntiDump(this.lib); 65 | } 66 | bool flag8 = protections == Protections.AntiDebug; 67 | if (flag8) 68 | { 69 | new AntiDebug(this.lib); 70 | } 71 | bool flag9 = protections == Protections.Mutation; 72 | if (flag9) 73 | { 74 | new Mutation(this.lib); 75 | } 76 | } 77 | foreach (Protections protections2 in this.protections) 78 | { 79 | bool flag10 = protections2 == Protections.PosConstants; 80 | if (flag10) 81 | { 82 | new PosConstants(this.lib); 83 | } 84 | bool flag11 = protections2 == Protections.Renamer; 85 | if (flag11) 86 | { 87 | new Renamer(this.lib); 88 | } 89 | bool flag12 = protections2 == Protections.FakeAttributes; 90 | if (flag12) 91 | { 92 | new FakeAttributes(this.lib); 93 | } 94 | bool flag13 = protections2 == Protections.WaterMark; 95 | if (flag13) 96 | { 97 | new WaterMark(this.lib); 98 | } 99 | } 100 | } 101 | 102 | // Token: 0x06000014 RID: 20 RVA: 0x0000374C File Offset: 0x0000194C 103 | public void Save() 104 | { 105 | this.lib.buildASM(saveMode.x86); 106 | } 107 | 108 | // Token: 0x04000014 RID: 20 109 | public List protections = new List(); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /SugarGuard/SugarGuard.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {96A2C21F-9D77-494C-8783-A6A5E0CB401F} 7 | WinExe 8 | Properties 9 | SugarGuard 10 | SugarGuard 11 | v4.6.1 12 | 512 13 | app.manifest 14 | SugarGuard.ico 15 | SugarGuard.Program 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | true 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | true 37 | 38 | 39 | 40 | ..\..\Suggar Guard\dnlib.dll 41 | 42 | 43 | ..\..\Suggar Guard\MaterialSkin.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Form 56 | 57 | 58 | Main.cs 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /SugarGuard/SugarGuard.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/SugarGuard/SugarGuard.ico -------------------------------------------------------------------------------- /SugarGuard/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Suggar Guard/MaterialSkin.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/Suggar Guard/MaterialSkin.dll -------------------------------------------------------------------------------- /Suggar Guard/SugarGuard.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/Suggar Guard/SugarGuard.exe -------------------------------------------------------------------------------- /Suggar Guard/dnlib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/Suggar Guard/dnlib.dll -------------------------------------------------------------------------------- /Suggar Guard/dnlib.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leexey/Sugar-Guard/8c38ccda39256d69a826219067afb71994839144/Suggar Guard/dnlib.pdb --------------------------------------------------------------------------------