csaki

Silkroad - basic multiclient

Mar 19th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.00 KB | None | 0 0
  1. // Written by DevSome - all credits to him!
  2. // http://forum.cp-g.de/user/50580-awesome/
  3. // http://www.elitepvpers.com/forum/members/1199443-devsome.html
  4. // Instructions: put the exe in your SRO directory!
  5.  
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Runtime.InteropServices;
  13. using System.Diagnostics;
  14. using System.IO;
  15. //using Microsoft.Win32;
  16. //using System.Xml.Serialization;
  17. namespace MulticlientProject
  18. {
  19.     class Program
  20.     {
  21.         [DllImport("kernel32.dll")]
  22.         static extern IntPtr LoadLibrary(string dllToLoad);
  23.         [DllImport("kernel32.dll")]
  24.         static extern IntPtr OpenProcess(uint dwDesiredAccess, int bInheritHandle, int dwProcessId);
  25.         [DllImport("kernel32.dll")]
  26.         static extern uint ReadProcessMemory(IntPtr hProcess, uint lpBaseAddress, uint lpbuffer, uint nSize, uint lpNumberOfBytesRead);
  27.         [DllImport("kernel32.dll")]
  28.         static extern uint WriteProcessMemory(IntPtr hProcess, uint lpBaseAddress, byte[] lpBuffer, int nSize, uint lpNumberOfBytesWritten);
  29.         [DllImport("kernel32.dll")]
  30.         static extern uint VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, uint flAllocationType, uint flProtect);
  31.         [DllImport("kernel32.dll")]
  32.         static extern IntPtr CreateMutex(IntPtr lpMutexAttributes, bool bInitialOwner, string lpName);
  33.         [DllImport("kernel32.dll")]
  34.         static extern IntPtr GetModuleHandle(string lpModuleName);
  35.         [DllImport("kernel32")]
  36.         static extern uint GetProcAddress(IntPtr hModule, string procName);
  37.         [DllImport("kernel32.dll")]
  38.         static extern uint WritePrivateProfileString(string section, string key, string val, string filePath);
  39.         [DllImport("kernel32.dll")]
  40.         static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
  41.        
  42.        
  43.        
  44.         #region Addresses
  45.         uint ByteArray = 0;
  46.         uint SeedPatchAdress = 0;
  47.         uint AlreadyProgramExe = 0;
  48.         uint MultiClientAddress = 0;
  49.         uint CallForwardAddress = 0;
  50.         uint MultiClientError = 0;
  51.         uint StartingMSG = 0;
  52.         uint ChangeVersion = 0;
  53.         #endregion
  54.  
  55.         #region BytePattern
  56.  
  57.         //byte[] RedirectIPAddressPattern = { 0x89, 0x86, 0x2C, 0x01, 0x00, 0x00, 0x8B, 0x17, 0x89, 0x56, 0x50, 0x8B, 0x47, 0x04, 0x89, 0x46, 0x54, 0x8B, 0x4F, 0x08, 0x89, 0x4E, 0x58, 0x8B, 0x57, 0x0C, 0x89, 0x56, 0x5C, 0x5E, 0xB8, 0x01, 0x00, 0x00, 0x00, 0x5D, 0xC3 };
  58.         byte[] SeedPatchPattern = { 0x8B, 0x4C, 0x24, 0x04, 0x81, 0xE1, 0xFF, 0xFF, 0xFF, 0x7F };
  59.         byte[] SeedPatch = { 0xB9, 0x33, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90 };
  60.         //byte[] NudePatchPattern = { 0x8B, 0x84, 0xEE, 0x1C, 0x01, 0x00, 0x00, 0x3B, 0x44, 0x24, 0x14 };
  61.         //byte[] ZoomhackPattern = { 0xDF, 0xE0, 0xF6, 0xC4, 0x41, 0x7A, 0x08, 0xD9, 0x9E };
  62.         byte[] MulticlientPattern = { 0x6A, 0x06, 0x8D, 0x44, 0x24, 0x48, 0x50, 0x8B, 0xCF };
  63.         byte[] CallForwardPattern = { 0x56, 0x8B, 0xF1, 0x0F, 0xB7, 0x86, 0x3E, 0x10, 0x00, 0x00, 0x57, 0x66, 0x8B, 0x7C, 0x24, 0x10, 0x0F, 0xB7, 0xCF, 0x8D, 0x14, 0x01, 0x3B, 0x96, 0x4C, 0x10, 0x00, 0x00 };
  64.         byte[] MultiClientErrorStringPattern = Encoding.Default.GetBytes("½ÇÅ©·Îµå°¡ ÀÌ¹Ì ½ÇÇà Áß ÀÔ´Ï´Ù.");
  65.         byte[] ChangeVersionStringPattern = Encoding.Unicode.GetBytes("Ver %d.%03d");
  66.         byte[] StartingMSGStringPattern = Encoding.Unicode.GetBytes("UIIT_STT_STARTING_MSG");
  67.         byte[] AlreadyProgramExeStringPattern = Encoding.ASCII.GetBytes("//////////////////////////////////////////////////////////////////");
  68.  
  69.         #endregion
  70.  
  71.         static void Main()
  72.         {
  73.             Console.WriteLine("Programm got stared.");
  74.             Program pr = new Program();
  75.             string StartingMessageText = "Visit devsome.com\r\nOpensource on elitepverps.com published by Devsome(dot)com";
  76.             byte[] HexColorArray = { 0xff, 0xa5, 0x00, 0x00 };
  77.             // pink             0xee, 0x82, 0xee, 0x00
  78.             // hell blau        0xff, 0xa5, 0x00, 0x00
  79.             uint BaseAddress = 0x400000;
  80.            
  81.             byte PUSH = 0x68;
  82.             byte[] JMP = { 0xEB };
  83.             uint ByteArray = 0;
  84.  
  85.             string currentDir = Environment.CurrentDirectory;
  86.             Console.WriteLine("Your current Directory: " + currentDir);
  87.  
  88.             byte[] FileArray = File.ReadAllBytes(currentDir + @"\sro_client.exe");
  89.             //AlreadyProgramExeSearch
  90.             pr.AlreadyProgramExe = pr.FindStringPattern(pr.AlreadyProgramExeStringPattern, FileArray, BaseAddress, PUSH, 1) - 2;
  91.             //SeedPatchSearch
  92.             pr.SeedPatchAdress = BaseAddress + pr.FindPattern(pr.SeedPatchPattern, FileArray, 1);
  93.             //ReplaceText
  94.             pr.StartingMSG = pr.FindStringPattern(pr.StartingMSGStringPattern, FileArray, BaseAddress, PUSH, 1) + 24;
  95.             pr.ChangeVersion = pr.FindStringPattern(pr.ChangeVersionStringPattern, FileArray, BaseAddress, PUSH, 1);
  96.  
  97.             //MulticlientSearch
  98.             pr.MultiClientAddress = BaseAddress + pr.FindPattern(pr.MulticlientPattern, FileArray, 1) + 9;
  99.             //CallForwardSearch
  100.             pr.CallForwardAddress = BaseAddress + pr.FindPattern(pr.CallForwardPattern, FileArray, 1);
  101.             //MultiClientErrorSearch
  102.             pr.MultiClientError = pr.FindStringPattern(pr.MultiClientErrorStringPattern, FileArray, BaseAddress, PUSH, 1) - 8;
  103.  
  104.  
  105.             CreateMutex(IntPtr.Zero, false, "Silkroad Online Launcher");
  106.             CreateMutex(IntPtr.Zero, false, "Ready");
  107.             Console.WriteLine("Silkroad Launcher started in background.");
  108.             Process SilkProcess;
  109.             SilkProcess = new Process();
  110.             SilkProcess.StartInfo.FileName = currentDir + @"\sro_client.exe";
  111.             SilkProcess.StartInfo.Arguments = "0 /22 0 0";
  112.             SilkProcess.Start();
  113.             Console.WriteLine("Process started with 0 /22 0 0");
  114.             IntPtr SroProcessHandle = OpenProcess((uint)(0x000F0000L | 0x00100000L | 0xFFF), 0, SilkProcess.Id);
  115.  
  116.             //Already Program Exe
  117.             WriteProcessMemory(SroProcessHandle, pr.AlreadyProgramExe, JMP, JMP.Length, ByteArray);
  118.             Console.WriteLine("Already opend (write in Memory)");
  119.             //Multiclient Error MessageBox
  120.             WriteProcessMemory(SroProcessHandle, pr.MultiClientError, JMP, JMP.Length, ByteArray);
  121.             WriteProcessMemory(SroProcessHandle, pr.SeedPatchAdress, pr.SeedPatch, pr.SeedPatch.Length, ByteArray);
  122.             Console.WriteLine("Multiclient Error MessageBox (write in Memory)");
  123.             pr.MultiClient(SroProcessHandle);
  124.             pr.StartingTextMSG(SroProcessHandle, StartingMessageText, HexColorArray);
  125.             Console.WriteLine("Writing the Version & Startmessage");
  126.         }
  127.  
  128.         private void MultiClient(IntPtr SroProcessHandle)
  129.         {
  130.             uint MultiClientCodeCave = VirtualAllocEx(SroProcessHandle, IntPtr.Zero, 45, 0x1000, 0x4);
  131.             uint MACCodeCave = VirtualAllocEx(SroProcessHandle, IntPtr.Zero, 4, 0x1000, 0x4);
  132.             uint GTC = GetProcAddress(GetModuleHandle("kernel32.dll"), "GetTickCount");
  133.  
  134.             byte[] CallBack = BitConverter.GetBytes(MultiClientCodeCave + 41);
  135.             byte[] CALLForward = BitConverter.GetBytes(CallForwardAddress - MultiClientCodeCave - 34);
  136.             byte[] MACAddress = BitConverter.GetBytes(MACCodeCave);
  137.             byte[] GTCAddress = BitConverter.GetBytes(GTC - MultiClientCodeCave - 18);
  138.  
  139.             byte[] MultiClientArray = BitConverter.GetBytes(MultiClientCodeCave - MultiClientAddress - 5);
  140.             byte[] MultiClientCodeArray = { 0xE8, MultiClientArray[0], MultiClientArray[1], MultiClientArray[2], MultiClientArray[3] };
  141.  
  142.             byte[] MultiClientCode = {   0x8F, 0x05, CallBack[0], CallBack[1], CallBack[2], CallBack[3], //POP DWORD PTR DS:[xxxxxxxx]
  143.                                          0xA3, MACAddress[0], MACAddress[1], MACAddress[2], MACAddress[3], //MOV DWORD PTR DS:[xxxxxxxx],EAX
  144.                                          0x60, //PUSHAD
  145.                                          0x9C, //PUSHFD
  146.                                          0xE8, GTCAddress[0], GTCAddress[1], GTCAddress[2], GTCAddress[3], // Call KERNEL32.gettickcount
  147.                                          0x8B, 0x0D, MACAddress[0], MACAddress[1], MACAddress[2], MACAddress[3], //MOV ECX,DWORD PTR DS:[xxxxxxxx]
  148.                                          0x89, 0x41, 0x02, // MOV DWORD PTR DS:[ECX+2],EAX
  149.                                          0x9D, //POPFD
  150.                                          0x61, //POPAD
  151.                                          0xE8, CALLForward[0], CALLForward[1], CALLForward[2], CALLForward[3], //CALL xxxxxxxx
  152.                                          0xFF, 0x35, CallBack[0], CallBack[1], CallBack[2], CallBack[3], // PUSH DWORD PTR DS:[xxxxxxxx]
  153.                                          0xC3 //RETN
  154.                                        };
  155.  
  156.             WriteProcessMemory(SroProcessHandle, MultiClientCodeCave, MultiClientCode, MultiClientCode.Length, ByteArray);
  157.             WriteProcessMemory(SroProcessHandle, MultiClientAddress, MultiClientCodeArray, MultiClientCodeArray.Length, ByteArray);
  158.         }
  159.  
  160.         private void StartingTextMSG(IntPtr SroProcessHandle, string StartingText, byte[] HexColor)
  161.         {
  162.             string ChangeVersionString = "Dev";
  163.             uint StartingMSGStringCodeCave = VirtualAllocEx(SroProcessHandle, IntPtr.Zero, StartingText.Length, 0x1000, 0x4);
  164.             uint ChangeVersionStringCodeCave = VirtualAllocEx(SroProcessHandle, IntPtr.Zero, StartingText.Length, 0x1000, 0x4);
  165.             byte[] StartingMSGByteArray = Encoding.Unicode.GetBytes(StartingText);
  166.             byte[] ChangeVersionByteArray = Encoding.Unicode.GetBytes(ChangeVersionString);
  167.             byte[] CallStartingMSG = BitConverter.GetBytes(StartingMSGStringCodeCave);
  168.             byte[] CallChangeVersion = BitConverter.GetBytes(ChangeVersionStringCodeCave);
  169.             byte[] StartingMSGCodeArray = { 0xB8, CallStartingMSG[0], CallStartingMSG[1], CallStartingMSG[2], CallStartingMSG[3] };
  170.             byte[] ChangeVersionCodeArray = { 0x68, CallChangeVersion[0], CallChangeVersion[1], CallChangeVersion[2], CallChangeVersion[3] };
  171.             WriteProcessMemory(SroProcessHandle, ChangeVersionStringCodeCave, ChangeVersionByteArray, ChangeVersionByteArray.Length, ByteArray);
  172.             WriteProcessMemory(SroProcessHandle, ChangeVersion, ChangeVersionCodeArray, ChangeVersionCodeArray.Length, ByteArray);
  173.             WriteProcessMemory(SroProcessHandle, ChangeVersion - 59, HexColor, HexColor.Length, ByteArray);
  174.             WriteProcessMemory(SroProcessHandle, StartingMSGStringCodeCave, StartingMSGByteArray, StartingMSGByteArray.Length, ByteArray);
  175.             WriteProcessMemory(SroProcessHandle, StartingMSG, StartingMSGCodeArray, StartingMSGCodeArray.Length, ByteArray);
  176.             WriteProcessMemory(SroProcessHandle, StartingMSG + 9, HexColor, HexColor.Length, ByteArray);
  177.             System.Environment.Exit(0);
  178.         }
  179.         private uint FindPattern(byte[] Pattern, byte[] FileByteArray, uint Result)
  180.         {
  181.             uint MyPosition = 0;
  182.             uint ResultCounter = 0;
  183.             for (uint PositionFileByteArray = 0; PositionFileByteArray < FileByteArray.Length - Pattern.Length; PositionFileByteArray++)
  184.             {
  185.                 bool found = true;
  186.                 for (uint PositionPattern = 0; PositionPattern < Pattern.Length; PositionPattern++)
  187.                 {
  188.                     if (FileByteArray[PositionFileByteArray + PositionPattern] != Pattern[PositionPattern])
  189.                     {
  190.                         found = false;
  191.                         break;
  192.                     }
  193.                 }
  194.                 if (found)
  195.                 {
  196.                     ResultCounter += 1;
  197.                     if (Result == ResultCounter)
  198.                     {
  199.                         MyPosition = PositionFileByteArray;
  200.                         break;
  201.                     }
  202.                 }
  203.             }
  204.             return MyPosition;
  205.         }
  206.         private uint FindStringPattern(byte[] StringByteArray, byte[] FileArray, uint BaseAddress, byte StringWorker, uint Result)
  207.         {
  208.             uint MyPosition = 0;
  209.             byte[] StringWorkerAddress = { StringWorker, 0x00, 0x00, 0x00, 0x00 };
  210.             byte[] StringAddress = new byte[4];
  211.             StringAddress = BitConverter.GetBytes(BaseAddress + FindPattern(StringByteArray, FileArray, 1));
  212.             StringWorkerAddress[1] = StringAddress[0];
  213.             StringWorkerAddress[2] = StringAddress[1];
  214.             StringWorkerAddress[3] = StringAddress[2];
  215.             StringWorkerAddress[4] = StringAddress[3];
  216.  
  217.             MyPosition = BaseAddress + FindPattern(StringWorkerAddress, FileArray, Result);
  218.             return MyPosition;
  219.         }
  220.     }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment