events.stream

This module is enabled by default and is responsible for reporting events (logs, new hosts being found, etc) generated by other modules during the interactive session. Moreover, it can be used to programmatically execute commands when specific events occur.

Events

Each module can generate an event with a custom payload and a unique identifier / tag depending on its meaning:

event iddescription
sys.logSimple log message event.
session.startedThe session started.
session.closingThe session is stopping.
update.availableAn update is available.
mod.startedA specific module started.
mod.stoppedA specific module stopped.
tickAn event generated by the ticker module.
gateway.changeIPv4 or IPv6 gateway change detected.
endpoint.newA new network host has been discovered.
endpoint.lostA previously discovered network host disconnected from this network.
wifi.ap.newA new WiFi access point has been discovered.
wifi.ap.lostA previously discovered WiFi access point is not in range anymore.
wifi.client.newA new WiFi client station has been discovered.
wifi.client.lostA previously discovered WiFi client station disconnected from its AP.
wifi.client.probeA WiFi client station is sending a probe for an ESSID.
wifi.client.handshakeWPA/WPA2 key material has been captured.
wifi.client.deauthenticationWPA/WPA2 deauthentication frame has been detected.
ble.device.newA new BLE device has been discovered.
ble.device.lostA previously discovered BLE device is not in range anymore.
ble.device.service.discoveredA new service has been discovered for a BLE device.
ble.device.characteristic.discoveredA new characteristic has been discovered for a BLE device.
ble.device.connectedConnected to the selected BLE device.
ble.connection.timeoutConnection to the specified BLE device timed out.
hid.device.newA new wireless HID device has been discovered.
hid.device.lostA previously discovered wireless HID device is not in range anymore.
http.spoofed-requestA HTTP request has been changed by a proxy module.
http.spoofed-responseA HTTP response has been changed by a proxy module.
https.spoofed-requestA HTTPS request has been changed by a proxy module.
https.spoofed-responseA HTTPS response has been changed by a proxy module.
syn.scanAn open port has been found on the target host.
net.sniff.*A new payload has been sniffed.

Basic Module Commands

events.stream on

Start the events stream.

events.stream off

Stop the events stream.

events.show LIMIT?

Show the events stream ( LIMIT is an optional parameter ).

events.ignore FILTER

Events with an identifier matching this filter will not be shown (use multiple times to add more filters).

events.include FILTER

Used to remove filters passed with the events.ignore command.

events.filters.clear

Clear the list of filters passed with the events.ignore command.

events.clear

Clear the events stream buffer.

Advanced Module Commands

events.waitfor TAG TIMEOUT?

Wait for an event with the given tag either forever or for a timeout in seconds.

events.on TAG COMMANDS

Define a new “trigger” that will run COMMANDS when an event with the specified TAG is triggered. Inside the COMMANDS parameter it is possible to use placeholders that will be replaced with the relative field of the event’s payload (it supports XPath queries on JSON between brackets).

events.triggers

Show the list of event triggers created by the events.on command.

events.trigger.delete TRIGGER_ID

Remove an event trigger given its TRIGGER_ID (use events.triggers to see the list of triggers).

events.triggers.clear

Remove all event triggers (use events.triggers to see the list of triggers).

Parameters

parameterdefaultdescription
events.stream.outputIf not empty, events will be written to this file instead of the standard output.
events.stream.time.format15:04:05Date and time format to use for events reporting.
events.stream.output.rotatetrueIf true will enable log rotation.
events.stream.output.rotate.compresstrueIf true will enable log rotation compression.
events.stream.output.rotate.howsizeRotate by size or time.
events.stream.output.rotate.when10485760File size or time duration in seconds for log rotation.
events.stream.output.rotate.format2006-01-02 15:04:05Datetime format to use for log rotation file names.
events.stream.http.request.dumpfalseIf true all HTTP requests will be dumped.
events.stream.http.response.dumpfalseIf true all HTTP responses will be dumped.

Examples

Start bettercap with full date and time format for events:

  1. sudo bettercap -eval "set events.stream.time.format Mon Jan 2 15:04:05 -0700 MST 2006"

Show every event:

  1. > events.show

Show the last 5 events, sleep one second and then clear the buffer:

  1. > events.show 5; sleep 1; events.clear

Ignore the endpoint.lost event:

  1. > events.ignore endpoint.lost

Re enable the endpoint.lost event:

  1. > events.include endpoint.lost

Start discovering BLE devices and wait that at least one is detected:

  1. > ble.recon on; events.waitfor ble.device.new

Same thing but with a 10 seconds timeout:

  1. > ble.recon on; events.waitfor ble.device.new 10

Whenever a new WiFi client station is discovered, launch a deauthentication attack and, whenever a new WiFi access point is discovered, try to associate to it:

  1. > events.on wifi.client.new wifi.deauth {{Client/mac}}
  2. > events.on wifi.ap.new wifi.assoc {{mac}}

Start bettercap without colors and terminal effects and write events to the file ~/bettercap-events.log:

  1. sudo bettercap -no-colors -eval "set events.stream.output ~/bettercap-events.log"