python-lancelot 0.10.1__tar.gz → 0.10.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/Cargo.lock +10 -10
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/PKG-INFO +1 -1
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/Cargo.toml +2 -2
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/cfg/code_references.rs +31 -10
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/cfg/flow.rs +44 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/cfg/mod.rs +639 -220
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/cfg/noret.rs +13 -9
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/dis.rs +10 -1
- python_lancelot-0.10.2/core/src/analysis/heuristics.rs +532 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/call_targets.rs +7 -1
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/mod.rs +47 -18
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/runtime_functions.rs +61 -42
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/export/binexport2.rs +4 -2
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/mod.rs +71 -8
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/Cargo.toml +1 -1
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/Cargo.toml +2 -2
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pyproject.toml +1 -1
- python_lancelot-0.10.1/core/src/analysis/heuristics.rs +0 -231
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/Cargo.toml +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/LICENSE.txt +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/README.md +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/README.md +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/benches/core.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/cfg/thunk.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/flirt.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/control_flow_guard.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/entrypoints.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/exports.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/patterns.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/pointers.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/analysis/pe/safeseh.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/arch.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/aspace.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/config.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/mmu.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/plat/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/plat/win/api.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/plat/win/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/plat/win/win32.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/plat/win/win64.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/emu/reg.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/lib.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/loader/coff/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/loader/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/loader/pe/imports.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/loader/pe/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/loader/pe/reloc.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/loader/pe/rsrc.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/module.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/pagemap.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/rsrc.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/test.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/util.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/config.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/export/binexport2.proto +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/export/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/export/pb.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/core/src/workspace/formatter.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/README.md +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/benches/fragments.txt +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/benches/patterns.txt +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/benches/regex.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/sig.bt +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/sigs/pat/__EH_prolog3.pat +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/sigs/sig/libcmt_15_msvc_x86.dumpsig +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/sigs/sig/libcmt_15_msvc_x86.sig +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/sigs/yara/__EH_prolog3.yara +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/bin/decompress_sig.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/bin/parsepat.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/bin/sig2pat.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/decision_tree.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/lib.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/pat/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/pattern_set.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/flirt/src/sig/mod.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/.env/devshell.toml +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/.env/flake.lock +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/.env/flake.nix +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/.envrc +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/.gitattributes +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/.gitignore +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/LICENSE.txt +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/README.md +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/justfile +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/scripts/generate-binexport2.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/scripts/inspect-workspace.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/scripts/list-functions.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/scripts/show-strings-by-function.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/setup.cfg +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/src/lib.rs +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/tests/conftest.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/tests/data/.gitignore +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/tests/data/altsvc.c.obj +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/tests/data/k32.dll_ +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/pylancelot/tests/test_pylancelot.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/python/lancelot/__init__.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/python/lancelot/be2utils/__init__.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/python/lancelot/be2utils/binexport2_pb2.py +0 -0
- {python_lancelot-0.10.1 → python_lancelot-0.10.2}/python/lancelot/be2utils/binexport2_pb2.pyi +0 -0
|
@@ -241,9 +241,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
|
|
241
241
|
|
|
242
242
|
[[package]]
|
|
243
243
|
name = "cc"
|
|
244
|
-
version = "1.
|
|
244
|
+
version = "1.10.0"
|
|
245
245
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
246
|
-
checksum = "
|
|
246
|
+
checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0"
|
|
247
247
|
dependencies = [
|
|
248
248
|
"find-msvc-tools",
|
|
249
249
|
"shlex 2.0.1",
|
|
@@ -726,7 +726,7 @@ dependencies = [
|
|
|
726
726
|
|
|
727
727
|
[[package]]
|
|
728
728
|
name = "jslancelot"
|
|
729
|
-
version = "0.10.
|
|
729
|
+
version = "0.10.2"
|
|
730
730
|
dependencies = [
|
|
731
731
|
"anyhow",
|
|
732
732
|
"chrono",
|
|
@@ -740,7 +740,7 @@ dependencies = [
|
|
|
740
740
|
|
|
741
741
|
[[package]]
|
|
742
742
|
name = "lancelot"
|
|
743
|
-
version = "0.10.
|
|
743
|
+
version = "0.10.2"
|
|
744
744
|
dependencies = [
|
|
745
745
|
"anyhow",
|
|
746
746
|
"bitflags 2.13.2",
|
|
@@ -767,7 +767,7 @@ dependencies = [
|
|
|
767
767
|
|
|
768
768
|
[[package]]
|
|
769
769
|
name = "lancelot-bin"
|
|
770
|
-
version = "0.10.
|
|
770
|
+
version = "0.10.2"
|
|
771
771
|
dependencies = [
|
|
772
772
|
"anyhow",
|
|
773
773
|
"ar",
|
|
@@ -785,7 +785,7 @@ dependencies = [
|
|
|
785
785
|
|
|
786
786
|
[[package]]
|
|
787
787
|
name = "lancelot-flirt"
|
|
788
|
-
version = "0.10.
|
|
788
|
+
version = "0.10.2"
|
|
789
789
|
dependencies = [
|
|
790
790
|
"anyhow",
|
|
791
791
|
"better-panic",
|
|
@@ -1066,7 +1066,7 @@ dependencies = [
|
|
|
1066
1066
|
|
|
1067
1067
|
[[package]]
|
|
1068
1068
|
name = "pylancelot"
|
|
1069
|
-
version = "0.10.
|
|
1069
|
+
version = "0.10.2"
|
|
1070
1070
|
dependencies = [
|
|
1071
1071
|
"anyhow",
|
|
1072
1072
|
"lancelot",
|
|
@@ -1150,7 +1150,7 @@ dependencies = [
|
|
|
1150
1150
|
|
|
1151
1151
|
[[package]]
|
|
1152
1152
|
name = "python-flirt"
|
|
1153
|
-
version = "0.10.
|
|
1153
|
+
version = "0.10.2"
|
|
1154
1154
|
dependencies = [
|
|
1155
1155
|
"anyhow",
|
|
1156
1156
|
"lancelot-flirt",
|
|
@@ -1466,9 +1466,9 @@ dependencies = [
|
|
|
1466
1466
|
|
|
1467
1467
|
[[package]]
|
|
1468
1468
|
name = "tokio"
|
|
1469
|
-
version = "1.54.
|
|
1469
|
+
version = "1.54.1"
|
|
1470
1470
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1471
|
-
checksum = "
|
|
1471
|
+
checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
|
|
1472
1472
|
dependencies = [
|
|
1473
1473
|
"bytes",
|
|
1474
1474
|
"pin-project-lite",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "lancelot"
|
|
3
3
|
description = "binary analysis framework for x32/x64 PE files"
|
|
4
4
|
license = "Apache-2.0"
|
|
5
|
-
version = "0.10.
|
|
5
|
+
version = "0.10.2"
|
|
6
6
|
authors = ["Willi Ballenthin <william.ballenthin@mandiant.com>"]
|
|
7
7
|
edition = "2021"
|
|
8
8
|
homepage = "https://github.com/williballenthin/lancelot"
|
|
@@ -36,7 +36,7 @@ fern = { version = "0.7", optional = true }
|
|
|
36
36
|
bitvec = { version = "1" }
|
|
37
37
|
|
|
38
38
|
# needed for flirt
|
|
39
|
-
lancelot-flirt = { path = "../flirt", version = "0.10.
|
|
39
|
+
lancelot-flirt = { path = "../flirt", version = "0.10.2", optional = true}
|
|
40
40
|
|
|
41
41
|
# needed for binexport2
|
|
42
42
|
prost = "0.13"
|
|
@@ -85,14 +85,39 @@ pub fn find_executable_pointers(module: &Module) -> Result<Vec<VA>> {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
pub fn find_new_code_references(module: &Module, insns: &cfg::InstructionIndex) -> Result<Vec<VA>> {
|
|
88
|
+
let scan: Vec<VA> = insns.insns_by_address.keys().cloned().collect();
|
|
89
|
+
find_new_code_references_from(module, insns, &scan)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// like `find_new_code_references`, but only inspect the operands of the given instructions.
|
|
93
|
+
///
|
|
94
|
+
/// whether an address is probably code doesn't depend on what's already in the index,
|
|
95
|
+
/// so after a round of exploration, only the newly added instructions can reference new code.
|
|
96
|
+
pub fn find_new_code_references_from(module: &Module, insns: &cfg::InstructionIndex, scan: &[VA]) -> Result<Vec<VA>> {
|
|
97
|
+
let decoder = dis::get_disassembler(module)?;
|
|
98
|
+
Ok(find_code_reference_candidates_from(module, insns, scan)?
|
|
99
|
+
.into_iter()
|
|
100
|
+
.filter(|&target| heuristics::is_probably_code(module, &decoder, target))
|
|
101
|
+
.inspect(|target| log::debug!("code references: found new likely code at {:#x}", target))
|
|
102
|
+
.collect())
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// The addresses that the operands of the given instructions reference,
|
|
106
|
+
/// and that aren't already code.
|
|
107
|
+
/// These may not be code, so check them, such as with `heuristics::is_probably_code`.
|
|
108
|
+
pub fn find_code_reference_candidates_from(
|
|
109
|
+
module: &Module,
|
|
110
|
+
insns: &cfg::InstructionIndex,
|
|
111
|
+
scan: &[VA],
|
|
112
|
+
) -> Result<Vec<VA>> {
|
|
88
113
|
let decoder = dis::get_disassembler(module)?;
|
|
89
114
|
// we prefer to read via a page cache,
|
|
90
115
|
// assuming that when we read instructions ordered by address,
|
|
91
116
|
// fetches will often be localized within one page.
|
|
92
117
|
let mut reader: CachingPageReader = Default::default();
|
|
93
118
|
|
|
94
|
-
let mut
|
|
95
|
-
for &va in
|
|
119
|
+
let mut candidates: BTreeSet<VA> = Default::default();
|
|
120
|
+
for &va in scan.iter() {
|
|
96
121
|
if let Ok(Some(insn)) = read_insn_with_cache(&mut reader, &module.address_space, va, &decoder) {
|
|
97
122
|
for op in dis::get_operands(&insn) {
|
|
98
123
|
if let Ok(Some(xref)) = dis::get_operand_xref(module, va, &insn, op) {
|
|
@@ -106,19 +131,15 @@ pub fn find_new_code_references(module: &Module, insns: &cfg::InstructionIndex)
|
|
|
106
131
|
continue;
|
|
107
132
|
}
|
|
108
133
|
|
|
109
|
-
|
|
110
|
-
// finally, we think we have some new code.
|
|
111
|
-
log::debug!("code references: found new likely code at {:#x}", target);
|
|
112
|
-
new_code.insert(target);
|
|
113
|
-
}
|
|
134
|
+
candidates.insert(target);
|
|
114
135
|
}
|
|
115
136
|
}
|
|
116
137
|
}
|
|
117
138
|
}
|
|
118
139
|
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
Ok(
|
|
140
|
+
// many instructions reference the same address,
|
|
141
|
+
// so report each referenced address only once.
|
|
142
|
+
Ok(candidates.into_iter().collect())
|
|
122
143
|
}
|
|
123
144
|
|
|
124
145
|
#[cfg(test)]
|
|
@@ -67,6 +67,12 @@ fn is_empty(module: &Module, va: VA) -> bool {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/// Is the given address a reasonable destination for a direct call or jump?
|
|
71
|
+
/// This is the same check that the flow helpers below apply to direct targets.
|
|
72
|
+
pub fn is_valid_target(module: &Module, va: VA) -> bool {
|
|
73
|
+
is_executable(module, va) && module.is_in_image(va) && !is_empty(module, va)
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
pub fn get_call_insn_flow(module: &Module, va: VA, insn: &dis::DecodedInstruction) -> Result<Flows> {
|
|
71
77
|
// if this is not a CALL, then its a programming error. panic!
|
|
72
78
|
// all CALLs should have an operand.
|
|
@@ -175,6 +181,44 @@ pub fn get_cjmp_insn_flow(module: &Module, va: VA, insn: &dis::DecodedInstructio
|
|
|
175
181
|
Ok(smallvec![])
|
|
176
182
|
}
|
|
177
183
|
|
|
184
|
+
/// Does `get_insn_flow` need the operands of an instruction with the given mnemonic?
|
|
185
|
+
/// For any other instruction, the only flow is the fallthrough.
|
|
186
|
+
/// This lets callers decode without operands, which is faster, and decode again only when necessary.
|
|
187
|
+
pub fn needs_operands(mnemonic: zydis::Mnemonic) -> bool {
|
|
188
|
+
use zydis::Mnemonic::*;
|
|
189
|
+
matches!(
|
|
190
|
+
mnemonic,
|
|
191
|
+
CALL | JMP
|
|
192
|
+
| RET
|
|
193
|
+
| IRET
|
|
194
|
+
| IRETD
|
|
195
|
+
| IRETQ
|
|
196
|
+
| INT
|
|
197
|
+
| INT3
|
|
198
|
+
| JB
|
|
199
|
+
| JBE
|
|
200
|
+
| JCXZ
|
|
201
|
+
| JECXZ
|
|
202
|
+
| JKNZD
|
|
203
|
+
| JKZD
|
|
204
|
+
| JL
|
|
205
|
+
| JLE
|
|
206
|
+
| JNB
|
|
207
|
+
| JNBE
|
|
208
|
+
| JNL
|
|
209
|
+
| JNLE
|
|
210
|
+
| JNO
|
|
211
|
+
| JNP
|
|
212
|
+
| JNS
|
|
213
|
+
| JNZ
|
|
214
|
+
| JO
|
|
215
|
+
| JP
|
|
216
|
+
| JRCXZ
|
|
217
|
+
| JS
|
|
218
|
+
| JZ
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
178
222
|
pub fn get_insn_flow(module: &Module, va: VA, insn: &dis::DecodedInstruction) -> Result<Flows> {
|
|
179
223
|
let mut flows = match insn.mnemonic {
|
|
180
224
|
zydis::Mnemonic::CALL => get_call_insn_flow(module, va, insn)?,
|