Fields that hold random numbers.

class scapy.volatile.AutoTime(base: Optional[int] = None, diff: Optional[float] = None)[source]

Bases: _AutoTime[float]

class scapy.volatile.CorruptedBits(s: str, p: float = 0.01, n: Optional[Any] = None)[source]

Bases: CorruptedBytes

class scapy.volatile.CorruptedBytes(s: str, p: float = 0.01, n: Optional[Any] = None)[source]

Bases: VolatileValue[bytes]

class scapy.volatile.CyclicPattern(size: Optional[int] = None, start: int = 0, charset_type: Optional[int] = None)[source]

Bases: VolatileValue[bytes]

Generate a cyclic pattern

  • size – Size of generated pattern. Default is random size.

  • start – Start offset of the generated pattern.

  • charset_type – Charset types: 0: basic (0-9A-Za-z) 1: extended 2: maximum (almost printable chars)

The code of this class was inspired by

PEDA - Python Exploit Development Assistance for GDB Copyright (C) 2012 Long Le Dinh <longld at> License: This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

static cyclic_pattern_charset(charset_type: Optional[int] = None) str[source]

charset_type – charset type 0: basic (0-9A-Za-z) 1: extended (default) 2: maximum (almost printable chars)


list of charset

static de_bruijn(charset: str, n: int, maxlen: int) str[source]

Generate the De Bruijn Sequence up to maxlen characters for the charset charset and subsequences of length n. Algorithm modified from wikipedia

class scapy.volatile.DelayedEval(expr: str)[source]

Bases: VolatileValue[Any]

Example of usage: DelayedEval(“time.time()”)

class scapy.volatile.GeneralizedTime(diff: int = 0)[source]

Bases: _AutoTime[str]

class scapy.volatile.IncrementalValue(start: int = 0, step: int = 1, restart: int = - 1)[source]

Bases: VolatileValue[int]

class scapy.volatile.IntAutoTime(base: Optional[int] = None, diff: Optional[float] = None)[source]

Bases: _AutoTime[int]

class scapy.volatile.RandBin(size: Optional[Union[int, RandNum]] = None)[source]

Bases: RandString

class scapy.volatile.RandBinFloat(min: int, max: int)[source]

Bases: RandFloat

class scapy.volatile.RandByte[source]

Bases: RandNum

class scapy.volatile.RandChoice(*args: Any)[source]

Bases: RandField[Any]

class scapy.volatile.RandEnum(min: int, max: int, seed: Optional[int] = None)[source]

Bases: RandNum

Instances evaluate to integer sampling without replacement from the given interval

class scapy.volatile.RandEnumByte[source]

Bases: RandEnum

class scapy.volatile.RandEnumInt[source]

Bases: RandEnum

class scapy.volatile.RandEnumKeys(enum: Dict[Any, Any], seed: Optional[int] = None)[source]

Bases: RandEnum

Picks a random value from dict keys list.

class scapy.volatile.RandEnumLong[source]

Bases: RandEnum

class scapy.volatile.RandEnumSByte[source]

Bases: RandEnum

class scapy.volatile.RandEnumSInt[source]

Bases: RandEnum

class scapy.volatile.RandEnumSLong[source]

Bases: RandEnum

class scapy.volatile.RandEnumSShort[source]

Bases: RandEnum

class scapy.volatile.RandEnumShort[source]

Bases: RandEnum

class scapy.volatile.RandField[source]

Bases: VolatileValue[_T], Generic[_T]

class scapy.volatile.RandFloat(min: int, max: int)[source]

Bases: _RandNumeral[float]

class scapy.volatile.RandIP(iptemplate: str = '')[source]

Bases: _RandString[str]

class scapy.volatile.RandIP6(ip6template: str = '**')[source]

Bases: _RandString[str]

class scapy.volatile.RandInt[source]

Bases: RandNum

class scapy.volatile.RandLong[source]

Bases: RandNum

class scapy.volatile.RandMAC(_template: str = '*')[source]

Bases: _RandString[str]

class scapy.volatile.RandNum(min: int, max: int)[source]

Bases: _RandNumeral[int]

Instances evaluate to random integers in selected range

max = 0
min = 0
class scapy.volatile.RandNumExpo(lambd: float, base: int = 0)[source]

Bases: RandNum

class scapy.volatile.RandNumGamma(alpha: int, beta: int)[source]

Bases: RandNum

class scapy.volatile.RandNumGauss(mu: int, sigma: int)[source]

Bases: RandNum

class scapy.volatile.RandOID(fmt: ~typing.Optional[str] = None, depth: ~scapy.volatile.RandNumExpo = <RandNumExpo>, idnum: ~scapy.volatile.RandNumExpo = <RandNumExpo>)[source]

Bases: _RandString[str]

class scapy.volatile.RandPool(*args: Tuple[VolatileValue[Any], int])[source]

Bases: RandField[VolatileValue[Any]]

class scapy.volatile.RandRegExp(regexp: str, lambda_: float = 0.3)[source]

Bases: RandField[str]

static choice_expand(s: str) str[source]
special_sets = {'[:alnum:]': '[a-zA-Z0-9]', '[:alpha:]': '[a-zA-Z]', '[:ascii:]': '[\x00-\x7f]', '[:blank:]': '[ \t]', '[:cntrl:]': '[\x00-\x1f\x7f]', '[:digit:]': '[0-9]', '[:graph:]': '[!-~]', '[:lower:]': '[a-z]', '[:print:]': '[ -~]', '[:punct:]': '[!"\\#$%&\'()*+,\\-./:;<=>?@\\[\\\\\\]^_{|}~]', '[:space:]': '[ \t\r\n\x0b\x0c]', '[:upper:]': '[A-Z]', '[:word:]': '[A-Za-z0-9_]', '[:xdigit:]': '[A-Fa-f0-9]'}
static stack_fix(lst: List[Any], index: List[Any]) str[source]
class scapy.volatile.RandSByte[source]

Bases: RandNum

class scapy.volatile.RandSInt[source]

Bases: RandNum

class scapy.volatile.RandSLong[source]

Bases: RandNum

class scapy.volatile.RandSShort[source]

Bases: RandNum

class scapy.volatile.RandShort[source]

Bases: RandNum

class scapy.volatile.RandSingByte[source]

Bases: RandSingNum

class scapy.volatile.RandSingInt[source]

Bases: RandSingNum

class scapy.volatile.RandSingLong[source]

Bases: RandSingNum

class scapy.volatile.RandSingNum(mn: int, mx: int)[source]

Bases: RandSingularity

static make_power_of_two(end: int) Set[int][source]
class scapy.volatile.RandSingSByte[source]

Bases: RandSingNum

class scapy.volatile.RandSingSInt[source]

Bases: RandSingNum

class scapy.volatile.RandSingSLong[source]

Bases: RandSingNum

class scapy.volatile.RandSingSShort[source]

Bases: RandSingNum

class scapy.volatile.RandSingShort[source]

Bases: RandSingNum

class scapy.volatile.RandSingString[source]

Bases: RandSingularity

class scapy.volatile.RandSingularity(*args: Any)[source]

Bases: RandChoice

class scapy.volatile.RandString(size: Optional[Union[int, RandNum]] = None, chars: bytes = b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')[source]

Bases: _RandString[bytes]

class scapy.volatile.RandTermString(size: Union[int, RandNum], term: bytes)[source]

Bases: RandBin

class scapy.volatile.RandUUID(template: Optional[Any] = None, node: Optional[int] = None, clock_seq: Optional[int] = None, namespace: Optional[UUID] = None, name: Optional[str] = None, version: Optional[Any] = None)[source]

Bases: RandField[UUID]

Generates a random UUID.

By default, this generates a RFC 4122 version 4 UUID (totally random).

See Python’s uuid module documentation for more information.

  • template (optional) – A template to build the UUID from. Not valid with any other option.

  • node (optional) – A 48-bit Host ID. Only valid for version 1 (where it is optional).

  • clock_seq (optional) – An integer of up to 14-bits for the sequence number. Only valid for version 1 (where it is optional).

  • namespace – A namespace identifier, which is also a UUID. Required for versions 3 and 5, must be omitted otherwise.

  • name – string, required for versions 3 and 5, must be omitted otherwise.

  • version – Version of UUID to use (1, 3, 4 or 5). If omitted, attempts to guess which version to generate, defaulting to version 4 (totally random).


ValueError – on invalid constructor arguments

VERSIONS = [1, 3, 4, 5]
class scapy.volatile.RandomEnumeration(inf: int, sup: int, seed: Optional[int] = None, forever: int = 1, renewkeys: int = 0)[source]

Bases: object

iterate through a sequence in random order. When all the values have been drawn, if forever=1, the drawing is done again. # noqa: E501 If renewkeys=0, the draw will be in the same order, guaranteeing that the same # noqa: E501 number will be drawn in not less than the number of integers of the sequence

next() int[source]
class scapy.volatile.VolatileValue[source]

Bases: Generic[_T]

command() str[source]
copy() Any[source]
class scapy.volatile.ZuluTime(diff: int = 0)[source]

Bases: _AutoTime[str]