repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
secdev/scapy | scapy/layers/tls/crypto/prf.py | PRF.derive_key_block | def derive_key_block(self, master_secret, server_random,
client_random, req_len):
"""
Perform the derivation of master_secret into a key_block of req_len
requested length. See RFC 5246, section 6.3.
"""
seed = server_random + client_random
if self... | python | def derive_key_block(self, master_secret, server_random,
client_random, req_len):
"""
Perform the derivation of master_secret into a key_block of req_len
requested length. See RFC 5246, section 6.3.
"""
seed = server_random + client_random
if self... | [
"def",
"derive_key_block",
"(",
"self",
",",
"master_secret",
",",
"server_random",
",",
"client_random",
",",
"req_len",
")",
":",
"seed",
"=",
"server_random",
"+",
"client_random",
"if",
"self",
".",
"tls_version",
"<=",
"0x0300",
":",
"return",
"self",
"."... | Perform the derivation of master_secret into a key_block of req_len
requested length. See RFC 5246, section 6.3. | [
"Perform",
"the",
"derivation",
"of",
"master_secret",
"into",
"a",
"key_block",
"of",
"req_len",
"requested",
"length",
".",
"See",
"RFC",
"5246",
"section",
"6",
".",
"3",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L224-L234 | train |
secdev/scapy | scapy/layers/tls/crypto/prf.py | PRF.compute_verify_data | def compute_verify_data(self, con_end, read_or_write,
handshake_msg, master_secret):
"""
Return verify_data based on handshake messages, connection end,
master secret, and read_or_write position. See RFC 5246, section 7.4.9.
Every TLS 1.2 cipher suite has a v... | python | def compute_verify_data(self, con_end, read_or_write,
handshake_msg, master_secret):
"""
Return verify_data based on handshake messages, connection end,
master secret, and read_or_write position. See RFC 5246, section 7.4.9.
Every TLS 1.2 cipher suite has a v... | [
"def",
"compute_verify_data",
"(",
"self",
",",
"con_end",
",",
"read_or_write",
",",
"handshake_msg",
",",
"master_secret",
")",
":",
"if",
"self",
".",
"tls_version",
"<",
"0x0300",
":",
"return",
"None",
"elif",
"self",
".",
"tls_version",
"==",
"0x0300",
... | Return verify_data based on handshake messages, connection end,
master secret, and read_or_write position. See RFC 5246, section 7.4.9.
Every TLS 1.2 cipher suite has a verify_data of length 12. Note also:
"This PRF with the SHA-256 hash function is used for all cipher
suites defined i... | [
"Return",
"verify_data",
"based",
"on",
"handshake",
"messages",
"connection",
"end",
"master",
"secret",
"and",
"read_or_write",
"position",
".",
"See",
"RFC",
"5246",
"section",
"7",
".",
"4",
".",
"9",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L236-L294 | train |
secdev/scapy | scapy/layers/tls/crypto/prf.py | PRF.postprocess_key_for_export | def postprocess_key_for_export(self, key, client_random, server_random,
con_end, read_or_write, req_len):
"""
Postprocess cipher key for EXPORT ciphersuite, i.e. weakens it.
An export key generation example is given in section 6.3.1 of RFC 2246.
See als... | python | def postprocess_key_for_export(self, key, client_random, server_random,
con_end, read_or_write, req_len):
"""
Postprocess cipher key for EXPORT ciphersuite, i.e. weakens it.
An export key generation example is given in section 6.3.1 of RFC 2246.
See als... | [
"def",
"postprocess_key_for_export",
"(",
"self",
",",
"key",
",",
"client_random",
",",
"server_random",
",",
"con_end",
",",
"read_or_write",
",",
"req_len",
")",
":",
"s",
"=",
"con_end",
"+",
"read_or_write",
"s",
"=",
"(",
"s",
"==",
"\"clientwrite\"",
... | Postprocess cipher key for EXPORT ciphersuite, i.e. weakens it.
An export key generation example is given in section 6.3.1 of RFC 2246.
See also page 86 of EKR's book. | [
"Postprocess",
"cipher",
"key",
"for",
"EXPORT",
"ciphersuite",
"i",
".",
"e",
".",
"weakens",
"it",
".",
"An",
"export",
"key",
"generation",
"example",
"is",
"given",
"in",
"section",
"6",
".",
"3",
".",
"1",
"of",
"RFC",
"2246",
".",
"See",
"also",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L296-L323 | train |
secdev/scapy | scapy/layers/tls/crypto/prf.py | PRF.generate_iv_for_export | def generate_iv_for_export(self, client_random, server_random,
con_end, read_or_write, req_len):
"""
Generate IV for EXPORT ciphersuite, i.e. weakens it.
An export IV generation example is given in section 6.3.1 of RFC 2246.
See also page 86 of EKR's book.
... | python | def generate_iv_for_export(self, client_random, server_random,
con_end, read_or_write, req_len):
"""
Generate IV for EXPORT ciphersuite, i.e. weakens it.
An export IV generation example is given in section 6.3.1 of RFC 2246.
See also page 86 of EKR's book.
... | [
"def",
"generate_iv_for_export",
"(",
"self",
",",
"client_random",
",",
"server_random",
",",
"con_end",
",",
"read_or_write",
",",
"req_len",
")",
":",
"s",
"=",
"con_end",
"+",
"read_or_write",
"s",
"=",
"(",
"s",
"==",
"\"clientwrite\"",
"or",
"s",
"==",... | Generate IV for EXPORT ciphersuite, i.e. weakens it.
An export IV generation example is given in section 6.3.1 of RFC 2246.
See also page 86 of EKR's book. | [
"Generate",
"IV",
"for",
"EXPORT",
"ciphersuite",
"i",
".",
"e",
".",
"weakens",
"it",
".",
"An",
"export",
"IV",
"generation",
"example",
"is",
"given",
"in",
"section",
"6",
".",
"3",
".",
"1",
"of",
"RFC",
"2246",
".",
"See",
"also",
"page",
"86",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L325-L352 | train |
secdev/scapy | scapy/data.py | load_protocols | def load_protocols(filename, _integer_base=10):
""""Parse /etc/protocols and return values as a dictionary."""
spaces = re.compile(b"[ \t]+|\n")
dct = DADict(_name=filename)
try:
with open(filename, "rb") as fdesc:
for line in fdesc:
try:
shrp = li... | python | def load_protocols(filename, _integer_base=10):
""""Parse /etc/protocols and return values as a dictionary."""
spaces = re.compile(b"[ \t]+|\n")
dct = DADict(_name=filename)
try:
with open(filename, "rb") as fdesc:
for line in fdesc:
try:
shrp = li... | [
"def",
"load_protocols",
"(",
"filename",
",",
"_integer_base",
"=",
"10",
")",
":",
"spaces",
"=",
"re",
".",
"compile",
"(",
"b\"[ \\t]+|\\n\"",
")",
"dct",
"=",
"DADict",
"(",
"_name",
"=",
"filename",
")",
"try",
":",
"with",
"open",
"(",
"filename",... | Parse /etc/protocols and return values as a dictionary. | [
"Parse",
"/",
"etc",
"/",
"protocols",
"and",
"return",
"values",
"as",
"a",
"dictionary",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L157-L184 | train |
secdev/scapy | scapy/data.py | load_manuf | def load_manuf(filename):
"""Load manuf file from Wireshark.
param:
- filename: the file to load the manuf file from"""
manufdb = ManufDA(_name=filename)
with open(filename, "rb") as fdesc:
for line in fdesc:
try:
line = line.strip()
if not line o... | python | def load_manuf(filename):
"""Load manuf file from Wireshark.
param:
- filename: the file to load the manuf file from"""
manufdb = ManufDA(_name=filename)
with open(filename, "rb") as fdesc:
for line in fdesc:
try:
line = line.strip()
if not line o... | [
"def",
"load_manuf",
"(",
"filename",
")",
":",
"manufdb",
"=",
"ManufDA",
"(",
"_name",
"=",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"fdesc",
":",
"for",
"line",
"in",
"fdesc",
":",
"try",
":",
"line",
"=",
"line"... | Load manuf file from Wireshark.
param:
- filename: the file to load the manuf file from | [
"Load",
"manuf",
"file",
"from",
"Wireshark",
".",
"param",
":",
"-",
"filename",
":",
"the",
"file",
"to",
"load",
"the",
"manuf",
"file",
"from"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L269-L288 | train |
secdev/scapy | scapy/data.py | ManufDA.lookup | def lookup(self, mac):
"""Find OUI name matching to a MAC"""
oui = ":".join(mac.split(":")[:3]).upper()
return self[oui] | python | def lookup(self, mac):
"""Find OUI name matching to a MAC"""
oui = ":".join(mac.split(":")[:3]).upper()
return self[oui] | [
"def",
"lookup",
"(",
"self",
",",
"mac",
")",
":",
"oui",
"=",
"\":\"",
".",
"join",
"(",
"mac",
".",
"split",
"(",
"\":\"",
")",
"[",
":",
"3",
"]",
")",
".",
"upper",
"(",
")",
"return",
"self",
"[",
"oui",
"]"
] | Find OUI name matching to a MAC | [
"Find",
"OUI",
"name",
"matching",
"to",
"a",
"MAC"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L248-L251 | train |
secdev/scapy | scapy/data.py | ManufDA.reverse_lookup | def reverse_lookup(self, name, case_sensitive=False):
"""Find all MACs registered to a OUI
params:
- name: the OUI name
- case_sensitive: default to False
returns: a dict of mac:tuples (Name, Extended Name)
"""
if case_sensitive:
filtr = lambda x, l:... | python | def reverse_lookup(self, name, case_sensitive=False):
"""Find all MACs registered to a OUI
params:
- name: the OUI name
- case_sensitive: default to False
returns: a dict of mac:tuples (Name, Extended Name)
"""
if case_sensitive:
filtr = lambda x, l:... | [
"def",
"reverse_lookup",
"(",
"self",
",",
"name",
",",
"case_sensitive",
"=",
"False",
")",
":",
"if",
"case_sensitive",
":",
"filtr",
"=",
"lambda",
"x",
",",
"l",
":",
"any",
"(",
"x",
"==",
"z",
"for",
"z",
"in",
"l",
")",
"else",
":",
"name",
... | Find all MACs registered to a OUI
params:
- name: the OUI name
- case_sensitive: default to False
returns: a dict of mac:tuples (Name, Extended Name) | [
"Find",
"all",
"MACs",
"registered",
"to",
"a",
"OUI",
"params",
":",
"-",
"name",
":",
"the",
"OUI",
"name",
"-",
"case_sensitive",
":",
"default",
"to",
"False",
"returns",
":",
"a",
"dict",
"of",
"mac",
":",
"tuples",
"(",
"Name",
"Extended",
"Name"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L253-L266 | train |
secdev/scapy | scapy/contrib/automotive/ccp.py | DTO.answers | def answers(self, other):
"""In CCP, the payload of a DTO packet is dependent on the cmd field
of a corresponding CRO packet. Two packets correspond, if there
ctr field is equal. If answers detect the corresponding CRO, it will
interpret the payload of a DTO with the correct class. In CC... | python | def answers(self, other):
"""In CCP, the payload of a DTO packet is dependent on the cmd field
of a corresponding CRO packet. Two packets correspond, if there
ctr field is equal. If answers detect the corresponding CRO, it will
interpret the payload of a DTO with the correct class. In CC... | [
"def",
"answers",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"hasattr",
"(",
"other",
",",
"\"ctr\"",
")",
":",
"return",
"0",
"if",
"self",
".",
"ctr",
"!=",
"other",
".",
"ctr",
":",
"return",
"0",
"if",
"not",
"hasattr",
"(",
"other",
"... | In CCP, the payload of a DTO packet is dependent on the cmd field
of a corresponding CRO packet. Two packets correspond, if there
ctr field is equal. If answers detect the corresponding CRO, it will
interpret the payload of a DTO with the correct class. In CCP, there is
no other way, to ... | [
"In",
"CCP",
"the",
"payload",
"of",
"a",
"DTO",
"packet",
"is",
"dependent",
"on",
"the",
"cmd",
"field",
"of",
"a",
"corresponding",
"CRO",
"packet",
".",
"Two",
"packets",
"correspond",
"if",
"there",
"ctr",
"field",
"is",
"equal",
".",
"If",
"answers... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/ccp.py#L562-L584 | train |
secdev/scapy | scapy/__init__.py | _version_from_git_describe | def _version_from_git_describe():
"""
Read the version from ``git describe``. It returns the latest tag with an
optional suffix if the current directory is not exactly on the tag.
Example::
$ git describe --always
v2.3.2-346-g164a52c075c8
The tag prefix (``v``) and the git commit ... | python | def _version_from_git_describe():
"""
Read the version from ``git describe``. It returns the latest tag with an
optional suffix if the current directory is not exactly on the tag.
Example::
$ git describe --always
v2.3.2-346-g164a52c075c8
The tag prefix (``v``) and the git commit ... | [
"def",
"_version_from_git_describe",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"_SCAPY_PKG_DIR",
")",
",",
"'.git'",
")",
")",
":",
"# noqa: E501",
"... | Read the version from ``git describe``. It returns the latest tag with an
optional suffix if the current directory is not exactly on the tag.
Example::
$ git describe --always
v2.3.2-346-g164a52c075c8
The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are
removed if p... | [
"Read",
"the",
"version",
"from",
"git",
"describe",
".",
"It",
"returns",
"the",
"latest",
"tag",
"with",
"an",
"optional",
"suffix",
"if",
"the",
"current",
"directory",
"is",
"not",
"exactly",
"on",
"the",
"tag",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/__init__.py#L21-L61 | train |
secdev/scapy | scapy/layers/tls/extensions.py | _TLS_Ext_CertTypeDispatcher | def _TLS_Ext_CertTypeDispatcher(m, *args, **kargs):
"""
We need to select the correct one on dissection. We use the length for
that, as 1 for client version would emply an empty list.
"""
tmp_len = struct.unpack("!H", m[2:4])[0]
if tmp_len == 1:
cls = TLS_Ext_ServerCertType
else:
... | python | def _TLS_Ext_CertTypeDispatcher(m, *args, **kargs):
"""
We need to select the correct one on dissection. We use the length for
that, as 1 for client version would emply an empty list.
"""
tmp_len = struct.unpack("!H", m[2:4])[0]
if tmp_len == 1:
cls = TLS_Ext_ServerCertType
else:
... | [
"def",
"_TLS_Ext_CertTypeDispatcher",
"(",
"m",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"tmp_len",
"=",
"struct",
".",
"unpack",
"(",
"\"!H\"",
",",
"m",
"[",
"2",
":",
"4",
"]",
")",
"[",
"0",
"]",
"if",
"tmp_len",
"==",
"1",
":",
... | We need to select the correct one on dissection. We use the length for
that, as 1 for client version would emply an empty list. | [
"We",
"need",
"to",
"select",
"the",
"correct",
"one",
"on",
"dissection",
".",
"We",
"use",
"the",
"length",
"for",
"that",
"as",
"1",
"for",
"client",
"version",
"would",
"emply",
"an",
"empty",
"list",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L372-L382 | train |
secdev/scapy | scapy/layers/tls/extensions.py | TLS_Ext_PrettyPacketList._show_or_dump | def _show_or_dump(self, dump=False, indent=3,
lvl="", label_lvl="", first_call=True):
""" Reproduced from packet.py """
ct = AnsiColorTheme() if dump else conf.color_theme
s = "%s%s %s %s \n" % (label_lvl, ct.punct("###["),
ct.layer_name(self.... | python | def _show_or_dump(self, dump=False, indent=3,
lvl="", label_lvl="", first_call=True):
""" Reproduced from packet.py """
ct = AnsiColorTheme() if dump else conf.color_theme
s = "%s%s %s %s \n" % (label_lvl, ct.punct("###["),
ct.layer_name(self.... | [
"def",
"_show_or_dump",
"(",
"self",
",",
"dump",
"=",
"False",
",",
"indent",
"=",
"3",
",",
"lvl",
"=",
"\"\"",
",",
"label_lvl",
"=",
"\"\"",
",",
"first_call",
"=",
"True",
")",
":",
"ct",
"=",
"AnsiColorTheme",
"(",
")",
"if",
"dump",
"else",
... | Reproduced from packet.py | [
"Reproduced",
"from",
"packet",
".",
"py"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L96-L135 | train |
secdev/scapy | scapy/layers/tls/extensions.py | _ExtensionsLenField.getfield | def getfield(self, pkt, s):
"""
We try to compute a length, usually from a msglen parsed earlier.
If this length is 0, we consider 'selection_present' (from RFC 5246)
to be False. This means that there should not be any length field.
However, with TLS 1.3, zero lengths are always... | python | def getfield(self, pkt, s):
"""
We try to compute a length, usually from a msglen parsed earlier.
If this length is 0, we consider 'selection_present' (from RFC 5246)
to be False. This means that there should not be any length field.
However, with TLS 1.3, zero lengths are always... | [
"def",
"getfield",
"(",
"self",
",",
"pkt",
",",
"s",
")",
":",
"ext",
"=",
"pkt",
".",
"get_field",
"(",
"self",
".",
"length_of",
")",
"tmp_len",
"=",
"ext",
".",
"length_from",
"(",
"pkt",
")",
"if",
"tmp_len",
"is",
"None",
"or",
"tmp_len",
"<=... | We try to compute a length, usually from a msglen parsed earlier.
If this length is 0, we consider 'selection_present' (from RFC 5246)
to be False. This means that there should not be any length field.
However, with TLS 1.3, zero lengths are always explicit. | [
"We",
"try",
"to",
"compute",
"a",
"length",
"usually",
"from",
"a",
"msglen",
"parsed",
"earlier",
".",
"If",
"this",
"length",
"is",
"0",
"we",
"consider",
"selection_present",
"(",
"from",
"RFC",
"5246",
")",
"to",
"be",
"False",
".",
"This",
"means",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L615-L628 | train |
secdev/scapy | scapy/layers/tls/extensions.py | _ExtensionsLenField.addfield | def addfield(self, pkt, s, i):
"""
There is a hack with the _ExtensionsField.i2len. It works only because
we expect _ExtensionsField.i2m to return a string of the same size (if
not of the same value) upon successive calls (e.g. through i2len here,
then i2m when directly building ... | python | def addfield(self, pkt, s, i):
"""
There is a hack with the _ExtensionsField.i2len. It works only because
we expect _ExtensionsField.i2m to return a string of the same size (if
not of the same value) upon successive calls (e.g. through i2len here,
then i2m when directly building ... | [
"def",
"addfield",
"(",
"self",
",",
"pkt",
",",
"s",
",",
"i",
")",
":",
"if",
"i",
"is",
"None",
":",
"if",
"self",
".",
"length_of",
"is",
"not",
"None",
":",
"fld",
",",
"fval",
"=",
"pkt",
".",
"getfield_and_val",
"(",
"self",
".",
"length_o... | There is a hack with the _ExtensionsField.i2len. It works only because
we expect _ExtensionsField.i2m to return a string of the same size (if
not of the same value) upon successive calls (e.g. through i2len here,
then i2m when directly building the _ExtensionsField).
XXX A proper way to... | [
"There",
"is",
"a",
"hack",
"with",
"the",
"_ExtensionsField",
".",
"i2len",
".",
"It",
"works",
"only",
"because",
"we",
"expect",
"_ExtensionsField",
".",
"i2m",
"to",
"return",
"a",
"string",
"of",
"the",
"same",
"size",
"(",
"if",
"not",
"of",
"the",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L630-L652 | train |
secdev/scapy | scapy/layers/netflow.py | _GenNetflowRecordV9 | def _GenNetflowRecordV9(cls, lengths_list):
"""Internal function used to generate the Records from
their template.
"""
_fields_desc = []
for j, k in lengths_list:
_f_data = NetflowV9TemplateFieldDecoders.get(k, None)
_f_type, _f_args = (
_f_data if isinstance(_f_data, tup... | python | def _GenNetflowRecordV9(cls, lengths_list):
"""Internal function used to generate the Records from
their template.
"""
_fields_desc = []
for j, k in lengths_list:
_f_data = NetflowV9TemplateFieldDecoders.get(k, None)
_f_type, _f_args = (
_f_data if isinstance(_f_data, tup... | [
"def",
"_GenNetflowRecordV9",
"(",
"cls",
",",
"lengths_list",
")",
":",
"_fields_desc",
"=",
"[",
"]",
"for",
"j",
",",
"k",
"in",
"lengths_list",
":",
"_f_data",
"=",
"NetflowV9TemplateFieldDecoders",
".",
"get",
"(",
"k",
",",
"None",
")",
"_f_type",
",... | Internal function used to generate the Records from
their template. | [
"Internal",
"function",
"used",
"to",
"generate",
"the",
"Records",
"from",
"their",
"template",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/netflow.py#L1284-L1318 | train |
secdev/scapy | scapy/layers/netflow.py | _netflowv9_defragment_packet | def _netflowv9_defragment_packet(pkt, definitions, definitions_opts, ignored):
"""Used internally to process a single packet during defragmenting"""
# Dataflowset definitions
if NetflowFlowsetV9 in pkt:
current = pkt
while NetflowFlowsetV9 in current:
current = current[NetflowFlo... | python | def _netflowv9_defragment_packet(pkt, definitions, definitions_opts, ignored):
"""Used internally to process a single packet during defragmenting"""
# Dataflowset definitions
if NetflowFlowsetV9 in pkt:
current = pkt
while NetflowFlowsetV9 in current:
current = current[NetflowFlo... | [
"def",
"_netflowv9_defragment_packet",
"(",
"pkt",
",",
"definitions",
",",
"definitions_opts",
",",
"ignored",
")",
":",
"# Dataflowset definitions",
"if",
"NetflowFlowsetV9",
"in",
"pkt",
":",
"current",
"=",
"pkt",
"while",
"NetflowFlowsetV9",
"in",
"current",
":... | Used internally to process a single packet during defragmenting | [
"Used",
"internally",
"to",
"process",
"a",
"single",
"packet",
"during",
"defragmenting"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/netflow.py#L1358-L1453 | train |
secdev/scapy | scapy/layers/netflow.py | netflowv9_defragment | def netflowv9_defragment(plist, verb=1):
"""Process all NetflowV9/10 Packets to match IDs of the DataFlowsets
with the Headers
params:
- plist: the list of mixed NetflowV9/10 packets.
- verb: verbose print (0/1)
"""
if not isinstance(plist, (PacketList, list)):
plist = [plist]
... | python | def netflowv9_defragment(plist, verb=1):
"""Process all NetflowV9/10 Packets to match IDs of the DataFlowsets
with the Headers
params:
- plist: the list of mixed NetflowV9/10 packets.
- verb: verbose print (0/1)
"""
if not isinstance(plist, (PacketList, list)):
plist = [plist]
... | [
"def",
"netflowv9_defragment",
"(",
"plist",
",",
"verb",
"=",
"1",
")",
":",
"if",
"not",
"isinstance",
"(",
"plist",
",",
"(",
"PacketList",
",",
"list",
")",
")",
":",
"plist",
"=",
"[",
"plist",
"]",
"# We need the whole packet to be dissected to access fi... | Process all NetflowV9/10 Packets to match IDs of the DataFlowsets
with the Headers
params:
- plist: the list of mixed NetflowV9/10 packets.
- verb: verbose print (0/1) | [
"Process",
"all",
"NetflowV9",
"/",
"10",
"Packets",
"to",
"match",
"IDs",
"of",
"the",
"DataFlowsets",
"with",
"the",
"Headers"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/netflow.py#L1456-L1479 | train |
secdev/scapy | scapy/layers/tls/cert.py | der2pem | def der2pem(der_string, obj="UNKNOWN"):
"""Convert DER octet string to PEM format (with optional header)"""
# Encode a byte string in PEM format. Header advertizes <obj> type.
pem_string = ("-----BEGIN %s-----\n" % obj).encode()
base64_string = base64.b64encode(der_string)
chunks = [base64_string[i:... | python | def der2pem(der_string, obj="UNKNOWN"):
"""Convert DER octet string to PEM format (with optional header)"""
# Encode a byte string in PEM format. Header advertizes <obj> type.
pem_string = ("-----BEGIN %s-----\n" % obj).encode()
base64_string = base64.b64encode(der_string)
chunks = [base64_string[i:... | [
"def",
"der2pem",
"(",
"der_string",
",",
"obj",
"=",
"\"UNKNOWN\"",
")",
":",
"# Encode a byte string in PEM format. Header advertizes <obj> type.",
"pem_string",
"=",
"(",
"\"-----BEGIN %s-----\\n\"",
"%",
"obj",
")",
".",
"encode",
"(",
")",
"base64_string",
"=",
"... | Convert DER octet string to PEM format (with optional header) | [
"Convert",
"DER",
"octet",
"string",
"to",
"PEM",
"format",
"(",
"with",
"optional",
"header",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L68-L76 | train |
secdev/scapy | scapy/layers/tls/cert.py | pem2der | def pem2der(pem_string):
"""Convert PEM string to DER format"""
# Encode all lines between the first '-----\n' and the 2nd-to-last '-----'.
pem_string = pem_string.replace(b"\r", b"")
first_idx = pem_string.find(b"-----\n") + 6
if pem_string.find(b"-----BEGIN", first_idx) != -1:
raise Except... | python | def pem2der(pem_string):
"""Convert PEM string to DER format"""
# Encode all lines between the first '-----\n' and the 2nd-to-last '-----'.
pem_string = pem_string.replace(b"\r", b"")
first_idx = pem_string.find(b"-----\n") + 6
if pem_string.find(b"-----BEGIN", first_idx) != -1:
raise Except... | [
"def",
"pem2der",
"(",
"pem_string",
")",
":",
"# Encode all lines between the first '-----\\n' and the 2nd-to-last '-----'.",
"pem_string",
"=",
"pem_string",
".",
"replace",
"(",
"b\"\\r\"",
",",
"b\"\"",
")",
"first_idx",
"=",
"pem_string",
".",
"find",
"(",
"b\"----... | Convert PEM string to DER format | [
"Convert",
"PEM",
"string",
"to",
"DER",
"format"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L80-L91 | train |
secdev/scapy | scapy/layers/tls/cert.py | split_pem | def split_pem(s):
"""
Split PEM objects. Useful to process concatenated certificates.
"""
pem_strings = []
while s != b"":
start_idx = s.find(b"-----BEGIN")
if start_idx == -1:
break
end_idx = s.find(b"-----END")
end_idx = s.find(b"\n", end_idx) + 1
... | python | def split_pem(s):
"""
Split PEM objects. Useful to process concatenated certificates.
"""
pem_strings = []
while s != b"":
start_idx = s.find(b"-----BEGIN")
if start_idx == -1:
break
end_idx = s.find(b"-----END")
end_idx = s.find(b"\n", end_idx) + 1
... | [
"def",
"split_pem",
"(",
"s",
")",
":",
"pem_strings",
"=",
"[",
"]",
"while",
"s",
"!=",
"b\"\"",
":",
"start_idx",
"=",
"s",
".",
"find",
"(",
"b\"-----BEGIN\"",
")",
"if",
"start_idx",
"==",
"-",
"1",
":",
"break",
"end_idx",
"=",
"s",
".",
"fin... | Split PEM objects. Useful to process concatenated certificates. | [
"Split",
"PEM",
"objects",
".",
"Useful",
"to",
"process",
"concatenated",
"certificates",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L94-L107 | train |
secdev/scapy | scapy/layers/tls/cert.py | _create_ca_file | def _create_ca_file(anchor_list, filename):
"""
Concatenate all the certificates (PEM format for the export) in
'anchor_list' and write the result to file 'filename'. On success
'filename' is returned, None otherwise.
If you are used to OpenSSL tools, this function builds a CAfile
that can be u... | python | def _create_ca_file(anchor_list, filename):
"""
Concatenate all the certificates (PEM format for the export) in
'anchor_list' and write the result to file 'filename'. On success
'filename' is returned, None otherwise.
If you are used to OpenSSL tools, this function builds a CAfile
that can be u... | [
"def",
"_create_ca_file",
"(",
"anchor_list",
",",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"as",
"f",
":",
"for",
"a",
"in",
"anchor_list",
":",
"s",
"=",
"a",
".",
"output",
"(",
"fmt",
"=",
"\"PEM\"",
... | Concatenate all the certificates (PEM format for the export) in
'anchor_list' and write the result to file 'filename'. On success
'filename' is returned, None otherwise.
If you are used to OpenSSL tools, this function builds a CAfile
that can be used for certificate and CRL check. | [
"Concatenate",
"all",
"the",
"certificates",
"(",
"PEM",
"format",
"for",
"the",
"export",
")",
"in",
"anchor_list",
"and",
"write",
"the",
"result",
"to",
"file",
"filename",
".",
"On",
"success",
"filename",
"is",
"returned",
"None",
"otherwise",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L1010-L1026 | train |
secdev/scapy | scapy/layers/tls/cert.py | PubKey.verifyCert | def verifyCert(self, cert):
""" Verifies either a Cert or an X509_Cert. """
tbsCert = cert.tbsCertificate
sigAlg = tbsCert.signature
h = hash_by_oid[sigAlg.algorithm.val]
sigVal = raw(cert.signatureValue)
return self.verify(raw(tbsCert), sigVal, h=h, t='pkcs') | python | def verifyCert(self, cert):
""" Verifies either a Cert or an X509_Cert. """
tbsCert = cert.tbsCertificate
sigAlg = tbsCert.signature
h = hash_by_oid[sigAlg.algorithm.val]
sigVal = raw(cert.signatureValue)
return self.verify(raw(tbsCert), sigVal, h=h, t='pkcs') | [
"def",
"verifyCert",
"(",
"self",
",",
"cert",
")",
":",
"tbsCert",
"=",
"cert",
".",
"tbsCertificate",
"sigAlg",
"=",
"tbsCert",
".",
"signature",
"h",
"=",
"hash_by_oid",
"[",
"sigAlg",
".",
"algorithm",
".",
"val",
"]",
"sigVal",
"=",
"raw",
"(",
"c... | Verifies either a Cert or an X509_Cert. | [
"Verifies",
"either",
"a",
"Cert",
"or",
"an",
"X509_Cert",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L245-L251 | train |
secdev/scapy | scapy/layers/tls/cert.py | PrivKey.signTBSCert | def signTBSCert(self, tbsCert, h="sha256"):
"""
Note that this will always copy the signature field from the
tbsCertificate into the signatureAlgorithm field of the result,
regardless of the coherence between its contents (which might
indicate ecdsa-with-SHA512) and the result (e... | python | def signTBSCert(self, tbsCert, h="sha256"):
"""
Note that this will always copy the signature field from the
tbsCertificate into the signatureAlgorithm field of the result,
regardless of the coherence between its contents (which might
indicate ecdsa-with-SHA512) and the result (e... | [
"def",
"signTBSCert",
"(",
"self",
",",
"tbsCert",
",",
"h",
"=",
"\"sha256\"",
")",
":",
"sigAlg",
"=",
"tbsCert",
".",
"signature",
"h",
"=",
"h",
"or",
"hash_by_oid",
"[",
"sigAlg",
".",
"algorithm",
".",
"val",
"]",
"sigVal",
"=",
"self",
".",
"s... | Note that this will always copy the signature field from the
tbsCertificate into the signatureAlgorithm field of the result,
regardless of the coherence between its contents (which might
indicate ecdsa-with-SHA512) and the result (e.g. RSA signing MD2).
There is a small inheritance tric... | [
"Note",
"that",
"this",
"will",
"always",
"copy",
"the",
"signature",
"field",
"from",
"the",
"tbsCertificate",
"into",
"the",
"signatureAlgorithm",
"field",
"of",
"the",
"result",
"regardless",
"of",
"the",
"coherence",
"between",
"its",
"contents",
"(",
"which... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L423-L444 | train |
secdev/scapy | scapy/layers/tls/cert.py | Cert.isSelfSigned | def isSelfSigned(self):
"""
Return True if the certificate is self-signed:
- issuer and subject are the same
- the signature of the certificate is valid.
"""
if self.issuer_hash == self.subject_hash:
return self.isIssuerCert(self)
return False | python | def isSelfSigned(self):
"""
Return True if the certificate is self-signed:
- issuer and subject are the same
- the signature of the certificate is valid.
"""
if self.issuer_hash == self.subject_hash:
return self.isIssuerCert(self)
return False | [
"def",
"isSelfSigned",
"(",
"self",
")",
":",
"if",
"self",
".",
"issuer_hash",
"==",
"self",
".",
"subject_hash",
":",
"return",
"self",
".",
"isIssuerCert",
"(",
"self",
")",
"return",
"False"
] | Return True if the certificate is self-signed:
- issuer and subject are the same
- the signature of the certificate is valid. | [
"Return",
"True",
"if",
"the",
"certificate",
"is",
"self",
"-",
"signed",
":",
"-",
"issuer",
"and",
"subject",
"are",
"the",
"same",
"-",
"the",
"signature",
"of",
"the",
"certificate",
"is",
"valid",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L659-L667 | train |
secdev/scapy | scapy/layers/tls/cert.py | Cert.isRevoked | def isRevoked(self, crl_list):
"""
Given a list of trusted CRL (their signature has already been
verified with trusted anchors), this function returns True if
the certificate is marked as revoked by one of those CRL.
Note that if the Certificate was on hold in a previous CRL and... | python | def isRevoked(self, crl_list):
"""
Given a list of trusted CRL (their signature has already been
verified with trusted anchors), this function returns True if
the certificate is marked as revoked by one of those CRL.
Note that if the Certificate was on hold in a previous CRL and... | [
"def",
"isRevoked",
"(",
"self",
",",
"crl_list",
")",
":",
"for",
"c",
"in",
"crl_list",
":",
"if",
"(",
"self",
".",
"authorityKeyID",
"is",
"not",
"None",
"and",
"c",
".",
"authorityKeyID",
"is",
"not",
"None",
"and",
"self",
".",
"authorityKeyID",
... | Given a list of trusted CRL (their signature has already been
verified with trusted anchors), this function returns True if
the certificate is marked as revoked by one of those CRL.
Note that if the Certificate was on hold in a previous CRL and
is now valid again in a new CRL and bot ar... | [
"Given",
"a",
"list",
"of",
"trusted",
"CRL",
"(",
"their",
"signature",
"has",
"already",
"been",
"verified",
"with",
"trusted",
"anchors",
")",
"this",
"function",
"returns",
"True",
"if",
"the",
"certificate",
"is",
"marked",
"as",
"revoked",
"by",
"one",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L713-L736 | train |
secdev/scapy | scapy/layers/tls/cert.py | Cert.export | def export(self, filename, fmt="DER"):
"""
Export certificate in 'fmt' format (DER or PEM) to file 'filename'
"""
f = open(filename, "wb")
if fmt == "DER":
f.write(self.der)
elif fmt == "PEM":
f.write(self.pem)
f.close() | python | def export(self, filename, fmt="DER"):
"""
Export certificate in 'fmt' format (DER or PEM) to file 'filename'
"""
f = open(filename, "wb")
if fmt == "DER":
f.write(self.der)
elif fmt == "PEM":
f.write(self.pem)
f.close() | [
"def",
"export",
"(",
"self",
",",
"filename",
",",
"fmt",
"=",
"\"DER\"",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"\"wb\"",
")",
"if",
"fmt",
"==",
"\"DER\"",
":",
"f",
".",
"write",
"(",
"self",
".",
"der",
")",
"elif",
"fmt",
"==",
... | Export certificate in 'fmt' format (DER or PEM) to file 'filename' | [
"Export",
"certificate",
"in",
"fmt",
"format",
"(",
"DER",
"or",
"PEM",
")",
"to",
"file",
"filename"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L738-L747 | train |
secdev/scapy | scapy/layers/tls/cert.py | Chain.verifyChain | def verifyChain(self, anchors, untrusted=None):
"""
Perform verification of certificate chains for that certificate.
A list of anchors is required. The certificates in the optional
untrusted list may be used as additional elements to the final chain.
On par with chain instantiati... | python | def verifyChain(self, anchors, untrusted=None):
"""
Perform verification of certificate chains for that certificate.
A list of anchors is required. The certificates in the optional
untrusted list may be used as additional elements to the final chain.
On par with chain instantiati... | [
"def",
"verifyChain",
"(",
"self",
",",
"anchors",
",",
"untrusted",
"=",
"None",
")",
":",
"untrusted",
"=",
"untrusted",
"or",
"[",
"]",
"for",
"a",
"in",
"anchors",
":",
"chain",
"=",
"Chain",
"(",
"self",
"+",
"untrusted",
",",
"a",
")",
"if",
... | Perform verification of certificate chains for that certificate.
A list of anchors is required. The certificates in the optional
untrusted list may be used as additional elements to the final chain.
On par with chain instantiation, only one chain constructed with the
untrusted candidates... | [
"Perform",
"verification",
"of",
"certificate",
"chains",
"for",
"that",
"certificate",
".",
"A",
"list",
"of",
"anchors",
"is",
"required",
".",
"The",
"certificates",
"in",
"the",
"optional",
"untrusted",
"list",
"may",
"be",
"used",
"as",
"additional",
"ele... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L910-L930 | train |
secdev/scapy | scapy/layers/tls/cert.py | Chain.verifyChainFromCAFile | def verifyChainFromCAFile(self, cafile, untrusted_file=None):
"""
Does the same job as .verifyChain() but using the list of anchors
from the cafile. As for .verifyChain(), a list of untrusted
certificates can be passed (as a file, this time).
"""
try:
f = open... | python | def verifyChainFromCAFile(self, cafile, untrusted_file=None):
"""
Does the same job as .verifyChain() but using the list of anchors
from the cafile. As for .verifyChain(), a list of untrusted
certificates can be passed (as a file, this time).
"""
try:
f = open... | [
"def",
"verifyChainFromCAFile",
"(",
"self",
",",
"cafile",
",",
"untrusted_file",
"=",
"None",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"cafile",
",",
"\"rb\"",
")",
"ca_certs",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"close",
"(",
")",
"ex... | Does the same job as .verifyChain() but using the list of anchors
from the cafile. As for .verifyChain(), a list of untrusted
certificates can be passed (as a file, this time). | [
"Does",
"the",
"same",
"job",
"as",
".",
"verifyChain",
"()",
"but",
"using",
"the",
"list",
"of",
"anchors",
"from",
"the",
"cafile",
".",
"As",
"for",
".",
"verifyChain",
"()",
"a",
"list",
"of",
"untrusted",
"certificates",
"can",
"be",
"passed",
"(",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L932-L957 | train |
secdev/scapy | scapy/layers/tls/cert.py | Chain.verifyChainFromCAPath | def verifyChainFromCAPath(self, capath, untrusted_file=None):
"""
Does the same job as .verifyChainFromCAFile() but using the list
of anchors in capath directory. The directory should (only) contain
certificates files in PEM format. As for .verifyChainFromCAFile(),
a list of untr... | python | def verifyChainFromCAPath(self, capath, untrusted_file=None):
"""
Does the same job as .verifyChainFromCAFile() but using the list
of anchors in capath directory. The directory should (only) contain
certificates files in PEM format. As for .verifyChainFromCAFile(),
a list of untr... | [
"def",
"verifyChainFromCAPath",
"(",
"self",
",",
"capath",
",",
"untrusted_file",
"=",
"None",
")",
":",
"try",
":",
"anchors",
"=",
"[",
"]",
"for",
"cafile",
"in",
"os",
".",
"listdir",
"(",
"capath",
")",
":",
"anchors",
".",
"append",
"(",
"Cert",... | Does the same job as .verifyChainFromCAFile() but using the list
of anchors in capath directory. The directory should (only) contain
certificates files in PEM format. As for .verifyChainFromCAFile(),
a list of untrusted certificates can be passed as a file
(concatenation of the certifica... | [
"Does",
"the",
"same",
"job",
"as",
".",
"verifyChainFromCAFile",
"()",
"but",
"using",
"the",
"list",
"of",
"anchors",
"in",
"capath",
"directory",
".",
"The",
"directory",
"should",
"(",
"only",
")",
"contain",
"certificates",
"files",
"in",
"PEM",
"format... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L959-L984 | train |
secdev/scapy | scapy/contrib/automotive/obd/obd.py | OBD.answers | def answers(self, other):
"""DEV: true if self is an answer from other"""
if other.__class__ == self.__class__:
return (other.service + 0x40) == self.service or \
(self.service == 0x7f and
self.request_service_id == other.service)
return False | python | def answers(self, other):
"""DEV: true if self is an answer from other"""
if other.__class__ == self.__class__:
return (other.service + 0x40) == self.service or \
(self.service == 0x7f and
self.request_service_id == other.service)
return False | [
"def",
"answers",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
".",
"__class__",
"==",
"self",
".",
"__class__",
":",
"return",
"(",
"other",
".",
"service",
"+",
"0x40",
")",
"==",
"self",
".",
"service",
"or",
"(",
"self",
".",
"service",
... | DEV: true if self is an answer from other | [
"DEV",
":",
"true",
"if",
"self",
"is",
"an",
"answer",
"from",
"other"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/obd/obd.py#L58-L64 | train |
secdev/scapy | scapy/sendrecv.py | _sndrcv_snd | def _sndrcv_snd(pks, timeout, inter, verbose, tobesent, hsent, timessent, stopevent): # noqa: E501
"""Function used in the sending thread of sndrcv()"""
try:
i = 0
rec_time = timessent is not None
if verbose:
print("Begin emission:")
for p in tobesent:
# ... | python | def _sndrcv_snd(pks, timeout, inter, verbose, tobesent, hsent, timessent, stopevent): # noqa: E501
"""Function used in the sending thread of sndrcv()"""
try:
i = 0
rec_time = timessent is not None
if verbose:
print("Begin emission:")
for p in tobesent:
# ... | [
"def",
"_sndrcv_snd",
"(",
"pks",
",",
"timeout",
",",
"inter",
",",
"verbose",
",",
"tobesent",
",",
"hsent",
",",
"timessent",
",",
"stopevent",
")",
":",
"# noqa: E501",
"try",
":",
"i",
"=",
"0",
"rec_time",
"=",
"timessent",
"is",
"not",
"None",
"... | Function used in the sending thread of sndrcv() | [
"Function",
"used",
"in",
"the",
"sending",
"thread",
"of",
"sndrcv",
"()"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L55-L90 | train |
secdev/scapy | scapy/sendrecv.py | _sndrcv_rcv | def _sndrcv_rcv(pks, hsent, stopevent, nbrecv, notans, verbose, chainCC,
multi, _storage_policy=None):
"""Function used to receive packets and check their hashret"""
if not _storage_policy:
_storage_policy = lambda x, y: (x, y)
ans = []
def _get_pkt():
# SuperSocket.sele... | python | def _sndrcv_rcv(pks, hsent, stopevent, nbrecv, notans, verbose, chainCC,
multi, _storage_policy=None):
"""Function used to receive packets and check their hashret"""
if not _storage_policy:
_storage_policy = lambda x, y: (x, y)
ans = []
def _get_pkt():
# SuperSocket.sele... | [
"def",
"_sndrcv_rcv",
"(",
"pks",
",",
"hsent",
",",
"stopevent",
",",
"nbrecv",
",",
"notans",
",",
"verbose",
",",
"chainCC",
",",
"multi",
",",
"_storage_policy",
"=",
"None",
")",
":",
"if",
"not",
"_storage_policy",
":",
"_storage_policy",
"=",
"lambd... | Function used to receive packets and check their hashret | [
"Function",
"used",
"to",
"receive",
"packets",
"and",
"check",
"their",
"hashret"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L93-L149 | train |
secdev/scapy | scapy/sendrecv.py | sndrcv | def sndrcv(pks, pkt, timeout=None, inter=0, verbose=None, chainCC=False,
retry=0, multi=False, rcv_pks=None, store_unanswered=True,
process=None, prebuild=False):
"""Scapy raw function to send a packet and receive its answer.
WARNING: This is an internal function. Using sr/srp/sr1/srp is
... | python | def sndrcv(pks, pkt, timeout=None, inter=0, verbose=None, chainCC=False,
retry=0, multi=False, rcv_pks=None, store_unanswered=True,
process=None, prebuild=False):
"""Scapy raw function to send a packet and receive its answer.
WARNING: This is an internal function. Using sr/srp/sr1/srp is
... | [
"def",
"sndrcv",
"(",
"pks",
",",
"pkt",
",",
"timeout",
"=",
"None",
",",
"inter",
"=",
"0",
",",
"verbose",
"=",
"None",
",",
"chainCC",
"=",
"False",
",",
"retry",
"=",
"0",
",",
"multi",
"=",
"False",
",",
"rcv_pks",
"=",
"None",
",",
"store_... | Scapy raw function to send a packet and receive its answer.
WARNING: This is an internal function. Using sr/srp/sr1/srp is
more appropriate in many cases. | [
"Scapy",
"raw",
"function",
"to",
"send",
"a",
"packet",
"and",
"receive",
"its",
"answer",
".",
"WARNING",
":",
"This",
"is",
"an",
"internal",
"function",
".",
"Using",
"sr",
"/",
"srp",
"/",
"sr1",
"/",
"srp",
"is",
"more",
"appropriate",
"in",
"man... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L178-L269 | train |
secdev/scapy | scapy/sendrecv.py | send | def send(x, inter=0, loop=0, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 3
send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501
[socket=None]) -> N... | python | def send(x, inter=0, loop=0, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 3
send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501
[socket=None]) -> N... | [
"def",
"send",
"(",
"x",
",",
"inter",
"=",
"0",
",",
"loop",
"=",
"0",
",",
"count",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"realtime",
"=",
"None",
",",
"return_packets",
"=",
"False",
",",
"socket",
"=",
"None",
",",
"*",
"args",
",",
... | Send packets at layer 3
send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501
[socket=None]) -> None | [
"Send",
"packets",
"at",
"layer",
"3",
"send",
"(",
"packets",
"[",
"inter",
"=",
"0",
"]",
"[",
"loop",
"=",
"0",
"]",
"[",
"count",
"=",
"None",
"]",
"[",
"verbose",
"=",
"conf",
".",
"verb",
"]",
"[",
"realtime",
"=",
"None",
"]",
"[",
"retu... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L316-L329 | train |
secdev/scapy | scapy/sendrecv.py | sendp | def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 2
sendp(packets, [inter=0], [loop=0], [iface=None], [iface_hint=None], [count=None], [verbose=conf.verb], # noqa: E501... | python | def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 2
sendp(packets, [inter=0], [loop=0], [iface=None], [iface_hint=None], [count=None], [verbose=conf.verb], # noqa: E501... | [
"def",
"sendp",
"(",
"x",
",",
"inter",
"=",
"0",
",",
"loop",
"=",
"0",
",",
"iface",
"=",
"None",
",",
"iface_hint",
"=",
"None",
",",
"count",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"realtime",
"=",
"None",
",",
"return_packets",
"=",
... | Send packets at layer 2
sendp(packets, [inter=0], [loop=0], [iface=None], [iface_hint=None], [count=None], [verbose=conf.verb], # noqa: E501
[realtime=None], [return_packets=False], [socket=None]) -> None | [
"Send",
"packets",
"at",
"layer",
"2",
"sendp",
"(",
"packets",
"[",
"inter",
"=",
"0",
"]",
"[",
"loop",
"=",
"0",
"]",
"[",
"iface",
"=",
"None",
"]",
"[",
"iface_hint",
"=",
"None",
"]",
"[",
"count",
"=",
"None",
"]",
"[",
"verbose",
"=",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L333-L348 | train |
secdev/scapy | scapy/sendrecv.py | sendpfast | def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, replay_args=None, # noqa: E501
parse_results=False):
"""Send packets at layer 2 using tcpreplay for performance
pps: packets per second
mpbs: MBits per second
realtime: use packet's timestamp, bend... | python | def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, replay_args=None, # noqa: E501
parse_results=False):
"""Send packets at layer 2 using tcpreplay for performance
pps: packets per second
mpbs: MBits per second
realtime: use packet's timestamp, bend... | [
"def",
"sendpfast",
"(",
"x",
",",
"pps",
"=",
"None",
",",
"mbps",
"=",
"None",
",",
"realtime",
"=",
"None",
",",
"loop",
"=",
"0",
",",
"file_cache",
"=",
"False",
",",
"iface",
"=",
"None",
",",
"replay_args",
"=",
"None",
",",
"# noqa: E501",
... | Send packets at layer 2 using tcpreplay for performance
pps: packets per second
mpbs: MBits per second
realtime: use packet's timestamp, bending time with real-time value
loop: number of times to process the packet list
file_cache: cache packets in RAM instead of reading from disk at each iteration... | [
"Send",
"packets",
"at",
"layer",
"2",
"using",
"tcpreplay",
"for",
"performance",
"pps",
":",
"packets",
"per",
"second",
"mpbs",
":",
"MBits",
"per",
"second",
"realtime",
":",
"use",
"packet",
"s",
"timestamp",
"bending",
"time",
"with",
"real",
"-",
"t... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L352-L407 | train |
secdev/scapy | scapy/sendrecv.py | _parse_tcpreplay_result | def _parse_tcpreplay_result(stdout, stderr, argv):
"""
Parse the output of tcpreplay and modify the results_dict to populate output information. # noqa: E501
Tested with tcpreplay v3.4.4
Tested with tcpreplay v4.1.2
:param stdout: stdout of tcpreplay subprocess call
:param stderr: stderr of tcp... | python | def _parse_tcpreplay_result(stdout, stderr, argv):
"""
Parse the output of tcpreplay and modify the results_dict to populate output information. # noqa: E501
Tested with tcpreplay v3.4.4
Tested with tcpreplay v4.1.2
:param stdout: stdout of tcpreplay subprocess call
:param stderr: stderr of tcp... | [
"def",
"_parse_tcpreplay_result",
"(",
"stdout",
",",
"stderr",
",",
"argv",
")",
":",
"try",
":",
"results",
"=",
"{",
"}",
"stdout",
"=",
"plain_str",
"(",
"stdout",
")",
".",
"lower",
"(",
")",
"stderr",
"=",
"plain_str",
"(",
"stderr",
")",
".",
... | Parse the output of tcpreplay and modify the results_dict to populate output information. # noqa: E501
Tested with tcpreplay v3.4.4
Tested with tcpreplay v4.1.2
:param stdout: stdout of tcpreplay subprocess call
:param stderr: stderr of tcpreplay subprocess call
:param argv: the command used in the... | [
"Parse",
"the",
"output",
"of",
"tcpreplay",
"and",
"modify",
"the",
"results_dict",
"to",
"populate",
"output",
"information",
".",
"#",
"noqa",
":",
"E501",
"Tested",
"with",
"tcpreplay",
"v3",
".",
"4",
".",
"4",
"Tested",
"with",
"tcpreplay",
"v4",
"."... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L410-L462 | train |
secdev/scapy | scapy/sendrecv.py | sr | def sr(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send and receive packets at layer 3"""
s = conf.L3socket(promisc=promisc, filter=filter,
iface=iface, nofilter=nofilter)
result = sndrcv(s, x, *args, **kargs)
s.close()
return result | python | def sr(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send and receive packets at layer 3"""
s = conf.L3socket(promisc=promisc, filter=filter,
iface=iface, nofilter=nofilter)
result = sndrcv(s, x, *args, **kargs)
s.close()
return result | [
"def",
"sr",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"s",
"=",
"conf",
".",
"L3socket",
"(",
"promisc",
"=",
... | Send and receive packets at layer 3 | [
"Send",
"and",
"receive",
"packets",
"at",
"layer",
"3"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L466-L472 | train |
secdev/scapy | scapy/sendrecv.py | sr1 | def sr1(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send packets at layer 3 and return only the first answer"""
s = conf.L3socket(promisc=promisc, filter=filter,
nofilter=nofilter, iface=iface)
ans, _ = sndrcv(s, x, *args, **kargs)
s.close()
if len... | python | def sr1(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send packets at layer 3 and return only the first answer"""
s = conf.L3socket(promisc=promisc, filter=filter,
nofilter=nofilter, iface=iface)
ans, _ = sndrcv(s, x, *args, **kargs)
s.close()
if len... | [
"def",
"sr1",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"s",
"=",
"conf",
".",
"L3socket",
"(",
"promisc",
"=",
... | Send packets at layer 3 and return only the first answer | [
"Send",
"packets",
"at",
"layer",
"3",
"and",
"return",
"only",
"the",
"first",
"answer"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L476-L485 | train |
secdev/scapy | scapy/sendrecv.py | srp | def srp(x, promisc=None, iface=None, iface_hint=None, filter=None,
nofilter=0, type=ETH_P_ALL, *args, **kargs):
"""Send and receive packets at layer 2"""
if iface is None and iface_hint is not None:
iface = conf.route.route(iface_hint)[0]
s = conf.L2socket(promisc=promisc, iface=iface,
... | python | def srp(x, promisc=None, iface=None, iface_hint=None, filter=None,
nofilter=0, type=ETH_P_ALL, *args, **kargs):
"""Send and receive packets at layer 2"""
if iface is None and iface_hint is not None:
iface = conf.route.route(iface_hint)[0]
s = conf.L2socket(promisc=promisc, iface=iface,
... | [
"def",
"srp",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"iface_hint",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"type",
"=",
"ETH_P_ALL",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
... | Send and receive packets at layer 2 | [
"Send",
"and",
"receive",
"packets",
"at",
"layer",
"2"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L489-L498 | train |
secdev/scapy | scapy/sendrecv.py | srp1 | def srp1(*args, **kargs):
"""Send and receive packets at layer 2 and return only the first answer"""
ans, _ = srp(*args, **kargs)
if len(ans) > 0:
return ans[0][1]
else:
return None | python | def srp1(*args, **kargs):
"""Send and receive packets at layer 2 and return only the first answer"""
ans, _ = srp(*args, **kargs)
if len(ans) > 0:
return ans[0][1]
else:
return None | [
"def",
"srp1",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"ans",
",",
"_",
"=",
"srp",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
"if",
"len",
"(",
"ans",
")",
">",
"0",
":",
"return",
"ans",
"[",
"0",
"]",
"[",
"1",
"]",
"... | Send and receive packets at layer 2 and return only the first answer | [
"Send",
"and",
"receive",
"packets",
"at",
"layer",
"2",
"and",
"return",
"only",
"the",
"first",
"answer"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L502-L508 | train |
secdev/scapy | scapy/sendrecv.py | srflood | def srflood(x, promisc=None, filter=None, iface=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: ... | python | def srflood(x, promisc=None, filter=None, iface=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: ... | [
"def",
"srflood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"s",
"=",
"conf",
".",
"L3socket",
"... | Flood and receive packets at layer 3
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"3",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"unique",
":",
"only",
"consider",
"packets",
"whose",
"print",
"nofilter",
":",
"put",
"1",
"to",
"avoid",
"use",
"of",
"BPF",
"filte... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L673-L683 | train |
secdev/scapy | scapy/sendrecv.py | sr1flood | def sr1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF ... | python | def sr1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF ... | [
"def",
"sr1flood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"s",
"=",
"conf",
".",
"L3socket",
"("... | Flood and receive packets at layer 3 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"3",
"and",
"return",
"only",
"the",
"first",
"answer",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"verbose",
":",
"set",
"verbosity",
"level",
"nofilter",
":",
"put",
"1",
"to",
"av... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L687-L700 | train |
secdev/scapy | scapy/sendrecv.py | srpflood | def srpflood(x, promisc=None, filter=None, iface=None, iface_hint=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | python | def srpflood(x, promisc=None, filter=None, iface=None, iface_hint=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | [
"def",
"srpflood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"iface_hint",
"=",
"None",
",",
"nofilter",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"if",... | Flood and receive packets at layer 2
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"2",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"unique",
":",
"only",
"consider",
"packets",
"whose",
"print",
"nofilter",
":",
"put",
"1",
"to",
"avoid",
"use",
"of",
"BPF",
"filte... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L704-L716 | train |
secdev/scapy | scapy/sendrecv.py | srp1flood | def srp1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | python | def srp1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | [
"def",
"srp1flood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"s",
"=",
"conf",
".",
"L2socket",
"(... | Flood and receive packets at layer 2 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"2",
"and",
"return",
"only",
"the",
"first",
"answer",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"verbose",
":",
"set",
"verbosity",
"level",
"nofilter",
":",
"put",
"1",
"to",
"av... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L720-L733 | train |
secdev/scapy | scapy/sendrecv.py | sniff | def sniff(count=0, store=True, offline=None, prn=None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None,
stop_filter=None, iface=None, started_callback=None,
session=None, *arg, **karg):
"""Sniff packets and return a list of packets.
Args:
count: number of pac... | python | def sniff(count=0, store=True, offline=None, prn=None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None,
stop_filter=None, iface=None, started_callback=None,
session=None, *arg, **karg):
"""Sniff packets and return a list of packets.
Args:
count: number of pac... | [
"def",
"sniff",
"(",
"count",
"=",
"0",
",",
"store",
"=",
"True",
",",
"offline",
"=",
"None",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
",",
"L2socket",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"opened_socket",
"=",
"None",
",",... | Sniff packets and return a list of packets.
Args:
count: number of packets to capture. 0 means infinity.
store: whether to store sniffed packets or discard them
prn: function to apply to each packet. If something is returned, it
is displayed.
--Ex: prn = lambda x: ... | [
"Sniff",
"packets",
"and",
"return",
"a",
"list",
"of",
"packets",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L739-L895 | train |
secdev/scapy | scapy/sendrecv.py | bridge_and_sniff | def bridge_and_sniff(if1, if2, xfrm12=None, xfrm21=None, prn=None, L2socket=None, # noqa: E501
*args, **kargs):
"""Forward traffic between interfaces if1 and if2, sniff and return
the exchanged packets.
Arguments:
if1, if2: the interfaces to use (interface names or opened sockets).
xfrm... | python | def bridge_and_sniff(if1, if2, xfrm12=None, xfrm21=None, prn=None, L2socket=None, # noqa: E501
*args, **kargs):
"""Forward traffic between interfaces if1 and if2, sniff and return
the exchanged packets.
Arguments:
if1, if2: the interfaces to use (interface names or opened sockets).
xfrm... | [
"def",
"bridge_and_sniff",
"(",
"if1",
",",
"if2",
",",
"xfrm12",
"=",
"None",
",",
"xfrm21",
"=",
"None",
",",
"prn",
"=",
"None",
",",
"L2socket",
"=",
"None",
",",
"# noqa: E501",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"for",
"arg",
"in"... | Forward traffic between interfaces if1 and if2, sniff and return
the exchanged packets.
Arguments:
if1, if2: the interfaces to use (interface names or opened sockets).
xfrm12: a function to call when forwarding a packet from if1 to
if2. If it returns True, the packet is forwarded as it. If it
returns... | [
"Forward",
"traffic",
"between",
"interfaces",
"if1",
"and",
"if2",
"sniff",
"and",
"return",
"the",
"exchanged",
"packets",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L899-L978 | train |
secdev/scapy | scapy/sendrecv.py | tshark | def tshark(*args, **kargs):
"""Sniff packets and print them calling pkt.summary(), a bit like text wireshark""" # noqa: E501
print("Capturing on '" + str(kargs.get('iface') if 'iface' in kargs else conf.iface) + "'") # noqa: E501
i = [0] # This should be a nonlocal variable, using a mutable object for Py... | python | def tshark(*args, **kargs):
"""Sniff packets and print them calling pkt.summary(), a bit like text wireshark""" # noqa: E501
print("Capturing on '" + str(kargs.get('iface') if 'iface' in kargs else conf.iface) + "'") # noqa: E501
i = [0] # This should be a nonlocal variable, using a mutable object for Py... | [
"def",
"tshark",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"print",
"(",
"\"Capturing on '\"",
"+",
"str",
"(",
"kargs",
".",
"get",
"(",
"'iface'",
")",
"if",
"'iface'",
"in",
"kargs",
"else",
"conf",
".",
"iface",
")",
"+"... | Sniff packets and print them calling pkt.summary(), a bit like text wireshark | [
"Sniff",
"packets",
"and",
"print",
"them",
"calling",
"pkt",
".",
"summary",
"()",
"a",
"bit",
"like",
"text",
"wireshark"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L982-L991 | train |
secdev/scapy | scapy/contrib/ikev2.py | ikev2scan | def ikev2scan(ip, **kwargs):
"""Send a IKEv2 SA to an IP and wait for answers."""
return sr(IP(dst=ip) / UDP() / IKEv2(init_SPI=RandString(8),
exch_type=34) / IKEv2_payload_SA(prop=IKEv2_payload_Proposal()), **kwargs) | python | def ikev2scan(ip, **kwargs):
"""Send a IKEv2 SA to an IP and wait for answers."""
return sr(IP(dst=ip) / UDP() / IKEv2(init_SPI=RandString(8),
exch_type=34) / IKEv2_payload_SA(prop=IKEv2_payload_Proposal()), **kwargs) | [
"def",
"ikev2scan",
"(",
"ip",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"sr",
"(",
"IP",
"(",
"dst",
"=",
"ip",
")",
"/",
"UDP",
"(",
")",
"/",
"IKEv2",
"(",
"init_SPI",
"=",
"RandString",
"(",
"8",
")",
",",
"exch_type",
"=",
"34",
")",
... | Send a IKEv2 SA to an IP and wait for answers. | [
"Send",
"a",
"IKEv2",
"SA",
"to",
"an",
"IP",
"and",
"wait",
"for",
"answers",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ikev2.py#L799-L802 | train |
secdev/scapy | scapy/asn1/mib.py | _mib_register | def _mib_register(ident, value, the_mib, unresolved):
"""Internal function used to register an OID and its name in a MIBDict"""
if ident in the_mib or ident in unresolved:
return ident in the_mib
resval = []
not_resolved = 0
for v in value:
if _mib_re_integer.match(v):
re... | python | def _mib_register(ident, value, the_mib, unresolved):
"""Internal function used to register an OID and its name in a MIBDict"""
if ident in the_mib or ident in unresolved:
return ident in the_mib
resval = []
not_resolved = 0
for v in value:
if _mib_re_integer.match(v):
re... | [
"def",
"_mib_register",
"(",
"ident",
",",
"value",
",",
"the_mib",
",",
"unresolved",
")",
":",
"if",
"ident",
"in",
"the_mib",
"or",
"ident",
"in",
"unresolved",
":",
"return",
"ident",
"in",
"the_mib",
"resval",
"=",
"[",
"]",
"not_resolved",
"=",
"0"... | Internal function used to register an OID and its name in a MIBDict | [
"Internal",
"function",
"used",
"to",
"register",
"an",
"OID",
"and",
"its",
"name",
"in",
"a",
"MIBDict"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L91-L128 | train |
secdev/scapy | scapy/asn1/mib.py | load_mib | def load_mib(filenames):
"""Load the conf.mib dict from a list of filenames"""
the_mib = {'iso': ['1']}
unresolved = {}
for k in six.iterkeys(conf.mib):
_mib_register(conf.mib[k], k.split("."), the_mib, unresolved)
if isinstance(filenames, (str, bytes)):
filenames = [filenames]
... | python | def load_mib(filenames):
"""Load the conf.mib dict from a list of filenames"""
the_mib = {'iso': ['1']}
unresolved = {}
for k in six.iterkeys(conf.mib):
_mib_register(conf.mib[k], k.split("."), the_mib, unresolved)
if isinstance(filenames, (str, bytes)):
filenames = [filenames]
... | [
"def",
"load_mib",
"(",
"filenames",
")",
":",
"the_mib",
"=",
"{",
"'iso'",
":",
"[",
"'1'",
"]",
"}",
"unresolved",
"=",
"{",
"}",
"for",
"k",
"in",
"six",
".",
"iterkeys",
"(",
"conf",
".",
"mib",
")",
":",
"_mib_register",
"(",
"conf",
".",
"... | Load the conf.mib dict from a list of filenames | [
"Load",
"the",
"conf",
".",
"mib",
"dict",
"from",
"a",
"list",
"of",
"filenames"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L131-L162 | train |
secdev/scapy | scapy/asn1/mib.py | MIBDict._findroot | def _findroot(self, x):
"""Internal MIBDict function used to find a partial OID"""
if x.startswith("."):
x = x[1:]
if not x.endswith("."):
x += "."
max = 0
root = "."
root_key = ""
for k in six.iterkeys(self):
if x.startswith(k ... | python | def _findroot(self, x):
"""Internal MIBDict function used to find a partial OID"""
if x.startswith("."):
x = x[1:]
if not x.endswith("."):
x += "."
max = 0
root = "."
root_key = ""
for k in six.iterkeys(self):
if x.startswith(k ... | [
"def",
"_findroot",
"(",
"self",
",",
"x",
")",
":",
"if",
"x",
".",
"startswith",
"(",
"\".\"",
")",
":",
"x",
"=",
"x",
"[",
"1",
":",
"]",
"if",
"not",
"x",
".",
"endswith",
"(",
"\".\"",
")",
":",
"x",
"+=",
"\".\"",
"max",
"=",
"0",
"r... | Internal MIBDict function used to find a partial OID | [
"Internal",
"MIBDict",
"function",
"used",
"to",
"find",
"a",
"partial",
"OID"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L36-L51 | train |
secdev/scapy | scapy/asn1/mib.py | MIBDict._oid | def _oid(self, x):
"""Parse the OID id/OID generator, and return real OID"""
xl = x.strip(".").split(".")
p = len(xl) - 1
while p >= 0 and _mib_re_integer.match(xl[p]):
p -= 1
if p != 0 or xl[p] not in six.itervalues(self.__dict__):
return x
xl[p] ... | python | def _oid(self, x):
"""Parse the OID id/OID generator, and return real OID"""
xl = x.strip(".").split(".")
p = len(xl) - 1
while p >= 0 and _mib_re_integer.match(xl[p]):
p -= 1
if p != 0 or xl[p] not in six.itervalues(self.__dict__):
return x
xl[p] ... | [
"def",
"_oid",
"(",
"self",
",",
"x",
")",
":",
"xl",
"=",
"x",
".",
"strip",
"(",
"\".\"",
")",
".",
"split",
"(",
"\".\"",
")",
"p",
"=",
"len",
"(",
"xl",
")",
"-",
"1",
"while",
"p",
">=",
"0",
"and",
"_mib_re_integer",
".",
"match",
"(",... | Parse the OID id/OID generator, and return real OID | [
"Parse",
"the",
"OID",
"id",
"/",
"OID",
"generator",
"and",
"return",
"real",
"OID"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L58-L67 | train |
secdev/scapy | scapy/contrib/mac_control.py | MACControl._get_underlayers_size | def _get_underlayers_size(self):
"""
get the total size of all under layers
:return: number of bytes
"""
under_layer = self.underlayer
under_layers_size = 0
while under_layer and isinstance(under_layer, Dot1Q):
under_layers_size += 4
und... | python | def _get_underlayers_size(self):
"""
get the total size of all under layers
:return: number of bytes
"""
under_layer = self.underlayer
under_layers_size = 0
while under_layer and isinstance(under_layer, Dot1Q):
under_layers_size += 4
und... | [
"def",
"_get_underlayers_size",
"(",
"self",
")",
":",
"under_layer",
"=",
"self",
".",
"underlayer",
"under_layers_size",
"=",
"0",
"while",
"under_layer",
"and",
"isinstance",
"(",
"under_layer",
",",
"Dot1Q",
")",
":",
"under_layers_size",
"+=",
"4",
"under_l... | get the total size of all under layers
:return: number of bytes | [
"get",
"the",
"total",
"size",
"of",
"all",
"under",
"layers",
":",
"return",
":",
"number",
"of",
"bytes"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L103-L121 | train |
secdev/scapy | scapy/contrib/mac_control.py | MACControl.post_build | def post_build(self, pkt, pay):
"""
add padding to the frame if required.
note that padding is only added if pay is None/empty. this allows us to add # noqa: E501
any payload after the MACControl* PDU if needed (piggybacking).
"""
if not pay:
under_layers_s... | python | def post_build(self, pkt, pay):
"""
add padding to the frame if required.
note that padding is only added if pay is None/empty. this allows us to add # noqa: E501
any payload after the MACControl* PDU if needed (piggybacking).
"""
if not pay:
under_layers_s... | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"if",
"not",
"pay",
":",
"under_layers_size",
"=",
"self",
".",
"_get_underlayers_size",
"(",
")",
"frame_size",
"=",
"(",
"len",
"(",
"pkt",
")",
"+",
"under_layers_size",
")",
"if",
... | add padding to the frame if required.
note that padding is only added if pay is None/empty. this allows us to add # noqa: E501
any payload after the MACControl* PDU if needed (piggybacking). | [
"add",
"padding",
"to",
"the",
"frame",
"if",
"required",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L123-L139 | train |
secdev/scapy | scapy/contrib/mac_control.py | MACControlPause.get_pause_time | def get_pause_time(self, speed=ETHER_SPEED_MBIT_1000):
"""
get pause time for given link speed in seconds
:param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
:return: pause time in seconds
:raises MACControlInvalidSpeed... | python | def get_pause_time(self, speed=ETHER_SPEED_MBIT_1000):
"""
get pause time for given link speed in seconds
:param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
:return: pause time in seconds
:raises MACControlInvalidSpeed... | [
"def",
"get_pause_time",
"(",
"self",
",",
"speed",
"=",
"ETHER_SPEED_MBIT_1000",
")",
":",
"try",
":",
"return",
"self",
".",
"pause_time",
"*",
"{",
"ETHER_SPEED_MBIT_10",
":",
"(",
"0.0000001",
"*",
"512",
")",
",",
"ETHER_SPEED_MBIT_100",
":",
"(",
"0.00... | get pause time for given link speed in seconds
:param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
:return: pause time in seconds
:raises MACControlInvalidSpeedException: on invalid speed selector | [
"get",
"pause",
"time",
"for",
"given",
"link",
"speed",
"in",
"seconds"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L152-L169 | train |
secdev/scapy | scapy/layers/can.py | rdcandump | def rdcandump(filename, count=None,
is_not_log_file_format=False,
interface=None):
"""Read a candump log file and return a packet list
count: read only <count> packets
is_not_log_file_format: read input with candumps stdout format
interfaces: return only packets from a specified interfa... | python | def rdcandump(filename, count=None,
is_not_log_file_format=False,
interface=None):
"""Read a candump log file and return a packet list
count: read only <count> packets
is_not_log_file_format: read input with candumps stdout format
interfaces: return only packets from a specified interfa... | [
"def",
"rdcandump",
"(",
"filename",
",",
"count",
"=",
"None",
",",
"is_not_log_file_format",
"=",
"False",
",",
"interface",
"=",
"None",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"filename",
",",
"six",
".",
"string_types",
")",
":",
"file",
"=",... | Read a candump log file and return a packet list
count: read only <count> packets
is_not_log_file_format: read input with candumps stdout format
interfaces: return only packets from a specified interface | [
"Read",
"a",
"candump",
"log",
"file",
"and",
"return",
"a",
"packet",
"list"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L87-L147 | train |
secdev/scapy | scapy/layers/can.py | CAN.inv_endianness | def inv_endianness(pkt):
""" Invert the order of the first four bytes of a CAN packet
This method is meant to be used specifically to convert a CAN packet
between the pcap format and the socketCAN format
:param pkt: str of the CAN packet
:return: packet str with the first four ... | python | def inv_endianness(pkt):
""" Invert the order of the first four bytes of a CAN packet
This method is meant to be used specifically to convert a CAN packet
between the pcap format and the socketCAN format
:param pkt: str of the CAN packet
:return: packet str with the first four ... | [
"def",
"inv_endianness",
"(",
"pkt",
")",
":",
"len_partial",
"=",
"len",
"(",
"pkt",
")",
"-",
"4",
"# len of the packet, CAN ID excluded",
"return",
"struct",
".",
"pack",
"(",
"'<I{}s'",
".",
"format",
"(",
"len_partial",
")",
",",
"*",
"struct",
".",
"... | Invert the order of the first four bytes of a CAN packet
This method is meant to be used specifically to convert a CAN packet
between the pcap format and the socketCAN format
:param pkt: str of the CAN packet
:return: packet str with the first four bytes swapped | [
"Invert",
"the",
"order",
"of",
"the",
"first",
"four",
"bytes",
"of",
"a",
"CAN",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L45-L56 | train |
secdev/scapy | scapy/layers/can.py | CAN.post_build | def post_build(self, pkt, pay):
""" Implements the swap-bytes functionality when building
this is based on a copy of the Packet.self_build default method.
The goal is to affect only the CAN layer data and keep
under layers (e.g LinuxCooked) unchanged
"""
if conf.contribs... | python | def post_build(self, pkt, pay):
""" Implements the swap-bytes functionality when building
this is based on a copy of the Packet.self_build default method.
The goal is to affect only the CAN layer data and keep
under layers (e.g LinuxCooked) unchanged
"""
if conf.contribs... | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"if",
"conf",
".",
"contribs",
"[",
"'CAN'",
"]",
"[",
"'swap-bytes'",
"]",
":",
"return",
"CAN",
".",
"inv_endianness",
"(",
"pkt",
")",
"+",
"pay",
"return",
"pkt",
"+",
"pay"
] | Implements the swap-bytes functionality when building
this is based on a copy of the Packet.self_build default method.
The goal is to affect only the CAN layer data and keep
under layers (e.g LinuxCooked) unchanged | [
"Implements",
"the",
"swap",
"-",
"bytes",
"functionality",
"when",
"building"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L68-L77 | train |
secdev/scapy | scapy/modules/p0f.py | pkt2uptime | def pkt2uptime(pkt, HZ=100):
"""Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
pkt2uptime(pkt, [HZ=100])"""
if not isinstance(pkt, Packet):
raise TypeError("Not a TCP packet")
if isinstance(pkt, NoPayload):
raise TypeError("Not a TCP packet")... | python | def pkt2uptime(pkt, HZ=100):
"""Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
pkt2uptime(pkt, [HZ=100])"""
if not isinstance(pkt, Packet):
raise TypeError("Not a TCP packet")
if isinstance(pkt, NoPayload):
raise TypeError("Not a TCP packet")... | [
"def",
"pkt2uptime",
"(",
"pkt",
",",
"HZ",
"=",
"100",
")",
":",
"if",
"not",
"isinstance",
"(",
"pkt",
",",
"Packet",
")",
":",
"raise",
"TypeError",
"(",
"\"Not a TCP packet\"",
")",
"if",
"isinstance",
"(",
"pkt",
",",
"NoPayload",
")",
":",
"raise... | Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
pkt2uptime(pkt, [HZ=100]) | [
"Calculate",
"the",
"date",
"the",
"machine",
"which",
"emitted",
"the",
"packet",
"booted",
"using",
"TCP",
"timestamp",
"#",
"noqa",
":",
"E501",
"pkt2uptime",
"(",
"pkt",
"[",
"HZ",
"=",
"100",
"]",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/p0f.py#L345-L360 | train |
secdev/scapy | scapy/modules/p0f.py | p0f_impersonate | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | python | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | [
"def",
"p0f_impersonate",
"(",
"pkt",
",",
"osgenre",
"=",
"None",
",",
"osdetails",
"=",
"None",
",",
"signature",
"=",
"None",
",",
"extrahops",
"=",
"0",
",",
"mtu",
"=",
"1500",
",",
"uptime",
"=",
"None",
")",
":",
"pkt",
"=",
"pkt",
".",
"cop... | Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also None,
we use a local signature (using p0f_getlocalsigs). If signature is
specified (as a tuple), we use the signature.
For now, only T... | [
"Modifies",
"pkt",
"so",
"that",
"p0f",
"will",
"think",
"it",
"has",
"been",
"sent",
"by",
"a",
"specific",
"OS",
".",
"If",
"osdetails",
"is",
"None",
"then",
"we",
"randomly",
"pick",
"up",
"a",
"personality",
"matching",
"osgenre",
".",
"If",
"osgenr... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/p0f.py#L363-L566 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | IODControlReq.get_response | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODControlRes()
for field in ["ARUUID", "SessionKey", "AlarmSequenceNumber"]:
res.setfieldval(field, self.getfieldval(f... | python | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODControlRes()
for field in ["ARUUID", "SessionKey", "AlarmSequenceNumber"]:
res.setfieldval(field, self.getfieldval(f... | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IODControlRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"ARUUID\"",
",",
"\"SessionKey\"",
",",
"\"AlarmSequenceNumber\"",
"]",
":",
"res",
".",
"setfieldval",
"(",
"field",
",",
"self",
".",
"getfi... | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L385-L394 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | IODWriteReq.get_response | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
r... | python | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
r... | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IODWriteRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"seqNum\"",
",",
"\"ARUUID\"",
",",
"\"API\"",
",",
"\"slotNumber\"",
",",
"\"subslotNumber\"",
",",
"\"index\"",
"]",
":",
"res",
".",
"setfiel... | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L445-L453 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | PadFieldWithLen.i2len | def i2len(self, pkt, val):
"""get the length of the field, including the padding length"""
fld_len = self._fld.i2len(pkt, val)
return fld_len + self.padlen(fld_len) | python | def i2len(self, pkt, val):
"""get the length of the field, including the padding length"""
fld_len = self._fld.i2len(pkt, val)
return fld_len + self.padlen(fld_len) | [
"def",
"i2len",
"(",
"self",
",",
"pkt",
",",
"val",
")",
":",
"fld_len",
"=",
"self",
".",
"_fld",
".",
"i2len",
"(",
"pkt",
",",
"val",
")",
"return",
"fld_len",
"+",
"self",
".",
"padlen",
"(",
"fld_len",
")"
] | get the length of the field, including the padding length | [
"get",
"the",
"length",
"of",
"the",
"field",
"including",
"the",
"padding",
"length"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L529-L532 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | IODWriteMultipleReq.get_response | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteMultipleRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
... | python | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteMultipleRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
... | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IODWriteMultipleRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"seqNum\"",
",",
"\"ARUUID\"",
",",
"\"API\"",
",",
"\"slotNumber\"",
",",
"\"subslotNumber\"",
",",
"\"index\"",
"]",
":",
"res",
".",
... | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L580-L594 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | ARBlockReq.get_response | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = ARBlockRes()
for field in ["ARType", "ARUUID", "SessionKey"]:
res.setfieldval(field, self.getfieldval(field))
r... | python | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = ARBlockRes()
for field in ["ARType", "ARUUID", "SessionKey"]:
res.setfieldval(field, self.getfieldval(field))
r... | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"ARBlockRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"ARType\"",
",",
"\"ARUUID\"",
",",
"\"SessionKey\"",
"]",
":",
"res",
".",
"setfieldval",
"(",
"field",
",",
"self",
".",
"getfieldval",
"(",
... | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L665-L672 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | IOCRBlockReq.get_response | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IOCRBlockRes()
for field in ["IOCRType", "IOCRReference", "FrameID"]:
res.setfieldval(field, self.getfieldval(field))
... | python | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IOCRBlockRes()
for field in ["IOCRType", "IOCRReference", "FrameID"]:
res.setfieldval(field, self.getfieldval(field))
... | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IOCRBlockRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"IOCRType\"",
",",
"\"IOCRReference\"",
",",
"\"FrameID\"",
"]",
":",
"res",
".",
"setfieldval",
"(",
"field",
",",
"self",
".",
"getfieldval",... | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L757-L764 | train |
secdev/scapy | scapy/contrib/pnio_rpc.py | PNIOServiceReqPDU.can_handle | def can_handle(cls, pkt, rpc):
"""heuristical guess_payload_class"""
# type = 0 => request
if rpc.getfieldval("type") == 0 and \
str(rpc.object_uuid).startswith("dea00000-6c97-11d1-8271-"):
return True
return False | python | def can_handle(cls, pkt, rpc):
"""heuristical guess_payload_class"""
# type = 0 => request
if rpc.getfieldval("type") == 0 and \
str(rpc.object_uuid).startswith("dea00000-6c97-11d1-8271-"):
return True
return False | [
"def",
"can_handle",
"(",
"cls",
",",
"pkt",
",",
"rpc",
")",
":",
"# type = 0 => request",
"if",
"rpc",
".",
"getfieldval",
"(",
"\"type\"",
")",
"==",
"0",
"and",
"str",
"(",
"rpc",
".",
"object_uuid",
")",
".",
"startswith",
"(",
"\"dea00000-6c97-11d1-8... | heuristical guess_payload_class | [
"heuristical",
"guess_payload_class"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L969-L975 | train |
secdev/scapy | scapy/contrib/macsec.py | MACsecSA.make_iv | def make_iv(self, pkt):
"""generate an IV for the packet"""
if self.xpn_en:
tmp_pn = (self.pn & 0xFFFFFFFF00000000) | (pkt[MACsec].pn & 0xFFFFFFFF) # noqa: E501
tmp_iv = self.ssci + struct.pack('!Q', tmp_pn)
return bytes(bytearray([a ^ b for a, b in zip(bytearray(tmp... | python | def make_iv(self, pkt):
"""generate an IV for the packet"""
if self.xpn_en:
tmp_pn = (self.pn & 0xFFFFFFFF00000000) | (pkt[MACsec].pn & 0xFFFFFFFF) # noqa: E501
tmp_iv = self.ssci + struct.pack('!Q', tmp_pn)
return bytes(bytearray([a ^ b for a, b in zip(bytearray(tmp... | [
"def",
"make_iv",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"self",
".",
"xpn_en",
":",
"tmp_pn",
"=",
"(",
"self",
".",
"pn",
"&",
"0xFFFFFFFF00000000",
")",
"|",
"(",
"pkt",
"[",
"MACsec",
"]",
".",
"pn",
"&",
"0xFFFFFFFF",
")",
"# noqa: E501",
"t... | generate an IV for the packet | [
"generate",
"an",
"IV",
"for",
"the",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L82-L89 | train |
secdev/scapy | scapy/contrib/macsec.py | MACsecSA.split_pkt | def split_pkt(pkt, assoclen, icvlen=0):
"""
split the packet into associated data, plaintext or ciphertext, and
optional ICV
"""
data = raw(pkt)
assoc = data[:assoclen]
if icvlen:
icv = data[-icvlen:]
enc = data[assoclen:-icvlen]
el... | python | def split_pkt(pkt, assoclen, icvlen=0):
"""
split the packet into associated data, plaintext or ciphertext, and
optional ICV
"""
data = raw(pkt)
assoc = data[:assoclen]
if icvlen:
icv = data[-icvlen:]
enc = data[assoclen:-icvlen]
el... | [
"def",
"split_pkt",
"(",
"pkt",
",",
"assoclen",
",",
"icvlen",
"=",
"0",
")",
":",
"data",
"=",
"raw",
"(",
"pkt",
")",
"assoc",
"=",
"data",
"[",
":",
"assoclen",
"]",
"if",
"icvlen",
":",
"icv",
"=",
"data",
"[",
"-",
"icvlen",
":",
"]",
"en... | split the packet into associated data, plaintext or ciphertext, and
optional ICV | [
"split",
"the",
"packet",
"into",
"associated",
"data",
"plaintext",
"or",
"ciphertext",
"and",
"optional",
"ICV"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L92-L105 | train |
secdev/scapy | scapy/contrib/macsec.py | MACsecSA.encap | def encap(self, pkt):
"""encapsulate a frame using this Secure Association"""
if pkt.name != Ether().name:
raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet') # noqa: E501
hdr = copy.deepcopy(pkt)
payload = hdr.payload
del hdr.payload
tag... | python | def encap(self, pkt):
"""encapsulate a frame using this Secure Association"""
if pkt.name != Ether().name:
raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet') # noqa: E501
hdr = copy.deepcopy(pkt)
payload = hdr.payload
del hdr.payload
tag... | [
"def",
"encap",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"pkt",
".",
"name",
"!=",
"Ether",
"(",
")",
".",
"name",
":",
"raise",
"TypeError",
"(",
"'cannot encapsulate packet in MACsec, must be Ethernet'",
")",
"# noqa: E501",
"hdr",
"=",
"copy",
".",
"deepc... | encapsulate a frame using this Secure Association | [
"encapsulate",
"a",
"frame",
"using",
"this",
"Secure",
"Association"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L123-L136 | train |
secdev/scapy | scapy/contrib/macsec.py | MACsecSA.decap | def decap(self, orig_pkt):
"""decapsulate a MACsec frame"""
if orig_pkt.name != Ether().name or orig_pkt.payload.name != MACsec().name: # noqa: E501
raise TypeError('cannot decapsulate MACsec packet, must be Ethernet/MACsec') # noqa: E501
packet = copy.deepcopy(orig_pkt)
pr... | python | def decap(self, orig_pkt):
"""decapsulate a MACsec frame"""
if orig_pkt.name != Ether().name or orig_pkt.payload.name != MACsec().name: # noqa: E501
raise TypeError('cannot decapsulate MACsec packet, must be Ethernet/MACsec') # noqa: E501
packet = copy.deepcopy(orig_pkt)
pr... | [
"def",
"decap",
"(",
"self",
",",
"orig_pkt",
")",
":",
"if",
"orig_pkt",
".",
"name",
"!=",
"Ether",
"(",
")",
".",
"name",
"or",
"orig_pkt",
".",
"payload",
".",
"name",
"!=",
"MACsec",
"(",
")",
".",
"name",
":",
"# noqa: E501",
"raise",
"TypeErro... | decapsulate a MACsec frame | [
"decapsulate",
"a",
"MACsec",
"frame"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L140-L151 | train |
secdev/scapy | scapy/contrib/macsec.py | MACsecSA.encrypt | def encrypt(self, orig_pkt, assoclen=None):
"""encrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
del hdr[MACsec].type
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
... | python | def encrypt(self, orig_pkt, assoclen=None):
"""encrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
del hdr[MACsec].type
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
... | [
"def",
"encrypt",
"(",
"self",
",",
"orig_pkt",
",",
"assoclen",
"=",
"None",
")",
":",
"hdr",
"=",
"copy",
".",
"deepcopy",
"(",
"orig_pkt",
")",
"del",
"hdr",
"[",
"MACsec",
"]",
".",
"payload",
"del",
"hdr",
"[",
"MACsec",
"]",
".",
"type",
"pkt... | encrypt a MACsec frame for this Secure Association | [
"encrypt",
"a",
"MACsec",
"frame",
"for",
"this",
"Secure",
"Association"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L153-L178 | train |
secdev/scapy | scapy/contrib/macsec.py | MACsecSA.decrypt | def decrypt(self, orig_pkt, assoclen=None):
"""decrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
hdrlen = NOSCI_LE... | python | def decrypt(self, orig_pkt, assoclen=None):
"""decrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
hdrlen = NOSCI_LE... | [
"def",
"decrypt",
"(",
"self",
",",
"orig_pkt",
",",
"assoclen",
"=",
"None",
")",
":",
"hdr",
"=",
"copy",
".",
"deepcopy",
"(",
"orig_pkt",
")",
"del",
"hdr",
"[",
"MACsec",
"]",
".",
"payload",
"pktlen",
"=",
"len",
"(",
"orig_pkt",
")",
"if",
"... | decrypt a MACsec frame for this Secure Association | [
"decrypt",
"a",
"MACsec",
"frame",
"for",
"this",
"Secure",
"Association"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L180-L207 | train |
secdev/scapy | scapy/layers/bluetooth.py | srbt | def srbt(bt_address, pkts, inter=0.1, *args, **kargs):
"""send and receive using a bluetooth socket"""
if "port" in kargs:
s = conf.BTsocket(bt_address=bt_address, port=kargs.pop("port"))
else:
s = conf.BTsocket(bt_address=bt_address)
a, b = sndrcv(s, pkts, inter=inter, *args, **kargs)
... | python | def srbt(bt_address, pkts, inter=0.1, *args, **kargs):
"""send and receive using a bluetooth socket"""
if "port" in kargs:
s = conf.BTsocket(bt_address=bt_address, port=kargs.pop("port"))
else:
s = conf.BTsocket(bt_address=bt_address)
a, b = sndrcv(s, pkts, inter=inter, *args, **kargs)
... | [
"def",
"srbt",
"(",
"bt_address",
",",
"pkts",
",",
"inter",
"=",
"0.1",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"\"port\"",
"in",
"kargs",
":",
"s",
"=",
"conf",
".",
"BTsocket",
"(",
"bt_address",
"=",
"bt_address",
",",
"port",... | send and receive using a bluetooth socket | [
"send",
"and",
"receive",
"using",
"a",
"bluetooth",
"socket"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/bluetooth.py#L1458-L1466 | train |
secdev/scapy | scapy/layers/bluetooth.py | srbt1 | def srbt1(bt_address, pkts, *args, **kargs):
"""send and receive 1 packet using a bluetooth socket"""
a, b = srbt(bt_address, pkts, *args, **kargs)
if len(a) > 0:
return a[0][1] | python | def srbt1(bt_address, pkts, *args, **kargs):
"""send and receive 1 packet using a bluetooth socket"""
a, b = srbt(bt_address, pkts, *args, **kargs)
if len(a) > 0:
return a[0][1] | [
"def",
"srbt1",
"(",
"bt_address",
",",
"pkts",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"a",
",",
"b",
"=",
"srbt",
"(",
"bt_address",
",",
"pkts",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
"if",
"len",
"(",
"a",
")",
">",
... | send and receive 1 packet using a bluetooth socket | [
"send",
"and",
"receive",
"1",
"packet",
"using",
"a",
"bluetooth",
"socket"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/bluetooth.py#L1470-L1474 | train |
secdev/scapy | scapy/layers/bluetooth.py | EIR_Manufacturer_Specific_Data.register_magic_payload | def register_magic_payload(cls, payload_cls, magic_check=None):
"""
Registers a payload type that uses magic data.
Traditional payloads require registration of a Bluetooth Company ID
(requires company membership of the Bluetooth SIG), or a Bluetooth
Short UUID (requires a once-o... | python | def register_magic_payload(cls, payload_cls, magic_check=None):
"""
Registers a payload type that uses magic data.
Traditional payloads require registration of a Bluetooth Company ID
(requires company membership of the Bluetooth SIG), or a Bluetooth
Short UUID (requires a once-o... | [
"def",
"register_magic_payload",
"(",
"cls",
",",
"payload_cls",
",",
"magic_check",
"=",
"None",
")",
":",
"if",
"magic_check",
"is",
"None",
":",
"if",
"hasattr",
"(",
"payload_cls",
",",
"\"magic_check\"",
")",
":",
"magic_check",
"=",
"payload_cls",
".",
... | Registers a payload type that uses magic data.
Traditional payloads require registration of a Bluetooth Company ID
(requires company membership of the Bluetooth SIG), or a Bluetooth
Short UUID (requires a once-off payment).
There are alternatives which don't require registration (such ... | [
"Registers",
"a",
"payload",
"type",
"that",
"uses",
"magic",
"data",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/bluetooth.py#L707-L744 | train |
secdev/scapy | scapy/contrib/automotive/someip.py | SOMEIP._is_tp | def _is_tp(pkt):
"""Returns true if pkt is using SOMEIP-TP, else returns false."""
tp = [SOMEIP.TYPE_TP_REQUEST, SOMEIP.TYPE_TP_REQUEST_NO_RET,
SOMEIP.TYPE_TP_NOTIFICATION, SOMEIP.TYPE_TP_RESPONSE,
SOMEIP.TYPE_TP_ERROR]
if isinstance(pkt, Packet):
return ... | python | def _is_tp(pkt):
"""Returns true if pkt is using SOMEIP-TP, else returns false."""
tp = [SOMEIP.TYPE_TP_REQUEST, SOMEIP.TYPE_TP_REQUEST_NO_RET,
SOMEIP.TYPE_TP_NOTIFICATION, SOMEIP.TYPE_TP_RESPONSE,
SOMEIP.TYPE_TP_ERROR]
if isinstance(pkt, Packet):
return ... | [
"def",
"_is_tp",
"(",
"pkt",
")",
":",
"tp",
"=",
"[",
"SOMEIP",
".",
"TYPE_TP_REQUEST",
",",
"SOMEIP",
".",
"TYPE_TP_REQUEST_NO_RET",
",",
"SOMEIP",
".",
"TYPE_TP_NOTIFICATION",
",",
"SOMEIP",
".",
"TYPE_TP_RESPONSE",
",",
"SOMEIP",
".",
"TYPE_TP_ERROR",
"]",... | Returns true if pkt is using SOMEIP-TP, else returns false. | [
"Returns",
"true",
"if",
"pkt",
"is",
"using",
"SOMEIP",
"-",
"TP",
"else",
"returns",
"false",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/someip.py#L179-L188 | train |
secdev/scapy | scapy/contrib/automotive/someip.py | SOMEIP.fragment | def fragment(self, fragsize=1392):
"""Fragment SOME/IP-TP"""
fnb = 0
fl = self
lst = list()
while fl.underlayer is not None:
fnb += 1
fl = fl.underlayer
for p in fl:
s = raw(p[fnb].payload)
nb = (len(s) + fragsize) // frags... | python | def fragment(self, fragsize=1392):
"""Fragment SOME/IP-TP"""
fnb = 0
fl = self
lst = list()
while fl.underlayer is not None:
fnb += 1
fl = fl.underlayer
for p in fl:
s = raw(p[fnb].payload)
nb = (len(s) + fragsize) // frags... | [
"def",
"fragment",
"(",
"self",
",",
"fragsize",
"=",
"1392",
")",
":",
"fnb",
"=",
"0",
"fl",
"=",
"self",
"lst",
"=",
"list",
"(",
")",
"while",
"fl",
".",
"underlayer",
"is",
"not",
"None",
":",
"fnb",
"+=",
"1",
"fl",
"=",
"fl",
".",
"under... | Fragment SOME/IP-TP | [
"Fragment",
"SOME",
"/",
"IP",
"-",
"TP"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/someip.py#L190-L216 | train |
secdev/scapy | scapy/layers/dot11.py | _next_radiotap_extpm | def _next_radiotap_extpm(pkt, lst, cur, s):
"""Generates the next RadioTapExtendedPresenceMask"""
if cur is None or (cur.present and cur.present.Ext):
st = len(lst) + (cur is not None)
return lambda *args: RadioTapExtendedPresenceMask(*args, index=st)
return None | python | def _next_radiotap_extpm(pkt, lst, cur, s):
"""Generates the next RadioTapExtendedPresenceMask"""
if cur is None or (cur.present and cur.present.Ext):
st = len(lst) + (cur is not None)
return lambda *args: RadioTapExtendedPresenceMask(*args, index=st)
return None | [
"def",
"_next_radiotap_extpm",
"(",
"pkt",
",",
"lst",
",",
"cur",
",",
"s",
")",
":",
"if",
"cur",
"is",
"None",
"or",
"(",
"cur",
".",
"present",
"and",
"cur",
".",
"present",
".",
"Ext",
")",
":",
"st",
"=",
"len",
"(",
"lst",
")",
"+",
"(",... | Generates the next RadioTapExtendedPresenceMask | [
"Generates",
"the",
"next",
"RadioTapExtendedPresenceMask"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot11.py#L140-L145 | train |
secdev/scapy | scapy/layers/dot11.py | _Dot11NetStats.network_stats | def network_stats(self):
"""Return a dictionary containing a summary of the Dot11
elements fields
"""
summary = {}
crypto = set()
akmsuite_types = {
0x00: "Reserved",
0x01: "802.1X",
0x02: "PSK"
}
p = self.payload
... | python | def network_stats(self):
"""Return a dictionary containing a summary of the Dot11
elements fields
"""
summary = {}
crypto = set()
akmsuite_types = {
0x00: "Reserved",
0x01: "802.1X",
0x02: "PSK"
}
p = self.payload
... | [
"def",
"network_stats",
"(",
"self",
")",
":",
"summary",
"=",
"{",
"}",
"crypto",
"=",
"set",
"(",
")",
"akmsuite_types",
"=",
"{",
"0x00",
":",
"\"Reserved\"",
",",
"0x01",
":",
"\"802.1X\"",
",",
"0x02",
":",
"\"PSK\"",
"}",
"p",
"=",
"self",
".",... | Return a dictionary containing a summary of the Dot11
elements fields | [
"Return",
"a",
"dictionary",
"containing",
"a",
"summary",
"of",
"the",
"Dot11",
"elements",
"fields"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot11.py#L619-L670 | train |
secdev/scapy | scapy/arch/linux.py | get_alias_address | def get_alias_address(iface_name, ip_mask, gw_str, metric):
"""
Get the correct source IP address of an interface alias
"""
# Detect the architecture
if scapy.consts.IS_64BITS:
offset, name_len = 16, 40
else:
offset, name_len = 32, 32
# Retrieve interfaces structures
sc... | python | def get_alias_address(iface_name, ip_mask, gw_str, metric):
"""
Get the correct source IP address of an interface alias
"""
# Detect the architecture
if scapy.consts.IS_64BITS:
offset, name_len = 16, 40
else:
offset, name_len = 32, 32
# Retrieve interfaces structures
sc... | [
"def",
"get_alias_address",
"(",
"iface_name",
",",
"ip_mask",
",",
"gw_str",
",",
"metric",
")",
":",
"# Detect the architecture",
"if",
"scapy",
".",
"consts",
".",
"IS_64BITS",
":",
"offset",
",",
"name_len",
"=",
"16",
",",
"40",
"else",
":",
"offset",
... | Get the correct source IP address of an interface alias | [
"Get",
"the",
"correct",
"source",
"IP",
"address",
"of",
"an",
"interface",
"alias"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L153-L201 | train |
secdev/scapy | scapy/arch/linux.py | in6_getifaddr | def in6_getifaddr():
"""
Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system.
"""
ret = []
try:
fdesc = open... | python | def in6_getifaddr():
"""
Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system.
"""
ret = []
try:
fdesc = open... | [
"def",
"in6_getifaddr",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"fdesc",
"=",
"open",
"(",
"\"/proc/net/if_inet6\"",
",",
"\"rb\"",
")",
"except",
"IOError",
":",
"return",
"ret",
"for",
"line",
"in",
"fdesc",
":",
"# addr, index, plen, scope, flags... | Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system. | [
"Returns",
"a",
"list",
"of",
"3",
"-",
"tuples",
"of",
"the",
"form",
"(",
"addr",
"scope",
"iface",
")",
"where",
"addr",
"is",
"the",
"address",
"of",
"scope",
"scope",
"associated",
"to",
"the",
"interface",
"ifcace",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L276-L301 | train |
secdev/scapy | scapy/arch/linux.py | get_iface_mode | def get_iface_mode(iface):
"""Return the interface mode.
params:
- iface: the iwconfig interface
"""
p = subprocess.Popen(["iwconfig", iface], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output, err = p.communicate()
match = re.search(br"mode:([a-zA-Z]*)", out... | python | def get_iface_mode(iface):
"""Return the interface mode.
params:
- iface: the iwconfig interface
"""
p = subprocess.Popen(["iwconfig", iface], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output, err = p.communicate()
match = re.search(br"mode:([a-zA-Z]*)", out... | [
"def",
"get_iface_mode",
"(",
"iface",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"iwconfig\"",
",",
"iface",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"output",
",",
"err... | Return the interface mode.
params:
- iface: the iwconfig interface | [
"Return",
"the",
"interface",
"mode",
".",
"params",
":",
"-",
"iface",
":",
"the",
"iwconfig",
"interface"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L386-L397 | train |
secdev/scapy | scapy/arch/linux.py | set_iface_monitor | def set_iface_monitor(iface, monitor):
"""Sets the monitor mode (or remove it) from an interface.
params:
- iface: the iwconfig interface
- monitor: True if the interface should be set in monitor mode,
False if it should be in managed mode
"""
mode = get_iface_mode(iface)
i... | python | def set_iface_monitor(iface, monitor):
"""Sets the monitor mode (or remove it) from an interface.
params:
- iface: the iwconfig interface
- monitor: True if the interface should be set in monitor mode,
False if it should be in managed mode
"""
mode = get_iface_mode(iface)
i... | [
"def",
"set_iface_monitor",
"(",
"iface",
",",
"monitor",
")",
":",
"mode",
"=",
"get_iface_mode",
"(",
"iface",
")",
"if",
"mode",
"==",
"\"unknown\"",
":",
"warning",
"(",
"\"Could not parse iwconfig !\"",
")",
"current_monitor",
"=",
"mode",
"==",
"\"monitor\... | Sets the monitor mode (or remove it) from an interface.
params:
- iface: the iwconfig interface
- monitor: True if the interface should be set in monitor mode,
False if it should be in managed mode | [
"Sets",
"the",
"monitor",
"mode",
"(",
"or",
"remove",
"it",
")",
"from",
"an",
"interface",
".",
"params",
":",
"-",
"iface",
":",
"the",
"iwconfig",
"interface",
"-",
"monitor",
":",
"True",
"if",
"the",
"interface",
"should",
"be",
"set",
"in",
"mon... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L400-L431 | train |
secdev/scapy | scapy/arch/linux.py | L2Socket.recv_raw | def recv_raw(self, x=MTU):
"""Receives a packet, then returns a tuple containing (cls, pkt_data, time)""" # noqa: E501
pkt, sa_ll = self.ins.recvfrom(x)
if self.outs and sa_ll[2] == socket.PACKET_OUTGOING:
return None, None, None
ts = get_last_packet_timestamp(self.ins)
... | python | def recv_raw(self, x=MTU):
"""Receives a packet, then returns a tuple containing (cls, pkt_data, time)""" # noqa: E501
pkt, sa_ll = self.ins.recvfrom(x)
if self.outs and sa_ll[2] == socket.PACKET_OUTGOING:
return None, None, None
ts = get_last_packet_timestamp(self.ins)
... | [
"def",
"recv_raw",
"(",
"self",
",",
"x",
"=",
"MTU",
")",
":",
"# noqa: E501",
"pkt",
",",
"sa_ll",
"=",
"self",
".",
"ins",
".",
"recvfrom",
"(",
"x",
")",
"if",
"self",
".",
"outs",
"and",
"sa_ll",
"[",
"2",
"]",
"==",
"socket",
".",
"PACKET_O... | Receives a packet, then returns a tuple containing (cls, pkt_data, time) | [
"Receives",
"a",
"packet",
"then",
"returns",
"a",
"tuple",
"containing",
"(",
"cls",
"pkt_data",
"time",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L484-L490 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | isBPFSocket | def isBPFSocket(obj):
"""Return True is obj is a BPF Super Socket"""
return isinstance(obj, L2bpfListenSocket) or isinstance(obj, L2bpfListenSocket) or isinstance(obj, L3bpfSocket) | python | def isBPFSocket(obj):
"""Return True is obj is a BPF Super Socket"""
return isinstance(obj, L2bpfListenSocket) or isinstance(obj, L2bpfListenSocket) or isinstance(obj, L3bpfSocket) | [
"def",
"isBPFSocket",
"(",
"obj",
")",
":",
"return",
"isinstance",
"(",
"obj",
",",
"L2bpfListenSocket",
")",
"or",
"isinstance",
"(",
"obj",
",",
"L2bpfListenSocket",
")",
"or",
"isinstance",
"(",
"obj",
",",
"L3bpfSocket",
")"
] | Return True is obj is a BPF Super Socket | [
"Return",
"True",
"is",
"obj",
"is",
"a",
"BPF",
"Super",
"Socket"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L364-L366 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | bpf_select | def bpf_select(fds_list, timeout=None):
"""A call to recv() can return several frames. This functions hides the fact
that some frames are read from the internal buffer."""
# Check file descriptors types
bpf_scks_buffered = list()
select_fds = list()
for tmp_fd in fds_list:
# Specif... | python | def bpf_select(fds_list, timeout=None):
"""A call to recv() can return several frames. This functions hides the fact
that some frames are read from the internal buffer."""
# Check file descriptors types
bpf_scks_buffered = list()
select_fds = list()
for tmp_fd in fds_list:
# Specif... | [
"def",
"bpf_select",
"(",
"fds_list",
",",
"timeout",
"=",
"None",
")",
":",
"# Check file descriptors types",
"bpf_scks_buffered",
"=",
"list",
"(",
")",
"select_fds",
"=",
"list",
"(",
")",
"for",
"tmp_fd",
"in",
"fds_list",
":",
"# Specific BPF sockets: get buf... | A call to recv() can return several frames. This functions hides the fact
that some frames are read from the internal buffer. | [
"A",
"call",
"to",
"recv",
"()",
"can",
"return",
"several",
"frames",
".",
"This",
"functions",
"hides",
"the",
"fact",
"that",
"some",
"frames",
"are",
"read",
"from",
"the",
"internal",
"buffer",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L369-L394 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | _L2bpfSocket.set_promisc | def set_promisc(self, value):
"""Set the interface in promiscuous mode"""
try:
fcntl.ioctl(self.ins, BIOCPROMISC, struct.pack('i', value))
except IOError:
raise Scapy_Exception("Cannot set promiscuous mode on interface "
"(%s)!" % self.i... | python | def set_promisc(self, value):
"""Set the interface in promiscuous mode"""
try:
fcntl.ioctl(self.ins, BIOCPROMISC, struct.pack('i', value))
except IOError:
raise Scapy_Exception("Cannot set promiscuous mode on interface "
"(%s)!" % self.i... | [
"def",
"set_promisc",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCPROMISC",
",",
"struct",
".",
"pack",
"(",
"'i'",
",",
"value",
")",
")",
"except",
"IOError",
":",
"raise",
"Scapy_Excep... | Set the interface in promiscuous mode | [
"Set",
"the",
"interface",
"in",
"promiscuous",
"mode"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L118-L125 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | _L2bpfSocket.guess_cls | def guess_cls(self):
"""Guess the packet class that must be used on the interface"""
# Get the data link type
try:
ret = fcntl.ioctl(self.ins, BIOCGDLT, struct.pack('I', 0))
ret = struct.unpack('I', ret)[0]
except IOError:
cls = conf.default_l2
... | python | def guess_cls(self):
"""Guess the packet class that must be used on the interface"""
# Get the data link type
try:
ret = fcntl.ioctl(self.ins, BIOCGDLT, struct.pack('I', 0))
ret = struct.unpack('I', ret)[0]
except IOError:
cls = conf.default_l2
... | [
"def",
"guess_cls",
"(",
"self",
")",
":",
"# Get the data link type",
"try",
":",
"ret",
"=",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCGDLT",
",",
"struct",
".",
"pack",
"(",
"'I'",
",",
"0",
")",
")",
"ret",
"=",
"struct",
".",
"... | Guess the packet class that must be used on the interface | [
"Guess",
"the",
"packet",
"class",
"that",
"must",
"be",
"used",
"on",
"the",
"interface"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L134-L152 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | _L2bpfSocket.set_nonblock | def set_nonblock(self, set_flag=True):
"""Set the non blocking flag on the socket"""
# Get the current flags
if self.fd_flags is None:
try:
self.fd_flags = fcntl.fcntl(self.ins, fcntl.F_GETFL)
except IOError:
warning("Cannot get flags on t... | python | def set_nonblock(self, set_flag=True):
"""Set the non blocking flag on the socket"""
# Get the current flags
if self.fd_flags is None:
try:
self.fd_flags = fcntl.fcntl(self.ins, fcntl.F_GETFL)
except IOError:
warning("Cannot get flags on t... | [
"def",
"set_nonblock",
"(",
"self",
",",
"set_flag",
"=",
"True",
")",
":",
"# Get the current flags",
"if",
"self",
".",
"fd_flags",
"is",
"None",
":",
"try",
":",
"self",
".",
"fd_flags",
"=",
"fcntl",
".",
"fcntl",
"(",
"self",
".",
"ins",
",",
"fcn... | Set the non blocking flag on the socket | [
"Set",
"the",
"non",
"blocking",
"flag",
"on",
"the",
"socket"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L154-L175 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | _L2bpfSocket.get_stats | def get_stats(self):
"""Get received / dropped statistics"""
try:
ret = fcntl.ioctl(self.ins, BIOCGSTATS, struct.pack("2I", 0, 0))
return struct.unpack("2I", ret)
except IOError:
warning("Unable to get stats from BPF !")
return (None, None) | python | def get_stats(self):
"""Get received / dropped statistics"""
try:
ret = fcntl.ioctl(self.ins, BIOCGSTATS, struct.pack("2I", 0, 0))
return struct.unpack("2I", ret)
except IOError:
warning("Unable to get stats from BPF !")
return (None, None) | [
"def",
"get_stats",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCGSTATS",
",",
"struct",
".",
"pack",
"(",
"\"2I\"",
",",
"0",
",",
"0",
")",
")",
"return",
"struct",
".",
"unpack",
"(",... | Get received / dropped statistics | [
"Get",
"received",
"/",
"dropped",
"statistics"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L177-L185 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | _L2bpfSocket.get_blen | def get_blen(self):
"""Get the BPF buffer length"""
try:
ret = fcntl.ioctl(self.ins, BIOCGBLEN, struct.pack("I", 0))
return struct.unpack("I", ret)[0]
except IOError:
warning("Unable to get the BPF buffer length")
return | python | def get_blen(self):
"""Get the BPF buffer length"""
try:
ret = fcntl.ioctl(self.ins, BIOCGBLEN, struct.pack("I", 0))
return struct.unpack("I", ret)[0]
except IOError:
warning("Unable to get the BPF buffer length")
return | [
"def",
"get_blen",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCGBLEN",
",",
"struct",
".",
"pack",
"(",
"\"I\"",
",",
"0",
")",
")",
"return",
"struct",
".",
"unpack",
"(",
"\"I\"",
","... | Get the BPF buffer length | [
"Get",
"the",
"BPF",
"buffer",
"length"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L187-L195 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | _L2bpfSocket.close | def close(self):
"""Close the Super Socket"""
if not self.closed and self.ins is not None:
os.close(self.ins)
self.closed = True
self.ins = None | python | def close(self):
"""Close the Super Socket"""
if not self.closed and self.ins is not None:
os.close(self.ins)
self.closed = True
self.ins = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"closed",
"and",
"self",
".",
"ins",
"is",
"not",
"None",
":",
"os",
".",
"close",
"(",
"self",
".",
"ins",
")",
"self",
".",
"closed",
"=",
"True",
"self",
".",
"ins",
"=",
"None... | Close the Super Socket | [
"Close",
"the",
"Super",
"Socket"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L201-L207 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | L2bpfListenSocket.extract_frames | def extract_frames(self, bpf_buffer):
"""Extract all frames from the buffer and stored them in the received list.""" # noqa: E501
# Ensure that the BPF buffer contains at least the header
len_bb = len(bpf_buffer)
if len_bb < 20: # Note: 20 == sizeof(struct bfp_hdr)
return
... | python | def extract_frames(self, bpf_buffer):
"""Extract all frames from the buffer and stored them in the received list.""" # noqa: E501
# Ensure that the BPF buffer contains at least the header
len_bb = len(bpf_buffer)
if len_bb < 20: # Note: 20 == sizeof(struct bfp_hdr)
return
... | [
"def",
"extract_frames",
"(",
"self",
",",
"bpf_buffer",
")",
":",
"# noqa: E501",
"# Ensure that the BPF buffer contains at least the header",
"len_bb",
"=",
"len",
"(",
"bpf_buffer",
")",
"if",
"len_bb",
"<",
"20",
":",
"# Note: 20 == sizeof(struct bfp_hdr)",
"return",
... | Extract all frames from the buffer and stored them in the received list. | [
"Extract",
"all",
"frames",
"from",
"the",
"buffer",
"and",
"stored",
"them",
"in",
"the",
"received",
"list",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L249-L287 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | L2bpfListenSocket.recv | def recv(self, x=BPF_BUFFER_LENGTH):
"""Receive a frame from the network"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Get data from BPF
try:
bpf_buffer = os.read(self.ins, x)
except EnvironmentError as... | python | def recv(self, x=BPF_BUFFER_LENGTH):
"""Receive a frame from the network"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Get data from BPF
try:
bpf_buffer = os.read(self.ins, x)
except EnvironmentError as... | [
"def",
"recv",
"(",
"self",
",",
"x",
"=",
"BPF_BUFFER_LENGTH",
")",
":",
"if",
"self",
".",
"buffered_frames",
"(",
")",
":",
"# Get a frame from the buffer",
"return",
"self",
".",
"get_frame",
"(",
")",
"# Get data from BPF",
"try",
":",
"bpf_buffer",
"=",
... | Receive a frame from the network | [
"Receive",
"a",
"frame",
"from",
"the",
"network"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L289-L306 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | L2bpfSocket.nonblock_recv | def nonblock_recv(self):
"""Non blocking receive"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Set the non blocking flag, read from the socket, and unset the flag
self.set_nonblock(True)
pkt = L2bpfListenSocket.rec... | python | def nonblock_recv(self):
"""Non blocking receive"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Set the non blocking flag, read from the socket, and unset the flag
self.set_nonblock(True)
pkt = L2bpfListenSocket.rec... | [
"def",
"nonblock_recv",
"(",
"self",
")",
":",
"if",
"self",
".",
"buffered_frames",
"(",
")",
":",
"# Get a frame from the buffer",
"return",
"self",
".",
"get_frame",
"(",
")",
"# Set the non blocking flag, read from the socket, and unset the flag",
"self",
".",
"set_... | Non blocking receive | [
"Non",
"blocking",
"receive"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L316-L327 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | L3bpfSocket.get_frame | def get_frame(self):
"""Get a frame or packet from the received list"""
pkt = super(L3bpfSocket, self).get_frame()
if pkt is not None:
return pkt.payload | python | def get_frame(self):
"""Get a frame or packet from the received list"""
pkt = super(L3bpfSocket, self).get_frame()
if pkt is not None:
return pkt.payload | [
"def",
"get_frame",
"(",
"self",
")",
":",
"pkt",
"=",
"super",
"(",
"L3bpfSocket",
",",
"self",
")",
".",
"get_frame",
"(",
")",
"if",
"pkt",
"is",
"not",
"None",
":",
"return",
"pkt",
".",
"payload"
] | Get a frame or packet from the received list | [
"Get",
"a",
"frame",
"or",
"packet",
"from",
"the",
"received",
"list"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L332-L336 | train |
secdev/scapy | scapy/arch/bpf/supersocket.py | L3bpfSocket.send | def send(self, pkt):
"""Send a packet"""
# Use the routing table to find the output interface
iff = pkt.route()[0]
if iff is None:
iff = conf.iface
# Assign the network interface to the BPF handle
if self.assigned_interface != iff:
try:
... | python | def send(self, pkt):
"""Send a packet"""
# Use the routing table to find the output interface
iff = pkt.route()[0]
if iff is None:
iff = conf.iface
# Assign the network interface to the BPF handle
if self.assigned_interface != iff:
try:
... | [
"def",
"send",
"(",
"self",
",",
"pkt",
")",
":",
"# Use the routing table to find the output interface",
"iff",
"=",
"pkt",
".",
"route",
"(",
")",
"[",
"0",
"]",
"if",
"iff",
"is",
"None",
":",
"iff",
"=",
"conf",
".",
"iface",
"# Assign the network interf... | Send a packet | [
"Send",
"a",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L338-L359 | train |
secdev/scapy | scapy/layers/tls/handshake_sslv2.py | _SSLv2Handshake.tls_session_update | def tls_session_update(self, msg_str):
"""
Covers both post_build- and post_dissection- context updates.
"""
self.tls_session.handshake_messages.append(msg_str)
self.tls_session.handshake_messages_parsed.append(self) | python | def tls_session_update(self, msg_str):
"""
Covers both post_build- and post_dissection- context updates.
"""
self.tls_session.handshake_messages.append(msg_str)
self.tls_session.handshake_messages_parsed.append(self) | [
"def",
"tls_session_update",
"(",
"self",
",",
"msg_str",
")",
":",
"self",
".",
"tls_session",
".",
"handshake_messages",
".",
"append",
"(",
"msg_str",
")",
"self",
".",
"tls_session",
".",
"handshake_messages_parsed",
".",
"append",
"(",
"self",
")"
] | Covers both post_build- and post_dissection- context updates. | [
"Covers",
"both",
"post_build",
"-",
"and",
"post_dissection",
"-",
"context",
"updates",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake_sslv2.py#L52-L57 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.