scapy.config

Implementation of the configuration object.

class scapy.config.CacheInstance(name='noname', timeout=None)

Bases: dict, object

flush()
get(item, default=None)
items()
iteritems()
iterkeys()
itervalues()
keys()
name
summary()
timeout
update(other)
values()
class scapy.config.CommandsList

Bases: list

register(cmd)
class scapy.config.Conf

Bases: scapy.config.ConfClass

This object contains the configuration of Scapy.

session

filename where the session will be saved

interactive_shell

can be “ipython”, “python” or “auto”. Default: Auto

stealth

if 1, prevents any unwanted packet to go out (ARP, DNS, …)

checkIPID

if 0, doesn’t check that IPID matches between IP sent and ICMP IP citation received if 1, checks that they either are equal or byte swapped equals (bug in some IP stacks) if 2, strictly checks that they are equals

checkIPsrc

if 1, checks IP src in IP and ICMP IP citation match (bug in some NAT stacks)

checkIPinIP

if True, checks that IP-in-IP layers match. If False, do not check IP layers that encapsulates another IP layer

check_TCPerror_seqack

if 1, also check that TCP seq and ack match the ones in ICMP citation

iff

selects the default output interface for srp() and sendp().

verb

level of verbosity, from 0 (almost mute) to 3 (verbose)

promisc

default mode for listening socket (to get answers if you spoof on a lan)

sniff_promisc

default mode for sniff()

filter

bpf filter added to every sniffing socket to exclude traffic from analysis

histfile

history file

padding

includes padding in disassembled packets

except_filter

BPF filter for packets to ignore

debug_match

when 1, store received packet that are not matched into debug.recv

route

holds the Scapy routing table and provides methods to manipulate it

warning_threshold

how much time between warnings from the same place

ASN1_default_codec

Codec used by default for ASN1 objects

mib

holds MIB direct access dictionary

resolve

holds list of fields for which resolution should be done

noenum

holds list of enum fields for which conversion to string should NOT be done

AS_resolver

choose the AS resolver class to use

extensions_paths

path or list of paths where extensions are to be looked for

contribs

a dict which can be used by contrib layers to store local configuration

debug_tls

When 1, print some TLS session secrets when they are computed.

recv_poll_rate

how often to check for new packets. Defaults to 0.05s.

raise_no_dst_mac

When True, raise exception if no dst MAC found otherwise broadcast. Default is False.

BTsocket = None
L2listen = None
L2socket = None
L3socket = None
L3socket6 = None
USBsocket = None
auto_crop_tables = True
auto_fragment = True
bufsize = 65536
cache_iflist = {}
checkIPID = False
checkIPaddr = True
checkIPinIP = True
checkIPsrc = True
check_TCPerror_seqack = False
color_theme
commands = bind_layers : Bind 2 layers on some specific fields' values. bridge_and_sniff : Forward traffic between interfaces if1 and if2, sniff and return chexdump : Build a per byte hexadecimal representation corrupt_bits : Flip a given percentage or number of bits from a string corrupt_bytes : Corrupt a given percentage or number of bytes from a string explore : Function used to discover the Scapy layers and protocols. fletcher16_checkbytes: Calculates the Fletcher-16 checkbytes returned as 2 byte binary-string. fletcher16_checksum : Calculates Fletcher-16 checksum of the given buffer. fuzz : hexdiff : Show differences between 2 binary strings hexdump : Build a tcpdump like hexadecimal view hexedit : Run hexedit on a list of packets, then return the edited packets. hexstr : Build a fancy tcpdump like hex from bytes. import_hexcap : Imports a tcpdump like hexadecimal view linehexdump : Build an equivalent view of hexdump() on a single line ls : List available layers, or infos on a given layer class or name. rdpcap : Read a pcap or pcapng file and return a packet list restart : Restarts scapy send : sendp : sendpfast : Send packets at layer 2 using tcpreplay for performance sniff : split_layers : Split 2 layers previously bound. sr : sr1 : sr1flood : Flood and receive packets at layer 3 and return only the first answer srflood : Flood and receive packets at layer 3 srloop : Send a packet at layer 3 in loop and print the answer each time srp : srp1 : srp1flood : Flood and receive packets at layer 2 and return only the first answer srpflood : Flood and receive packets at layer 2 srploop : Send a packet at layer 2 in loop and print the answer each time tcpdump : Run tcpdump or tshark on a list of packets. tdecode : tshark : Sniff packets and print them calling pkt.summary(). wireshark : wrpcap : Write a list of packets to a pcap file
contribs = {}
crypto_valid = False
crypto_valid_advanced = False
crypto_valid_recent = False
debug_dissector = False
debug_match = False
debug_tls = False
default_l2 = None
dot15d4_protocol = None
emph = <Emphasize []>
except_filter = ''
extensions_paths = '.'
fancy_prompt = True
geoip_city = None
histfile = '/home/docs/.scapy_history'
iface = None
iface6 = None
interactive = False
interactive_shell = ''
ipv6_enabled = True
l2types =
l3types =
layers = Packet : <member 'name' of 'Packet' objects> NoPayload : <member 'name' of 'Packet' objects> Raw : <member 'name' of 'Packet' objects> Padding : <member 'name' of 'Packet' objects> ASN1_Packet : <member 'name' of 'Packet' objects>
load_layers = ['bluetooth', 'bluetooth4LE', 'dhcp', 'dhcp6', 'dns', 'dot11', 'dot15d4', 'eap', 'gprs', 'hsrp', 'inet', 'inet6', 'ipsec', 'ir', 'isakmp', 'l2', 'l2tp', 'llmnr', 'lltd', 'mgcp', 'mobileip', 'netbios', 'netflow', 'ntp', 'ppi', 'ppp', 'pptp', 'radius', 'rip', 'rtp', 'sctp', 'sixlowpan', 'skinny', 'smb', 'snmp', 'tftp', 'vrrp', 'vxlan', 'x509', 'zigbee']
logLevel
min_pkt_size = 60
netcache =
noenum = <Resolve []>
padding = 1
prog = display = 'display' dot = 'dot' hexedit = 'hexer' ifconfig = 'ifconfig' pdfreader = 'xdg-open' psreader = 'xdg-open' svgreader = 'xdg-open' tcpdump = 'tcpdump' tcpreplay = 'tcpreplay' tshark = 'tshark' universal_open = 'xdg-open' wireshark = 'wireshark'
promisc = True
prompt
raise_no_dst_mac = False
raw_layer = None
raw_summary = False
recv_poll_rate = 0.05
resolve = <Resolve []>
route = None
route6 = None
session = ''
sniff_promisc = 1
stats_classic_protocols = []
stats_dot11_protocols = []
stealth = 'not implemented'
temp_files = []
use_bpf
use_dnet = False
use_npcap = False
use_pcap
use_pypy
verb = 2
version
warning_threshold = 5
wepkey = ''
class scapy.config.ConfClass

Bases: object

configure(cnf)
class scapy.config.ConfigFieldList

Bases: object

add(*flds)
remove(*flds)
class scapy.config.Emphasize

Bases: scapy.config.ConfigFieldList

class scapy.config.Interceptor(name=None, default=None, hook=None, args=None, kargs=None)

Bases: object

static set_from_hook(obj, name, val)
class scapy.config.LayersList

Bases: list

layers()
register(layer)
class scapy.config.NetCache

Bases: object

add_cache(cache)
flush()
new_cache(name, timeout=None)
update(other)
class scapy.config.Num2Layer

Bases: object

get(item, default=None)
register(num, layer)
register_layer2num(num, layer)
register_num2layer(num, layer)
class scapy.config.ProgPath

Bases: scapy.config.ConfClass

display = 'display'
dot = 'dot'
hexedit = 'hexer'
ifconfig = 'ifconfig'
pdfreader = 'xdg-open'
psreader = 'xdg-open'
svgreader = 'xdg-open'
tcpdump = 'tcpdump'
tcpreplay = 'tcpreplay'
tshark = 'tshark'
universal_open = 'xdg-open'
wireshark = 'wireshark'
class scapy.config.Resolve

Bases: scapy.config.ConfigFieldList

scapy.config.crypto_validator(func)

This a decorator to be used for any method relying on the cryptography library. # noqa: E501 Its behaviour depends on the ‘crypto_valid’ attribute of the global ‘conf’.

scapy.config.isCryptographyAdvanced()

Check if the cryptography library is present, and if it supports X25519, ChaCha20Poly1305 and such (v2.0 or later).

scapy.config.isCryptographyRecent()

Check if the cryptography library is recent (2.0 and later)

scapy.config.isCryptographyValid()

Check if the cryptography library is present, and if it is recent enough for most usages in scapy (v1.7 or later).

scapy.config.isPyPy()

Returns either scapy is running under PyPy or not

scapy.config.lsc()

Displays Scapy’s default commands