-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list_exports func added and initial RPC code. #147
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c54d201
list_exports func added. example showing how to use it. initial rpc c…
Xoffio 8a6a3a8
s1341's notes have been addressed.
Xoffio ecf1c17
intentional js error removed. pid gets pass by parameter.
Xoffio b61065b
trying to fix CI
Xoffio 80ae226
Merge branch 'main' into xo-rpc-1
Xoffio ee52266
fix no_std ci issues
Xoffio 909792e
changed list_exports return value and updated the example
Xoffio 01d51b0
deleted extra spaces
Xoffio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "list_exports" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Ricardo J Marques Montilla / Xoffio"] | ||
|
||
[dependencies] | ||
frida = { path = "../../../frida" } | ||
frida-sys = { path = "../../../frida-sys" } | ||
lazy_static = "1.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Example to showing how to use `script.list_exports()`. | ||
Once ran you should expect an output similar to the next one: | ||
|
||
``` | ||
[*] Frida version: 16.4.8 | ||
[*] Device name: Local System | ||
- 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" }) | ||
[*] Script loaded. | ||
["increment", "getvalue"] | ||
["increment", "getvalue"] | ||
["increment", "getvalue"] | ||
[*] Script unloaded | ||
[*] Session detached | ||
Exiting... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use frida::{Frida, Message}; | ||
use lazy_static::lazy_static; | ||
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_local_device(); | ||
|
||
if let Ok(device) = local_device { | ||
println!("[*] Frida version: {}", frida::Frida::version()); | ||
println!("[*] Device name: {}", device.get_name()); | ||
|
||
// Attach to the program | ||
let session = device.attach(0).unwrap(); | ||
|
||
if session.is_detached() { | ||
println!("Session is detached"); | ||
return; | ||
} | ||
|
||
let script_source = r#" | ||
var globalVar = 0; | ||
console.log("Logging message from JS"); | ||
console.warn("Warning message from JS"); | ||
console.debug("Debug message from JS"); | ||
console.error("Error message from JS"); | ||
|
||
rpc.exports = { | ||
increment: function() { | ||
globalVar += 1; | ||
return globalVar; | ||
}, | ||
getvalue: function() { | ||
return globalVar; | ||
} | ||
}; | ||
"#; | ||
let mut script_option = frida::ScriptOption::default(); | ||
let mut script = match session.create_script(script_source, &mut script_option) { | ||
Ok(s) => s, | ||
Err(err) => { | ||
println!("{}", err); | ||
return; | ||
} | ||
}; | ||
|
||
let msg_handler = script.handle_message(Handler); | ||
if let Err(err) = msg_handler { | ||
panic!("{:?}", err); | ||
} | ||
|
||
script.load().unwrap(); | ||
println!("[*] Script loaded."); | ||
|
||
println!("{:?}", script.list_exports().unwrap()); | ||
|
||
for _ in 0..2 { | ||
thread::sleep(Duration::from_secs(1)); | ||
println!("{:?}", script.list_exports().unwrap()); | ||
} | ||
|
||
script.unload().unwrap(); | ||
println!("[*] Script unloaded"); | ||
|
||
session.detach().unwrap(); | ||
println!("[*] Session detached"); | ||
} | ||
|
||
println!("Exiting..."); | ||
} | ||
|
||
struct Handler; | ||
|
||
impl frida::ScriptHandler for Handler { | ||
fn on_message(&mut self, message: &Message) { | ||
println!("- {:?}", message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the
'a
lifetime here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'b: 'a
ensures that the lifetime of the input is at least as long as'a
. I had to put that because 117003b broke theno_std
testThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't realize
'a
was on the Interceptor.