Skip to content

Commit eefa524

Browse files
committed
Create from_hex.rs
1 parent ea83da5 commit eefa524

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//! Execute payload from hex string
2+
//! Author: BlackTechX
3+
4+
use process_ghosting::{GhostingBuilder, parse_hex_string, init};
5+
6+
fn main() {
7+
init();
8+
9+
println!("[*] From Hex String Example\n");
10+
11+
// Example: Various hex formats supported
12+
let hex_formats = [
13+
("Continuous", "4D5A90000300000004000000FFFF0000"),
14+
("Spaced", "4D 5A 90 00 03 00 00 00"),
15+
("C-style", "0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00"),
16+
("Escaped", "\\x4D\\x5A\\x90\\x00\\x03\\x00"),
17+
];
18+
19+
println!("[*] Supported hex formats:\n");
20+
21+
for (name, hex) in &hex_formats {
22+
match parse_hex_string(hex) {
23+
Ok(bytes) => {
24+
println!(" {}: {} -> {:02X?}", name, hex, &bytes[..bytes.len().min(4)]);
25+
}
26+
Err(e) => {
27+
println!(" {}: Error - {}", name, e);
28+
}
29+
}
30+
}
31+
32+
println!();
33+
34+
// For actual execution, you would use a complete PE file in hex
35+
// This is just a demonstration of the parsing
36+
37+
let sample_hex = "0x4D, 0x5A, 0x90, 0x00"; // MZ header start
38+
39+
match GhostingBuilder::from_hex_string(sample_hex) {
40+
Ok(builder) => {
41+
println!("[+] Successfully parsed hex string");
42+
println!("[*] Payload size: {} bytes", builder.build().payload.len());
43+
44+
// Note: This would fail with just the header
45+
// In real usage, provide complete PE bytes
46+
// builder.x64().execute();
47+
}
48+
Err(e) => {
49+
eprintln!("[-] Failed to parse: {}", e);
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)