private void Hook(string targetProcess, string scriptLocation) { try { Devices = new List <Frida.Device>(); Processes = new List <Frida.Process>(); deviceManager = new Frida.DeviceManager(Dispatcher.CurrentDispatcher); var devices = deviceManager.EnumerateDevices(); //we want the local device var device = devices.Where(x => x.Name == "Local System").FirstOrDefault(); if (device == null) { Console.WriteLine("[*] Failed to select device!"); return; } var processes = device.EnumerateProcesses(); foreach (var process in processes) { Processes.Add(process); } Console.WriteLine(String.Format("[*] Got {0} processes...", Processes.Count)); //find the process var target = Processes.Where(x => x.Name == targetProcess).FirstOrDefault(); if (target == null) { foreach (Frida.Process p in Processes) { Console.WriteLine(p.Name); } Console.WriteLine("[*] Failed to identify target process!"); return; } Console.WriteLine(String.Format("[*] Process {0} found...", targetProcess)); session = device.Attach(target.Pid); Console.WriteLine(String.Format("[*] Hooked process with PID {0}", target.Pid.ToString())); //Inject the script... Console.WriteLine("[*] Injecting script..."); try { Console.WriteLine(String.Format("[*] Loading script from {0}...", scriptLocation)); string scriptText = File.ReadAllText(scriptLocation); script = session.CreateScript(scriptText); Console.WriteLine("[*] Script loaded..."); script.Message += new Frida.ScriptMessageHandler(script_Message); script.Load(); } catch (Exception ex) { Console.WriteLine("[*] Error loading script!"); Console.WriteLine(ex.ToString()); return; } } catch (Exception ex) { Console.WriteLine("[*] Fail!"); } }
private void loadButton_Click(object sender, RoutedEventArgs e) { session = localdevice.Attach(ggproc.Pid); script = session.CreateScript(scriptsource); script.Message += Script_Message; script.Load(); loadButton.IsEnabled = false; }
private void loadScriptButton_Click(object sender, RoutedEventArgs e) { try { script.Load(); scriptLoaded = true; RefreshAllowedActions(); } catch (Exception ex) { debugConsole.Items.Add("Load failed: " + ex.Message); } }
private void loadScriptButton_Click(object sender, RoutedEventArgs e) { try { script.Load(); scriptLoaded = true; RefreshAllowedActions(); } catch (Exception ex) { Module.Output.AppendLine("Load failed: " + ex.Message); } }