#optenum
optenum(1) is a command-line option enumerator for ELF executables.
optenum(1) uses static analysis to extract the options accepted by a binary and lets you use bash's autocompletion with options.
<space> - <TAB> <TAB>
- it's magic!
##Installing optenum
Building optenum is quick and easy. Download the source into a staging directory, run cmake
then make install
$ git clone git://github.com/mattboyer/optenum.git
$ cd optenum/
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=~/.local .
$ make install
Note The above will install optenum under the current user's home directory. For a system-wide install, replace the cmake invocation above with cmake .
. This will cause optenum to be installed under /usr/local/
, which will require elevated privileges.
All that's left to do is make sure the completion function is sourced and registered by your shell. You may want to add the following to your ~/.bashrc
:
. ~/.local/share/optenum/optenum.sh
##About
optenum(1) uses libbfd
and libopcodes
from the GNU binutils package to parse the dynamic symbols used by a binary executable and disassemble its code.
When it finds a call to one of the supported option-parsing functions below, optenum will attempt to reconstitute the arguments passed as part of the call and, in the event the argument(s) that describes valid options has successfully been retrieved and points to a chunk of data hardcoded in the binary, finally parses it and exposes options to the user.
optenum(1) never executes foreign code and doesn't rely on any particular behaviour in the target binary. No usage message? No problem!
There are several moving parts and optenum operates on a best-effort basis. When optenum can't retrieve options, it will try to fail gracefully and fail fast.
##Support
###Option parsing functions
optenum(1) extracts options from binary executables by relying on the assumption that the task of defining valid command line options is done through a call to one of the following supported functions:
Function | Library | Used by |
---|---|---|
getopt | libc | GNU Coreutils, systemd utils, GNU NetCat and many more POSIX-compliant tools |
getopt_long | ||
getopt_long_only | ||
g_option_context_add_main_entries | Glib | Gimp, Xchat,... |
poptGetContext | popt | Samba utils, logrotate, cryptsetup... |
###Architectures
optenum(1) only supports x86_64
argument passing conventions at this time.
##Contact
Please log any bugs you may encounter using the GitHub issue tracker or alternatively send a mail to mboyer <AT> sdf <DOT> org
.