Skip to content

Commit

Permalink
intentional js error removed. pid gets pass by parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xoffio committed Sep 5, 2024
1 parent 8a6a3a8 commit ecf1c17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
3 changes: 1 addition & 2 deletions examples/core/list_exports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ Once ran you should expect an output similar to the next one:
```
[*] Frida version: 16.4.8
[*] Device name: Local System
[*] Attached to PID 1124009
[*] Attached to PID 7581
- Log(MessageLog { level: Info, payload: "Logging message from JS" })
- Log(MessageLog { level: Warning, payload: "Warning message from JS" })
- Log(MessageLog { level: Debug, payload: "Debug message from JS" })
- Log(MessageLog { level: Error, payload: "Error message from JS" })
- Error(MessageError { description: "ReferenceError: 'sdfsa' is not defined", stack: "ReferenceError: 'sdfsa' is not defined\n at <eval> (/script1.js:18)", file_name: "/script1.js", line_number: 18, column_number: 1 })
[*] Script loaded.
Some(["increment", "getvalue"])
Some(["increment", "getvalue"])
Expand Down
24 changes: 8 additions & 16 deletions examples/core/list_exports/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
use frida::{Frida, Message};
use lazy_static::lazy_static;
use std::io::{self, Write};
use std::{thread, time::Duration};

lazy_static! {
static ref FRIDA: Frida = unsafe { Frida::obtain() };
}

fn main() {
let device_manager = frida::DeviceManager::obtain(&FRIDA);
let local_device = device_manager.get_device_by_type(frida::DeviceType::Local);
let args: Vec<String> = std::env::args().collect();

print!("Enter pid: ",);
io::stdout().flush().expect("Failed to flush stdout");

let mut pid_input = String::new();
io::stdin()
.read_line(&mut pid_input)
.expect("Failed to read pid");
if args.len() < 2 {
println!("Usage: {} <PID>", args[0]);
return;
}

let pid = pid_input
.trim()
.parse()
.expect("Please enter a valid number");
let device_manager = frida::DeviceManager::obtain(&FRIDA);
let local_device = device_manager.get_device_by_type(frida::DeviceType::Local);
let pid: u32 = args[1].parse().unwrap();

if let Ok(device) = local_device {
println!("[*] Frida version: {}", frida::Frida::version());
Expand Down Expand Up @@ -60,8 +54,6 @@ fn main() {
return globalVar;
}
};
;sdfsa // <- Intentional error here
"#;
let mut script_option = frida::ScriptOption::default();
let mut script = match session.create_script(script_source, &mut script_option) {
Expand Down

0 comments on commit ecf1c17

Please sign in to comment.