mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 10:46:42 +01:00
colorize output
This commit is contained in:
parent
9deba511bd
commit
40356b31c7
2 changed files with 15 additions and 6 deletions
|
|
@ -38,10 +38,12 @@ impl Show {
|
||||||
let module = call.map(|call|call.module.as_ref()).flatten();
|
let module = call.map(|call|call.module.as_ref()).flatten();
|
||||||
let method = call.map(|call|call.method.as_ref()).flatten();
|
let method = call.map(|call|call.method.as_ref()).flatten();
|
||||||
if module.is_some() || method.is_some() {
|
if module.is_some() || method.is_some() {
|
||||||
println!(" {}{}{}",
|
println!(" {GREEN}{}{}{}{RESET}",
|
||||||
module.map(|x|x.as_ref()).unwrap_or(&""),
|
module.map(|x|x.as_ref()).unwrap_or(&""),
|
||||||
if module.is_some() && method.is_some() { "::" } else { "" },
|
if module.is_some() && method.is_some() { "::" } else { "" },
|
||||||
method.map(|x|x.as_ref()).unwrap_or(&""));
|
method.map(|x|x.as_ref()).unwrap_or(&""));
|
||||||
|
} else {
|
||||||
|
println!(" {RED}(unresolved){RESET}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +71,7 @@ impl Show {
|
||||||
} else {
|
} else {
|
||||||
write!(&mut output, " ");
|
write!(&mut output, " ");
|
||||||
}
|
}
|
||||||
write!(&mut output, "{byte:08x}");
|
write!(&mut output, "{:08x}", byte + base);
|
||||||
}
|
}
|
||||||
write!(&mut output, "{DIM}");
|
write!(&mut output, "{DIM}");
|
||||||
if (byte >= addr) && (byte < addr + length) {
|
if (byte >= addr) && (byte < addr + length) {
|
||||||
|
|
@ -85,23 +87,27 @@ impl Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(&mut output, "{:02x}", dll.code[byte]);
|
write!(&mut output, "{:02x}", dll.code[byte]);
|
||||||
|
write!(&mut output, "{RESET}");
|
||||||
if byte % line == line - 1 {
|
if byte % line == line - 1 {
|
||||||
|
if snap(byte) == snap(addr) {
|
||||||
|
let dasm = Self::call_dasm(&dll.code[addr..addr+length]);
|
||||||
|
write!(&mut output, " -> {dasm}");
|
||||||
|
}
|
||||||
write!(&mut output, " \n");
|
write!(&mut output, " \n");
|
||||||
}
|
}
|
||||||
write!(&mut output, "{RESET}");
|
|
||||||
}
|
}
|
||||||
print!("{output}");
|
print!("{output}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn call_dasm (bytes: &[u8]) {
|
pub fn call_dasm (bytes: &[u8]) -> Arc<str> {
|
||||||
let mut decoder = Decoder::with_ip(64, bytes, 0x0, DecoderOptions::NONE);
|
let mut decoder = Decoder::with_ip(64, bytes, 0x0, DecoderOptions::NONE);
|
||||||
while decoder.can_decode() {
|
while decoder.can_decode() {
|
||||||
let position = decoder.position();
|
let position = decoder.position();
|
||||||
let instruction = decoder.decode();
|
let instruction = decoder.decode();
|
||||||
let opcodes = &bytes[position..position+instruction.len()];
|
let opcodes = &bytes[position..position+instruction.len()];
|
||||||
println!(" ╰-------> {BOLD}{instruction}{RESET} ({DIM}{}{RESET})", fmt_bytes(opcodes));
|
return format!("{BOLD}{instruction}{RESET} ({DIM}{}{RESET})", fmt_bytes(opcodes)).into()
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,15 @@ pub(crate) use ::pretty_hex::*;
|
||||||
pub(crate) use ::exe::{Buffer, PE, VecPE, PtrPE, types::*, headers::*};
|
pub(crate) use ::exe::{Buffer, PE, VecPE, PtrPE, types::*, headers::*};
|
||||||
pub(crate) use ::iced_x86::{Encoder, Decoder, DecoderOptions, Instruction, OpKind, FlowControl};
|
pub(crate) use ::iced_x86::{Encoder, Decoder, DecoderOptions, Instruction, OpKind, FlowControl};
|
||||||
pub(crate) type Usually<T> = Result<T, Box<dyn std::error::Error>>;
|
pub(crate) type Usually<T> = Result<T, Box<dyn std::error::Error>>;
|
||||||
|
pub const ESC: &str = "\u{001b}";
|
||||||
pub const RESET: &str = "\u{001b}[0m";
|
pub const RESET: &str = "\u{001b}[0m";
|
||||||
pub const BOLD: &str = "\u{001b}[1m";
|
pub const BOLD: &str = "\u{001b}[1m";
|
||||||
pub const DIM: &str = "\u{001b}[2m";
|
pub const DIM: &str = "\u{001b}[2m";
|
||||||
pub const ITALIC: &str = "\u{001b}[3m";
|
pub const ITALIC: &str = "\u{001b}[3m";
|
||||||
pub const UNDERLINE: &str = "\u{001b}[4m";
|
pub const UNDERLINE: &str = "\u{001b}[4m";
|
||||||
pub const INVERT: &str = "\u{001b}[7m";
|
pub const INVERT: &str = "\u{001b}[7m";
|
||||||
|
pub const RED: &str = "\u{001b}[1;31m";
|
||||||
|
pub const GREEN: &str = "\u{001b}[1;32m";
|
||||||
pub enum Verbosity {
|
pub enum Verbosity {
|
||||||
Silent,
|
Silent,
|
||||||
Terse,
|
Terse,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue