Skip to content

Interactive Session

Once the tool starts with sudo bettercap, you’ll see an interactive session (Metasploit-style). Here you can run commands, enable or disable modules, and get or set parameters. See command line arguments for all options.

Functionalities are organized into:

  • Core commands: Basic operations like setting parameters, getting values, and clearing the screen
  • Session modules: Feature-specific sub commands that use session parameters for configuration

You can also script your interactive session using caplets. Caplets are script files with a .cap extension. Think of them like Metasploit’s .rc files. Each line is a command that executes at runtime.

For instance, a simple caplet that sets the ticker.commands parameter and enables the net.probe and ticker modules would be:

example.cap
set ticker.commands 'clear; net.show; events.show 10'
net.probe on
ticker on

Once saved as an example.cap file, you’ll be able to load and execute it via:

Terminal window
sudo bettercap -caplet /path/to/example.cap

It is also possible to load a caplet by name, without its path and extension:

Terminal window
sudo bettercap -caplet example

In this case the search order will be:

  1. ./example.cap
  2. ./caplets/example.cap
  3. Any folder in the environment variable $CAPSPATH (values are separated by :, like for $PATH).
  4. /usr/local/share/bettercap/caplets/example.cap (the default path where caplets are installed).

You can install or update the predefined caplets from the caplets repository. Use the caplet module from the command line:

Terminal window
sudo bettercap -eval "caplets.update; q"

Or simply from the interactive session:

Terminal window
caplets.update

You can then check what’s been installed in /usr/local/share/bettercap/caplets/ with the command:

Terminal window
caplets.show

The basic command line arguments ( bettercap -h ) are:

A comma separated list of modules that are automatically started (default to events.stream).

Read commands from this file and execute them in the interactive session.

Specify an alternative base path for caplets.

Run one or more commands separated by ; in the interactive session, used to set variables via command line.

Load a session script.

Network interface to bind to. If empty, the default interface is auto-selected. Accepts interface name, IP, or MAC address.

Use the provided IP address instead of the default gateway. If not specified or invalid, the default gateway is auto-detected.

Disable the interactive session history file ~/.bettercap.history.

Disable terminal colors and effects.

Preload parameter values from this file if found. Set to empty to disable environment persistence. Default: ~/bettercap.env.

Suppress all logs which are not errors.

Write a CPU profile file when exiting (used for debugging and benchmarking).

Write memory profile file when exiting (used for debugging and benchmarking).

Enable debug messages (must be used to report bugs).

Print version and build information, then exit (must be used to report bugs).

Will list all available commands and print the name of each module and its status (running or not running).

Will print the module specific help menu, with its sub commands and parameters.

Show which modules are running and their parameters.

Close the session and exit.

Sleep for the given amount of seconds.

Get the value of the specified parameter, use * for all.

Set the value of PARAMETER to VALUE, use "" or '' to clear its contents.

Show a PROMPT to ask the user for input that will be saved inside PARAMETER.

Clear the screen.

Load and run this caplet in the current session. You can also just specify the caplet name as a command.

Execute a shell command and print its output into the session.

Assign an alias to a given endpoint given its MAC address (will be persistent on ~/bettercap.aliases).

The interactive session prompt can be modified by setting the $ variable. For instance:

Terminal window
set $ something

This sets the prompt to the string something.

You can also access parameters and use colors/effects with special operators. See the $ parameter default value:

get $
{by}{fw}{cidr} {fb}{env.iface.ipv4} {reset} {bold}» {reset}

The available effects are:

OperatorDescription
{bold}Set text to bold.
{dim}Set dim effect on text.
{r}Set text foreground color to red.
{g}Set text foreground color to green.
{b}Set text foreground color to blue.
{y}Set text foreground color to yellow.
{fb}Set text foreground color to black.
{fw}Set text foreground color to white.
{bdg}Set text background color to dark gray.
{br}Set text background color to red.
{bg}Set text background color to green.
{by}Set text background color to yellow.
{blb}Set text background color to light blue.
{reset}Reset text effects (added by default at the end of the prompt if not specified).

There are also other operators you can use in order to access specific information about the session.

OperatorDescription
{cidr}Selected interface subnet CIDR.
{net.sent}Number of bytes being sent by the tool on the network.
{net.sent.human}Number of bytes being sent by the tool on the network (human readable form).
{net.errors}Number of errors while sending packets.
{net.received}Number of bytes being sniffed from the tool on the network.
{net.received.human}Number of bytes being sniffed from the tool from the network (human readable form).
{net.packets}Number of packets being sniffed by the tool from the network.

You can also access any session variable using the {env.NAME-OF-THE-VAR} operator.

For example, the default prompt uses {env.iface.ipv4}. This is replaced by the iface.ipv4 session variable contents. Check it with get iface.ipv4.

Set the arp.spoof.targets parameter and enable the arp.spoof module:

Terminal window
sudo bettercap -eval "set arp.spoof.targets 192.168.1.20; arp.spoof on"

To quickly get a module’s help menu and quit (like a man command), use -eval:

Terminal window
sudo bettercap -eval "help net.recon; q"

Ask the user to fill the arp.spoof.targets parameter:

Terminal window
read arp.spoof.targets "Select the target to spoof: "

Set the alias “MY IPAD” to the device with MAC address DE:AD:DE:AD:BE:EF:

Terminal window
alias DE:AD:DE:AD:BE:EF MY IPAD