scapy.volatile

Fields that hold random numbers.

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

Bases: scapy.volatile._AutoTime[float]

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

Bases: scapy.volatile.CorruptedBytes

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

Bases: scapy.volatile.VolatileValue[bytes]

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

Bases: scapy.volatile.VolatileValue[Any]

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

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

Bases: scapy.volatile._AutoTime[str]

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

Bases: scapy.volatile.VolatileValue[int]

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

Bases: scapy.volatile._AutoTime[int]

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

Bases: scapy.volatile.RandString

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

Bases: scapy.volatile.RandFloat

class scapy.volatile.RandByte[source]

Bases: scapy.volatile.RandNum

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

Bases: scapy.volatile.RandField[Any]

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

Bases: scapy.volatile.RandNum

Instances evaluate to integer sampling without replacement from the given interval

class scapy.volatile.RandEnumByte[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandEnumInt[source]

Bases: scapy.volatile.RandEnum

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

Bases: scapy.volatile.RandEnum

Picks a random value from dict keys list.

class scapy.volatile.RandEnumLong[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandEnumSByte[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandEnumSInt[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandEnumSLong[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandEnumSShort[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandEnumShort[source]

Bases: scapy.volatile.RandEnum

class scapy.volatile.RandField[source]

Bases: scapy.volatile.VolatileValue[scapy.volatile._T], Generic[scapy.volatile._T]

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

Bases: scapy.volatile._RandNumeral[float]

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

Bases: scapy.volatile._RandString[str]

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

Bases: scapy.volatile._RandString[str]

class scapy.volatile.RandInt[source]

Bases: scapy.volatile.RandNum

class scapy.volatile.RandLong[source]

Bases: scapy.volatile.RandNum

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

Bases: scapy.volatile._RandString[str]

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

Bases: scapy.volatile._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: scapy.volatile.RandNum

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

Bases: scapy.volatile.RandNum

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

Bases: scapy.volatile.RandNum

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

Bases: scapy.volatile._RandString[str]

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

Bases: scapy.volatile.RandField[scapy.volatile.VolatileValue[Any]]

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

Bases: scapy.volatile.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: scapy.volatile.RandNum

class scapy.volatile.RandSInt[source]

Bases: scapy.volatile.RandNum

class scapy.volatile.RandSLong[source]

Bases: scapy.volatile.RandNum

class scapy.volatile.RandSShort[source]

Bases: scapy.volatile.RandNum

class scapy.volatile.RandShort[source]

Bases: scapy.volatile.RandNum

class scapy.volatile.RandSingByte[source]

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingInt[source]

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingLong[source]

Bases: scapy.volatile.RandSingNum

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

Bases: scapy.volatile.RandSingularity

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

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingSInt[source]

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingSLong[source]

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingSShort[source]

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingShort[source]

Bases: scapy.volatile.RandSingNum

class scapy.volatile.RandSingString[source]

Bases: scapy.volatile.RandSingularity

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

Bases: scapy.volatile.RandChoice

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

Bases: scapy.volatile._RandString[bytes]

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

Bases: scapy.volatile.RandBin

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

Bases: scapy.volatile.RandField[uuid.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.

Parameters
  • 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).

Raises

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[scapy.volatile._T]

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

Bases: scapy.volatile._AutoTime[str]