@@ -6,42 +6,38 @@ use gdbstub::outputln;
6
6
mod parser;
7
7
use parser:: { Command , TaintTarget } ;
8
8
9
- mod thread_info;
10
9
mod proc_info;
11
10
mod proc_list;
11
+ mod thread_info;
12
12
13
13
pub ( crate ) fn handle_command ( cmd : & str , cpu : & mut CPUState , mut out : impl std:: fmt:: Write ) {
14
14
let cmd = cmd. trim ( ) ;
15
15
// this parsing is totally fine™
16
16
match Command :: parse ( cmd) {
17
- Ok ( Command :: Taint ( target, label) ) => {
18
- match target {
19
- TaintTarget :: Address ( addr) => {
20
- let addr = panda:: mem:: virt_to_phys ( cpu, addr) ;
21
- taint:: label_ram ( addr, label) ;
22
- outputln ! ( out, "Memory location {:#x?} tainted." , addr) ;
23
- }
24
- TaintTarget :: Register ( reg) => {
25
- taint:: label_reg ( reg, label) ;
26
- outputln ! ( out, "Register {} tainted." , reg. to_string( ) ) ;
27
- }
17
+ Ok ( Command :: Taint ( target, label) ) => match target {
18
+ TaintTarget :: Address ( addr) => {
19
+ let addr = panda:: mem:: virt_to_phys ( cpu, addr) . unwrap ( ) ;
20
+ taint:: label_ram ( addr, label) ;
21
+ outputln ! ( out, "Memory location {:#x?} tainted." , addr) ;
22
+ }
23
+ TaintTarget :: Register ( reg) => {
24
+ taint:: label_reg ( reg, label) ;
25
+ outputln ! ( out, "Register {} tainted." , reg. to_string( ) ) ;
28
26
}
29
27
} ,
30
- Ok ( Command :: CheckTaint ( target) ) => {
31
- match target {
32
- TaintTarget :: Address ( addr) => {
33
- let addr = panda:: mem:: virt_to_phys ( cpu, addr) ;
34
- outputln ! ( out, "{:?}" , taint:: check_ram( addr) ) ;
35
- }
36
- TaintTarget :: Register ( reg) => {
37
- outputln ! ( out, "{:?}" , taint:: check_reg( reg) ) ;
38
- }
28
+ Ok ( Command :: CheckTaint ( target) ) => match target {
29
+ TaintTarget :: Address ( addr) => {
30
+ let addr = panda:: mem:: virt_to_phys ( cpu, addr) . unwrap ( ) ;
31
+ outputln ! ( out, "{:?}" , taint:: check_ram( addr) ) ;
32
+ }
33
+ TaintTarget :: Register ( reg) => {
34
+ outputln ! ( out, "{:?}" , taint:: check_reg( reg) ) ;
39
35
}
40
36
} ,
41
37
Ok ( Command :: GetTaint ( target) ) => {
42
38
match target {
43
39
TaintTarget :: Address ( addr) => {
44
- let addr = panda:: mem:: virt_to_phys ( cpu, addr) ;
40
+ let addr = panda:: mem:: virt_to_phys ( cpu, addr) . unwrap ( ) ;
45
41
// TODO: fix segfault
46
42
if taint:: check_ram ( addr) {
47
43
outputln ! ( out, "{:?}" , taint:: get_ram( addr) ) ;
@@ -58,7 +54,7 @@ pub(crate) fn handle_command(cmd: &str, cpu: &mut CPUState, mut out: impl std::f
58
54
}
59
55
}
60
56
}
61
- } ,
57
+ }
62
58
Ok ( Command :: MemInfo ) => crate :: memory_map:: print_to_gdb ( cpu, out) ,
63
59
Ok ( Command :: ThreadInfo ) => thread_info:: print ( cpu, out) ,
64
60
Ok ( Command :: ProcInfo ) => proc_info:: print ( cpu, out) ,
@@ -93,10 +89,22 @@ fn print_help_text(mut out: impl std::fmt::Write) {
93
89
outputln ! ( out) ;
94
90
outputln ! ( out, "Commands:" ) ;
95
91
outputln ! ( out, " meminfo - print out the current memory map" ) ;
96
- outputln ! ( out, " taint - apply taint to a given register/memory location" ) ;
97
- outputln ! ( out, " check_taint - check if a given register/memory location is tainted" ) ;
98
- outputln ! ( out, " get_taint - get the taint labels for a given register/memory location" ) ;
99
- outputln ! ( out, " threadinfo - get info about threads of the current process" ) ;
92
+ outputln ! (
93
+ out,
94
+ " taint - apply taint to a given register/memory location"
95
+ ) ;
96
+ outputln ! (
97
+ out,
98
+ " check_taint - check if a given register/memory location is tainted"
99
+ ) ;
100
+ outputln ! (
101
+ out,
102
+ " get_taint - get the taint labels for a given register/memory location"
103
+ ) ;
104
+ outputln ! (
105
+ out,
106
+ " threadinfo - get info about threads of the current process"
107
+ ) ;
100
108
outputln ! ( out, " procinfo - get info about the current process" ) ;
101
109
outputln ! ( out, " proclist - list all the currently running processes" ) ;
102
110
}
0 commit comments