pry0cc / axiom

The dynamic infrastructure framework for everybody! Distribute the workload of many different scanning tools with ease, including nmap, ffuf, masscan, nuclei, meg and many more!
MIT License
4k stars 622 forks source link

axiom-exec refactor #515

Closed 0xtavian closed 2 years ago

0xtavian commented 2 years ago

This brings a lot of new features and functionality with one small syntax change. By default execute on the instances listed in ~/.axiom/selected.conf, but to choose a different fleet or instance you now specify the instance/fleet with arguments -i/--instance or -f/--fleet.

this also brings a beta version of interactive command line execution, such as, I was able to run the following (as an illustrative example )

axiom-exec 'bash <(curl -s https://raw.githubusercontent.com/pry0cc/axiom/master/interact/axiom-configure)'

using axiom-exec to install axiom and interactively provide user input, like API keys and cloud provider details etc in real time. This also works with a fleet (press enter to cycle through the instances) but can be somewhat challenging atm however I was able to interactively configure 3 controllers simultaneously and run axiom-build etc all in one axiom-exec.

Description:
  Evaluate shell one-liners or execute single commands on one or more instances in parallel                                                                                                                       
  Expand local and remote environment variables respectively                                                                                                                                                      
  Specify the fleet prefix, or let axiom use selected.conf by default (located in ~/.axiom/selected.conf)                                                                                                         
  Optionally execute command(s) in a detached tmux session on the remote instances (commands run in the background)                                                                                               
  Temporarily prevent axiom's SSH key regeneration and instead connect with a cached SSH config (default is ~/.axiom/.sshconfig)                                                                                  
Examples:                                                                                                                                                                                                         
  axiom-exec id # Execute command id across all instances currently selected.conf (located in ~/.axiom/selected.conf)
  axiom-exec 'sleep $(($RANDOM % 10)) && echo done' --instance testy01 # Evaluate complex one-liners on instance named tasty01
  axiom-exec ifconfig --fleet testy # Execute ifconfig on testy fleet. Automatically select all instances in fleet testy.
  axiom-exec 'sleep 10' -q --cache --fleet OtherFleet --tmux MySession01 # Quietly execute command(s) inside a detacted tmux session on the remote instances with custom session name.
  axiom-exec whoami -q --cache --sshconfig ~/.axiom/log/exec/axiom-exec+1234567890/sshconfig --fleet oldfleet --tmux # Specify the axiom SSH config to use (default is ~/.axiom/.sshconfig)
Usage:
  <commands> required string
    Command(s) to run on the remote axiom instances, multiple commands must be wrapped in single or double quotes.
  -f/--fleet <fleet prefix>
    Fleet prefix to execute on (default is ~/.axiom/selected.conf). Automatic wildcard support.
  -i/--instance <instance name>
    Single instance to execute on.
  --tmux <optional tmux session name>
    Execute commands in a detacted tmux session (commands run in the background). The default tmux session name is axiom-exec+$TIMESTAMP, or supply a custom tmux session name.
  --sshconfig <sshconfig_file> (optional string)
    Path to axiom's SSH config (default is ~/.axiom/.sshconfig)
  -q/--quiet
    Disable progress bar, and reduce verbosity
  --debug
    Enable debug mode (VERY VERBOSE!)
  --cache
    Temporarily do not generate SSH config and instead connect with cached SSH config
  --logs
    Do not delete logs (logs will be stored in ~/.axiom/logs/exec/axiom-exec$TIMESTAMP).
  --help
    Display this help menu

new-axiom-exec-help-menu