Skip to content

Commit 11e1a94

Browse files
committed
Update config
1 parent e3bc5ad commit 11e1a94

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

crates/libmwemu/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct Config {
4444
pub command: Option<String>,
4545
pub definitions: HashMap<u64, Definition>,
4646
pub entropy: bool,
47+
pub shellcode: bool
4748
}
4849

4950
impl Default for Config {
@@ -94,6 +95,7 @@ impl Config {
9495
command: None,
9596
definitions: HashMap::new(),
9697
entropy: false,
98+
shellcode: false,
9799
}
98100
}
99101
}

crates/libmwemu/src/emu/loaders.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl Emu {
485485
//let map_name = self.filename_to_mapname(filename);
486486
//self.cfg.filename = map_name;
487487

488-
if Elf32::is_elf32(filename) {
488+
if Elf32::is_elf32(filename) && !self.cfg.shellcode {
489489
self.linux = true;
490490
self.cfg.is_64bits = false;
491491

@@ -497,13 +497,13 @@ impl Emu {
497497
let stack = self.alloc("stack", stack_sz, Permission::READ_WRITE);
498498
self.regs_mut().rsp = stack + (stack_sz / 2);
499499
//unimplemented!("elf32 is not supported for now");
500-
} else if Elf64::is_elf64(filename) {
500+
} else if Elf64::is_elf64(filename) && !self.cfg.shellcode {
501501
self.linux = true;
502502
self.cfg.is_64bits = true;
503503
self.maps.clear();
504504

505505
let base = self.load_elf64(filename);
506-
} else if !self.cfg.is_64bits && PE32::is_pe32(filename) {
506+
} else if !self.cfg.is_64bits && PE32::is_pe32(filename) && !self.cfg.shellcode {
507507
log::info!("PE32 header detected.");
508508
let clear_registers = false; // TODO: this needs to be more dynamic, like if we have a register set via args or not
509509
let clear_flags = false; // TODO: this needs to be more dynamic, like if we have a flag set via args or not
@@ -521,7 +521,7 @@ impl Emu {
521521
}*/
522522

523523
self.regs_mut().rip = ep;
524-
} else if self.cfg.is_64bits && PE64::is_pe64(filename) {
524+
} else if self.cfg.is_64bits && PE64::is_pe64(filename) && !self.cfg.shellcode {
525525
log::info!("PE64 header detected.");
526526
let clear_registers = false; // TODO: this needs to be more dynamic, like if we have a register set via args or not
527527
let clear_flags = false; // TODO: this needs to be more dynamic, like if we have a flag set via args or not

crates/mwemu/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ fn main() {
136136
.arg(clap_arg!("cmd", "", "cmd", "launch a console command", "COMMAND"))
137137
.arg(clap_arg!("entropy", "", "entropy", "display changes in the entropy"))
138138
.arg(clap_arg!("multithread", "", "multithread", "enable multithread emulation"))
139+
.arg(clap_arg!("is_shellcode", "", "is_shellcode", "Force the binary to be shellcode"))
139140
.get_matches();
140141

141142
if !matches.is_present("filename") {
@@ -424,6 +425,10 @@ fn main() {
424425
);
425426
}
426427

428+
if matches.is_present("is_shellcode") {
429+
emu.cfg.shellcode = true;
430+
}
431+
427432
// args
428433
if matches.is_present("args") {
429434
log::info!(

0 commit comments

Comments
 (0)