Advertisement
Guest User

Untitled

a guest
Aug 21st, 2016
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using ELFSharp.ELF;
  7. using ELFSharp.ELF.Sections;
  8. using System.IO;
  9.  
  10. class Program
  11. {
  12.     static void Main(string[] args)
  13.     {
  14.         string path = @"gdeliveryd";
  15.         var elf = ELFReader.Load(path);
  16.         var function = ((ISymbolTable)elf.GetSection(".symtab")).Entries
  17.             .FirstOrDefault(ent =>
  18.                 ent.Type == SymbolType.Function &&
  19.                 ent.Name == "_ZN4GNET11GetSavedMsg7ProcessEPNS_8Protocol7ManagerEj"
  20.             );
  21.         if (function == null)
  22.             throw new Exception("Function does not exists.");
  23.         int address = int.Parse(function.ToString().Split(new [] { ": 0x" }, StringSplitOptions.None)[1].Split(',')[0], System.Globalization.NumberStyles.HexNumber) - 0x8048000;
  24.         elf.Dispose();
  25.         using (var writer = File.OpenWrite(path))
  26.         {
  27.             writer.Seek(address, SeekOrigin.Begin);
  28.             writer.WriteByte(0xC3);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement