repo stringlengths 7 54 | 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 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
secdev/scapy | scapy/contrib/http2.py | HPackHdrTable.get_idx_by_name | def get_idx_by_name(self, name):
# type: (str) -> Optional[int]
""" get_idx_by_name returns the index of a matching registered header
This implementation will prefer returning a static entry index whenever
possible. If multiple matching header name are found in the static
table,... | python | def get_idx_by_name(self, name):
# type: (str) -> Optional[int]
""" get_idx_by_name returns the index of a matching registered header
This implementation will prefer returning a static entry index whenever
possible. If multiple matching header name are found in the static
table,... | [
"def",
"get_idx_by_name",
"(",
"self",
",",
"name",
")",
":",
"# type: (str) -> Optional[int]",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"for",
"key",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"type",
"(",
"self",
")",
".",
"_static_entries",
"... | get_idx_by_name returns the index of a matching registered header
This implementation will prefer returning a static entry index whenever
possible. If multiple matching header name are found in the static
table, there is insurance that the first entry (lowest index number)
will be retur... | [
"get_idx_by_name",
"returns",
"the",
"index",
"of",
"a",
"matching",
"registered",
"header"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L2409-L2426 | train | This method returns the index of a matching registered header in the static entry table that matches the given name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/http2.py | HPackHdrTable.gen_txt_repr | def gen_txt_repr(self, hdrs, register=True):
# type: (Union[H2Frame, List[HPackHeaders]], Optional[bool]) -> str
""" gen_txt_repr returns a "textual" representation of the provided
headers.
The output of this function is compatible with the input of
parse_txt_hdrs.
@para... | python | def gen_txt_repr(self, hdrs, register=True):
# type: (Union[H2Frame, List[HPackHeaders]], Optional[bool]) -> str
""" gen_txt_repr returns a "textual" representation of the provided
headers.
The output of this function is compatible with the input of
parse_txt_hdrs.
@para... | [
"def",
"gen_txt_repr",
"(",
"self",
",",
"hdrs",
",",
"register",
"=",
"True",
")",
":",
"# type: (Union[H2Frame, List[HPackHeaders]], Optional[bool]) -> str",
"lst",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"hdrs",
",",
"H2Frame",
")",
":",
"hdrs",
"=",
"hdrs",
... | gen_txt_repr returns a "textual" representation of the provided
headers.
The output of this function is compatible with the input of
parse_txt_hdrs.
@param H2Frame|list of HPackHeaders hdrs: the list of headers to convert to textual representation # noqa: E501
@param bool: whet... | [
"gen_txt_repr",
"returns",
"a",
"textual",
"representation",
"of",
"the",
"provided",
"headers",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L2453-L2501 | train | This function returns a textual representation of the provided headers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/http2.py | HPackHdrTable._convert_a_header_to_a_h2_header | def _convert_a_header_to_a_h2_header(self, hdr_name, hdr_value, is_sensitive, should_index): # noqa: E501
# type: (str, str, Callable[[str, str], bool], Callable[[str], bool]) -> Tuple[HPackHeaders, int] # noqa: E501
""" _convert_a_header_to_a_h2_header builds a HPackHeaders from a header
name... | python | def _convert_a_header_to_a_h2_header(self, hdr_name, hdr_value, is_sensitive, should_index): # noqa: E501
# type: (str, str, Callable[[str, str], bool], Callable[[str], bool]) -> Tuple[HPackHeaders, int] # noqa: E501
""" _convert_a_header_to_a_h2_header builds a HPackHeaders from a header
name... | [
"def",
"_convert_a_header_to_a_h2_header",
"(",
"self",
",",
"hdr_name",
",",
"hdr_value",
",",
"is_sensitive",
",",
"should_index",
")",
":",
"# noqa: E501",
"# type: (str, str, Callable[[str, str], bool], Callable[[str], bool]) -> Tuple[HPackHeaders, int] # noqa: E501",
"# If both... | _convert_a_header_to_a_h2_header builds a HPackHeaders from a header
name and a value. It returns a HPackIndexedHdr whenever possible. If not, # noqa: E501
it returns a HPackLitHdrFldWithoutIndexing or a
HPackLitHdrFldWithIncrIndexing, based on the should_index callback.
HPackLitHdrFldW... | [
"_convert_a_header_to_a_h2_header",
"builds",
"a",
"HPackHeaders",
"from",
"a",
"header",
"name",
"and",
"a",
"value",
".",
"It",
"returns",
"a",
"HPackIndexedHdr",
"whenever",
"possible",
".",
"If",
"not",
"#",
"noqa",
":",
"E501",
"it",
"returns",
"a",
"HPac... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L2512-L2605 | train | This function converts a header name and value to a HPackHeader. It returns a HPackIndexedHdr if possible and a HPackLitHdrFldWithIncrIndexing if possible. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/http2.py | HPackHdrTable.parse_txt_hdrs | def parse_txt_hdrs(self,
s, # type: str
stream_id=1, # type: int
body=None, # type: Optional[str]
max_frm_sz=4096, # type: int
max_hdr_lst_sz=0, # type: int
is_sensitive=lambda ... | python | def parse_txt_hdrs(self,
s, # type: str
stream_id=1, # type: int
body=None, # type: Optional[str]
max_frm_sz=4096, # type: int
max_hdr_lst_sz=0, # type: int
is_sensitive=lambda ... | [
"def",
"parse_txt_hdrs",
"(",
"self",
",",
"s",
",",
"# type: str",
"stream_id",
"=",
"1",
",",
"# type: int",
"body",
"=",
"None",
",",
"# type: Optional[str]",
"max_frm_sz",
"=",
"4096",
",",
"# type: int",
"max_hdr_lst_sz",
"=",
"0",
",",
"# type: int",
"is... | parse_txt_hdrs parses headers expressed in text and converts them
into a series of H2Frames with the "correct" flags. A body can be provided # noqa: E501
in which case, the data frames are added, bearing the End Stream flag,
instead of the H2HeadersFrame/H2ContinuationFrame. The generated frame... | [
"parse_txt_hdrs",
"parses",
"headers",
"expressed",
"in",
"text",
"and",
"converts",
"them",
"into",
"a",
"series",
"of",
"H2Frames",
"with",
"the",
"correct",
"flags",
".",
"A",
"body",
"can",
"be",
"provided",
"#",
"noqa",
":",
"E501",
"in",
"which",
"ca... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L2625-L2730 | train | Parses the given string s into a series of H2Frames with the correct flags. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/diameter.py | AVP | def AVP(avpId, **fields):
""" Craft an AVP based on its id and optional parameter fields"""
val = None
classType = AVP_Unknown
if isinstance(avpId, str):
try:
for vnd in AvpDefDict:
for code in AvpDefDict[vnd]:
val = AvpDefDict[vnd][code]
... | python | def AVP(avpId, **fields):
""" Craft an AVP based on its id and optional parameter fields"""
val = None
classType = AVP_Unknown
if isinstance(avpId, str):
try:
for vnd in AvpDefDict:
for code in AvpDefDict[vnd]:
val = AvpDefDict[vnd][code]
... | [
"def",
"AVP",
"(",
"avpId",
",",
"*",
"*",
"fields",
")",
":",
"val",
"=",
"None",
"classType",
"=",
"AVP_Unknown",
"if",
"isinstance",
"(",
"avpId",
",",
"str",
")",
":",
"try",
":",
"for",
"vnd",
"in",
"AvpDefDict",
":",
"for",
"code",
"in",
"Avp... | Craft an AVP based on its id and optional parameter fields | [
"Craft",
"an",
"AVP",
"based",
"on",
"its",
"id",
"and",
"optional",
"parameter",
"fields"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/diameter.py#L391-L440 | train | Craft an AVP based on its id and optional parameter fields | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/diameter.py | getCmdParams | def getCmdParams(cmd, request, **fields):
"""Update or fill the fields parameters depending on command code. Both cmd and drAppId can be provided # noqa: E501
in string or int format."""
drCode = None
params = None
drAppId = None
# Fetch the parameters if cmd is found in dict
if isinstan... | python | def getCmdParams(cmd, request, **fields):
"""Update or fill the fields parameters depending on command code. Both cmd and drAppId can be provided # noqa: E501
in string or int format."""
drCode = None
params = None
drAppId = None
# Fetch the parameters if cmd is found in dict
if isinstan... | [
"def",
"getCmdParams",
"(",
"cmd",
",",
"request",
",",
"*",
"*",
"fields",
")",
":",
"drCode",
"=",
"None",
"params",
"=",
"None",
"drAppId",
"=",
"None",
"# Fetch the parameters if cmd is found in dict",
"if",
"isinstance",
"(",
"cmd",
",",
"int",
")",
":"... | Update or fill the fields parameters depending on command code. Both cmd and drAppId can be provided # noqa: E501
in string or int format. | [
"Update",
"or",
"fill",
"the",
"fields",
"parameters",
"depending",
"on",
"command",
"code",
".",
"Both",
"cmd",
"and",
"drAppId",
"can",
"be",
"provided",
"#",
"noqa",
":",
"E501",
"in",
"string",
"or",
"int",
"format",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/diameter.py#L4744-L4808 | train | Update or fill the fields with the parameters depending on the command code. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/diameter.py | DiamReq | def DiamReq(cmd, **fields):
"""Craft Diameter request commands"""
upfields, name = getCmdParams(cmd, True, **fields)
p = DiamG(**upfields)
p.name = name
return p | python | def DiamReq(cmd, **fields):
"""Craft Diameter request commands"""
upfields, name = getCmdParams(cmd, True, **fields)
p = DiamG(**upfields)
p.name = name
return p | [
"def",
"DiamReq",
"(",
"cmd",
",",
"*",
"*",
"fields",
")",
":",
"upfields",
",",
"name",
"=",
"getCmdParams",
"(",
"cmd",
",",
"True",
",",
"*",
"*",
"fields",
")",
"p",
"=",
"DiamG",
"(",
"*",
"*",
"upfields",
")",
"p",
".",
"name",
"=",
"nam... | Craft Diameter request commands | [
"Craft",
"Diameter",
"request",
"commands"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/diameter.py#L4811-L4816 | train | Craft Diameter request commands | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/diameter.py | DiamAns | def DiamAns(cmd, **fields):
"""Craft Diameter answer commands"""
upfields, name = getCmdParams(cmd, False, **fields)
p = DiamG(**upfields)
p.name = name
return p | python | def DiamAns(cmd, **fields):
"""Craft Diameter answer commands"""
upfields, name = getCmdParams(cmd, False, **fields)
p = DiamG(**upfields)
p.name = name
return p | [
"def",
"DiamAns",
"(",
"cmd",
",",
"*",
"*",
"fields",
")",
":",
"upfields",
",",
"name",
"=",
"getCmdParams",
"(",
"cmd",
",",
"False",
",",
"*",
"*",
"fields",
")",
"p",
"=",
"DiamG",
"(",
"*",
"*",
"upfields",
")",
"p",
".",
"name",
"=",
"na... | Craft Diameter answer commands | [
"Craft",
"Diameter",
"answer",
"commands"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/diameter.py#L4819-L4824 | train | Craft Diameter answer commands | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/fields.py | Field.i2m | def i2m(self, pkt, x):
"""Convert internal value to machine value"""
if x is None:
x = 0
elif isinstance(x, str):
return bytes_encode(x)
return x | python | def i2m(self, pkt, x):
"""Convert internal value to machine value"""
if x is None:
x = 0
elif isinstance(x, str):
return bytes_encode(x)
return x | [
"def",
"i2m",
"(",
"self",
",",
"pkt",
",",
"x",
")",
":",
"if",
"x",
"is",
"None",
":",
"x",
"=",
"0",
"elif",
"isinstance",
"(",
"x",
",",
"str",
")",
":",
"return",
"bytes_encode",
"(",
"x",
")",
"return",
"x"
] | Convert internal value to machine value | [
"Convert",
"internal",
"value",
"to",
"machine",
"value"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/fields.py#L117-L123 | train | Convert internal value to machine value | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/fields.py | MultipleTypeField._iterate_fields_cond | def _iterate_fields_cond(self, pkt, val, use_val):
"""Internal function used by _find_fld_pkt & _find_fld_pkt_val"""
# Iterate through the fields
for fld, cond in self.flds:
if isinstance(cond, tuple):
if use_val:
if cond[1](pkt, val):
... | python | def _iterate_fields_cond(self, pkt, val, use_val):
"""Internal function used by _find_fld_pkt & _find_fld_pkt_val"""
# Iterate through the fields
for fld, cond in self.flds:
if isinstance(cond, tuple):
if use_val:
if cond[1](pkt, val):
... | [
"def",
"_iterate_fields_cond",
"(",
"self",
",",
"pkt",
",",
"val",
",",
"use_val",
")",
":",
"# Iterate through the fields",
"for",
"fld",
",",
"cond",
"in",
"self",
".",
"flds",
":",
"if",
"isinstance",
"(",
"cond",
",",
"tuple",
")",
":",
"if",
"use_v... | Internal function used by _find_fld_pkt & _find_fld_pkt_val | [
"Internal",
"function",
"used",
"by",
"_find_fld_pkt",
"&",
"_find_fld_pkt_val"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/fields.py#L278-L291 | train | Internal function used by _find_fld_pkt & _find_fld_pkt_val | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/fields.py | MultipleTypeField._find_fld_pkt_val | def _find_fld_pkt_val(self, pkt, val):
"""Given a Packet instance `pkt` and the value `val` to be set,
returns the Field subclass to be used, and the updated `val` if necessary.
"""
fld = self._iterate_fields_cond(pkt, val, True)
# Default ? (in this case, let's make sure it's up-do-dat... | python | def _find_fld_pkt_val(self, pkt, val):
"""Given a Packet instance `pkt` and the value `val` to be set,
returns the Field subclass to be used, and the updated `val` if necessary.
"""
fld = self._iterate_fields_cond(pkt, val, True)
# Default ? (in this case, let's make sure it's up-do-dat... | [
"def",
"_find_fld_pkt_val",
"(",
"self",
",",
"pkt",
",",
"val",
")",
":",
"fld",
"=",
"self",
".",
"_iterate_fields_cond",
"(",
"pkt",
",",
"val",
",",
"True",
")",
"# Default ? (in this case, let's make sure it's up-do-date)",
"dflts_pkt",
"=",
"pkt",
".",
"de... | Given a Packet instance `pkt` and the value `val` to be set,
returns the Field subclass to be used, and the updated `val` if necessary. | [
"Given",
"a",
"Packet",
"instance",
"pkt",
"and",
"the",
"value",
"val",
"to",
"be",
"set",
"returns",
"the",
"Field",
"subclass",
"to",
"be",
"used",
"and",
"the",
"updated",
"val",
"if",
"necessary",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/fields.py#L301-L312 | train | Given a Packet instance pkt and the value val to be set returns the Field subclass to be used and the updated val. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/fields.py | MultipleTypeField._find_fld | def _find_fld(self):
"""Returns the Field subclass to be used, depending on the Packet
instance, or the default subclass.
DEV: since the Packet instance is not provided, we have to use a hack
to guess it. It should only be used if you cannot provide the current
Packet instance (for example, because of the curr... | python | def _find_fld(self):
"""Returns the Field subclass to be used, depending on the Packet
instance, or the default subclass.
DEV: since the Packet instance is not provided, we have to use a hack
to guess it. It should only be used if you cannot provide the current
Packet instance (for example, because of the curr... | [
"def",
"_find_fld",
"(",
"self",
")",
":",
"# Hack to preserve current Scapy API",
"# See https://stackoverflow.com/a/7272464/3223422",
"frame",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
".",
"f_back",
"while",
"frame",
"is",
"not",
"None",
":",
... | Returns the Field subclass to be used, depending on the Packet
instance, or the default subclass.
DEV: since the Packet instance is not provided, we have to use a hack
to guess it. It should only be used if you cannot provide the current
Packet instance (for example, because of the current Scapy API).
If you have the... | [
"Returns",
"the",
"Field",
"subclass",
"to",
"be",
"used",
"depending",
"on",
"the",
"Packet",
"instance",
"or",
"the",
"default",
"subclass",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/fields.py#L314-L338 | train | Returns the Field subclass to be used depending on the Packet instance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/fields.py | FlagsField._fixup_val | def _fixup_val(self, x):
"""Returns a FlagValue instance when needed. Internal method, to be
used in *2i() and i2*() methods.
"""
if isinstance(x, (list, tuple)):
return type(x)(
v if v is None or isinstance(v, FlagValue)
else FlagValue(v, self.names)... | python | def _fixup_val(self, x):
"""Returns a FlagValue instance when needed. Internal method, to be
used in *2i() and i2*() methods.
"""
if isinstance(x, (list, tuple)):
return type(x)(
v if v is None or isinstance(v, FlagValue)
else FlagValue(v, self.names)... | [
"def",
"_fixup_val",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"type",
"(",
"x",
")",
"(",
"v",
"if",
"v",
"is",
"None",
"or",
"isinstance",
"(",
"v",
",",
"FlagValue... | Returns a FlagValue instance when needed. Internal method, to be
used in *2i() and i2*() methods. | [
"Returns",
"a",
"FlagValue",
"instance",
"when",
"needed",
".",
"Internal",
"method",
"to",
"be",
"used",
"in",
"*",
"2i",
"()",
"and",
"i2",
"*",
"()",
"methods",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/fields.py#L1965-L1976 | train | Returns a FlagValue instance when needed. Internal method to be
used in i2i and i2o methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/fields.py | UUIDField._check_uuid_fmt | def _check_uuid_fmt(self):
"""Checks .uuid_fmt, and raises an exception if it is not valid."""
if self.uuid_fmt not in UUIDField.FORMATS:
raise FieldValueRangeException(
"Unsupported uuid_fmt ({})".format(self.uuid_fmt)) | python | def _check_uuid_fmt(self):
"""Checks .uuid_fmt, and raises an exception if it is not valid."""
if self.uuid_fmt not in UUIDField.FORMATS:
raise FieldValueRangeException(
"Unsupported uuid_fmt ({})".format(self.uuid_fmt)) | [
"def",
"_check_uuid_fmt",
"(",
"self",
")",
":",
"if",
"self",
".",
"uuid_fmt",
"not",
"in",
"UUIDField",
".",
"FORMATS",
":",
"raise",
"FieldValueRangeException",
"(",
"\"Unsupported uuid_fmt ({})\"",
".",
"format",
"(",
"self",
".",
"uuid_fmt",
")",
")"
] | Checks .uuid_fmt, and raises an exception if it is not valid. | [
"Checks",
".",
"uuid_fmt",
"and",
"raises",
"an",
"exception",
"if",
"it",
"is",
"not",
"valid",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/fields.py#L2392-L2396 | train | Checks. uuid_fmt and raises an exception if it is not valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/record_tls13.py | TLSInnerPlaintext.pre_dissect | def pre_dissect(self, s):
"""
We need to parse the padding and type as soon as possible,
else we won't be able to parse the message list...
"""
if len(s) < 1:
raise Exception("Invalid InnerPlaintext (too short).")
tmp_len = len(s) - 1
if s[-1] != b"\x... | python | def pre_dissect(self, s):
"""
We need to parse the padding and type as soon as possible,
else we won't be able to parse the message list...
"""
if len(s) < 1:
raise Exception("Invalid InnerPlaintext (too short).")
tmp_len = len(s) - 1
if s[-1] != b"\x... | [
"def",
"pre_dissect",
"(",
"self",
",",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"<",
"1",
":",
"raise",
"Exception",
"(",
"\"Invalid InnerPlaintext (too short).\"",
")",
"tmp_len",
"=",
"len",
"(",
"s",
")",
"-",
"1",
"if",
"s",
"[",
"-",
"1",
"... | We need to parse the padding and type as soon as possible,
else we won't be able to parse the message list... | [
"We",
"need",
"to",
"parse",
"the",
"padding",
"and",
"type",
"as",
"soon",
"as",
"possible",
"else",
"we",
"won",
"t",
"be",
"able",
"to",
"parse",
"the",
"message",
"list",
"..."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L39-L59 | train | Parse the message list and set the type field. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/record_tls13.py | TLS13._tls_auth_decrypt | def _tls_auth_decrypt(self, s):
"""
Provided with the record header and AEAD-ciphered data, return the
sliced and clear tuple (TLSInnerPlaintext, tag). Note that
we still return the slicing of the original input in case of decryption
failure. Also, if the integrity check fails, a... | python | def _tls_auth_decrypt(self, s):
"""
Provided with the record header and AEAD-ciphered data, return the
sliced and clear tuple (TLSInnerPlaintext, tag). Note that
we still return the slicing of the original input in case of decryption
failure. Also, if the integrity check fails, a... | [
"def",
"_tls_auth_decrypt",
"(",
"self",
",",
"s",
")",
":",
"rcs",
"=",
"self",
".",
"tls_session",
".",
"rcs",
"read_seq_num",
"=",
"struct",
".",
"pack",
"(",
"\"!Q\"",
",",
"rcs",
".",
"seq_num",
")",
"rcs",
".",
"seq_num",
"+=",
"1",
"try",
":",... | Provided with the record header and AEAD-ciphered data, return the
sliced and clear tuple (TLSInnerPlaintext, tag). Note that
we still return the slicing of the original input in case of decryption
failure. Also, if the integrity check fails, a warning will be issued,
but we still return... | [
"Provided",
"with",
"the",
"record",
"header",
"and",
"AEAD",
"-",
"ciphered",
"data",
"return",
"the",
"sliced",
"and",
"clear",
"tuple",
"(",
"TLSInnerPlaintext",
"tag",
")",
".",
"Note",
"that",
"we",
"still",
"return",
"the",
"slicing",
"of",
"the",
"o... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L104-L122 | train | Decrypt the input string s with AEAD - ciphered data and return the decrypted AEAD - encrypted data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/record_tls13.py | TLS13.pre_dissect | def pre_dissect(self, s):
"""
Decrypt, verify and decompress the message.
"""
if len(s) < 5:
raise Exception("Invalid record: header is too short.")
if isinstance(self.tls_session.rcs.cipher, Cipher_NULL):
self.deciphered_len = None
return s
... | python | def pre_dissect(self, s):
"""
Decrypt, verify and decompress the message.
"""
if len(s) < 5:
raise Exception("Invalid record: header is too short.")
if isinstance(self.tls_session.rcs.cipher, Cipher_NULL):
self.deciphered_len = None
return s
... | [
"def",
"pre_dissect",
"(",
"self",
",",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"<",
"5",
":",
"raise",
"Exception",
"(",
"\"Invalid record: header is too short.\"",
")",
"if",
"isinstance",
"(",
"self",
".",
"tls_session",
".",
"rcs",
".",
"cipher",
... | Decrypt, verify and decompress the message. | [
"Decrypt",
"verify",
"and",
"decompress",
"the",
"message",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L124-L139 | train | Decrypt verify and decompress the message. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/record_tls13.py | TLS13.post_dissect | def post_dissect(self, s):
"""
Commit the pending read state if it has been triggered. We update
nothing if the prcs was not set, as this probably means that we're
working out-of-context (and we need to keep the default rcs).
"""
if self.tls_session.triggered_prcs_commit:... | python | def post_dissect(self, s):
"""
Commit the pending read state if it has been triggered. We update
nothing if the prcs was not set, as this probably means that we're
working out-of-context (and we need to keep the default rcs).
"""
if self.tls_session.triggered_prcs_commit:... | [
"def",
"post_dissect",
"(",
"self",
",",
"s",
")",
":",
"if",
"self",
".",
"tls_session",
".",
"triggered_prcs_commit",
":",
"if",
"self",
".",
"tls_session",
".",
"prcs",
"is",
"not",
"None",
":",
"self",
".",
"tls_session",
".",
"rcs",
"=",
"self",
"... | Commit the pending read state if it has been triggered. We update
nothing if the prcs was not set, as this probably means that we're
working out-of-context (and we need to keep the default rcs). | [
"Commit",
"the",
"pending",
"read",
"state",
"if",
"it",
"has",
"been",
"triggered",
".",
"We",
"update",
"nothing",
"if",
"the",
"prcs",
"was",
"not",
"set",
"as",
"this",
"probably",
"means",
"that",
"we",
"re",
"working",
"out",
"-",
"of",
"-",
"con... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L141-L152 | train | Update the pending read state if the prcs has been set. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/record_tls13.py | TLS13._tls_auth_encrypt | def _tls_auth_encrypt(self, s):
"""
Return the TLSCiphertext.encrypted_record for AEAD ciphers.
"""
wcs = self.tls_session.wcs
write_seq_num = struct.pack("!Q", wcs.seq_num)
wcs.seq_num += 1
return wcs.cipher.auth_encrypt(s, b"", write_seq_num) | python | def _tls_auth_encrypt(self, s):
"""
Return the TLSCiphertext.encrypted_record for AEAD ciphers.
"""
wcs = self.tls_session.wcs
write_seq_num = struct.pack("!Q", wcs.seq_num)
wcs.seq_num += 1
return wcs.cipher.auth_encrypt(s, b"", write_seq_num) | [
"def",
"_tls_auth_encrypt",
"(",
"self",
",",
"s",
")",
":",
"wcs",
"=",
"self",
".",
"tls_session",
".",
"wcs",
"write_seq_num",
"=",
"struct",
".",
"pack",
"(",
"\"!Q\"",
",",
"wcs",
".",
"seq_num",
")",
"wcs",
".",
"seq_num",
"+=",
"1",
"return",
... | Return the TLSCiphertext.encrypted_record for AEAD ciphers. | [
"Return",
"the",
"TLSCiphertext",
".",
"encrypted_record",
"for",
"AEAD",
"ciphers",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L172-L179 | train | Encrypt a string with the AEAD ciphertext. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/record_tls13.py | TLS13.post_build | def post_build(self, pkt, pay):
"""
Apply the previous methods according to the writing cipher type.
"""
# Compute the length of TLSPlaintext fragment
hdr, frag = pkt[:5], pkt[5:]
if not isinstance(self.tls_session.rcs.cipher, Cipher_NULL):
frag = self._tls_au... | python | def post_build(self, pkt, pay):
"""
Apply the previous methods according to the writing cipher type.
"""
# Compute the length of TLSPlaintext fragment
hdr, frag = pkt[:5], pkt[5:]
if not isinstance(self.tls_session.rcs.cipher, Cipher_NULL):
frag = self._tls_au... | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"# Compute the length of TLSPlaintext fragment",
"hdr",
",",
"frag",
"=",
"pkt",
"[",
":",
"5",
"]",
",",
"pkt",
"[",
"5",
":",
"]",
"if",
"not",
"isinstance",
"(",
"self",
".",
"tls_s... | Apply the previous methods according to the writing cipher type. | [
"Apply",
"the",
"previous",
"methods",
"according",
"to",
"the",
"writing",
"cipher",
"type",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L181-L206 | train | Apply the previous methods according to the writing cipher type. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | ARC4_encrypt | def ARC4_encrypt(key, data, skip=0):
"""Encrypt data @data with key @key, skipping @skip first bytes of the
keystream"""
algorithm = algorithms.ARC4(key)
cipher = Cipher(algorithm, mode=None, backend=default_backend())
encryptor = cipher.encryptor()
if skip:
encryptor.update(b"\x00" * s... | python | def ARC4_encrypt(key, data, skip=0):
"""Encrypt data @data with key @key, skipping @skip first bytes of the
keystream"""
algorithm = algorithms.ARC4(key)
cipher = Cipher(algorithm, mode=None, backend=default_backend())
encryptor = cipher.encryptor()
if skip:
encryptor.update(b"\x00" * s... | [
"def",
"ARC4_encrypt",
"(",
"key",
",",
"data",
",",
"skip",
"=",
"0",
")",
":",
"algorithm",
"=",
"algorithms",
".",
"ARC4",
"(",
"key",
")",
"cipher",
"=",
"Cipher",
"(",
"algorithm",
",",
"mode",
"=",
"None",
",",
"backend",
"=",
"default_backend",
... | Encrypt data @data with key @key, skipping @skip first bytes of the
keystream | [
"Encrypt",
"data"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L18-L27 | train | Encrypt data with key key. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | customPRF512 | def customPRF512(key, amac, smac, anonce, snonce):
"""Source https://stackoverflow.com/questions/12018920/"""
A = b"Pairwise key expansion"
B = b"".join(sorted([amac, smac]) + sorted([anonce, snonce]))
blen = 64
i = 0
R = b''
while i <= ((blen * 8 + 159) / 160):
hmacsha1 = hmac.new(... | python | def customPRF512(key, amac, smac, anonce, snonce):
"""Source https://stackoverflow.com/questions/12018920/"""
A = b"Pairwise key expansion"
B = b"".join(sorted([amac, smac]) + sorted([anonce, snonce]))
blen = 64
i = 0
R = b''
while i <= ((blen * 8 + 159) / 160):
hmacsha1 = hmac.new(... | [
"def",
"customPRF512",
"(",
"key",
",",
"amac",
",",
"smac",
",",
"anonce",
",",
"snonce",
")",
":",
"A",
"=",
"b\"Pairwise key expansion\"",
"B",
"=",
"b\"\"",
".",
"join",
"(",
"sorted",
"(",
"[",
"amac",
",",
"smac",
"]",
")",
"+",
"sorted",
"(",
... | Source https://stackoverflow.com/questions/12018920/ | [
"Source",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"12018920",
"/"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L38-L50 | train | Custom PRF512 implementation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | gen_TKIP_RC4_key | def gen_TKIP_RC4_key(TSC, TA, TK):
"""Implement TKIP WEPSeed generation
TSC: packet IV
TA: target addr bytes
TK: temporal key
"""
assert len(TSC) == 6
assert len(TA) == 6
assert len(TK) == 16
assert all(isinstance(x, six.integer_types) for x in TSC + TA + TK)
# Phase 1
# 80... | python | def gen_TKIP_RC4_key(TSC, TA, TK):
"""Implement TKIP WEPSeed generation
TSC: packet IV
TA: target addr bytes
TK: temporal key
"""
assert len(TSC) == 6
assert len(TA) == 6
assert len(TK) == 16
assert all(isinstance(x, six.integer_types) for x in TSC + TA + TK)
# Phase 1
# 80... | [
"def",
"gen_TKIP_RC4_key",
"(",
"TSC",
",",
"TA",
",",
"TK",
")",
":",
"assert",
"len",
"(",
"TSC",
")",
"==",
"6",
"assert",
"len",
"(",
"TA",
")",
"==",
"6",
"assert",
"len",
"(",
"TK",
")",
"==",
"16",
"assert",
"all",
"(",
"isinstance",
"(",
... | Implement TKIP WEPSeed generation
TSC: packet IV
TA: target addr bytes
TK: temporal key | [
"Implement",
"TKIP",
"WEPSeed",
"generation",
"TSC",
":",
"packet",
"IV",
"TA",
":",
"target",
"addr",
"bytes",
"TK",
":",
"temporal",
"key"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L148-L214 | train | Implement TKIP WEPSeed generation | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | _michael_b | def _michael_b(m_l, m_r):
"""Defined in 802.11i p.49"""
m_r = m_r ^ _rotate_left32(m_l, 17)
m_l = (m_l + m_r) % 2**32
m_r = m_r ^ _XSWAP(m_l)
m_l = (m_l + m_r) % 2**32
m_r = m_r ^ _rotate_left32(m_l, 3)
m_l = (m_l + m_r) % 2**32
m_r = m_r ^ _rotate_right32(m_l, 2)
m_l = (m_l + m_r) %... | python | def _michael_b(m_l, m_r):
"""Defined in 802.11i p.49"""
m_r = m_r ^ _rotate_left32(m_l, 17)
m_l = (m_l + m_r) % 2**32
m_r = m_r ^ _XSWAP(m_l)
m_l = (m_l + m_r) % 2**32
m_r = m_r ^ _rotate_left32(m_l, 3)
m_l = (m_l + m_r) % 2**32
m_r = m_r ^ _rotate_right32(m_l, 2)
m_l = (m_l + m_r) %... | [
"def",
"_michael_b",
"(",
"m_l",
",",
"m_r",
")",
":",
"m_r",
"=",
"m_r",
"^",
"_rotate_left32",
"(",
"m_l",
",",
"17",
")",
"m_l",
"=",
"(",
"m_l",
"+",
"m_r",
")",
"%",
"2",
"**",
"32",
"m_r",
"=",
"m_r",
"^",
"_XSWAP",
"(",
"m_l",
")",
"m_... | Defined in 802.11i p.49 | [
"Defined",
"in",
"802",
".",
"11i",
"p",
".",
"49"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L233-L243 | train | Defined in 802. 11i p. 49 | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | michael | def michael(key, to_hash):
"""Defined in 802.11i p.48"""
# Block size: 4
nb_block, nb_extra_bytes = divmod(len(to_hash), 4)
# Add padding
data = to_hash + chb(0x5a) + b"\x00" * (7 - nb_extra_bytes)
# Hash
m_l, m_r = unpack('<II', key)
for i in range(nb_block + 2):
# Convert i-t... | python | def michael(key, to_hash):
"""Defined in 802.11i p.48"""
# Block size: 4
nb_block, nb_extra_bytes = divmod(len(to_hash), 4)
# Add padding
data = to_hash + chb(0x5a) + b"\x00" * (7 - nb_extra_bytes)
# Hash
m_l, m_r = unpack('<II', key)
for i in range(nb_block + 2):
# Convert i-t... | [
"def",
"michael",
"(",
"key",
",",
"to_hash",
")",
":",
"# Block size: 4",
"nb_block",
",",
"nb_extra_bytes",
"=",
"divmod",
"(",
"len",
"(",
"to_hash",
")",
",",
"4",
")",
"# Add padding",
"data",
"=",
"to_hash",
"+",
"chb",
"(",
"0x5a",
")",
"+",
"b\... | Defined in 802.11i p.48 | [
"Defined",
"in",
"802",
".",
"11i",
"p",
".",
"48"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L246-L261 | train | Michael key to_hash | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | parse_TKIP_hdr | def parse_TKIP_hdr(pkt):
"""Extract TSCs, TA and encoded-data from a packet @pkt"""
# Note: FCS bit is not handled
assert pkt.FCfield.protected
# 802.11i - 8.3.2.2
tkip_layer = pkt[Dot11TKIP]
payload = tkip_layer.data
# IV
if not tkip_layer.ext_iv:
# 802.11i p. 46
raise... | python | def parse_TKIP_hdr(pkt):
"""Extract TSCs, TA and encoded-data from a packet @pkt"""
# Note: FCS bit is not handled
assert pkt.FCfield.protected
# 802.11i - 8.3.2.2
tkip_layer = pkt[Dot11TKIP]
payload = tkip_layer.data
# IV
if not tkip_layer.ext_iv:
# 802.11i p. 46
raise... | [
"def",
"parse_TKIP_hdr",
"(",
"pkt",
")",
":",
"# Note: FCS bit is not handled",
"assert",
"pkt",
".",
"FCfield",
".",
"protected",
"# 802.11i - 8.3.2.2",
"tkip_layer",
"=",
"pkt",
"[",
"Dot11TKIP",
"]",
"payload",
"=",
"tkip_layer",
".",
"data",
"# IV",
"if",
"... | Extract TSCs, TA and encoded-data from a packet @pkt | [
"Extract",
"TSCs",
"TA",
"and",
"encoded",
"-",
"data",
"from",
"a",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L266-L295 | train | Extract TSCs TA and encoded - data from a packet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | build_TKIP_payload | def build_TKIP_payload(data, iv, mac, tk):
"""Build a TKIP header for IV @iv and mac @mac, and encrypt @data
based on temporal key @tk
"""
TSC5, TSC4, TSC3, TSC2, TSC1, TSC0 = (
(iv >> 40) & 0xFF,
(iv >> 32) & 0xFF,
(iv >> 24) & 0xFF,
(iv >> 16) & 0xFF,
(iv >> 8) ... | python | def build_TKIP_payload(data, iv, mac, tk):
"""Build a TKIP header for IV @iv and mac @mac, and encrypt @data
based on temporal key @tk
"""
TSC5, TSC4, TSC3, TSC2, TSC1, TSC0 = (
(iv >> 40) & 0xFF,
(iv >> 32) & 0xFF,
(iv >> 24) & 0xFF,
(iv >> 16) & 0xFF,
(iv >> 8) ... | [
"def",
"build_TKIP_payload",
"(",
"data",
",",
"iv",
",",
"mac",
",",
"tk",
")",
":",
"TSC5",
",",
"TSC4",
",",
"TSC3",
",",
"TSC2",
",",
"TSC1",
",",
"TSC0",
"=",
"(",
"(",
"iv",
">>",
"40",
")",
"&",
"0xFF",
",",
"(",
"iv",
">>",
"32",
")",... | Build a TKIP header for IV @iv and mac @mac, and encrypt @data
based on temporal key @tk | [
"Build",
"a",
"TKIP",
"header",
"for",
"IV"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L298-L319 | train | Build a TKIP payload for IV and MAC and encrypt it based on temporal key tk. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | parse_data_pkt | def parse_data_pkt(pkt, tk):
"""Extract data from a WPA packet @pkt with temporal key @tk"""
TSC, TA, data = parse_TKIP_hdr(pkt)
TK = [orb(x) for x in tk]
rc4_key = gen_TKIP_RC4_key(TSC, TA, TK)
return ARC4_decrypt(rc4_key, data) | python | def parse_data_pkt(pkt, tk):
"""Extract data from a WPA packet @pkt with temporal key @tk"""
TSC, TA, data = parse_TKIP_hdr(pkt)
TK = [orb(x) for x in tk]
rc4_key = gen_TKIP_RC4_key(TSC, TA, TK)
return ARC4_decrypt(rc4_key, data) | [
"def",
"parse_data_pkt",
"(",
"pkt",
",",
"tk",
")",
":",
"TSC",
",",
"TA",
",",
"data",
"=",
"parse_TKIP_hdr",
"(",
"pkt",
")",
"TK",
"=",
"[",
"orb",
"(",
"x",
")",
"for",
"x",
"in",
"tk",
"]",
"rc4_key",
"=",
"gen_TKIP_RC4_key",
"(",
"TSC",
",... | Extract data from a WPA packet @pkt with temporal key @tk | [
"Extract",
"data",
"from",
"a",
"WPA",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L322-L328 | train | Extract data from a WPA packet with temporal key tk | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | check_MIC_ICV | def check_MIC_ICV(data, mic_key, source, dest):
"""Check MIC, ICV & return the data from a decrypted TKIP packet"""
assert len(data) > 12
# DATA - MIC(DA - SA - Priority=0 - 0 - 0 - 0 - DATA) - ICV
# 802.11i p.47
ICV = data[-4:]
MIC = data[-12:-4]
data_clear = data[:-12]
expected_ICV ... | python | def check_MIC_ICV(data, mic_key, source, dest):
"""Check MIC, ICV & return the data from a decrypted TKIP packet"""
assert len(data) > 12
# DATA - MIC(DA - SA - Priority=0 - 0 - 0 - 0 - DATA) - ICV
# 802.11i p.47
ICV = data[-4:]
MIC = data[-12:-4]
data_clear = data[:-12]
expected_ICV ... | [
"def",
"check_MIC_ICV",
"(",
"data",
",",
"mic_key",
",",
"source",
",",
"dest",
")",
":",
"assert",
"len",
"(",
"data",
")",
">",
"12",
"# DATA - MIC(DA - SA - Priority=0 - 0 - 0 - 0 - DATA) - ICV",
"# 802.11i p.47",
"ICV",
"=",
"data",
"[",
"-",
"4",
":",
"]... | Check MIC, ICV & return the data from a decrypted TKIP packet | [
"Check",
"MIC",
"ICV",
"&",
"return",
"the",
"data",
"from",
"a",
"decrypted",
"TKIP",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L341-L363 | train | Check MIC and ICV & return the data from a decrypted TKIP packet | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/modules/krack/crypto.py | build_MIC_ICV | def build_MIC_ICV(data, mic_key, source, dest):
"""Compute and return the data with its MIC and ICV"""
# DATA - MIC(DA - SA - Priority=0 - 0 - 0 - 0 - DATA) - ICV
# 802.11i p.47
sa = mac2str(source) # Source MAC
da = mac2str(dest) # Dest MAC
MIC = michael(mic_key, da + sa + b"\x00" + b"\x00" ... | python | def build_MIC_ICV(data, mic_key, source, dest):
"""Compute and return the data with its MIC and ICV"""
# DATA - MIC(DA - SA - Priority=0 - 0 - 0 - 0 - DATA) - ICV
# 802.11i p.47
sa = mac2str(source) # Source MAC
da = mac2str(dest) # Dest MAC
MIC = michael(mic_key, da + sa + b"\x00" + b"\x00" ... | [
"def",
"build_MIC_ICV",
"(",
"data",
",",
"mic_key",
",",
"source",
",",
"dest",
")",
":",
"# DATA - MIC(DA - SA - Priority=0 - 0 - 0 - 0 - DATA) - ICV",
"# 802.11i p.47",
"sa",
"=",
"mac2str",
"(",
"source",
")",
"# Source MAC",
"da",
"=",
"mac2str",
"(",
"dest",
... | Compute and return the data with its MIC and ICV | [
"Compute",
"and",
"return",
"the",
"data",
"with",
"its",
"MIC",
"and",
"ICV"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/crypto.py#L366-L376 | train | Compute and return the data with its MIC and ICV | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | _lcm | def _lcm(a, b):
"""
Least Common Multiple between 2 integers.
"""
if a == 0 or b == 0:
return 0
else:
return abs(a * b) // gcd(a, b) | python | def _lcm(a, b):
"""
Least Common Multiple between 2 integers.
"""
if a == 0 or b == 0:
return 0
else:
return abs(a * b) // gcd(a, b) | [
"def",
"_lcm",
"(",
"a",
",",
"b",
")",
":",
"if",
"a",
"==",
"0",
"or",
"b",
"==",
"0",
":",
"return",
"0",
"else",
":",
"return",
"abs",
"(",
"a",
"*",
"b",
")",
"//",
"gcd",
"(",
"a",
",",
"b",
")"
] | Least Common Multiple between 2 integers. | [
"Least",
"Common",
"Multiple",
"between",
"2",
"integers",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L186-L193 | train | Return the Least Common Multiple between 2 integers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | split_for_transport | def split_for_transport(orig_pkt, transport_proto):
"""
Split an IP(v6) packet in the correct location to insert an ESP or AH
header.
@param orig_pkt: the packet to split. Must be an IP or IPv6 packet
@param transport_proto: the IPsec protocol number that will be inserted
... | python | def split_for_transport(orig_pkt, transport_proto):
"""
Split an IP(v6) packet in the correct location to insert an ESP or AH
header.
@param orig_pkt: the packet to split. Must be an IP or IPv6 packet
@param transport_proto: the IPsec protocol number that will be inserted
... | [
"def",
"split_for_transport",
"(",
"orig_pkt",
",",
"transport_proto",
")",
":",
"# force resolution of default fields to avoid padding errors",
"header",
"=",
"orig_pkt",
".",
"__class__",
"(",
"raw",
"(",
"orig_pkt",
")",
")",
"next_hdr",
"=",
"header",
".",
"payloa... | Split an IP(v6) packet in the correct location to insert an ESP or AH
header.
@param orig_pkt: the packet to split. Must be an IP or IPv6 packet
@param transport_proto: the IPsec protocol number that will be inserted
at the split position.
@return: a tuple (header, nh, paylo... | [
"Split",
"an",
"IP",
"(",
"v6",
")",
"packet",
"in",
"the",
"correct",
"location",
"to",
"insert",
"an",
"ESP",
"or",
"AH",
"header",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L642-L688 | train | Split an IP or IPv6 packet into two components. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | CryptAlgo.new_cipher | def new_cipher(self, key, mode_iv, digest=None):
"""
@param key: the secret key, a byte string
@param mode_iv: the initialization vector or nonce, a byte string.
Formatted by `format_mode_iv`.
@param digest: also known as tag or icv. A byte string containing ... | python | def new_cipher(self, key, mode_iv, digest=None):
"""
@param key: the secret key, a byte string
@param mode_iv: the initialization vector or nonce, a byte string.
Formatted by `format_mode_iv`.
@param digest: also known as tag or icv. A byte string containing ... | [
"def",
"new_cipher",
"(",
"self",
",",
"key",
",",
"mode_iv",
",",
"digest",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_aead",
"and",
"digest",
"is",
"not",
"None",
":",
"# With AEAD, the mode needs the digest during decryption.",
"return",
"Cipher",
"(",
"... | @param key: the secret key, a byte string
@param mode_iv: the initialization vector or nonce, a byte string.
Formatted by `format_mode_iv`.
@param digest: also known as tag or icv. A byte string containing the
digest of the encrypted data. Only use th... | [
"@param",
"key",
":",
"the",
"secret",
"key",
"a",
"byte",
"string",
"@param",
"mode_iv",
":",
"the",
"initialization",
"vector",
"or",
"nonce",
"a",
"byte",
"string",
".",
"Formatted",
"by",
"format_mode_iv",
".",
"@param",
"digest",
":",
"also",
"known",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L281-L304 | train | Returns a new Cipher object for the current object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | CryptAlgo.pad | def pad(self, esp):
"""
Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm's block size.
Also, make sure that the total ESP packet length is a multiple of 4
bytes.
@param esp: an unencrypted _ESPPlain packet
... | python | def pad(self, esp):
"""
Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm's block size.
Also, make sure that the total ESP packet length is a multiple of 4
bytes.
@param esp: an unencrypted _ESPPlain packet
... | [
"def",
"pad",
"(",
"self",
",",
"esp",
")",
":",
"# 2 extra bytes for padlen and nh",
"data_len",
"=",
"len",
"(",
"esp",
".",
"data",
")",
"+",
"2",
"# according to the RFC4303, section 2.4. Padding (for Encryption)",
"# the size of the ESP payload must be a multiple of 32 b... | Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm's block size.
Also, make sure that the total ESP packet length is a multiple of 4
bytes.
@param esp: an unencrypted _ESPPlain packet
@return: an unencrypted _ESPPlain pac... | [
"Add",
"the",
"correct",
"amount",
"of",
"padding",
"so",
"that",
"the",
"data",
"to",
"encrypt",
"is",
"exactly",
"a",
"multiple",
"of",
"the",
"algorithm",
"s",
"block",
"size",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L306-L339 | train | Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm s block size. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | CryptAlgo.encrypt | def encrypt(self, sa, esp, key):
"""
Encrypt an ESP packet
@param sa: the SecurityAssociation associated with the ESP packet.
@param esp: an unencrypted _ESPPlain packet with valid padding
@param key: the secret key used for encryption
@return: a valid ESP packet... | python | def encrypt(self, sa, esp, key):
"""
Encrypt an ESP packet
@param sa: the SecurityAssociation associated with the ESP packet.
@param esp: an unencrypted _ESPPlain packet with valid padding
@param key: the secret key used for encryption
@return: a valid ESP packet... | [
"def",
"encrypt",
"(",
"self",
",",
"sa",
",",
"esp",
",",
"key",
")",
":",
"data",
"=",
"esp",
".",
"data_for_encryption",
"(",
")",
"if",
"self",
".",
"cipher",
":",
"mode_iv",
"=",
"self",
".",
"_format_mode_iv",
"(",
"algo",
"=",
"self",
",",
"... | Encrypt an ESP packet
@param sa: the SecurityAssociation associated with the ESP packet.
@param esp: an unencrypted _ESPPlain packet with valid padding
@param key: the secret key used for encryption
@return: a valid ESP packet encrypted with this algorithm | [
"Encrypt",
"an",
"ESP",
"packet"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L341-L366 | train | Encrypt an ESP packet with this algorithm | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | AuthAlgo.check_key | def check_key(self, key):
"""
Check that the key length is valid.
@param key: a byte string
"""
if self.key_size and len(key) not in self.key_size:
raise TypeError('invalid key size %s, must be one of %s' %
(len(key), self.key_size)) | python | def check_key(self, key):
"""
Check that the key length is valid.
@param key: a byte string
"""
if self.key_size and len(key) not in self.key_size:
raise TypeError('invalid key size %s, must be one of %s' %
(len(key), self.key_size)) | [
"def",
"check_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"key_size",
"and",
"len",
"(",
"key",
")",
"not",
"in",
"self",
".",
"key_size",
":",
"raise",
"TypeError",
"(",
"'invalid key size %s, must be one of %s'",
"%",
"(",
"len",
"(",
"... | Check that the key length is valid.
@param key: a byte string | [
"Check",
"that",
"the",
"key",
"length",
"is",
"valid",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L516-L524 | train | Check that the key length is valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | AuthAlgo.sign | def sign(self, pkt, key):
"""
Sign an IPsec (ESP or AH) packet with this algo.
@param pkt: a packet that contains a valid encrypted ESP or AH layer
@param key: the authentication key, a byte string
@return: the signed packet
"""
if not self.mac:
... | python | def sign(self, pkt, key):
"""
Sign an IPsec (ESP or AH) packet with this algo.
@param pkt: a packet that contains a valid encrypted ESP or AH layer
@param key: the authentication key, a byte string
@return: the signed packet
"""
if not self.mac:
... | [
"def",
"sign",
"(",
"self",
",",
"pkt",
",",
"key",
")",
":",
"if",
"not",
"self",
".",
"mac",
":",
"return",
"pkt",
"mac",
"=",
"self",
".",
"new_mac",
"(",
"key",
")",
"if",
"pkt",
".",
"haslayer",
"(",
"ESP",
")",
":",
"mac",
".",
"update",
... | Sign an IPsec (ESP or AH) packet with this algo.
@param pkt: a packet that contains a valid encrypted ESP or AH layer
@param key: the authentication key, a byte string
@return: the signed packet | [
"Sign",
"an",
"IPsec",
"(",
"ESP",
"or",
"AH",
")",
"packet",
"with",
"this",
"algo",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L537-L560 | train | Sign an IPsec packet with this algo. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | AuthAlgo.verify | def verify(self, pkt, key):
"""
Check that the integrity check value (icv) of a packet is valid.
@param pkt: a packet that contains a valid encrypted ESP or AH layer
@param key: the authentication key, a byte string
@raise IPSecIntegrityError: if the integrity check fails... | python | def verify(self, pkt, key):
"""
Check that the integrity check value (icv) of a packet is valid.
@param pkt: a packet that contains a valid encrypted ESP or AH layer
@param key: the authentication key, a byte string
@raise IPSecIntegrityError: if the integrity check fails... | [
"def",
"verify",
"(",
"self",
",",
"pkt",
",",
"key",
")",
":",
"if",
"not",
"self",
".",
"mac",
"or",
"self",
".",
"icv_size",
"==",
"0",
":",
"return",
"mac",
"=",
"self",
".",
"new_mac",
"(",
"key",
")",
"pkt_icv",
"=",
"'not found'",
"computed_... | Check that the integrity check value (icv) of a packet is valid.
@param pkt: a packet that contains a valid encrypted ESP or AH layer
@param key: the authentication key, a byte string
@raise IPSecIntegrityError: if the integrity check fails | [
"Check",
"that",
"the",
"integrity",
"check",
"value",
"(",
"icv",
")",
"of",
"a",
"packet",
"is",
"valid",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L562-L598 | train | Verify that the ICV of a packet is valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | SecurityAssociation.encrypt | def encrypt(self, pkt, seq_num=None, iv=None):
"""
Encrypt (and encapsulate) an IP(v6) packet with ESP or AH according
to this SecurityAssociation.
@param pkt: the packet to encrypt
@param seq_num: if specified, use this sequence number instead of the
... | python | def encrypt(self, pkt, seq_num=None, iv=None):
"""
Encrypt (and encapsulate) an IP(v6) packet with ESP or AH according
to this SecurityAssociation.
@param pkt: the packet to encrypt
@param seq_num: if specified, use this sequence number instead of the
... | [
"def",
"encrypt",
"(",
"self",
",",
"pkt",
",",
"seq_num",
"=",
"None",
",",
"iv",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"pkt",
",",
"self",
".",
"SUPPORTED_PROTOS",
")",
":",
"raise",
"TypeError",
"(",
"'cannot encrypt %s, supported proto... | Encrypt (and encapsulate) an IP(v6) packet with ESP or AH according
to this SecurityAssociation.
@param pkt: the packet to encrypt
@param seq_num: if specified, use this sequence number instead of the
generated one
@param iv: if specified, use this initi... | [
"Encrypt",
"(",
"and",
"encapsulate",
")",
"an",
"IP",
"(",
"v6",
")",
"packet",
"with",
"ESP",
"or",
"AH",
"according",
"to",
"this",
"SecurityAssociation",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L959-L978 | train | Encrypt an IP ( v6 packet with ESP or AH according to this SecurityAssociation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/ipsec.py | SecurityAssociation.decrypt | def decrypt(self, pkt, verify=True):
"""
Decrypt (and decapsulate) an IP(v6) packet containing ESP or AH.
@param pkt: the packet to decrypt
@param verify: if False, do not perform the integrity check
@return: the decrypted/decapsulated packet
@raise IPSecIntegrityE... | python | def decrypt(self, pkt, verify=True):
"""
Decrypt (and decapsulate) an IP(v6) packet containing ESP or AH.
@param pkt: the packet to decrypt
@param verify: if False, do not perform the integrity check
@return: the decrypted/decapsulated packet
@raise IPSecIntegrityE... | [
"def",
"decrypt",
"(",
"self",
",",
"pkt",
",",
"verify",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"pkt",
",",
"self",
".",
"SUPPORTED_PROTOS",
")",
":",
"raise",
"TypeError",
"(",
"'cannot decrypt %s, supported protos are %s'",
"%",
"(",
"pkt"... | Decrypt (and decapsulate) an IP(v6) packet containing ESP or AH.
@param pkt: the packet to decrypt
@param verify: if False, do not perform the integrity check
@return: the decrypted/decapsulated packet
@raise IPSecIntegrityError: if the integrity check fails | [
"Decrypt",
"(",
"and",
"decapsulate",
")",
"an",
"IP",
"(",
"v6",
")",
"packet",
"containing",
"ESP",
"or",
"AH",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L1053-L1072 | train | Decrypt an IP ( v6 packet and return the decrypted packet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/cipher_aead.py | _AEADCipher._update_nonce_explicit | def _update_nonce_explicit(self):
"""
Increment the explicit nonce while avoiding any overflow.
"""
ne = self.nonce_explicit + 1
self.nonce_explicit = ne % 2**(self.nonce_explicit_len * 8) | python | def _update_nonce_explicit(self):
"""
Increment the explicit nonce while avoiding any overflow.
"""
ne = self.nonce_explicit + 1
self.nonce_explicit = ne % 2**(self.nonce_explicit_len * 8) | [
"def",
"_update_nonce_explicit",
"(",
"self",
")",
":",
"ne",
"=",
"self",
".",
"nonce_explicit",
"+",
"1",
"self",
".",
"nonce_explicit",
"=",
"ne",
"%",
"2",
"**",
"(",
"self",
".",
"nonce_explicit_len",
"*",
"8",
")"
] | Increment the explicit nonce while avoiding any overflow. | [
"Increment",
"the",
"explicit",
"nonce",
"while",
"avoiding",
"any",
"overflow",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_aead.py#L130-L135 | train | Update the explicit nonce. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/cipher_aead.py | _AEADCipher.auth_encrypt | def auth_encrypt(self, P, A, seq_num=None):
"""
Encrypt the data then prepend the explicit part of the nonce. The
authentication tag is directly appended with the most recent crypto
API. Additional data may be authenticated without encryption (as A).
The 'seq_num' should never b... | python | def auth_encrypt(self, P, A, seq_num=None):
"""
Encrypt the data then prepend the explicit part of the nonce. The
authentication tag is directly appended with the most recent crypto
API. Additional data may be authenticated without encryption (as A).
The 'seq_num' should never b... | [
"def",
"auth_encrypt",
"(",
"self",
",",
"P",
",",
"A",
",",
"seq_num",
"=",
"None",
")",
":",
"if",
"False",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"ready",
")",
":",
"raise",
"CipherError",
"(",
"P",
",",
"A",
")",
"if",
"hasattr",
"... | Encrypt the data then prepend the explicit part of the nonce. The
authentication tag is directly appended with the most recent crypto
API. Additional data may be authenticated without encryption (as A).
The 'seq_num' should never be used here, it is only a safeguard needed
because one c... | [
"Encrypt",
"the",
"data",
"then",
"prepend",
"the",
"explicit",
"part",
"of",
"the",
"nonce",
".",
"The",
"authentication",
"tag",
"is",
"directly",
"appended",
"with",
"the",
"most",
"recent",
"crypto",
"API",
".",
"Additional",
"data",
"may",
"be",
"authen... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_aead.py#L137-L163 | train | Encrypt the data then prepend the explicit part of the nonce. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/cipher_aead.py | _AEADCipher.auth_decrypt | def auth_decrypt(self, A, C, seq_num=None, add_length=True):
"""
Decrypt the data and authenticate the associated data (i.e. A).
If the verification fails, an AEADTagError is raised. It is the user's
responsibility to catch it if deemed useful. If we lack the key, we
raise a Ciph... | python | def auth_decrypt(self, A, C, seq_num=None, add_length=True):
"""
Decrypt the data and authenticate the associated data (i.e. A).
If the verification fails, an AEADTagError is raised. It is the user's
responsibility to catch it if deemed useful. If we lack the key, we
raise a Ciph... | [
"def",
"auth_decrypt",
"(",
"self",
",",
"A",
",",
"C",
",",
"seq_num",
"=",
"None",
",",
"add_length",
"=",
"True",
")",
":",
"nonce_explicit_str",
",",
"C",
",",
"mac",
"=",
"(",
"C",
"[",
":",
"self",
".",
"nonce_explicit_len",
"]",
",",
"C",
"[... | Decrypt the data and authenticate the associated data (i.e. A).
If the verification fails, an AEADTagError is raised. It is the user's
responsibility to catch it if deemed useful. If we lack the key, we
raise a CipherError which contains the encrypted input.
Note that we add the TLSCiph... | [
"Decrypt",
"the",
"data",
"and",
"authenticate",
"the",
"associated",
"data",
"(",
"i",
".",
"e",
".",
"A",
")",
".",
"If",
"the",
"verification",
"fails",
"an",
"AEADTagError",
"is",
"raised",
".",
"It",
"is",
"the",
"user",
"s",
"responsibility",
"to",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_aead.py#L165-L211 | train | Decrypt the data and authenticate the associated data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/cipher_aead.py | _AEADCipher_TLS13.auth_encrypt | def auth_encrypt(self, P, A, seq_num):
"""
Encrypt the data, and append the computed authentication code.
TLS 1.3 does not use additional data, but we leave this option to the
user nonetheless.
Note that the cipher's authentication tag must be None when encrypting.
"""
... | python | def auth_encrypt(self, P, A, seq_num):
"""
Encrypt the data, and append the computed authentication code.
TLS 1.3 does not use additional data, but we leave this option to the
user nonetheless.
Note that the cipher's authentication tag must be None when encrypting.
"""
... | [
"def",
"auth_encrypt",
"(",
"self",
",",
"P",
",",
"A",
",",
"seq_num",
")",
":",
"if",
"False",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"ready",
")",
":",
"raise",
"CipherError",
"(",
"P",
",",
"A",
")",
"if",
"hasattr",
"(",
"self",
"... | Encrypt the data, and append the computed authentication code.
TLS 1.3 does not use additional data, but we leave this option to the
user nonetheless.
Note that the cipher's authentication tag must be None when encrypting. | [
"Encrypt",
"the",
"data",
"and",
"append",
"the",
"computed",
"authentication",
"code",
".",
"TLS",
"1",
".",
"3",
"does",
"not",
"use",
"additional",
"data",
"but",
"we",
"leave",
"this",
"option",
"to",
"the",
"user",
"nonetheless",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_aead.py#L308-L333 | train | Encrypt the data and append the computed authentication code. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/cipher_aead.py | _AEADCipher_TLS13.auth_decrypt | def auth_decrypt(self, A, C, seq_num):
"""
Decrypt the data and verify the authentication code (in this order).
Note that TLS 1.3 is not supposed to use any additional data A.
If the verification fails, an AEADTagError is raised. It is the user's
responsibility to catch it if dee... | python | def auth_decrypt(self, A, C, seq_num):
"""
Decrypt the data and verify the authentication code (in this order).
Note that TLS 1.3 is not supposed to use any additional data A.
If the verification fails, an AEADTagError is raised. It is the user's
responsibility to catch it if dee... | [
"def",
"auth_decrypt",
"(",
"self",
",",
"A",
",",
"C",
",",
"seq_num",
")",
":",
"C",
",",
"mac",
"=",
"C",
"[",
":",
"-",
"self",
".",
"tag_len",
"]",
",",
"C",
"[",
"-",
"self",
".",
"tag_len",
":",
"]",
"if",
"False",
"in",
"six",
".",
... | Decrypt the data and verify the authentication code (in this order).
Note that TLS 1.3 is not supposed to use any additional data A.
If the verification fails, an AEADTagError is raised. It is the user's
responsibility to catch it if deemed useful. If we lack the key, we
raise a CipherEr... | [
"Decrypt",
"the",
"data",
"and",
"verify",
"the",
"authentication",
"code",
"(",
"in",
"this",
"order",
")",
".",
"Note",
"that",
"TLS",
"1",
".",
"3",
"is",
"not",
"supposed",
"to",
"use",
"any",
"additional",
"data",
"A",
".",
"If",
"the",
"verificat... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_aead.py#L335-L370 | train | Decrypt the data and verify the authentication code. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/tzsp.py | _tzsp_guess_next_tag | def _tzsp_guess_next_tag(payload):
"""
:return: class representing the next tag, Raw on error, None on missing payload # noqa: E501
"""
if not payload:
warning('missing payload')
return None
tag_type = orb(payload[0])
try:
tag_class_definition = _TZSP_TAG_CLASSES[tag_... | python | def _tzsp_guess_next_tag(payload):
"""
:return: class representing the next tag, Raw on error, None on missing payload # noqa: E501
"""
if not payload:
warning('missing payload')
return None
tag_type = orb(payload[0])
try:
tag_class_definition = _TZSP_TAG_CLASSES[tag_... | [
"def",
"_tzsp_guess_next_tag",
"(",
"payload",
")",
":",
"if",
"not",
"payload",
":",
"warning",
"(",
"'missing payload'",
")",
"return",
"None",
"tag_type",
"=",
"orb",
"(",
"payload",
"[",
"0",
"]",
")",
"try",
":",
"tag_class_definition",
"=",
"_TZSP_TAG_... | :return: class representing the next tag, Raw on error, None on missing payload # noqa: E501 | [
":",
"return",
":",
"class",
"representing",
"the",
"next",
"tag",
"Raw",
"on",
"error",
"None",
"on",
"missing",
"payload",
"#",
"noqa",
":",
"E501"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/tzsp.py#L153-L187 | train | Helper function to guess the next tag from a list of payload. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/tzsp.py | TZSP.get_encapsulated_payload_class | def get_encapsulated_payload_class(self):
"""
get the class that holds the encapsulated payload of the TZSP packet
:return: class representing the payload, Raw() on error
"""
try:
return TZSP.ENCAPSULATED_PROTOCOL_CLASSES[self.encapsulated_protocol] # noqa: E501
... | python | def get_encapsulated_payload_class(self):
"""
get the class that holds the encapsulated payload of the TZSP packet
:return: class representing the payload, Raw() on error
"""
try:
return TZSP.ENCAPSULATED_PROTOCOL_CLASSES[self.encapsulated_protocol] # noqa: E501
... | [
"def",
"get_encapsulated_payload_class",
"(",
"self",
")",
":",
"try",
":",
"return",
"TZSP",
".",
"ENCAPSULATED_PROTOCOL_CLASSES",
"[",
"self",
".",
"encapsulated_protocol",
"]",
"# noqa: E501",
"except",
"KeyError",
":",
"warning",
"(",
"'unknown or invalid encapsulat... | get the class that holds the encapsulated payload of the TZSP packet
:return: class representing the payload, Raw() on error | [
"get",
"the",
"class",
"that",
"holds",
"the",
"encapsulated",
"payload",
"of",
"the",
"TZSP",
"packet",
":",
"return",
":",
"class",
"representing",
"the",
"payload",
"Raw",
"()",
"on",
"error"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/tzsp.py#L100-L111 | train | get the class that holds the encapsulated payload of the TZSP packet
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/tzsp.py | TZSPTagEnd.guess_payload_class | def guess_payload_class(self, payload):
"""
the type of the payload encapsulation is given be the outer TZSP layers attribute encapsulation_protocol # noqa: E501
"""
under_layer = self.underlayer
tzsp_header = None
while under_layer:
if isinstance(under_lay... | python | def guess_payload_class(self, payload):
"""
the type of the payload encapsulation is given be the outer TZSP layers attribute encapsulation_protocol # noqa: E501
"""
under_layer = self.underlayer
tzsp_header = None
while under_layer:
if isinstance(under_lay... | [
"def",
"guess_payload_class",
"(",
"self",
",",
"payload",
")",
":",
"under_layer",
"=",
"self",
".",
"underlayer",
"tzsp_header",
"=",
"None",
"while",
"under_layer",
":",
"if",
"isinstance",
"(",
"under_layer",
",",
"TZSP",
")",
":",
"tzsp_header",
"=",
"u... | the type of the payload encapsulation is given be the outer TZSP layers attribute encapsulation_protocol # noqa: E501 | [
"the",
"type",
"of",
"the",
"payload",
"encapsulation",
"is",
"given",
"be",
"the",
"outer",
"TZSP",
"layers",
"attribute",
"encapsulation_protocol",
"#",
"noqa",
":",
"E501"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/tzsp.py#L246-L264 | train | Guesses the type of the payload encapsulation is given be the outer TZSP layers attribute encapsulation_protocol | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/eigrp.py | ShortVersionField.h2i | def h2i(self, pkt, x):
"""The field accepts string values like v12.1, v1.1 or integer values.
String values have to start with a "v" folled by a floating point number.
Valid numbers are between 0 and 255.
"""
if isinstance(x, str) and x.startswith("v") and len(x) <= 8:
... | python | def h2i(self, pkt, x):
"""The field accepts string values like v12.1, v1.1 or integer values.
String values have to start with a "v" folled by a floating point number.
Valid numbers are between 0 and 255.
"""
if isinstance(x, str) and x.startswith("v") and len(x) <= 8:
... | [
"def",
"h2i",
"(",
"self",
",",
"pkt",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"str",
")",
"and",
"x",
".",
"startswith",
"(",
"\"v\"",
")",
"and",
"len",
"(",
"x",
")",
"<=",
"8",
":",
"major",
"=",
"int",
"(",
"x",
".",
"sp... | The field accepts string values like v12.1, v1.1 or integer values.
String values have to start with a "v" folled by a floating point number.
Valid numbers are between 0 and 255. | [
"The",
"field",
"accepts",
"string",
"values",
"like",
"v12",
".",
"1",
"v1",
".",
"1",
"or",
"integer",
"values",
".",
"String",
"values",
"have",
"to",
"start",
"with",
"a",
"v",
"folled",
"by",
"a",
"floating",
"point",
"number",
".",
"Valid",
"numb... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/eigrp.py#L284-L305 | train | The field accepts string values like v12. 1. 255. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/suites.py | get_algs_from_ciphersuite_name | def get_algs_from_ciphersuite_name(ciphersuite_name):
"""
Return the 3-tuple made of the Key Exchange Algorithm class, the Cipher
class and the HMAC class, through the parsing of the ciphersuite name.
"""
tls1_3 = False
if ciphersuite_name.startswith("TLS"):
s = ciphersuite_name[4:]
... | python | def get_algs_from_ciphersuite_name(ciphersuite_name):
"""
Return the 3-tuple made of the Key Exchange Algorithm class, the Cipher
class and the HMAC class, through the parsing of the ciphersuite name.
"""
tls1_3 = False
if ciphersuite_name.startswith("TLS"):
s = ciphersuite_name[4:]
... | [
"def",
"get_algs_from_ciphersuite_name",
"(",
"ciphersuite_name",
")",
":",
"tls1_3",
"=",
"False",
"if",
"ciphersuite_name",
".",
"startswith",
"(",
"\"TLS\"",
")",
":",
"s",
"=",
"ciphersuite_name",
"[",
"4",
":",
"]",
"if",
"s",
".",
"endswith",
"(",
"\"C... | Return the 3-tuple made of the Key Exchange Algorithm class, the Cipher
class and the HMAC class, through the parsing of the ciphersuite name. | [
"Return",
"the",
"3",
"-",
"tuple",
"made",
"of",
"the",
"Key",
"Exchange",
"Algorithm",
"class",
"the",
"Cipher",
"class",
"and",
"the",
"HMAC",
"class",
"through",
"the",
"parsing",
"of",
"the",
"ciphersuite",
"name",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/suites.py#L21-L67 | train | Returns the 3 - tuple made of the Key Exchange Algorithm class the CipherExchange Algorithm class and the HMAC class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/crypto/suites.py | get_usable_ciphersuites | def get_usable_ciphersuites(l, kx):
"""
From a list of proposed ciphersuites, this function returns a list of
usable cipher suites, i.e. for which key exchange, cipher and hash
algorithms are known to be implemented and usable in current version of the
TLS extension. The order of the cipher suites i... | python | def get_usable_ciphersuites(l, kx):
"""
From a list of proposed ciphersuites, this function returns a list of
usable cipher suites, i.e. for which key exchange, cipher and hash
algorithms are known to be implemented and usable in current version of the
TLS extension. The order of the cipher suites i... | [
"def",
"get_usable_ciphersuites",
"(",
"l",
",",
"kx",
")",
":",
"res",
"=",
"[",
"]",
"for",
"c",
"in",
"l",
":",
"if",
"c",
"in",
"_tls_cipher_suites_cls",
":",
"ciph",
"=",
"_tls_cipher_suites_cls",
"[",
"c",
"]",
"if",
"ciph",
".",
"usable",
":",
... | From a list of proposed ciphersuites, this function returns a list of
usable cipher suites, i.e. for which key exchange, cipher and hash
algorithms are known to be implemented and usable in current version of the
TLS extension. The order of the cipher suites in the list returned by the
function matches ... | [
"From",
"a",
"list",
"of",
"proposed",
"ciphersuites",
"this",
"function",
"returns",
"a",
"list",
"of",
"usable",
"cipher",
"suites",
"i",
".",
"e",
".",
"for",
"which",
"key",
"exchange",
"cipher",
"and",
"hash",
"algorithms",
"are",
"known",
"to",
"be",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/suites.py#L1300-L1317 | train | This function returns a list of usable cipher suites i. e. for which key exchange cipher and hash cipher algorithms are known to be implemented and usable in current version of the TLS extension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | in4_chksum | def in4_chksum(proto, u, p):
"""
As Specified in RFC 2460 - 8.1 Upper-Layer Checksums
Performs IPv4 Upper Layer checksum computation. Provided parameters are:
- 'proto' : value of upper layer protocol
- 'u' : IP upper layer instance
- 'p' : the payload of the upper layer provided as a string
... | python | def in4_chksum(proto, u, p):
"""
As Specified in RFC 2460 - 8.1 Upper-Layer Checksums
Performs IPv4 Upper Layer checksum computation. Provided parameters are:
- 'proto' : value of upper layer protocol
- 'u' : IP upper layer instance
- 'p' : the payload of the upper layer provided as a string
... | [
"def",
"in4_chksum",
"(",
"proto",
",",
"u",
",",
"p",
")",
":",
"if",
"not",
"isinstance",
"(",
"u",
",",
"IP",
")",
":",
"warning",
"(",
"\"No IP underlayer to compute checksum. Leaving null.\"",
")",
"return",
"0",
"if",
"u",
".",
"len",
"is",
"not",
... | As Specified in RFC 2460 - 8.1 Upper-Layer Checksums
Performs IPv4 Upper Layer checksum computation. Provided parameters are:
- 'proto' : value of upper layer protocol
- 'u' : IP upper layer instance
- 'p' : the payload of the upper layer provided as a string | [
"As",
"Specified",
"in",
"RFC",
"2460",
"-",
"8",
".",
"1",
"Upper",
"-",
"Layer",
"Checksums"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L578-L604 | train | Compute the checksum of an IPv4 upper layer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | _defrag_list | def _defrag_list(lst, defrag, missfrag):
"""Internal usage only. Part of the _defrag_logic"""
p = lst[0]
lastp = lst[-1]
if p.frag > 0 or lastp.flags.MF: # first or last fragment missing
missfrag.append(lst)
return
p = p.copy()
if conf.padding_layer in p:
del(p[conf.padd... | python | def _defrag_list(lst, defrag, missfrag):
"""Internal usage only. Part of the _defrag_logic"""
p = lst[0]
lastp = lst[-1]
if p.frag > 0 or lastp.flags.MF: # first or last fragment missing
missfrag.append(lst)
return
p = p.copy()
if conf.padding_layer in p:
del(p[conf.padd... | [
"def",
"_defrag_list",
"(",
"lst",
",",
"defrag",
",",
"missfrag",
")",
":",
"p",
"=",
"lst",
"[",
"0",
"]",
"lastp",
"=",
"lst",
"[",
"-",
"1",
"]",
"if",
"p",
".",
"frag",
">",
"0",
"or",
"lastp",
".",
"flags",
".",
"MF",
":",
"# first or las... | Internal usage only. Part of the _defrag_logic | [
"Internal",
"usage",
"only",
".",
"Part",
"of",
"the",
"_defrag_logic"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1018-L1055 | train | Internal usage only. Part of the _defrag_logic | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | _defrag_logic | def _defrag_logic(plist, complete=False):
"""Internal function used to defragment a list of packets.
It contains the logic behind the defrag() and defragment() functions
"""
frags = defaultdict(lambda: [])
final = []
pos = 0
for p in plist:
p._defrag_pos = pos
pos += 1
... | python | def _defrag_logic(plist, complete=False):
"""Internal function used to defragment a list of packets.
It contains the logic behind the defrag() and defragment() functions
"""
frags = defaultdict(lambda: [])
final = []
pos = 0
for p in plist:
p._defrag_pos = pos
pos += 1
... | [
"def",
"_defrag_logic",
"(",
"plist",
",",
"complete",
"=",
"False",
")",
":",
"frags",
"=",
"defaultdict",
"(",
"lambda",
":",
"[",
"]",
")",
"final",
"=",
"[",
"]",
"pos",
"=",
"0",
"for",
"p",
"in",
"plist",
":",
"p",
".",
"_defrag_pos",
"=",
... | Internal function used to defragment a list of packets.
It contains the logic behind the defrag() and defragment() functions | [
"Internal",
"function",
"used",
"to",
"defragment",
"a",
"list",
"of",
"packets",
".",
"It",
"contains",
"the",
"logic",
"behind",
"the",
"defrag",
"()",
"and",
"defragment",
"()",
"functions"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1058-L1097 | train | Internal function used to defragment a list of packets. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | _packetlist_timeskew_graph | def _packetlist_timeskew_graph(self, ip, **kargs):
"""Tries to graph the timeskew between the timestamps and real time for a given ip""" # noqa: E501
# Filter TCP segments which source address is 'ip'
tmp = (self._elt2pkt(x) for x in self.res)
b = (x for x in tmp if IP in x and x[IP].src == ip and TCP... | python | def _packetlist_timeskew_graph(self, ip, **kargs):
"""Tries to graph the timeskew between the timestamps and real time for a given ip""" # noqa: E501
# Filter TCP segments which source address is 'ip'
tmp = (self._elt2pkt(x) for x in self.res)
b = (x for x in tmp if IP in x and x[IP].src == ip and TCP... | [
"def",
"_packetlist_timeskew_graph",
"(",
"self",
",",
"ip",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"# Filter TCP segments which source address is 'ip'",
"tmp",
"=",
"(",
"self",
".",
"_elt2pkt",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"res",
... | Tries to graph the timeskew between the timestamps and real time for a given ip | [
"Tries",
"to",
"graph",
"the",
"timeskew",
"between",
"the",
"timestamps",
"and",
"real",
"time",
"for",
"a",
"given",
"ip"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1114-L1159 | train | Tries to plot the timeskew between the timestamps and real time for a given ip | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | traceroute | def traceroute(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), l4=None, filter=None, timeout=2, verbose=None, **kargs): # noqa: E501
"""Instant TCP traceroute
traceroute(target, [maxttl=30,] [dport=80,] [sport=80,] [verbose=conf.verb]) -> None # noqa: E501
"""
if verbose is None:
verbose = c... | python | def traceroute(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), l4=None, filter=None, timeout=2, verbose=None, **kargs): # noqa: E501
"""Instant TCP traceroute
traceroute(target, [maxttl=30,] [dport=80,] [sport=80,] [verbose=conf.verb]) -> None # noqa: E501
"""
if verbose is None:
verbose = c... | [
"def",
"traceroute",
"(",
"target",
",",
"dport",
"=",
"80",
",",
"minttl",
"=",
"1",
",",
"maxttl",
"=",
"30",
",",
"sport",
"=",
"RandShort",
"(",
")",
",",
"l4",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"timeout",
"=",
"2",
",",
"verbose"... | Instant TCP traceroute
traceroute(target, [maxttl=30,] [dport=80,] [sport=80,] [verbose=conf.verb]) -> None # noqa: E501 | [
"Instant",
"TCP",
"traceroute",
"traceroute",
"(",
"target",
"[",
"maxttl",
"=",
"30",
"]",
"[",
"dport",
"=",
"80",
"]",
"[",
"sport",
"=",
"80",
"]",
"[",
"verbose",
"=",
"conf",
".",
"verb",
"]",
")",
"-",
">",
"None",
"#",
"noqa",
":",
"E501"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1643-L1666 | train | Instant TCP traceroute | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | report_ports | def report_ports(target, ports):
"""portscan a target and output a LaTeX table
report_ports(target, ports) -> string"""
ans, unans = sr(IP(dst=target) / TCP(dport=ports), timeout=5)
rep = "\\begin{tabular}{|r|l|l|}\n\\hline\n"
for s, r in ans:
if not r.haslayer(ICMP):
if r.payload.fl... | python | def report_ports(target, ports):
"""portscan a target and output a LaTeX table
report_ports(target, ports) -> string"""
ans, unans = sr(IP(dst=target) / TCP(dport=ports), timeout=5)
rep = "\\begin{tabular}{|r|l|l|}\n\\hline\n"
for s, r in ans:
if not r.haslayer(ICMP):
if r.payload.fl... | [
"def",
"report_ports",
"(",
"target",
",",
"ports",
")",
":",
"ans",
",",
"unans",
"=",
"sr",
"(",
"IP",
"(",
"dst",
"=",
"target",
")",
"/",
"TCP",
"(",
"dport",
"=",
"ports",
")",
",",
"timeout",
"=",
"5",
")",
"rep",
"=",
"\"\\\\begin{tabular}{|... | portscan a target and output a LaTeX table
report_ports(target, ports) -> string | [
"portscan",
"a",
"target",
"and",
"output",
"a",
"LaTeX",
"table",
"report_ports",
"(",
"target",
"ports",
")",
"-",
">",
"string"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1811-L1830 | train | portscan a target and output a LaTeX table
report_ports | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | IPID_count | def IPID_count(lst, funcID=lambda x: x[1].id, funcpres=lambda x: x[1].summary()): # noqa: E501
"""Identify IP id values classes in a list of packets
lst: a list of packets
funcID: a function that returns IP id values
funcpres: a function used to summarize packets"""
idlst = [funcID(e) for e in lst]
... | python | def IPID_count(lst, funcID=lambda x: x[1].id, funcpres=lambda x: x[1].summary()): # noqa: E501
"""Identify IP id values classes in a list of packets
lst: a list of packets
funcID: a function that returns IP id values
funcpres: a function used to summarize packets"""
idlst = [funcID(e) for e in lst]
... | [
"def",
"IPID_count",
"(",
"lst",
",",
"funcID",
"=",
"lambda",
"x",
":",
"x",
"[",
"1",
"]",
".",
"id",
",",
"funcpres",
"=",
"lambda",
"x",
":",
"x",
"[",
"1",
"]",
".",
"summary",
"(",
")",
")",
":",
"# noqa: E501",
"idlst",
"=",
"[",
"funcID... | Identify IP id values classes in a list of packets
lst: a list of packets
funcID: a function that returns IP id values
funcpres: a function used to summarize packets | [
"Identify",
"IP",
"id",
"values",
"classes",
"in",
"a",
"list",
"of",
"packets"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1834-L1848 | train | Identify IP id values classes in a list of packets
lst a list of packets
funcID a function that returns IP id values classes
a list of packets
lst a list of packets
funcpres a function that returns IP id values classes
a list of packets that return IP id values | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | IPTools._ttl | def _ttl(self):
"""Returns ttl or hlim, depending on the IP version"""
return self.hlim if isinstance(self, scapy.layers.inet6.IPv6) else self.ttl | python | def _ttl(self):
"""Returns ttl or hlim, depending on the IP version"""
return self.hlim if isinstance(self, scapy.layers.inet6.IPv6) else self.ttl | [
"def",
"_ttl",
"(",
"self",
")",
":",
"return",
"self",
".",
"hlim",
"if",
"isinstance",
"(",
"self",
",",
"scapy",
".",
"layers",
".",
"inet6",
".",
"IPv6",
")",
"else",
"self",
".",
"ttl"
] | Returns ttl or hlim, depending on the IP version | [
"Returns",
"ttl",
"or",
"hlim",
"depending",
"on",
"the",
"IP",
"version"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L62-L64 | train | Returns ttl or hlim depending on the IP version | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | TracerouteResult.trace3D | def trace3D(self, join=True):
"""Give a 3D representation of the traceroute.
right button: rotate the scene
middle button: zoom
shift-left button: move the scene
left button on a ball: toggle IP displaying
double-click button on a ball: scan ports 21,22,23,25,80 and 443 a... | python | def trace3D(self, join=True):
"""Give a 3D representation of the traceroute.
right button: rotate the scene
middle button: zoom
shift-left button: move the scene
left button on a ball: toggle IP displaying
double-click button on a ball: scan ports 21,22,23,25,80 and 443 a... | [
"def",
"trace3D",
"(",
"self",
",",
"join",
"=",
"True",
")",
":",
"# noqa: E501",
"# When not ran from a notebook, vpython pooly closes itself",
"# using os._exit once finished. We pack it into a Process",
"import",
"multiprocessing",
"p",
"=",
"multiprocessing",
".",
"Process... | Give a 3D representation of the traceroute.
right button: rotate the scene
middle button: zoom
shift-left button: move the scene
left button on a ball: toggle IP displaying
double-click button on a ball: scan ports 21,22,23,25,80 and 443 and display the result | [
"Give",
"a",
"3D",
"representation",
"of",
"the",
"traceroute",
".",
"right",
"button",
":",
"rotate",
"the",
"scene",
"middle",
"button",
":",
"zoom",
"shift",
"-",
"left",
"button",
":",
"move",
"the",
"scene",
"left",
"button",
"on",
"a",
"ball",
":",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1202-L1215 | train | Give a 3D representation of the traceroute. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | TracerouteResult.trace3D_notebook | def trace3D_notebook(self):
"""Same than trace3D, used when ran from Jupyther notebooks"""
trace = self.get_trace()
import vpython
class IPsphere(vpython.sphere):
def __init__(self, ip, **kargs):
vpython.sphere.__init__(self, **kargs)
self.ip ... | python | def trace3D_notebook(self):
"""Same than trace3D, used when ran from Jupyther notebooks"""
trace = self.get_trace()
import vpython
class IPsphere(vpython.sphere):
def __init__(self, ip, **kargs):
vpython.sphere.__init__(self, **kargs)
self.ip ... | [
"def",
"trace3D_notebook",
"(",
"self",
")",
":",
"trace",
"=",
"self",
".",
"get_trace",
"(",
")",
"import",
"vpython",
"class",
"IPsphere",
"(",
"vpython",
".",
"sphere",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"ip",
",",
"*",
"*",
"kargs",
... | Same than trace3D, used when ran from Jupyther notebooks | [
"Same",
"than",
"trace3D",
"used",
"when",
"ran",
"from",
"Jupyther",
"notebooks"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1217-L1362 | train | Same than trace3D_notebook but used when ran from Jupyther notebooks | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | TracerouteResult.world_trace | def world_trace(self):
"""Display traceroute results on a world map."""
# Check that the geoip2 module can be imported
# Doc: http://geoip2.readthedocs.io/en/latest/
try:
# GeoIP2 modules need to be imported as below
import geoip2.database
import geoi... | python | def world_trace(self):
"""Display traceroute results on a world map."""
# Check that the geoip2 module can be imported
# Doc: http://geoip2.readthedocs.io/en/latest/
try:
# GeoIP2 modules need to be imported as below
import geoip2.database
import geoi... | [
"def",
"world_trace",
"(",
"self",
")",
":",
"# Check that the geoip2 module can be imported",
"# Doc: http://geoip2.readthedocs.io/en/latest/",
"try",
":",
"# GeoIP2 modules need to be imported as below",
"import",
"geoip2",
".",
"database",
"import",
"geoip2",
".",
"errors",
... | Display traceroute results on a world map. | [
"Display",
"traceroute",
"results",
"on",
"a",
"world",
"map",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1364-L1480 | train | Display traceroute results on a world map. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/inet.py | TracerouteResult.graph | def graph(self, ASres=conf.AS_resolver, padding=0, **kargs):
"""x.graph(ASres=conf.AS_resolver, other args):
ASres=None : no AS resolver => no clustering
ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net)
ASres=AS_resolver_cymru(): use whois.cymru.com whois data... | python | def graph(self, ASres=conf.AS_resolver, padding=0, **kargs):
"""x.graph(ASres=conf.AS_resolver, other args):
ASres=None : no AS resolver => no clustering
ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net)
ASres=AS_resolver_cymru(): use whois.cymru.com whois data... | [
"def",
"graph",
"(",
"self",
",",
"ASres",
"=",
"conf",
".",
"AS_resolver",
",",
"padding",
"=",
"0",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"(",
"self",
".",
"graphdef",
"is",
"None",
"or",
"self",
".",
"graphASres",
"!=",
"ASres",
"or",
"self",
... | x.graph(ASres=conf.AS_resolver, other args):
ASres=None : no AS resolver => no clustering
ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net)
ASres=AS_resolver_cymru(): use whois.cymru.com whois database
ASres=AS_resolver(server="whois.ra.net")
type: outp... | [
"x",
".",
"graph",
"(",
"ASres",
"=",
"conf",
".",
"AS_resolver",
"other",
"args",
")",
":",
"ASres",
"=",
"None",
":",
"no",
"AS",
"resolver",
"=",
">",
"no",
"clustering",
"ASres",
"=",
"AS_resolver",
"()",
":",
"default",
"whois",
"AS",
"resolver",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1625-L1639 | train | x. graph - T output of the current image | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/asn1fields.py | ASN1F_field.m2i | def m2i(self, pkt, s):
"""
The good thing about safedec is that it may still decode ASN1
even if there is a mismatch between the expected tag (self.ASN1_tag)
and the actual tag; the decoded ASN1 object will simply be put
into an ASN1_BADTAG object. However, safedec prevents the r... | python | def m2i(self, pkt, s):
"""
The good thing about safedec is that it may still decode ASN1
even if there is a mismatch between the expected tag (self.ASN1_tag)
and the actual tag; the decoded ASN1 object will simply be put
into an ASN1_BADTAG object. However, safedec prevents the r... | [
"def",
"m2i",
"(",
"self",
",",
"pkt",
",",
"s",
")",
":",
"diff_tag",
",",
"s",
"=",
"BER_tagging_dec",
"(",
"s",
",",
"hidden_tag",
"=",
"self",
".",
"ASN1_tag",
",",
"implicit_tag",
"=",
"self",
".",
"implicit_tag",
",",
"explicit_tag",
"=",
"self",... | The good thing about safedec is that it may still decode ASN1
even if there is a mismatch between the expected tag (self.ASN1_tag)
and the actual tag; the decoded ASN1 object will simply be put
into an ASN1_BADTAG object. However, safedec prevents the raising of
exceptions needed for ASN... | [
"The",
"good",
"thing",
"about",
"safedec",
"is",
"that",
"it",
"may",
"still",
"decode",
"ASN1",
"even",
"if",
"there",
"is",
"a",
"mismatch",
"between",
"the",
"expected",
"tag",
"(",
"self",
".",
"ASN1_tag",
")",
"and",
"the",
"actual",
"tag",
";",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1fields.py#L74-L101 | train | Decode a string into a single object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/asn1fields.py | ASN1F_SEQUENCE.m2i | def m2i(self, pkt, s):
"""
ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being
dissected one by one. Because we use obj.dissect (see loop below)
instead of obj.m2i (as we trust dissect to do the appropriate set_vals)
we do not directly retrieve the list of nested... | python | def m2i(self, pkt, s):
"""
ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being
dissected one by one. Because we use obj.dissect (see loop below)
instead of obj.m2i (as we trust dissect to do the appropriate set_vals)
we do not directly retrieve the list of nested... | [
"def",
"m2i",
"(",
"self",
",",
"pkt",
",",
"s",
")",
":",
"diff_tag",
",",
"s",
"=",
"BER_tagging_dec",
"(",
"s",
",",
"hidden_tag",
"=",
"self",
".",
"ASN1_tag",
",",
"implicit_tag",
"=",
"self",
".",
"implicit_tag",
",",
"explicit_tag",
"=",
"self",... | ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being
dissected one by one. Because we use obj.dissect (see loop below)
instead of obj.m2i (as we trust dissect to do the appropriate set_vals)
we do not directly retrieve the list of nested objects.
Thus m2i returns an empty... | [
"ASN1F_SEQUENCE",
"behaves",
"transparently",
"with",
"nested",
"ASN1_objects",
"being",
"dissected",
"one",
"by",
"one",
".",
"Because",
"we",
"use",
"obj",
".",
"dissect",
"(",
"see",
"loop",
"below",
")",
"instead",
"of",
"obj",
".",
"m2i",
"(",
"as",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1fields.py#L344-L375 | train | This method dissects the given ASN1_SEQUENCE and returns the list of the objects that are in the given ASN1_SEQUENCE. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/asn1fields.py | ASN1F_CHOICE.m2i | def m2i(self, pkt, s):
"""
First we have to retrieve the appropriate choice.
Then we extract the field/packet, according to this choice.
"""
if len(s) == 0:
raise ASN1_Error("ASN1F_CHOICE: got empty string")
_, s = BER_tagging_dec(s, hidden_tag=self.ASN1_tag,
... | python | def m2i(self, pkt, s):
"""
First we have to retrieve the appropriate choice.
Then we extract the field/packet, according to this choice.
"""
if len(s) == 0:
raise ASN1_Error("ASN1F_CHOICE: got empty string")
_, s = BER_tagging_dec(s, hidden_tag=self.ASN1_tag,
... | [
"def",
"m2i",
"(",
"self",
",",
"pkt",
",",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"==",
"0",
":",
"raise",
"ASN1_Error",
"(",
"\"ASN1F_CHOICE: got empty string\"",
")",
"_",
",",
"s",
"=",
"BER_tagging_dec",
"(",
"s",
",",
"hidden_tag",
"=",
"se... | First we have to retrieve the appropriate choice.
Then we extract the field/packet, according to this choice. | [
"First",
"we",
"have",
"to",
"retrieve",
"the",
"appropriate",
"choice",
".",
"Then",
"we",
"extract",
"the",
"field",
"/",
"packet",
"according",
"to",
"this",
"choice",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1fields.py#L530-L555 | train | This method will take a string and return the corresponding field or packet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/igmp.py | IGMP.igmpize | def igmpize(self):
"""Called to explicitly fixup the packet according to the IGMP RFC
The rules are:
General:
1. the Max Response time is meaningful only in Membership Queries and should be zero
IP:
1. Send General Group Query to 224.0.0.1 (all systems)
... | python | def igmpize(self):
"""Called to explicitly fixup the packet according to the IGMP RFC
The rules are:
General:
1. the Max Response time is meaningful only in Membership Queries and should be zero
IP:
1. Send General Group Query to 224.0.0.1 (all systems)
... | [
"def",
"igmpize",
"(",
"self",
")",
":",
"gaddr",
"=",
"self",
".",
"gaddr",
"if",
"hasattr",
"(",
"self",
",",
"\"gaddr\"",
")",
"and",
"self",
".",
"gaddr",
"else",
"\"0.0.0.0\"",
"# noqa: E501",
"underlayer",
"=",
"self",
".",
"underlayer",
"if",
"sel... | Called to explicitly fixup the packet according to the IGMP RFC
The rules are:
General:
1. the Max Response time is meaningful only in Membership Queries and should be zero
IP:
1. Send General Group Query to 224.0.0.1 (all systems)
2. Send Leave Group to 224... | [
"Called",
"to",
"explicitly",
"fixup",
"the",
"packet",
"according",
"to",
"the",
"IGMP",
"RFC"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/igmp.py#L95-L152 | train | This function will attempt to fixup the IGMP message according to the RFC 2236 section 2. 1. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/bgp.py | _bgp_dispatcher | def _bgp_dispatcher(payload):
"""
Returns the right class for a given BGP message.
"""
cls = conf.raw_layer
# By default, calling BGP() will build a BGPHeader.
if payload is None:
cls = _get_cls("BGPHeader", conf.raw_layer)
else:
if len(payload) >= _BGP_HEADER_SIZE and\
... | python | def _bgp_dispatcher(payload):
"""
Returns the right class for a given BGP message.
"""
cls = conf.raw_layer
# By default, calling BGP() will build a BGPHeader.
if payload is None:
cls = _get_cls("BGPHeader", conf.raw_layer)
else:
if len(payload) >= _BGP_HEADER_SIZE and\
... | [
"def",
"_bgp_dispatcher",
"(",
"payload",
")",
":",
"cls",
"=",
"conf",
".",
"raw_layer",
"# By default, calling BGP() will build a BGPHeader.",
"if",
"payload",
"is",
"None",
":",
"cls",
"=",
"_get_cls",
"(",
"\"BGPHeader\"",
",",
"conf",
".",
"raw_layer",
")",
... | Returns the right class for a given BGP message. | [
"Returns",
"the",
"right",
"class",
"for",
"a",
"given",
"BGP",
"message",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L423-L445 | train | Returns the right class for a given BGP message. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/bgp.py | _bgp_capability_dispatcher | def _bgp_capability_dispatcher(payload):
"""
Returns the right class for a given BGP capability.
"""
cls = _capabilities_registry["BGPCapGeneric"]
# By default, calling BGPCapability() will build a "generic" capability.
if payload is None:
cls = _capabilities_registry["BGPCapGeneric"]
... | python | def _bgp_capability_dispatcher(payload):
"""
Returns the right class for a given BGP capability.
"""
cls = _capabilities_registry["BGPCapGeneric"]
# By default, calling BGPCapability() will build a "generic" capability.
if payload is None:
cls = _capabilities_registry["BGPCapGeneric"]
... | [
"def",
"_bgp_capability_dispatcher",
"(",
"payload",
")",
":",
"cls",
"=",
"_capabilities_registry",
"[",
"\"BGPCapGeneric\"",
"]",
"# By default, calling BGPCapability() will build a \"generic\" capability.",
"if",
"payload",
"is",
"None",
":",
"cls",
"=",
"_capabilities_reg... | Returns the right class for a given BGP capability. | [
"Returns",
"the",
"right",
"class",
"for",
"a",
"given",
"BGP",
"capability",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L551-L568 | train | Returns the right class for a given BGP capability. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/bgp.py | BGPFieldIPv4.i2m | def i2m(self, pkt, i):
""""Internal" (IP as bytes, mask as int) to "machine"
representation."""
mask, ip = i
ip = socket.inet_aton(ip)
return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)] | python | def i2m(self, pkt, i):
""""Internal" (IP as bytes, mask as int) to "machine"
representation."""
mask, ip = i
ip = socket.inet_aton(ip)
return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)] | [
"def",
"i2m",
"(",
"self",
",",
"pkt",
",",
"i",
")",
":",
"mask",
",",
"ip",
"=",
"i",
"ip",
"=",
"socket",
".",
"inet_aton",
"(",
"ip",
")",
"return",
"struct",
".",
"pack",
"(",
"\">B\"",
",",
"mask",
")",
"+",
"ip",
"[",
":",
"self",
".",... | Internal" (IP as bytes, mask as int) to "machine"
representation. | [
"Internal",
"(",
"IP",
"as",
"bytes",
"mask",
"as",
"int",
")",
"to",
"machine",
"representation",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L129-L134 | train | Internal IP as bytes mask as int to machine name representation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/bgp.py | BGPFieldIPv6.i2m | def i2m(self, pkt, i):
""""Internal" (IP as bytes, mask as int) to "machine" representation.""" # noqa: E501
mask, ip = i
ip = pton_ntop.inet_pton(socket.AF_INET6, ip)
return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)] | python | def i2m(self, pkt, i):
""""Internal" (IP as bytes, mask as int) to "machine" representation.""" # noqa: E501
mask, ip = i
ip = pton_ntop.inet_pton(socket.AF_INET6, ip)
return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)] | [
"def",
"i2m",
"(",
"self",
",",
"pkt",
",",
"i",
")",
":",
"# noqa: E501",
"mask",
",",
"ip",
"=",
"i",
"ip",
"=",
"pton_ntop",
".",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"ip",
")",
"return",
"struct",
".",
"pack",
"(",
"\">B\"",
",",
... | Internal" (IP as bytes, mask as int) to "machine" representation. | [
"Internal",
"(",
"IP",
"as",
"bytes",
"mask",
"as",
"int",
")",
"to",
"machine",
"representation",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L174-L178 | train | Internal representation of the internal entry. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/bgp.py | BGPCapability.pre_dissect | def pre_dissect(self, s):
"""
Check that the payload is long enough (at least 2 bytes).
"""
length = len(s)
if length < _BGP_CAPABILITY_MIN_SIZE:
err = " ({}".format(length) + " is < _BGP_CAPABILITY_MIN_SIZE "
err += "({})).".format(_BGP_CAPABILITY_MIN_SIZ... | python | def pre_dissect(self, s):
"""
Check that the payload is long enough (at least 2 bytes).
"""
length = len(s)
if length < _BGP_CAPABILITY_MIN_SIZE:
err = " ({}".format(length) + " is < _BGP_CAPABILITY_MIN_SIZE "
err += "({})).".format(_BGP_CAPABILITY_MIN_SIZ... | [
"def",
"pre_dissect",
"(",
"self",
",",
"s",
")",
":",
"length",
"=",
"len",
"(",
"s",
")",
"if",
"length",
"<",
"_BGP_CAPABILITY_MIN_SIZE",
":",
"err",
"=",
"\" ({}\"",
".",
"format",
"(",
"length",
")",
"+",
"\" is < _BGP_CAPABILITY_MIN_SIZE \"",
"err",
... | Check that the payload is long enough (at least 2 bytes). | [
"Check",
"that",
"the",
"payload",
"is",
"long",
"enough",
"(",
"at",
"least",
"2",
"bytes",
")",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L596-L605 | train | Check that the payload is long enough. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPHeader.post_build | def post_build(self, pkt, pay):
"""
This will set the ByteField 'length' to the correct value.
"""
if self.length is None:
pkt = pkt[:4] + chb(len(pay)) + pkt[5:]
return pkt + pay | python | def post_build(self, pkt, pay):
"""
This will set the ByteField 'length' to the correct value.
"""
if self.length is None:
pkt = pkt[:4] + chb(len(pay)) + pkt[5:]
return pkt + pay | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"if",
"self",
".",
"length",
"is",
"None",
":",
"pkt",
"=",
"pkt",
"[",
":",
"4",
"]",
"+",
"chb",
"(",
"len",
"(",
"pay",
")",
")",
"+",
"pkt",
"[",
"5",
":",
"]",
"return... | This will set the ByteField 'length' to the correct value. | [
"This",
"will",
"set",
"the",
"ByteField",
"length",
"to",
"the",
"correct",
"value",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L200-L206 | train | This method is called when the packet is built and the pay is added to the packet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPHeader.guess_payload_class | def guess_payload_class(self, payload):
"""
ISOTP encodes the frame type in the first nibble of a frame.
"""
t = (orb(payload[0]) & 0xf0) >> 4
if t == 0:
return ISOTP_SF
elif t == 1:
return ISOTP_FF
elif t == 2:
return ISOTP_CF
... | python | def guess_payload_class(self, payload):
"""
ISOTP encodes the frame type in the first nibble of a frame.
"""
t = (orb(payload[0]) & 0xf0) >> 4
if t == 0:
return ISOTP_SF
elif t == 1:
return ISOTP_FF
elif t == 2:
return ISOTP_CF
... | [
"def",
"guess_payload_class",
"(",
"self",
",",
"payload",
")",
":",
"t",
"=",
"(",
"orb",
"(",
"payload",
"[",
"0",
"]",
")",
"&",
"0xf0",
")",
">>",
"4",
"if",
"t",
"==",
"0",
":",
"return",
"ISOTP_SF",
"elif",
"t",
"==",
"1",
":",
"return",
... | ISOTP encodes the frame type in the first nibble of a frame. | [
"ISOTP",
"encodes",
"the",
"frame",
"type",
"in",
"the",
"first",
"nibble",
"of",
"a",
"frame",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L208-L220 | train | Guesses the ISOTP class from the payload. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPMessageBuilder.feed | def feed(self, can):
"""Attempt to feed an incoming CAN frame into the state machine"""
if not isinstance(can, CAN):
raise Scapy_Exception("argument is not a CAN frame")
identifier = can.identifier
data = bytes(can.data)
if len(data) > 1 and self.use_ext_addr is not ... | python | def feed(self, can):
"""Attempt to feed an incoming CAN frame into the state machine"""
if not isinstance(can, CAN):
raise Scapy_Exception("argument is not a CAN frame")
identifier = can.identifier
data = bytes(can.data)
if len(data) > 1 and self.use_ext_addr is not ... | [
"def",
"feed",
"(",
"self",
",",
"can",
")",
":",
"if",
"not",
"isinstance",
"(",
"can",
",",
"CAN",
")",
":",
"raise",
"Scapy_Exception",
"(",
"\"argument is not a CAN frame\"",
")",
"identifier",
"=",
"can",
".",
"identifier",
"data",
"=",
"bytes",
"(",
... | Attempt to feed an incoming CAN frame into the state machine | [
"Attempt",
"to",
"feed",
"an",
"incoming",
"CAN",
"frame",
"into",
"the",
"state",
"machine"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L329-L340 | train | Attempt to feed an incoming CAN frame into the state machine. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPMessageBuilder.pop | def pop(self, identifier=None, ext_addr=None, basecls=ISOTP):
"""
Returns a built ISOTP message
:param identifier: if not None, only return isotp messages with this
destination
:param ext_addr: if identifier is not None, only return isotp messages
... | python | def pop(self, identifier=None, ext_addr=None, basecls=ISOTP):
"""
Returns a built ISOTP message
:param identifier: if not None, only return isotp messages with this
destination
:param ext_addr: if identifier is not None, only return isotp messages
... | [
"def",
"pop",
"(",
"self",
",",
"identifier",
"=",
"None",
",",
"ext_addr",
"=",
"None",
",",
"basecls",
"=",
"ISOTP",
")",
":",
"if",
"identifier",
"is",
"not",
"None",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"ready",
")",
... | Returns a built ISOTP message
:param identifier: if not None, only return isotp messages with this
destination
:param ext_addr: if identifier is not None, only return isotp messages
with this extended address for destination
:param basecls: the... | [
"Returns",
"a",
"built",
"ISOTP",
"message",
":",
"param",
"identifier",
":",
"if",
"not",
"None",
"only",
"return",
"isotp",
"messages",
"with",
"this",
"destination",
":",
"param",
"ext_addr",
":",
"if",
"identifier",
"is",
"not",
"None",
"only",
"return",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L347-L370 | train | Returns an ISOTP message with the specified identifier and extended address. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSoftSocket.begin_send | def begin_send(self, p):
"""Begin the transmission of message p. This method returns after
sending the first frame. If multiple frames are necessary to send the
message, this socket will unable to send other messages until either
the transmission of this frame succeeds or it fails."""
... | python | def begin_send(self, p):
"""Begin the transmission of message p. This method returns after
sending the first frame. If multiple frames are necessary to send the
message, this socket will unable to send other messages until either
the transmission of this frame succeeds or it fails."""
... | [
"def",
"begin_send",
"(",
"self",
",",
"p",
")",
":",
"if",
"hasattr",
"(",
"p",
",",
"\"sent_time\"",
")",
":",
"p",
".",
"sent_time",
"=",
"time",
".",
"time",
"(",
")",
"return",
"self",
".",
"outs",
".",
"begin_send",
"(",
"bytes",
"(",
"p",
... | Begin the transmission of message p. This method returns after
sending the first frame. If multiple frames are necessary to send the
message, this socket will unable to send other messages until either
the transmission of this frame succeeds or it fails. | [
"Begin",
"the",
"transmission",
"of",
"message",
"p",
".",
"This",
"method",
"returns",
"after",
"sending",
"the",
"first",
"frame",
".",
"If",
"multiple",
"frames",
"are",
"necessary",
"to",
"send",
"the",
"message",
"this",
"socket",
"will",
"unable",
"to"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L602-L610 | train | Begin the transmission of a message p. This method returns after the message has been sent. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSoftSocket.recv_with_timeout | def recv_with_timeout(self, timeout=1):
"""Receive a complete ISOTP message, blocking until a message is
received or the specified timeout is reached.
If timeout is 0, then this function doesn't block and returns the
first frame in the receive buffer or None if there isn't any."""
... | python | def recv_with_timeout(self, timeout=1):
"""Receive a complete ISOTP message, blocking until a message is
received or the specified timeout is reached.
If timeout is 0, then this function doesn't block and returns the
first frame in the receive buffer or None if there isn't any."""
... | [
"def",
"recv_with_timeout",
"(",
"self",
",",
"timeout",
"=",
"1",
")",
":",
"msg",
"=",
"self",
".",
"ins",
".",
"recv",
"(",
"timeout",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"if",
"msg",
"is",
"None",
":",
"raise",
"Scapy_Exception",
"(",... | Receive a complete ISOTP message, blocking until a message is
received or the specified timeout is reached.
If timeout is 0, then this function doesn't block and returns the
first frame in the receive buffer or None if there isn't any. | [
"Receive",
"a",
"complete",
"ISOTP",
"message",
"blocking",
"until",
"a",
"message",
"is",
"received",
"or",
"the",
"specified",
"timeout",
"is",
"reached",
".",
"If",
"timeout",
"is",
"0",
"then",
"this",
"function",
"doesn",
"t",
"block",
"and",
"returns",... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L612-L621 | train | Receive a complete ISOTP message blocking until a message is received or the specified timeout is reached. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSoftSocket.recv_raw | def recv_raw(self, x=0xffff):
"""Receive a complete ISOTP message, blocking until a message is
received or the specified timeout is reached.
If self.timeout is 0, then this function doesn't block and returns the
first frame in the receive buffer or None if there isn't any."""
msg... | python | def recv_raw(self, x=0xffff):
"""Receive a complete ISOTP message, blocking until a message is
received or the specified timeout is reached.
If self.timeout is 0, then this function doesn't block and returns the
first frame in the receive buffer or None if there isn't any."""
msg... | [
"def",
"recv_raw",
"(",
"self",
",",
"x",
"=",
"0xffff",
")",
":",
"msg",
"=",
"self",
".",
"ins",
".",
"recv",
"(",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"return",
"self",
".",
"basecls",
",",
"msg",
",",
"t"
] | Receive a complete ISOTP message, blocking until a message is
received or the specified timeout is reached.
If self.timeout is 0, then this function doesn't block and returns the
first frame in the receive buffer or None if there isn't any. | [
"Receive",
"a",
"complete",
"ISOTP",
"message",
"blocking",
"until",
"a",
"message",
"is",
"received",
"or",
"the",
"specified",
"timeout",
"is",
"reached",
".",
"If",
"self",
".",
"timeout",
"is",
"0",
"then",
"this",
"function",
"doesn",
"t",
"block",
"a... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L623-L630 | train | Receive a complete ISOTP message. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSoftSocket.select | def select(sockets, remain=None):
"""This function is called during sendrecv() routine to wait for
sockets to be ready to receive
"""
blocking = remain is None or remain > 0
def find_ready_sockets():
return list(filter(lambda x: not x.ins.rx_queue.empty(), sockets))
... | python | def select(sockets, remain=None):
"""This function is called during sendrecv() routine to wait for
sockets to be ready to receive
"""
blocking = remain is None or remain > 0
def find_ready_sockets():
return list(filter(lambda x: not x.ins.rx_queue.empty(), sockets))
... | [
"def",
"select",
"(",
"sockets",
",",
"remain",
"=",
"None",
")",
":",
"blocking",
"=",
"remain",
"is",
"None",
"or",
"remain",
">",
"0",
"def",
"find_ready_sockets",
"(",
")",
":",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"not",
"x"... | This function is called during sendrecv() routine to wait for
sockets to be ready to receive | [
"This",
"function",
"is",
"called",
"during",
"sendrecv",
"()",
"routine",
"to",
"wait",
"for",
"sockets",
"to",
"be",
"ready",
"to",
"receive"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L646-L678 | train | This function is called during sendrecv routine to wait for a set of sockets to be ready to receive a new entry. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | TimeoutThread.set_timeout | def set_timeout(self, timeout, callback):
"""Call 'callback' in 'timeout' seconds, unless cancelled."""
if not self._ready_sem.acquire(False):
raise Scapy_Exception("Timer was already started")
self._callback = callback
self._timeout = timeout
self._cancelled.clear()... | python | def set_timeout(self, timeout, callback):
"""Call 'callback' in 'timeout' seconds, unless cancelled."""
if not self._ready_sem.acquire(False):
raise Scapy_Exception("Timer was already started")
self._callback = callback
self._timeout = timeout
self._cancelled.clear()... | [
"def",
"set_timeout",
"(",
"self",
",",
"timeout",
",",
"callback",
")",
":",
"if",
"not",
"self",
".",
"_ready_sem",
".",
"acquire",
"(",
"False",
")",
":",
"raise",
"Scapy_Exception",
"(",
"\"Timer was already started\"",
")",
"self",
".",
"_callback",
"="... | Call 'callback' in 'timeout' seconds, unless cancelled. | [
"Call",
"callback",
"in",
"timeout",
"seconds",
"unless",
"cancelled",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L791-L799 | train | Call callback in timeout seconds unless cancelled. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | TimeoutThread.cancel | def cancel(self):
"""Stop the timer without executing the callback."""
self._cancelled.set()
if not self._dead:
self._ready_sem.acquire()
self._ready_sem.release() | python | def cancel(self):
"""Stop the timer without executing the callback."""
self._cancelled.set()
if not self._dead:
self._ready_sem.acquire()
self._ready_sem.release() | [
"def",
"cancel",
"(",
"self",
")",
":",
"self",
".",
"_cancelled",
".",
"set",
"(",
")",
"if",
"not",
"self",
".",
"_dead",
":",
"self",
".",
"_ready_sem",
".",
"acquire",
"(",
")",
"self",
".",
"_ready_sem",
".",
"release",
"(",
")"
] | Stop the timer without executing the callback. | [
"Stop",
"the",
"timer",
"without",
"executing",
"the",
"callback",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L801-L806 | train | Stop the timer without executing the callback. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | TimeoutThread.stop | def stop(self):
"""Stop the thread, making this object unusable."""
if not self._dead:
self._killed = True
self._cancelled.set()
self._busy_sem.release()
self.join()
if not self._ready_sem.acquire(False):
warning("ISOTP Timer th... | python | def stop(self):
"""Stop the thread, making this object unusable."""
if not self._dead:
self._killed = True
self._cancelled.set()
self._busy_sem.release()
self.join()
if not self._ready_sem.acquire(False):
warning("ISOTP Timer th... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_dead",
":",
"self",
".",
"_killed",
"=",
"True",
"self",
".",
"_cancelled",
".",
"set",
"(",
")",
"self",
".",
"_busy_sem",
".",
"release",
"(",
")",
"self",
".",
"join",
"(",
")",... | Stop the thread, making this object unusable. | [
"Stop",
"the",
"thread",
"making",
"this",
"object",
"unusable",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L808-L817 | train | Stop the thread making this object unusable. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation._rx_timer_handler | def _rx_timer_handler(self):
"""Method called every time the rx_timer times out, due to the peer not
sending a consecutive frame within the expected time window"""
with self.rx_mutex:
if self.rx_state == ISOTP_WAIT_DATA:
# we did not get new data frames in time.
... | python | def _rx_timer_handler(self):
"""Method called every time the rx_timer times out, due to the peer not
sending a consecutive frame within the expected time window"""
with self.rx_mutex:
if self.rx_state == ISOTP_WAIT_DATA:
# we did not get new data frames in time.
... | [
"def",
"_rx_timer_handler",
"(",
"self",
")",
":",
"with",
"self",
".",
"rx_mutex",
":",
"if",
"self",
".",
"rx_state",
"==",
"ISOTP_WAIT_DATA",
":",
"# we did not get new data frames in time.",
"# reset rx state",
"self",
".",
"rx_state",
"=",
"ISOTP_IDLE",
"warnin... | Method called every time the rx_timer times out, due to the peer not
sending a consecutive frame within the expected time window | [
"Method",
"called",
"every",
"time",
"the",
"rx_timer",
"times",
"out",
"due",
"to",
"the",
"peer",
"not",
"sending",
"a",
"consecutive",
"frame",
"within",
"the",
"expected",
"time",
"window"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L959-L968 | train | Method called every time the rx_timer times out due to the peer not
sending a consecutive frame within the expected time window. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation._tx_timer_handler | def _tx_timer_handler(self):
"""Method called every time the tx_timer times out, which can happen in
two situations: either a Flow Control frame was not received in time,
or the Separation Time Min is expired and a new frame must be sent."""
with self.tx_mutex:
if (self.tx_s... | python | def _tx_timer_handler(self):
"""Method called every time the tx_timer times out, which can happen in
two situations: either a Flow Control frame was not received in time,
or the Separation Time Min is expired and a new frame must be sent."""
with self.tx_mutex:
if (self.tx_s... | [
"def",
"_tx_timer_handler",
"(",
"self",
")",
":",
"with",
"self",
".",
"tx_mutex",
":",
"if",
"(",
"self",
".",
"tx_state",
"==",
"ISOTP_WAIT_FC",
"or",
"self",
".",
"tx_state",
"==",
"ISOTP_WAIT_FIRST_FC",
")",
":",
"# we did not get any flow control frame in ti... | Method called every time the tx_timer times out, which can happen in
two situations: either a Flow Control frame was not received in time,
or the Separation Time Min is expired and a new frame must be sent. | [
"Method",
"called",
"every",
"time",
"the",
"tx_timer",
"times",
"out",
"which",
"can",
"happen",
"in",
"two",
"situations",
":",
"either",
"a",
"Flow",
"Control",
"frame",
"was",
"not",
"received",
"in",
"time",
"or",
"the",
"Separation",
"Time",
"Min",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L970-L1018 | train | This method is called every time the Tx_timer times out. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation.on_recv | def on_recv(self, cf):
"""Function that must be called every time a CAN frame is received, to
advance the state machine."""
data = bytes(cf.data)
if len(data) < 2:
return
ae = 0
if self.extended_rx_addr is not None:
ae = 1
if len(dat... | python | def on_recv(self, cf):
"""Function that must be called every time a CAN frame is received, to
advance the state machine."""
data = bytes(cf.data)
if len(data) < 2:
return
ae = 0
if self.extended_rx_addr is not None:
ae = 1
if len(dat... | [
"def",
"on_recv",
"(",
"self",
",",
"cf",
")",
":",
"data",
"=",
"bytes",
"(",
"cf",
".",
"data",
")",
"if",
"len",
"(",
"data",
")",
"<",
"2",
":",
"return",
"ae",
"=",
"0",
"if",
"self",
".",
"extended_rx_addr",
"is",
"not",
"None",
":",
"ae"... | Function that must be called every time a CAN frame is received, to
advance the state machine. | [
"Function",
"that",
"must",
"be",
"called",
"every",
"time",
"a",
"CAN",
"frame",
"is",
"received",
"to",
"advance",
"the",
"state",
"machine",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1020-L1050 | train | Function that must be called every time a CAN frame is received. to
is called every time a CAN frame is received. to
is advance the state machine. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation._recv_fc | def _recv_fc(self, data):
"""Process a received 'Flow Control' frame"""
if (self.tx_state != ISOTP_WAIT_FC and
self.tx_state != ISOTP_WAIT_FIRST_FC):
return 0
self.tx_timer.cancel()
if len(data) < 3:
self.tx_state = ISOTP_IDLE
self.tx... | python | def _recv_fc(self, data):
"""Process a received 'Flow Control' frame"""
if (self.tx_state != ISOTP_WAIT_FC and
self.tx_state != ISOTP_WAIT_FIRST_FC):
return 0
self.tx_timer.cancel()
if len(data) < 3:
self.tx_state = ISOTP_IDLE
self.tx... | [
"def",
"_recv_fc",
"(",
"self",
",",
"data",
")",
":",
"if",
"(",
"self",
".",
"tx_state",
"!=",
"ISOTP_WAIT_FC",
"and",
"self",
".",
"tx_state",
"!=",
"ISOTP_WAIT_FIRST_FC",
")",
":",
"return",
"0",
"self",
".",
"tx_timer",
".",
"cancel",
"(",
")",
"i... | Process a received 'Flow Control' frame | [
"Process",
"a",
"received",
"Flow",
"Control",
"frame"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1052-L1108 | train | Process a received Flow Control frame and return the corresponding ISO - 8601 version of the data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation._recv_sf | def _recv_sf(self, data):
"""Process a received 'Single Frame' frame"""
self.rx_timer.cancel()
if self.rx_state != ISOTP_IDLE:
warning("RX state was reset because single frame was received")
self.rx_state = ISOTP_IDLE
length = six.indexbytes(data, 0) & 0xf
... | python | def _recv_sf(self, data):
"""Process a received 'Single Frame' frame"""
self.rx_timer.cancel()
if self.rx_state != ISOTP_IDLE:
warning("RX state was reset because single frame was received")
self.rx_state = ISOTP_IDLE
length = six.indexbytes(data, 0) & 0xf
... | [
"def",
"_recv_sf",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"rx_timer",
".",
"cancel",
"(",
")",
"if",
"self",
".",
"rx_state",
"!=",
"ISOTP_IDLE",
":",
"warning",
"(",
"\"RX state was reset because single frame was received\"",
")",
"self",
".",
"rx_s... | Process a received 'Single Frame' frame | [
"Process",
"a",
"received",
"Single",
"Frame",
"frame"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1110-L1126 | train | Process a single frame from the broker. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation._recv_ff | def _recv_ff(self, data):
"""Process a received 'First Frame' frame"""
self.rx_timer.cancel()
if self.rx_state != ISOTP_IDLE:
warning("RX state was reset because first frame was received")
self.rx_state = ISOTP_IDLE
if len(data) < 7:
return 1
... | python | def _recv_ff(self, data):
"""Process a received 'First Frame' frame"""
self.rx_timer.cancel()
if self.rx_state != ISOTP_IDLE:
warning("RX state was reset because first frame was received")
self.rx_state = ISOTP_IDLE
if len(data) < 7:
return 1
... | [
"def",
"_recv_ff",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"rx_timer",
".",
"cancel",
"(",
")",
"if",
"self",
".",
"rx_state",
"!=",
"ISOTP_IDLE",
":",
"warning",
"(",
"\"RX state was reset because first frame was received\"",
")",
"self",
".",
"rx_st... | Process a received 'First Frame' frame | [
"Process",
"a",
"received",
"First",
"Frame",
"frame"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1128-L1173 | train | Process a first Frame frame from the packet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation._recv_cf | def _recv_cf(self, data):
"""Process a received 'Consecutive Frame' frame"""
if self.rx_state != ISOTP_WAIT_DATA:
return 0
self.rx_timer.cancel()
# CFs are never longer than the FF
if len(data) > self.rx_ll_dl:
return 1
# CFs have usually the LL... | python | def _recv_cf(self, data):
"""Process a received 'Consecutive Frame' frame"""
if self.rx_state != ISOTP_WAIT_DATA:
return 0
self.rx_timer.cancel()
# CFs are never longer than the FF
if len(data) > self.rx_ll_dl:
return 1
# CFs have usually the LL... | [
"def",
"_recv_cf",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"rx_state",
"!=",
"ISOTP_WAIT_DATA",
":",
"return",
"0",
"self",
".",
"rx_timer",
".",
"cancel",
"(",
")",
"# CFs are never longer than the FF",
"if",
"len",
"(",
"data",
")",
">",
... | Process a received 'Consecutive Frame' frame | [
"Process",
"a",
"received",
"Consecutive",
"Frame",
"frame"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1175-L1229 | train | Process a received Consecutive Frame frame and return the next CF. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation.begin_send | def begin_send(self, x):
"""Begins sending an ISOTP message. This method does not block."""
with self.tx_mutex:
if self.tx_state != ISOTP_IDLE:
raise Scapy_Exception("Socket is already sending, retry later")
self.tx_done.clear()
self.tx_exception = No... | python | def begin_send(self, x):
"""Begins sending an ISOTP message. This method does not block."""
with self.tx_mutex:
if self.tx_state != ISOTP_IDLE:
raise Scapy_Exception("Socket is already sending, retry later")
self.tx_done.clear()
self.tx_exception = No... | [
"def",
"begin_send",
"(",
"self",
",",
"x",
")",
":",
"with",
"self",
".",
"tx_mutex",
":",
"if",
"self",
".",
"tx_state",
"!=",
"ISOTP_IDLE",
":",
"raise",
"Scapy_Exception",
"(",
"\"Socket is already sending, retry later\"",
")",
"self",
".",
"tx_done",
".",... | Begins sending an ISOTP message. This method does not block. | [
"Begins",
"sending",
"an",
"ISOTP",
"message",
".",
"This",
"method",
"does",
"not",
"block",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1231-L1273 | train | Starts sending an ISOTP message. This method does not block. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation.send | def send(self, p):
"""Send an ISOTP frame and block until the message is sent or an error
happens."""
with self.send_mutex:
self.begin_send(p)
# Wait until the tx callback is called
self.tx_done.wait()
if self.tx_exception is not None:
... | python | def send(self, p):
"""Send an ISOTP frame and block until the message is sent or an error
happens."""
with self.send_mutex:
self.begin_send(p)
# Wait until the tx callback is called
self.tx_done.wait()
if self.tx_exception is not None:
... | [
"def",
"send",
"(",
"self",
",",
"p",
")",
":",
"with",
"self",
".",
"send_mutex",
":",
"self",
".",
"begin_send",
"(",
"p",
")",
"# Wait until the tx callback is called",
"self",
".",
"tx_done",
".",
"wait",
"(",
")",
"if",
"self",
".",
"tx_exception",
... | Send an ISOTP frame and block until the message is sent or an error
happens. | [
"Send",
"an",
"ISOTP",
"frame",
"and",
"block",
"until",
"the",
"message",
"is",
"sent",
"or",
"an",
"error",
"happens",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1275-L1285 | train | Send an ISOTP frame and block until the message is sent or an error occurs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/contrib/isotp.py | ISOTPSocketImplementation.recv | def recv(self, timeout=None):
"""Receive an ISOTP frame, blocking if none is available in the buffer
for at most 'timeout' seconds."""
try:
return self.rx_queue.get(timeout is None or timeout > 0, timeout)
except queue.Empty:
return None | python | def recv(self, timeout=None):
"""Receive an ISOTP frame, blocking if none is available in the buffer
for at most 'timeout' seconds."""
try:
return self.rx_queue.get(timeout is None or timeout > 0, timeout)
except queue.Empty:
return None | [
"def",
"recv",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"rx_queue",
".",
"get",
"(",
"timeout",
"is",
"None",
"or",
"timeout",
">",
"0",
",",
"timeout",
")",
"except",
"queue",
".",
"Empty",
":",
"retur... | Receive an ISOTP frame, blocking if none is available in the buffer
for at most 'timeout' seconds. | [
"Receive",
"an",
"ISOTP",
"frame",
"blocking",
"if",
"none",
"is",
"available",
"in",
"the",
"buffer",
"for",
"at",
"most",
"timeout",
"seconds",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1287-L1294 | train | Receive an ISOTP frame blocking if none is available in the buffer
for at most timeout seconds. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/automaton_cli.py | TLSClientAutomaton.should_add_ClientCertificate | def should_add_ClientCertificate(self):
"""
If the server sent a CertificateRequest, we send a Certificate message.
If no certificate is available, an empty Certificate message is sent:
- this is a SHOULD in RFC 4346 (Section 7.4.6)
- this is a MUST in RFC 5246 (Section 7.4.6)
... | python | def should_add_ClientCertificate(self):
"""
If the server sent a CertificateRequest, we send a Certificate message.
If no certificate is available, an empty Certificate message is sent:
- this is a SHOULD in RFC 4346 (Section 7.4.6)
- this is a MUST in RFC 5246 (Section 7.4.6)
... | [
"def",
"should_add_ClientCertificate",
"(",
"self",
")",
":",
"hs_msg",
"=",
"[",
"type",
"(",
"m",
")",
"for",
"m",
"in",
"self",
".",
"cur_session",
".",
"handshake_messages_parsed",
"]",
"if",
"TLSCertificateRequest",
"not",
"in",
"hs_msg",
":",
"return",
... | If the server sent a CertificateRequest, we send a Certificate message.
If no certificate is available, an empty Certificate message is sent:
- this is a SHOULD in RFC 4346 (Section 7.4.6)
- this is a MUST in RFC 5246 (Section 7.4.6)
XXX We may want to add a complete chain. | [
"If",
"the",
"server",
"sent",
"a",
"CertificateRequest",
"we",
"send",
"a",
"Certificate",
"message",
".",
"If",
"no",
"certificate",
"is",
"available",
"an",
"empty",
"Certificate",
"message",
"is",
"sent",
":",
"-",
"this",
"is",
"a",
"SHOULD",
"in",
"R... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L312-L328 | train | Check if we should add a client certificate. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/automaton_cli.py | TLSClientAutomaton.should_add_ClientVerify | def should_add_ClientVerify(self):
"""
XXX Section 7.4.7.1 of RFC 5246 states that the CertificateVerify
message is only sent following a client certificate that has signing
capability (i.e. not those containing fixed DH params).
We should verify that before adding the message. W... | python | def should_add_ClientVerify(self):
"""
XXX Section 7.4.7.1 of RFC 5246 states that the CertificateVerify
message is only sent following a client certificate that has signing
capability (i.e. not those containing fixed DH params).
We should verify that before adding the message. W... | [
"def",
"should_add_ClientVerify",
"(",
"self",
")",
":",
"hs_msg",
"=",
"[",
"type",
"(",
"m",
")",
"for",
"m",
"in",
"self",
".",
"cur_session",
".",
"handshake_messages_parsed",
"]",
"if",
"(",
"TLSCertificateRequest",
"not",
"in",
"hs_msg",
"or",
"self",
... | XXX Section 7.4.7.1 of RFC 5246 states that the CertificateVerify
message is only sent following a client certificate that has signing
capability (i.e. not those containing fixed DH params).
We should verify that before adding the message. We should also handle
the case when the Certific... | [
"XXX",
"Section",
"7",
".",
"4",
".",
"7",
".",
"1",
"of",
"RFC",
"5246",
"states",
"that",
"the",
"CertificateVerify",
"message",
"is",
"only",
"sent",
"following",
"a",
"client",
"certificate",
"that",
"has",
"signing",
"capability",
"(",
"i",
".",
"e"... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L351-L365 | train | This method is used to add a CertificateVerify message to the current session. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/tls/automaton_cli.py | TLSClientAutomaton.add_ClientData | def add_ClientData(self):
"""
The user may type in:
GET / HTTP/1.1\r\nHost: testserver.com\r\n\r\n
Special characters are handled so that it becomes a valid HTTP request.
"""
if not self.data_to_send:
data = six.moves.input().replace('\\r', '\r').replace('\\n'... | python | def add_ClientData(self):
"""
The user may type in:
GET / HTTP/1.1\r\nHost: testserver.com\r\n\r\n
Special characters are handled so that it becomes a valid HTTP request.
"""
if not self.data_to_send:
data = six.moves.input().replace('\\r', '\r').replace('\\n'... | [
"def",
"add_ClientData",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"data_to_send",
":",
"data",
"=",
"six",
".",
"moves",
".",
"input",
"(",
")",
".",
"replace",
"(",
"'\\\\r'",
",",
"'\\r'",
")",
".",
"replace",
"(",
"'\\\\n'",
",",
"'\\n'",
... | The user may type in:
GET / HTTP/1.1\r\nHost: testserver.com\r\n\r\n
Special characters are handled so that it becomes a valid HTTP request. | [
"The",
"user",
"may",
"type",
"in",
":",
"GET",
"/",
"HTTP",
"/",
"1",
".",
"1",
"\\",
"r",
"\\",
"nHost",
":",
"testserver",
".",
"com",
"\\",
"r",
"\\",
"n",
"\\",
"r",
"\\",
"n",
"Special",
"characters",
"are",
"handled",
"so",
"that",
"it",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L446-L462 | train | Add client data to the message buffer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/eap.py | MKAParamSet.dispatch_hook | def dispatch_hook(cls, _pkt=None, *args, **kargs):
"""
Returns the right parameter set class.
"""
cls = conf.raw_layer
if _pkt is not None:
ptype = orb(_pkt[0])
return globals().get(_param_set_cls.get(ptype), conf.raw_layer)
return cls | python | def dispatch_hook(cls, _pkt=None, *args, **kargs):
"""
Returns the right parameter set class.
"""
cls = conf.raw_layer
if _pkt is not None:
ptype = orb(_pkt[0])
return globals().get(_param_set_cls.get(ptype), conf.raw_layer)
return cls | [
"def",
"dispatch_hook",
"(",
"cls",
",",
"_pkt",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"cls",
"=",
"conf",
".",
"raw_layer",
"if",
"_pkt",
"is",
"not",
"None",
":",
"ptype",
"=",
"orb",
"(",
"_pkt",
"[",
"0",
"]",
")"... | Returns the right parameter set class. | [
"Returns",
"the",
"right",
"parameter",
"set",
"class",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/eap.py#L485-L495 | train | Dispatches the class to get the right parameter set class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/sixlowpan.py | source_addr_mode2 | def source_addr_mode2(pkt):
"""source_addr_mode
This function depending on the arguments returns the amount of bits to be
used by the source address.
Keyword arguments:
pkt -- packet object instance
"""
if pkt.sac == 0x0:
if pkt.sam == 0x0:
return 16
elif pkt.sa... | python | def source_addr_mode2(pkt):
"""source_addr_mode
This function depending on the arguments returns the amount of bits to be
used by the source address.
Keyword arguments:
pkt -- packet object instance
"""
if pkt.sac == 0x0:
if pkt.sam == 0x0:
return 16
elif pkt.sa... | [
"def",
"source_addr_mode2",
"(",
"pkt",
")",
":",
"if",
"pkt",
".",
"sac",
"==",
"0x0",
":",
"if",
"pkt",
".",
"sam",
"==",
"0x0",
":",
"return",
"16",
"elif",
"pkt",
".",
"sam",
"==",
"0x1",
":",
"return",
"8",
"elif",
"pkt",
".",
"sam",
"==",
... | source_addr_mode
This function depending on the arguments returns the amount of bits to be
used by the source address.
Keyword arguments:
pkt -- packet object instance | [
"source_addr_mode"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L213-L239 | train | source_addr_mode2 - Returns the amount of bits that are used by the source address. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/sixlowpan.py | destiny_addr_mode | def destiny_addr_mode(pkt):
"""destiny_addr_mode
This function depending on the arguments returns the amount of bits to be
used by the destiny address.
Keyword arguments:
pkt -- packet object instance
"""
if pkt.m == 0 and pkt.dac == 0:
if pkt.dam == 0x0:
return 16
... | python | def destiny_addr_mode(pkt):
"""destiny_addr_mode
This function depending on the arguments returns the amount of bits to be
used by the destiny address.
Keyword arguments:
pkt -- packet object instance
"""
if pkt.m == 0 and pkt.dac == 0:
if pkt.dam == 0x0:
return 16
... | [
"def",
"destiny_addr_mode",
"(",
"pkt",
")",
":",
"if",
"pkt",
".",
"m",
"==",
"0",
"and",
"pkt",
".",
"dac",
"==",
"0",
":",
"if",
"pkt",
".",
"dam",
"==",
"0x0",
":",
"return",
"16",
"elif",
"pkt",
".",
"dam",
"==",
"0x1",
":",
"return",
"8",... | destiny_addr_mode
This function depending on the arguments returns the amount of bits to be
used by the destiny address.
Keyword arguments:
pkt -- packet object instance | [
"destiny_addr_mode"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L242-L286 | train | This function returns the amount of bits required by the destiny address. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
secdev/scapy | scapy/layers/sixlowpan.py | _extract_dot15d4address | def _extract_dot15d4address(pkt, source=True):
"""This function extracts the source/destination address of a 6LoWPAN
from its upper Dot15d4Data (802.15.4 data) layer.
params:
- source: if True, the address is the source one. Otherwise, it is the
destination.
returns: the packed & pr... | python | def _extract_dot15d4address(pkt, source=True):
"""This function extracts the source/destination address of a 6LoWPAN
from its upper Dot15d4Data (802.15.4 data) layer.
params:
- source: if True, the address is the source one. Otherwise, it is the
destination.
returns: the packed & pr... | [
"def",
"_extract_dot15d4address",
"(",
"pkt",
",",
"source",
"=",
"True",
")",
":",
"underlayer",
"=",
"pkt",
".",
"underlayer",
"while",
"underlayer",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"underlayer",
",",
"Dot15d4Data",
")",
":",
"# noqa:... | This function extracts the source/destination address of a 6LoWPAN
from its upper Dot15d4Data (802.15.4 data) layer.
params:
- source: if True, the address is the source one. Otherwise, it is the
destination.
returns: the packed & processed address | [
"This",
"function",
"extracts",
"the",
"source",
"/",
"destination",
"address",
"of",
"a",
"6LoWPAN",
"from",
"its",
"upper",
"Dot15d4Data",
"(",
"802",
".",
"15",
".",
"4",
"data",
")",
"layer",
"."
] | 3ffe757c184017dd46464593a8f80f85abc1e79a | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L358-L383 | train | This function extracts the source and destination address of a 6LoWPAN
from the given packet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.