Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ex0dus-0x committed May 27, 2024
1 parent 5290959 commit 3080f77
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __binsec__ is a minimal static analysis utility for detecting security mitigatio
* Supports ELF, PE and Mach-Os
* Backends [libgoblin](/~https://github.com/m4b/goblin) for binary parsing
* JSON serialization
* Small release builds at ~2.44Mb, with analysis done in 30ms.
* Small release builds at ~2.2Mb, with analysis done in 30ms.

The project currently supports static detection for a variety of executable checks:

Expand Down
6 changes: 3 additions & 3 deletions src/check/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl ElfCompilationProperties for Elf<'_> {
self.interpreter
}

// TODO(alan): match on other stdlib runtimes
// TODO(alan): match on other stdlib runtimes, right now only glibc support
fn libc(&self) -> f64 {
let mut glibcs: Vec<f64> = vec![];
for sym in self.dynstrtab.to_vec().unwrap() {
Expand All @@ -142,7 +142,7 @@ impl ElfCompilationProperties for Elf<'_> {
if !glibcs.is_empty() {
glibcs.iter().fold(f64::INFINITY, |a, &b| a.min(b))
} else {
0.0
f64::INFINITY
}
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ impl Analyze for Elf<'_> {
comp_map.insert("Linker Path".to_string(), json!(linker));
}

if self.libc() != 0.0 {
if self.libc() != f64::INFINITY {
comp_map.insert(
"Minimum Libc Version".to_string(),
json!(format!("2.{:?}", self.libc())),
Expand Down
9 changes: 7 additions & 2 deletions src/check/mach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ impl Analyze for MachO<'_> {
fn mitigations(&self) -> GenericMap {
let mut mitigate_map: GenericMap = GenericMap::new();
mitigate_map.insert(
"Executable Stack".to_string(),
"Non-executable Stack".to_string(),
json!(self.executable_stack()),
);
mitigate_map.insert("Executable Heap".to_string(), json!(self.executable_heap()));
mitigate_map.insert("Non-executable Heap".to_string(), json!(self.executable_heap()));
mitigate_map.insert(
"Position Independent Executable / ASLR".to_string(),
json!(self.position_independent()),
Expand All @@ -108,6 +108,11 @@ impl Analyze for MachO<'_> {
"__RESTRICT segment".to_string(),
json!(self.restricted_segment()),
);
mitigate_map.insert(
"__PAGEZERO segment".to_string(),
json!(self.pagezero_segment()),
);

mitigate_map
}

Expand Down
1 change: 1 addition & 0 deletions src/check/pe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl Analyze for PE<'_> {
mitigation_checks
}

// TODO
fn instrumentation(&self) -> GenericMap {
GenericMap::new()
}
Expand Down

0 comments on commit 3080f77

Please sign in to comment.