33 lines
1.1 KiB
OCaml
33 lines
1.1 KiB
OCaml
|
(** Firmware extractor
|
||
|
|
||
|
1. Verify if the file is a welknown archive format
|
||
|
2. Checking internal bytes for common filesystem
|
||
|
3. Recursive
|
||
|
|
||
|
Some files might require different approach
|
||
|
|
||
|
Common archive file formats are ZIP XZ TAR
|
||
|
Common filesystem are SQUASHFS JIFFS
|
||
|
*)
|
||
|
|
||
|
open Cmdliner
|
||
|
|
||
|
let extract =
|
||
|
let info = Cmd.info "extract" ~doc:"Extract the file." in
|
||
|
let dry = Arg.(value & opt bool false & info ["d"; "dry"] ~docv:"false" ~doc:"Dry run") in
|
||
|
let file = Arg.(required & pos 0 (some string) None & info [] ~docv:"FILE") in
|
||
|
Cmd.v info Term.(const Extract.runner $ dry $ file)
|
||
|
|
||
|
let detect =
|
||
|
let info = Cmd.info "detect" ~doc:"Detect the file type and its internal contents." in
|
||
|
let isa = Arg.(value & opt bool false & info ["isa"] ~docv:"false" ~doc:"Detect Instruction Set Architecture") in
|
||
|
let file = Arg.(required & pos 0 (some string) None & info [] ~docv:"FILE") in
|
||
|
Cmd.v info Term.(const Detect.runner $ isa $ file)
|
||
|
|
||
|
let cmd =
|
||
|
let info = Cmd.info "firmex group" ~version:"0.0.0-alpha" in
|
||
|
Cmd.group info [extract; detect;]
|
||
|
|
||
|
|
||
|
let () = exit (Cmd.eval cmd)
|