Skip to content

Commit

Permalink
Scapy terminal improvements (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 authored Jul 31, 2023
1 parent 204605b commit 7fced60
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 71 deletions.
8 changes: 4 additions & 4 deletions doc/scapy.1
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ increase log verbosity. Can be used many times.
use FILE to save/load session values (variables, functions, instances, ...)
.TP
\fB\-p\fR PRESTART_FILE
use PRESTART_FILE instead of $HOME/.scapy_prestart.py as pre-startup file
use PRESTART_FILE instead of $HOME/.config/scapy/prestart.py as pre-startup file
.TP
\fB\-P\fR
do not run prestart file
.TP
\fB\-c\fR STARTUP_FILE
use STARTUP_FILE instead of $HOME/.scapy_startup.py as startup file
use STARTUP_FILE instead of $HOME/.config/scapy/startup.py as startup file
.TP
\fB\-C\fR
do not run startup file
Expand All @@ -82,7 +82,7 @@ lists scapy's main user commands.
this object contains the configuration.

.SH FILES
\fB$HOME/.scapy_prestart.py\fR
\fB$HOME/.config/scapy/prestart.py\fR
This file is run before Scapy core is loaded. Only the \fBconf\fP object
is available. This file can be used to manipulate \fBconf.load_layers\fP
list to choose which layers will be loaded:
Expand All @@ -92,7 +92,7 @@ conf.load_layers.remove("bluetooth")
conf.load_layers.append("new_layer")
.fi

\fB$HOME/.scapy_startup.py\fR
\fB$HOME/.config/scapy/startup.py\fR
This file is run after Scapy is loaded. It can be used to configure
some of the Scapy behaviors:

Expand Down
Binary file not shown.
19 changes: 1 addition & 18 deletions doc/scapy/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,13 @@ some features will not be available::

The basic features of sending and receiving packets should still work, though.


Customizing the Terminal
------------------------

Before you actually start using Scapy, you may want to configure Scapy to properly render colors on your terminal. To do so, set ``conf.color_theme`` to one of of the following themes::

DefaultTheme, BrightTheme, RastaTheme, ColorOnBlackTheme, BlackAndWhite, HTMLTheme, LatexTheme

For instance::

conf.color_theme = BrightTheme()

.. image:: graphics/animations/animation-scapy-themes-demo.gif
:align: center

Other parameters such as ``conf.prompt`` can also provide some customization. Note Scapy will update the shell automatically as soon as the ``conf`` values are changed.


Interactive tutorial
====================

This section will show you several of Scapy's features with Python 2.
Just open a Scapy session as shown above and try the examples yourself.

.. note:: You can configure the Scapy terminal by modifying the ``~/.config/scapy/prestart.py`` file.

First steps
-----------
Expand Down
15 changes: 11 additions & 4 deletions scapy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,11 @@ class Conf(ConfClass):
version = ReadOnlyAttribute("version", VERSION)
session = "" #: filename where the session will be saved
interactive = False
#: can be "ipython", "python" or "auto". Default: Auto
interactive_shell = ""
#: can be "ipython", "bpython", "ptpython", "ptipython", "python" or "auto".
#: Default: Auto
interactive_shell = "auto"
#: Configuration for "ipython" to use jedi (disabled by default)
ipython_use_jedi = False
#: if 1, prevents any unwanted packet to go out (ARP, DNS, ...)
stealth = "not implemented"
#: selects the default output interface for srp() and sendp().
Expand Down Expand Up @@ -768,7 +771,8 @@ class Conf(ConfClass):
#: history file
histfile = os.getenv('SCAPY_HISTFILE',
os.path.join(os.path.expanduser("~"),
".scapy_history"))
".config", "scapy",
"history"))
#: includes padding in disassembled packets
padding = 1
#: BPF filter for packets to ignore
Expand Down Expand Up @@ -889,7 +893,10 @@ class Conf(ConfClass):
contribs = dict() # type: Dict[str, Any]
crypto_valid = isCryptographyValid()
crypto_valid_advanced = isCryptographyAdvanced()
fancy_prompt = True
#: controls whether or not to display the fancy banner
fancy_banner = True
#: controls whether tables (conf.iface, conf.route...) should be cropped
#: to fit the terminal
auto_crop_tables = True
#: how often to check for new packets.
#: Defaults to 0.05s.
Expand Down
Loading

0 comments on commit 7fced60

Please sign in to comment.