Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Net;
- using System.Runtime.InteropServices;
- namespace SynapseX_API
- {
- class Program
- {
- [DllImport("kernel32.dll")]
- static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
- [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- static extern IntPtr GetModuleHandle(string lpModuleName);
- [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
- static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
- [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
- static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, int dwFreeType);
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out IntPtr lpNumberOfBytesWritten);
- [DllImport("kernel32.dll")]
- static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
- static void Main(string[] args)
- {
- Process[] robloxProcesses = Process.GetProcessesByName("RobloxPlayerBeta");
- if (robloxProcesses.Length == 0)
- {
- Console.WriteLine("RobloxPlayerBeta is not running!");
- return;
- }
- Process robloxProcess = robloxProcesses[0];
- IntPtr robloxHandle = OpenProcess(0x1F0FFF, false, robloxProcess.Id);
- if (robloxHandle == IntPtr.Zero)
- {
- Console.WriteLine("Failed to open Roblox process!");
- return;
- }
- string scriptPath = "C:\\scripts\\myscript.lua";
- string scriptContent = File.ReadAllText(scriptPath);
- IntPtr allocAddress = VirtualAllocEx(robloxHandle, IntPtr.Zero, (uint)(scriptContent.Length + 1), 0x1000, 0x40);
- if (allocAddress == IntPtr.Zero)
- {
- Console.WriteLine("Failed to allocate memory in Roblox process!");
- return;
- }
- byte[] scriptBytes = System.Text.Encoding.UTF8.GetBytes(scriptContent);
- IntPtr bytesWritten;
- if (!WriteProcessMemory(robloxHandle, allocAddress, scriptBytes, (uint)scriptBytes.Length, out bytesWritten))
- {
- Console.WriteLine("Failed to write script to allocated memory!");
- VirtualFreeEx(robloxHandle, allocAddress, scriptContent.Length + 1, 0x8000);
- return;
- }
- IntPtr loadScriptAddr = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
- if (loadScriptAddr == IntPtr.Zero)
- {
- Console.WriteLine("Failed to get LoadLibraryA address!");
- VirtualFreeEx(robloxHandle, allocAddress, scriptContent.Length + 1, 0x8000);
- return;
- }
- IntPtr threadHandle = CreateRemoteThread(robloxHandle, IntPtr.Zero, 0, loadScriptAddr, allocAddress, 0, IntPtr.Zero);
- if (threadHandle == IntPtr.Zero)
- {
- Console.WriteLine("Failed to create remote thread!");
- VirtualFreeEx(robloxHandle, allocAddress, scriptContent.Length + 1, 0x8000);
- return;
- }
- Console.WriteLine("Successfully executed script!");
- VirtualFreeEx(robloxHandle, allocAddress, scriptContent.Length + 1, 0x8000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement