beehive-lab / mambo

A low-overhead dynamic binary instrumentation and modification tool for ARM (both AArch32 and AArch64 support) and RISC-V (RV64GC).
Apache License 2.0
318 stars 69 forks source link

accept some command line options (--help, --version) #62

Closed umarcor closed 3 months ago

umarcor commented 2 years ago

This PR adds support for CLI options --help and --version. Moreover, a shell script named test/test_info.sh is added for testing purposes.

The version string is set through DBM_VERSION, which defaults to VERSION, otherwise to untracked.

If plugins are enabled, the full help prints the list of plugins. Furthermore, if functions are watched, those are listed, along with the id of plugin which they belong.

See example output without plugins or CFLAGS:

> Run ./dbm (without plugins or CFLAGS)
MAMBO: A Low-Overhead Dynamic Binary Modification Tool for ARM (<nogit>)

Usage: ./dbm <elf_file> [<arguments>]

Exit code: 1
> Run ./dbm --help (without plugins or CFLAGS)
MAMBO: A Low-Overhead Dynamic Binary Modification Tool for ARM (<nogit>)

Usage: ./dbm <elf_file> [<arguments>]

Exit code: 0
> Run ./dbm --version (without plugins or CFLAGS)
MAMBO: A Low-Overhead Dynamic Binary Modification Tool for ARM (<nogit>)
 Compiled with GNU GCC 7.5.0
Written by Cosmin Gorgovan, with contributions from Guillermo Callaghan
and others (github.com/beehive-lab/mambo/graphs/contributors).

Licensed under the Apache License, Version 2.0. MAMBO is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied.

Exit code: 0

And with two plugins enabled, as well as overriding DBM_VERSION:

> Run ./dbm (with plugins and CFLAGS)
MAMBO: A Low-Overhead Dynamic Binary Modification Tool for ARM (v0)

Usage: ./dbm <elf_file> [<arguments>]

Plugins:

  [0] 0x70000c3970
  [1] 0x70000c39f0

Watched func: 1

  malloc [1]

Exit code: 1
> Run ./dbm --help (with plugins and CFLAGS)
MAMBO: A Low-Overhead Dynamic Binary Modification Tool for ARM (v0)

Usage: ./dbm <elf_file> [<arguments>]

Plugins:

  [0] 0x70000c3970
  [1] 0x70000c39f0

Watched func: 1

  malloc [1]

Exit code: 0
> Run ./dbm --version (with plugins and CFLAGS)
MAMBO: A Low-Overhead Dynamic Binary Modification Tool for ARM (v0)
 Compiled with GNU GCC 7.5.0
Written by Cosmin Gorgovan, with contributions from Guillermo Callaghan
and others (github.com/beehive-lab/mambo/graphs/contributors).

Licensed under the Apache License, Version 2.0. MAMBO is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied.

Exit code: 0

Ref: #37

IgWod commented 3 months ago

Closing due to inactivity. Please re-open if required.