Changing a register value
This commit is contained in:
parent
fa83367ebf
commit
cd8ae69d7f
17
src/main.rs
17
src/main.rs
|
|
@ -1,10 +1,10 @@
|
|||
mod child;
|
||||
|
||||
use nix::libc::user_regs_struct;
|
||||
use nix::sys::ptrace::*;
|
||||
use nix::sys::wait::waitpid;
|
||||
use nix::unistd::{ForkResult, fork};
|
||||
use nix::unistd::{fork, ForkResult};
|
||||
use std::ffi::CString;
|
||||
use std::io;
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
|
|
@ -38,8 +38,17 @@ fn main() -> ExitCode {
|
|||
},
|
||||
Stopped(_pid, _signal) => {
|
||||
let regs = getregs(child_pid).unwrap();
|
||||
println!("🔎 [{}] rip= 0x{:016X}, rax = 0x{rax:X} ({rax})", before_instruction, regs.rip, rax = regs.rax);
|
||||
io::stdin().read_line(&mut String::new()).unwrap();
|
||||
println!(
|
||||
"🔎 [{}] rip= 0x{:016X}, rax = 0x{rax:X} ({rax})",
|
||||
before_instruction,
|
||||
regs.rip,
|
||||
rax = regs.rax
|
||||
);
|
||||
if regs.rax == 60 {
|
||||
println!("Let's change a register!");
|
||||
let new_regs = user_regs_struct { rdi: 54, ..regs };
|
||||
setregs(child_pid, new_regs).unwrap();
|
||||
}
|
||||
before_instruction += 1;
|
||||
step(child_pid, None).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue