-
-
Save vladimir-poleh/9397450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Reflection; | |
using ICVT.JPEGMini.Common; | |
namespace JpegMini.Crack.Runtime | |
{ | |
public static class OnStartup | |
{ | |
public static void Run() | |
{ | |
try | |
{ | |
ActivationManager a = ActivationManager.Current; | |
a.DailyLimitChanged += OnDailyLimitChanged; | |
OnDailyLimitChanged(0); | |
} | |
catch (Exception e) | |
{ | |
File.WriteAllText("injected_exception.txt", e.ToString()); | |
} | |
} | |
static void OnDailyLimitChanged(int v) | |
{ | |
try | |
{ | |
ActivationManager a = ActivationManager.Current; | |
if (a == null) | |
throw new Exception("a is null"); | |
MethodInfo m = a.GetType() | |
.GetProperty("RemindedDailyLimit") | |
.GetSetMethod(true); | |
if (m == null) | |
throw new Exception("m is null"); | |
m.Invoke(a, new object[] { 99 }); | |
} | |
catch (Exception e) | |
{ | |
File.WriteAllText("injected_exception2.txt", e.ToString()); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Reflection; | |
using Mono.Cecil; | |
using Mono.Cecil.Cil; | |
using Mono.Collections.Generic; | |
namespace JpegMini.Crack | |
{ | |
class Program | |
{ | |
static void Injected() | |
{ | |
Assembly.Load("JpegMini.Crack.Runtime") | |
.GetType("JpegMini.Crack.Runtime.OnStartup") | |
.GetMethod("Run") | |
.Invoke(null, null); | |
} | |
static void Main() | |
{ | |
AssemblyDefinition a = AssemblyDefinition.ReadAssembly("log4net.dll"); | |
MethodDefinition cctor = a.MainModule.GetType("log4net.LogManager").Methods.Single(m => m.Name == ".cctor"); | |
Collection<Instruction> insns = cctor.Body.Instructions; | |
int last = insns.Count - 1; | |
if (insns[last].OpCode != OpCodes.Ret) | |
throw new InvalidOperationException(); | |
insns.RemoveAt(last); | |
string injectedName = new Action(Injected).Method.Name; | |
Collection<Instruction> injected = | |
AssemblyDefinition.ReadAssembly("JpegMini.Crack.exe") | |
.MainModule.GetType(typeof(Program).FullName) | |
.Methods | |
.Single(m => m.Name == injectedName) | |
.Body.Instructions; | |
foreach (Instruction insn in injected) | |
{ | |
if (insn.OpCode == OpCodes.Call || insn.OpCode == OpCodes.Callvirt) | |
{ | |
MethodReference op = (MethodReference)insn.Operand; | |
insn.Operand = a.MainModule.Import(op); | |
} | |
insns.Add(insn); | |
} | |
a.Write("log4net.injected.dll"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment