Skip to content

Commit

Permalink
Update all panda-rs plugins to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
jamcleod committed Sep 17, 2024
1 parent 3787038 commit 569658d
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 178 deletions.
76 changes: 9 additions & 67 deletions panda/plugins/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions panda/plugins/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"gdb",
"rust_skeleton",
Expand Down
2 changes: 1 addition & 1 deletion panda/plugins/cosi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["cdylib"]

[dependencies]
once_cell = "1.8.0"
panda-re = { version = "0.46.0", default-features = false }
panda-re = { version = "0.47.0", default-features = false }
regex = "1.5.4"
curl = "0.4.44"
volatility_profile = { path = "./volatility_profile" }
Expand Down
2 changes: 1 addition & 1 deletion panda/plugins/cosi_strace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
panda-re = { version = "0.45.0", default-features = false }
panda-re = { version = "0.47.0", default-features = false }
chumsky = "0.8"
log = "0.4"
once_cell = "1"
Expand Down
2 changes: 1 addition & 1 deletion panda/plugins/gdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
panda-re = { version = "0.14.0", default-features = false }
panda-re = { version = "0.47.0", default-features = false }
gdbstub = "0.5"
lazy_static = "1.4.0"
gdbstub_arch = "0.1.0"
Expand Down
8 changes: 4 additions & 4 deletions panda/plugins/gdb/src/memory_map.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use panda::prelude::*;
use panda::plugins::osi::OSI;
use panda::prelude::*;

use std::ffi::CStr;
use gdbstub::outputln;
use std::ffi::CStr;

pub(crate) fn print(cpu: &mut CPUState) {
let mut proc = OSI.get_current_process(cpu);
let mut proc = OSI.get_current_process(cpu).unwrap();
let mappings = OSI.get_mappings(cpu, &mut *proc);

println!("Memory map:");
Expand Down Expand Up @@ -33,7 +33,7 @@ pub(crate) fn print(cpu: &mut CPUState) {
}

pub(crate) fn print_to_gdb(cpu: &mut CPUState, mut out: impl std::fmt::Write) {
let mut proc = OSI.get_current_process(cpu);
let mut proc = OSI.get_current_process(cpu).unwrap();
let mappings = OSI.get_mappings(cpu, &mut *proc);

outputln!(out);
Expand Down
62 changes: 35 additions & 27 deletions panda/plugins/gdb/src/monitor_commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,38 @@ use gdbstub::outputln;
mod parser;
use parser::{Command, TaintTarget};

mod thread_info;
mod proc_info;
mod proc_list;
mod thread_info;

pub(crate) fn handle_command(cmd: &str, cpu: &mut CPUState, mut out: impl std::fmt::Write) {
let cmd = cmd.trim();
// this parsing is totally fine™
match Command::parse(cmd) {
Ok(Command::Taint(target, label)) => {
match target {
TaintTarget::Address(addr) => {
let addr = panda::mem::virt_to_phys(cpu, addr);
taint::label_ram(addr, label);
outputln!(out, "Memory location {:#x?} tainted.", addr);
}
TaintTarget::Register(reg) => {
taint::label_reg(reg, label);
outputln!(out, "Register {} tainted.", reg.to_string());
}
Ok(Command::Taint(target, label)) => match target {
TaintTarget::Address(addr) => {
let addr = panda::mem::virt_to_phys(cpu, addr).unwrap();
taint::label_ram(addr, label);
outputln!(out, "Memory location {:#x?} tainted.", addr);
}
TaintTarget::Register(reg) => {
taint::label_reg(reg, label);
outputln!(out, "Register {} tainted.", reg.to_string());
}
},
Ok(Command::CheckTaint(target)) => {
match target {
TaintTarget::Address(addr) => {
let addr = panda::mem::virt_to_phys(cpu, addr);
outputln!(out, "{:?}", taint::check_ram(addr));
}
TaintTarget::Register(reg) => {
outputln!(out, "{:?}", taint::check_reg(reg));
}
Ok(Command::CheckTaint(target)) => match target {
TaintTarget::Address(addr) => {
let addr = panda::mem::virt_to_phys(cpu, addr).unwrap();
outputln!(out, "{:?}", taint::check_ram(addr));
}
TaintTarget::Register(reg) => {
outputln!(out, "{:?}", taint::check_reg(reg));
}
},
Ok(Command::GetTaint(target)) => {
match target {
TaintTarget::Address(addr) => {
let addr = panda::mem::virt_to_phys(cpu, addr);
let addr = panda::mem::virt_to_phys(cpu, addr).unwrap();
// TODO: fix segfault
if taint::check_ram(addr) {
outputln!(out, "{:?}", taint::get_ram(addr));
Expand All @@ -58,7 +54,7 @@ pub(crate) fn handle_command(cmd: &str, cpu: &mut CPUState, mut out: impl std::f
}
}
}
},
}
Ok(Command::MemInfo) => crate::memory_map::print_to_gdb(cpu, out),
Ok(Command::ThreadInfo) => thread_info::print(cpu, out),
Ok(Command::ProcInfo) => proc_info::print(cpu, out),
Expand Down Expand Up @@ -93,10 +89,22 @@ fn print_help_text(mut out: impl std::fmt::Write) {
outputln!(out);
outputln!(out, "Commands:");
outputln!(out, " meminfo - print out the current memory map");
outputln!(out, " taint - apply taint to a given register/memory location");
outputln!(out, " check_taint - check if a given register/memory location is tainted");
outputln!(out, " get_taint - get the taint labels for a given register/memory location");
outputln!(out, " threadinfo - get info about threads of the current process");
outputln!(
out,
" taint - apply taint to a given register/memory location"
);
outputln!(
out,
" check_taint - check if a given register/memory location is tainted"
);
outputln!(
out,
" get_taint - get the taint labels for a given register/memory location"
);
outputln!(
out,
" threadinfo - get info about threads of the current process"
);
outputln!(out, " procinfo - get info about the current process");
outputln!(out, " proclist - list all the currently running processes");
}
10 changes: 7 additions & 3 deletions panda/plugins/gdb/src/monitor_commands/proc_info.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use panda::prelude::*;
use panda::plugins::osi::OSI;
use panda::prelude::*;

use gdbstub::outputln;

pub(crate) fn print(cpu: &mut CPUState, mut out: impl std::fmt::Write) {
let proc = OSI.get_current_process(cpu);
let proc = OSI.get_current_process(cpu).unwrap();

outputln!(out);
outputln!(out, "{}", proc.get_name());
Expand All @@ -13,6 +13,10 @@ pub(crate) fn print(cpu: &mut CPUState, mut out: impl std::fmt::Write) {
outputln!(out, "ASID: {:#x?}", proc.asid);
outputln!(out, "Parent PID: {}", proc.ppid);
outputln!(out, "Creation time: {}", proc.create_time);
outputln!(out, "PC in shared library: {}", OSI.in_shared_object(cpu, &*proc));
outputln!(
out,
"PC in shared library: {}",
OSI.in_shared_object(cpu, &*proc)
);
outputln!(out);
}
10 changes: 6 additions & 4 deletions panda/plugins/gdb/src/monitor_commands/proc_list.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
use panda::prelude::*;
use panda::plugins::osi::OSI;
use panda::prelude::*;

use gdbstub::outputln;
use tabwriter::{TabWriter, Alignment};
use tabwriter::{Alignment, TabWriter};

use std::io::Write;

pub(crate) fn print(cpu: &mut CPUState, mut out: impl std::fmt::Write) {
let procs = OSI.get_processes(cpu);
let current_pid = OSI.get_current_process(cpu).pid;
let current_pid = OSI.get_current_process(cpu).unwrap().pid;

outputln!(out);

let output = Vec::new();
let mut output = TabWriter::new(output).padding(1).alignment(Alignment::Right);
let mut output = TabWriter::new(output)
.padding(1)
.alignment(Alignment::Right);

let _ = writeln!(output, " \tPID\tASID\tParent\tCreate Time\tProcess Name");
let _ = writeln!(output, " \t===\t====\t======\t===========\t============");
Expand Down
Loading

0 comments on commit 569658d

Please sign in to comment.