Skip to content

Commit d9983c0

Browse files
committed
Create architecture_selection.rs
1 parent 495446a commit d9983c0

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//! Select between x86 and x64 architecture
2+
//! Author: BlackTechX
3+
4+
use process_ghosting::{GhostingBuilder, Architecture, init};
5+
use std::env;
6+
7+
fn main() {
8+
init();
9+
10+
println!("[*] Architecture Selection Example\n");
11+
12+
let args: Vec<String> = env::args().collect();
13+
14+
// Parse arguments
15+
let (file_path, arch) = if args.len() >= 3 {
16+
let arch = match args[2].to_lowercase().as_str() {
17+
"x86" | "32" | "i386" => Architecture::X86,
18+
"x64" | "64" | "amd64" => Architecture::X64,
19+
_ => {
20+
eprintln!("[-] Unknown architecture: {}", args[2]);
21+
eprintln!(" Use: x86, x64, 32, or 64");
22+
return;
23+
}
24+
};
25+
(args[1].as_str(), arch)
26+
} else if args.len() == 2 {
27+
(args[1].as_str(), Architecture::X64) // Default to x64
28+
} else {
29+
println!("Usage: {} <payload.exe> [arch]", args[0]);
30+
println!();
31+
println!("Architectures:");
32+
println!(" x86, 32, i386 - 32-bit");
33+
println!(" x64, 64, amd64 - 64-bit (default)");
34+
return;
35+
};
36+
37+
println!("[*] File: {}", file_path);
38+
println!("[*] Architecture: {}", arch);
39+
println!();
40+
41+
match GhostingBuilder::from_file(file_path) {
42+
Ok(builder) => {
43+
let result = builder
44+
.architecture(arch)
45+
.with_logging()
46+
.execute();
47+
48+
match result {
49+
Ok(_) => println!("\n[+] Success!"),
50+
Err(e) => eprintln!("\n[-] Failed: {}", e),
51+
}
52+
}
53+
Err(e) => eprintln!("[-] Error: {}", e),
54+
}
55+
}

0 commit comments

Comments
 (0)