firmex/bin/detect.ml

28 lines
628 B
OCaml
Raw Normal View History

2024-08-18 03:49:34 +07:00
(** detection module
detect a given file for formats or ISA
*)
2024-08-18 09:10:24 +07:00
open Firmex
2024-08-18 03:49:34 +07:00
open Printf
2024-08-18 09:10:24 +07:00
let try_unarchive (archive : Archive.t) : unit =
printf "archive file=%s type=%s" archive.file archive.typ
2024-08-18 03:49:34 +07:00
2024-08-18 09:10:24 +07:00
let try_detect file =
printf "detect file %s" file
let runner isa file =
if isa then
()
else
(* assume file exists *)
(* check if file is an archive, else try analyze as a firmware
for now, let's use binwalk result
in the future, finding for signatures inside the file
*)
match Archive.from file with
| Some archive -> try_unarchive archive
| None -> try_detect file