Skip to content

Commit e696847

Browse files
committed
Merge remote-tracking branch 'sha0coder/main'
2 parents 1719f3b + 13dca5b commit e696847

File tree

432 files changed

+5034
-5657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+5034
-5657
lines changed

Cargo.lock

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Rust apps https://crates.io/crates/libmwemu
8383
## Usage
8484

8585
```
86-
MWEMU emulator for malware.
86+
MWEMU emulator for malware 0.7.11
8787
@sha0coder
8888
8989
USAGE:
@@ -102,11 +102,13 @@ FLAGS:
102102
-r, --regs print the register values in every step.
103103
-p, --stack_trace trace stack on push/pop
104104
-t, --test test mode
105-
-V, --version Prints version information
105+
--version Prints version information
106106
-v, --verbose -vv for view the assembly, -v only messages, without verbose only see the api calls and goes
107107
faster
108108
109109
OPTIONS:
110+
-A, --args <ARGS> provide arguments to the EXE like: --args '"aa" "bb"'
111+
--cmd <COMMAND> launch a console command
110112
-b, --base <ADDRESS> set base address for code
111113
-c, --console <NUMBER> select in which moment will spawn the console to inspect.
112114
-C, --console_addr <ADDRESS> spawn console on first eip = address
@@ -141,6 +143,8 @@ OPTIONS:
141143
-s, --string <ADDRESS> monitor string on a specific address
142144
-T, --trace <TRACE_FILENAME> output trace to specified file
143145
-S, --trace_start <TRACE_START> start trace at specified position
146+
-V, --verbose_at <NUMBER> start displaying assembly at specific position (is like -vv enabled in specific
147+
moment)
144148
```
145149

146150
## Command line examples

crates/libmwemu/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libmwemu"
3-
version = "0.21.6"
3+
version = "0.22.1"
44
edition = "2018"
55
authors = ["sha0coder"]
66
license = "MIT"
@@ -33,9 +33,12 @@ serde_arrays = "0.2.0"
3333
slab = { version = "0.4.10", features=["serde"] }
3434
bytemuck = "1.23.1"
3535
minidump = "0.26.0"
36+
serde_yaml = "0.9"
37+
fast_log = { version = "1.7" }
3638

3739
[dev-dependencies]
3840
env_logger = "0.11.8"
41+
hex = "0.4.3"
3942

4043
[features]
4144
default = []

crates/libmwemu/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ use libmwemu::emu32;
1818
fn main() {
1919
let mut emu = emu32();
2020
emu.set_maps_folder("/tmp/maps32/");
21-
emu.init(false, false);
21+
emu.init_logger();
2222
```
2323

2424
Load your shellcode or PE binary and run the emulator.
2525
None parameter means emulate for-ever.
2626

2727
```rust
28+
// emu.init(false, false); needed if load_code is not called
2829
emu.load_code("shellcodes32/shikata.bin");
2930
emu.set_verbose(2);
3031
emu.run(None).unwrap();

crates/libmwemu/src/config.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
use std::collections::HashMap;
2+
13
use serde::{Deserialize, Serialize};
2-
use crate::constants;
4+
use crate::{constants, definitions::Definition};
35

46
#[derive(Clone, Serialize, Deserialize)]
57
pub struct Config {
@@ -40,6 +42,8 @@ pub struct Config {
4042
pub enable_threading: bool, // Enable multi-threading support
4143
pub verbose_at: Option<u64>,
4244
pub command: Option<String>,
45+
pub definitions: HashMap<u64, Definition>,
46+
pub entropy: bool,
4347
}
4448

4549
impl Default for Config {
@@ -87,7 +91,9 @@ impl Config {
8791
arguments: "".to_string(),
8892
enable_threading: false, // Default to single-threaded for backward compatibility
8993
verbose_at: None,
90-
command: None
94+
command: None,
95+
definitions: HashMap::new(),
96+
entropy: false,
9197
}
9298
}
9399
}

crates/libmwemu/src/console.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl Console {
183183
let precmd = format!("dr rax={}?; dr rbx={}?; dr rcx={}?; dr rdx={}?; dr rsi={}?;
184184
dr rdi={}?; dr rbp={}?; dr rsp={}?; dr rip={}?; dr r8={}?
185185
dr r9={}?; dr r10={}?; dr r11={}?; dr r12={}?; dr r13={}?;
186-
dr r14={}?; dr r15={}?; decai -e model=qwen3-coder:30?",
186+
dr r14={}?; dr r15={}?; decai -e model=qwen3-coder:30b; r2ai -e r2ai.model=qwen3-coder:30b;",
187187
emu.regs().rax, emu.regs().rbx, emu.regs().rcx, emu.regs().rdx,
188188
emu.regs().rsi, emu.regs().rdi, emu.regs().rbp, emu.regs().rsp,
189189
emu.regs().rip, emu.regs().r8, emu.regs().r9, emu.regs().r10,

crates/libmwemu/src/constants.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ pub const SYSTEM_DIRECTORY: &str = "C:\\Windows\\System32"; // randomize this
1818
pub const CFG_DEFAULT_BASE: u64 = 0x3c0000;
1919

2020
pub const BLOCK_LEN: usize = 0x300;
21+
pub const ALLOC32_MIN: u64 = 0x60000000;
22+
pub const ALLOC32_MAX: u64 = 0x6FFFFFFF;
2123
pub const LIBS32_MIN: u64 = 0x70000000;
2224
pub const LIBS32_MAX: u64 = 0x7FFFFFFF;
25+
26+
pub const ALLOC64_MIN: u64 = 0x7fe000000000;
27+
pub const ALLOC64_MAX: u64 = 0x7fefffffffff;
2328
pub const LIBS64_MIN: u64 = 0x7FF000000000;
2429
pub const LIBS64_MAX: u64 = 0x7FFFFFFFFFFF;
2530

@@ -90,11 +95,15 @@ pub const INTERNET_OPTION_DATA_SEND_TIMEOUT: u32 = 7;
9095
// https://docs.microsoft.com/en-us/windows/win32/wininet/api-flags
9196
pub const INTERNET_FLAG_SECURE: u64 = 0x00800000;
9297

93-
pub const ERROR_NO_MORE_FILES: u64 = 18;
94-
pub const CREATE_SUSPENDED: u64 = 0x00000004;
95-
pub const EXCEPTION_CONTINUE_EXECUTION: u32 = 0xFFFFFFFF;
98+
// exceptions
99+
pub const EXCEPTION_CONTINUE_EXECUTION32: u32 = 0xffffffff;
100+
pub const EXCEPTION_CONTINUE_EXECUTION64: u64 = 0xffffffff_ffffffff;
96101
pub const EXCEPTION_CONTINUE_SEARCH: u32 = 0x00000000;
97102
pub const EXCEPTION_EXECUTE_HANDLER: u32 = 0x00000001;
103+
104+
105+
pub const ERROR_NO_MORE_FILES: u64 = 18;
106+
pub const CREATE_SUSPENDED: u64 = 0x00000004;
98107
pub const STATUS_BREAKPOINT: u32 = 0x80000003;
99108
pub const STATUS_INTEGER_DIVIDE_BY_ZERO: u32 = 0xc0000094;
100109
pub const STATUS_INTEGER_OVERFLOW: u32 = 0xc0000095;
@@ -344,6 +353,10 @@ pub fn get_crypto_key_len(value: u32) -> usize {
344353
pub const PT_LOAD: u32 = 1;
345354
pub const ELF_PAGE_SIZE: u64 = 4096;
346355
pub const ELF_PAGE_MASK: u64 = ELF_PAGE_SIZE - 1;
356+
pub const ELF64_DYN_BASE: u64 = 0x555555554000;
357+
pub const ELF64_STA_BASE: u64 = 0x400000;
358+
pub const LIBC_BASE: u64 = 0x7ffff7da7000;
359+
pub const LD_BASE: u64 = 0x7ffff7fd2000;
347360

348361
// linux errors
349362
pub const ENOTSOCK: u64 = -1i64 as u64; /* not open sock */
@@ -772,27 +785,6 @@ pub const ARCH_GET_FS: u64 = 0x1003;
772785
pub const ARCH_GET_GS: u64 = 0x1004;
773786

774787
pub const LOCALE_USER_DEFAULT: u64 = 0x400;
775-
pub const LOCALE_SABBREVMONTHNAME1: u64 = 68;
776-
pub const LOCALE_SABBREVMONTHNAME2: u64 = 69;
777-
pub const LOCALE_SABBREVMONTHNAME3: u64 = 70;
778-
pub const LOCALE_SABBREVMONTHNAME4: u64 = 71;
779-
pub const LOCALE_SABBREVMONTHNAME5: u64 = 72;
780-
pub const LOCALE_SABBREVMONTHNAME6: u64 = 73;
781-
pub const LOCALE_SABBREVMONTHNAME7: u64 = 74;
782-
pub const LOCALE_SABBREVMONTHNAME8: u64 = 75;
783-
pub const LOCALE_SABBREVMONTHNAME9: u64 = 76;
784-
pub const LOCALE_SABBREVMONTHNAME10: u64 = 77;
785-
pub const LOCALE_SABBREVMONTHNAME11: u64 = 78;
786-
pub const LOCALE_SABBREVMONTHNAME12: u64 = 79;
787-
pub const LOCALE_SLANGUAGE: u64 = 0x00000002;
788-
pub const LOCALE_SCOUNTRY: u64 = 0x00000006;
789-
pub const LOCALE_SLIST: u64 = 0x0000000C;
790-
pub const LOCALE_SDECIMAL: u64 = 0x0000000E;
791-
pub const LOCALE_STHOUSAND: u64 = 0x0000000F;
792-
pub const LOCALE_SCURRENCY: u64 = 0x00000014;
793-
pub const LOCALE_SDATE: u64 = 0x0000001D;
794-
pub const LOCALE_STIME: u64 = 0x0000001E;
795-
pub const LOCALE_RETURN_NUMBER: u64 = 0x20000000;
796788

797789
pub const HEAP_GENERATE_EXCEPTIONS: u64 = 0x00000004;
798790
pub const HEAP_NO_SERIALIZE: u64 = 0x00000001;

0 commit comments

Comments
 (0)