yo guys need some help. Nios build a patcher/keygen for ectune software. whats great but not for the right version.
i got the right files now only the patcher is not patching the new file. i'm not great in visual studio but i found this:
// Try to patch new Thread(() => { if (!this.Busy) { this.Busy = true; this.SetStatus("Patching file..."); Patcher patcher = new Patcher(filepath); var results = patcher.Patch(); if (results.SignatureCheck && results.KeyCheck) { patcher.Write(destination); this.SetStatus(String.Format("File patched: {0}", destination)); } else this.SetStatus("File not patched"); this.Busy = false; }
thats mean the new file is not checks out the (results.SignatureCheck && results.KeyCheck)
can someone help whit this problem?
using System; using System.Drawing; using System.IO; using System.Threading; using System.Windows.Forms; namespace eCtuneKeygen { public partial class KeygenForm : Form { public Boolean Busy { get; private set; } public License License { get; private set; } public static readonly String DestinationPath = "license.xml"; public KeygenForm() { InitializeComponent(); this.Busy = false; } private void KeygenForm_Load(object sender, EventArgs e) { this.License = new License(); this.NameTextBox.Text = this.License.Name; this.OrgTextBox.Text = this.License.Org; this.EmailTextBox.Text = this.License.Email; } private void AboutButton_Click(object sender, EventArgs e) { AboutForm about = new AboutForm(); about.ShowDialog(this); } private void GenerateButton_Click(object sender, EventArgs e) { this.License.Name = this.NameTextBox.Text; this.License.Org = this.OrgTextBox.Text; this.License.Email = this.EmailTextBox.Text; this.License.Type = this.SelectedLicenseType; new Thread(() => { if (!this.Busy) { this.Busy = true; this.SetStatus("Generating license file..."); String license = this.License.ToString(); File.WriteAllText(DestinationPath, license); this.Invoke((MethodInvoker)delegate { this.SetStatus("Wrote license to " + DestinationPath); }); this.Busy = false; } }).Start(); } private void LinePanel_Paint(object sender, PaintEventArgs e) { Panel panel = (Panel)sender; Int32 thickness = 1, halfThickness = thickness / 2; Int32 w = panel.ClientSize.Width, h = panel.ClientSize.Height; using (Pen p = new Pen(Color.White, thickness)) { e.Graphics.FillRectangle(p.Brush, new Rectangle( 0, (h/2) - halfThickness, w, thickness )); } } private void OstrichButton_Click(object sender, EventArgs e) { OstrichForm form = new OstrichForm(this.License); form.ShowDialog(this); } private void PatchButton_Click(object sender, EventArgs e) { String filepath = "eCtune.EXE", destination = "eCtune-patched.EXE"; if (!File.Exists(filepath)) {eCtuneKeygen.KeygenForm.PatchButton_Click(object, System.EventArgs) filepath = Patcher.GetDefaultInstalledExePath; if (!File.Exists(filepath)) { MessageBox.Show( "eCtune.EXE not found, copy it to the same directory as the patcher and try again", "Patch Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Try to patch new Thread(() => { if (!this.Busy) { this.Busy = true; this.SetStatus("Patching file..."); Patcher patcher = new Patcher(filepath); var results = patcher.Patch(); if (results.SignatureCheck && results.KeyCheck) { patcher.Write(destination); this.SetStatus(String.Format("File patched: {0}", destination)); } else this.SetStatus("File not patched"); this.Busy = false; } }).Start(); } public LicenseType SelectedLicenseType { get { if (this.DataloggerRadioButton.Checked) return LicenseType.DataLogger; if (this.DemonRadioButton.Checked) return LicenseType.ProDemon; if (this.OstrichRadioButton.Checked) return LicenseType.ProOstrich; if (this.TunerRadioButton.Checked) return LicenseType.Tuner; if (this.DeveloperRadioButton.Checked) return LicenseType.Developer; return LicenseType.Free; } } public void SetStatus(String text) { this.Invoke((MethodInvoker)delegate { this.StatusBar.Text = text; }); } } }
using System; using System.IO; using System.Collections.Generic; using dnlib.DotNet; using dnlib.DotNet.Emit; using dnlib.DotNet.Writer; namespace eCtuneKeygen { public class Patcher { public ModuleDefMD Module { get; private set; } /// <summary> /// Construct a patcher for a file. /// </summary> /// <param name="filepath">Filepath</param> public Patcher(String filepath) { this.Module = ModuleDefMD.Load(filepath); } /// <summary> /// Attempt to patch the loaded module. /// </summary> /// <returns>Results of patching</returns> public PatchResults Patch() { if (this.Module == null) return null; Boolean sigCheckPatched = false, keyCheckPatched = false; var types = this.Module.GetTypes(); foreach(var type in types) { if (this.PatchLicenseSignatureCheck(type)) { sigCheckPatched = true; // Only check for key check methods if in the same class as signature check methods if(this.PatchLicenseKeyChecks(type)) { keyCheckPatched = true; } } } return new PatchResults(sigCheckPatched, keyCheckPatched); } /// <summary> /// Write the modified module to a file. /// </summary> /// <param name="filepath">Filepath</param> public void Write(String filepath) { var options = new ModuleWriterOptions(this.Module); options.MetaDataOptions.Flags |= MetaDataFlags.PreserveAll; options.MetaDataOptions.Flags |= MetaDataFlags.KeepOldMaxStack; options.Logger = DummyLogger.NoThrowInstance; // Avoid "ResolutionScope is null" exception this.Module.Write(filepath, options); } /// <summary> /// Check for and patch the license signature check to always return true. /// </summary> /// <param name="type">Type (Class) to inspect and patch if detected</param> /// <returns>true if patched, false if not modified</returns> private Boolean PatchLicenseSignatureCheck(TypeDef type) { if (type == null) return false; MethodDef sigCheckMethod = null, rsaProviderMethod = null; IList<MethodDef> methods = type.Methods; foreach(var method in methods) { if (method == null) continue; // Check for signature verification method // Looks like: <private bool method(RSA)> if (!method.IsStatic && method.ReturnType.FullName.Equals("System.Boolean") && method.Parameters.Count == 2 && method.Parameters[1].Type.FullName.Equals("System.Security.Cryptography.RSA")) { sigCheckMethod = method; } // Check for static RSA service provider method // Looks like: <private static RSACryptoServiceProvider method()> if(method.IsPrivate && method.IsStatic && method.ReturnType.FullName.Equals("System.Security.Cryptography.RSACryptoServiceProvider") && method.Parameters.Count == 0) { rsaProviderMethod = method; } if (sigCheckMethod != null && rsaProviderMethod != null) { // If found, replace signature verification body with `return true;` sigCheckMethod.Body = CreateReturnTrueBody(sigCheckMethod.Body); return true; } } return false; } /// <summary> /// Patch LicKey checks. /// </summary> /// <param name="type">Type (Class)</param> /// <returns>true if patched, false if not</returns> private Boolean PatchLicenseKeyChecks(TypeDef type) { Int32 patchCount = 0; IList<MethodDef> methods = type.Methods; foreach (var method in methods) { if (method == null) continue; // Check for key check method // Looks like: <bool method()> if (!method.IsStatic && method.ReturnType.FullName.Equals("System.Boolean") && method.Parameters.Count == 1 && method.Body.Instructions.Count > 10) // Using instruction count is a bit hacky { method.Body = CreateReturnTrueBody(method.Body); patchCount++; } } return patchCount == 2; } /// <summary> /// Create a method body equivalent to `return true;`. /// </summary> /// <param name="body">Optional existing method body</param> /// <returns>Method body</returns> public static CilBody CreateReturnTrueBody(CilBody body = null) { if (body == null) body = new CilBody(); else { body.KeepOldMaxStack = true; body.Instructions.Clear(); } body.Instructions.Add(OpCodes.Ldc_I4_1.ToInstruction()); // ldc.i4.1 body.Instructions.Add(OpCodes.Ret.ToInstruction()); // ret return body; } /// <summary> /// Get the path to X86 Program Files directory. /// </summary> public static string ProgramFilesX86 { get { if (8 == IntPtr.Size || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432")))) { return Environment.GetEnvironmentVariable("ProgramFiles(x86)"); } return Environment.GetEnvironmentVariable("ProgramFiles"); } } /// <summary> /// Get the default location of eCtune.EXE if it is installed. /// </summary> public static String GetDefaultInstalledExePath { get { return Path.Combine(Path.Combine(ProgramFilesX86, "eCtune"), "eCtune.EXE"); } } } /// <summary> /// Patch results. /// </summary> public class PatchResults { public Boolean SignatureCheck { get; private set; } public Boolean KeyCheck { get; private set; } public PatchResults(Boolean sigCheck, Boolean keyCheck) { this.SignatureCheck = sigCheck; this.KeyCheck = keyCheck; } } }