partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Cert.isRevoked | Given a list of trusted CRL (their signature has already been
verified with trusted anchors), this function returns True if
the certificate is marked as revoked by one of those CRL.
Note that if the Certificate was on hold in a previous CRL and
is now valid again in a new CRL and bot ar... | scapy/layers/tls/cert.py | def isRevoked(self, crl_list):
"""
Given a list of trusted CRL (their signature has already been
verified with trusted anchors), this function returns True if
the certificate is marked as revoked by one of those CRL.
Note that if the Certificate was on hold in a previous CRL and... | def isRevoked(self, crl_list):
"""
Given a list of trusted CRL (their signature has already been
verified with trusted anchors), this function returns True if
the certificate is marked as revoked by one of those CRL.
Note that if the Certificate was on hold in a previous CRL and... | [
"Given",
"a",
"list",
"of",
"trusted",
"CRL",
"(",
"their",
"signature",
"has",
"already",
"been",
"verified",
"with",
"trusted",
"anchors",
")",
"this",
"function",
"returns",
"True",
"if",
"the",
"certificate",
"is",
"marked",
"as",
"revoked",
"by",
"one",... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L713-L736 | [
"def",
"isRevoked",
"(",
"self",
",",
"crl_list",
")",
":",
"for",
"c",
"in",
"crl_list",
":",
"if",
"(",
"self",
".",
"authorityKeyID",
"is",
"not",
"None",
"and",
"c",
".",
"authorityKeyID",
"is",
"not",
"None",
"and",
"self",
".",
"authorityKeyID",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | Cert.export | Export certificate in 'fmt' format (DER or PEM) to file 'filename' | scapy/layers/tls/cert.py | def export(self, filename, fmt="DER"):
"""
Export certificate in 'fmt' format (DER or PEM) to file 'filename'
"""
f = open(filename, "wb")
if fmt == "DER":
f.write(self.der)
elif fmt == "PEM":
f.write(self.pem)
f.close() | def export(self, filename, fmt="DER"):
"""
Export certificate in 'fmt' format (DER or PEM) to file 'filename'
"""
f = open(filename, "wb")
if fmt == "DER":
f.write(self.der)
elif fmt == "PEM":
f.write(self.pem)
f.close() | [
"Export",
"certificate",
"in",
"fmt",
"format",
"(",
"DER",
"or",
"PEM",
")",
"to",
"file",
"filename"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L738-L747 | [
"def",
"export",
"(",
"self",
",",
"filename",
",",
"fmt",
"=",
"\"DER\"",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"\"wb\"",
")",
"if",
"fmt",
"==",
"\"DER\"",
":",
"f",
".",
"write",
"(",
"self",
".",
"der",
")",
"elif",
"fmt",
"==",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | Chain.verifyChain | Perform verification of certificate chains for that certificate.
A list of anchors is required. The certificates in the optional
untrusted list may be used as additional elements to the final chain.
On par with chain instantiation, only one chain constructed with the
untrusted candidates... | scapy/layers/tls/cert.py | def verifyChain(self, anchors, untrusted=None):
"""
Perform verification of certificate chains for that certificate.
A list of anchors is required. The certificates in the optional
untrusted list may be used as additional elements to the final chain.
On par with chain instantiati... | def verifyChain(self, anchors, untrusted=None):
"""
Perform verification of certificate chains for that certificate.
A list of anchors is required. The certificates in the optional
untrusted list may be used as additional elements to the final chain.
On par with chain instantiati... | [
"Perform",
"verification",
"of",
"certificate",
"chains",
"for",
"that",
"certificate",
".",
"A",
"list",
"of",
"anchors",
"is",
"required",
".",
"The",
"certificates",
"in",
"the",
"optional",
"untrusted",
"list",
"may",
"be",
"used",
"as",
"additional",
"ele... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L910-L930 | [
"def",
"verifyChain",
"(",
"self",
",",
"anchors",
",",
"untrusted",
"=",
"None",
")",
":",
"untrusted",
"=",
"untrusted",
"or",
"[",
"]",
"for",
"a",
"in",
"anchors",
":",
"chain",
"=",
"Chain",
"(",
"self",
"+",
"untrusted",
",",
"a",
")",
"if",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | Chain.verifyChainFromCAFile | Does the same job as .verifyChain() but using the list of anchors
from the cafile. As for .verifyChain(), a list of untrusted
certificates can be passed (as a file, this time). | scapy/layers/tls/cert.py | def verifyChainFromCAFile(self, cafile, untrusted_file=None):
"""
Does the same job as .verifyChain() but using the list of anchors
from the cafile. As for .verifyChain(), a list of untrusted
certificates can be passed (as a file, this time).
"""
try:
f = open... | def verifyChainFromCAFile(self, cafile, untrusted_file=None):
"""
Does the same job as .verifyChain() but using the list of anchors
from the cafile. As for .verifyChain(), a list of untrusted
certificates can be passed (as a file, this time).
"""
try:
f = open... | [
"Does",
"the",
"same",
"job",
"as",
".",
"verifyChain",
"()",
"but",
"using",
"the",
"list",
"of",
"anchors",
"from",
"the",
"cafile",
".",
"As",
"for",
".",
"verifyChain",
"()",
"a",
"list",
"of",
"untrusted",
"certificates",
"can",
"be",
"passed",
"(",... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L932-L957 | [
"def",
"verifyChainFromCAFile",
"(",
"self",
",",
"cafile",
",",
"untrusted_file",
"=",
"None",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"cafile",
",",
"\"rb\"",
")",
"ca_certs",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"close",
"(",
")",
"ex... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | Chain.verifyChainFromCAPath | Does the same job as .verifyChainFromCAFile() but using the list
of anchors in capath directory. The directory should (only) contain
certificates files in PEM format. As for .verifyChainFromCAFile(),
a list of untrusted certificates can be passed as a file
(concatenation of the certifica... | scapy/layers/tls/cert.py | def verifyChainFromCAPath(self, capath, untrusted_file=None):
"""
Does the same job as .verifyChainFromCAFile() but using the list
of anchors in capath directory. The directory should (only) contain
certificates files in PEM format. As for .verifyChainFromCAFile(),
a list of untr... | def verifyChainFromCAPath(self, capath, untrusted_file=None):
"""
Does the same job as .verifyChainFromCAFile() but using the list
of anchors in capath directory. The directory should (only) contain
certificates files in PEM format. As for .verifyChainFromCAFile(),
a list of untr... | [
"Does",
"the",
"same",
"job",
"as",
".",
"verifyChainFromCAFile",
"()",
"but",
"using",
"the",
"list",
"of",
"anchors",
"in",
"capath",
"directory",
".",
"The",
"directory",
"should",
"(",
"only",
")",
"contain",
"certificates",
"files",
"in",
"PEM",
"format... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L959-L984 | [
"def",
"verifyChainFromCAPath",
"(",
"self",
",",
"capath",
",",
"untrusted_file",
"=",
"None",
")",
":",
"try",
":",
"anchors",
"=",
"[",
"]",
"for",
"cafile",
"in",
"os",
".",
"listdir",
"(",
"capath",
")",
":",
"anchors",
".",
"append",
"(",
"Cert",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | OBD.answers | DEV: true if self is an answer from other | scapy/contrib/automotive/obd/obd.py | def answers(self, other):
"""DEV: true if self is an answer from other"""
if other.__class__ == self.__class__:
return (other.service + 0x40) == self.service or \
(self.service == 0x7f and
self.request_service_id == other.service)
return False | def answers(self, other):
"""DEV: true if self is an answer from other"""
if other.__class__ == self.__class__:
return (other.service + 0x40) == self.service or \
(self.service == 0x7f and
self.request_service_id == other.service)
return False | [
"DEV",
":",
"true",
"if",
"self",
"is",
"an",
"answer",
"from",
"other"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/obd/obd.py#L58-L64 | [
"def",
"answers",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
".",
"__class__",
"==",
"self",
".",
"__class__",
":",
"return",
"(",
"other",
".",
"service",
"+",
"0x40",
")",
"==",
"self",
".",
"service",
"or",
"(",
"self",
".",
"service",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _sndrcv_snd | Function used in the sending thread of sndrcv() | scapy/sendrecv.py | def _sndrcv_snd(pks, timeout, inter, verbose, tobesent, hsent, timessent, stopevent): # noqa: E501
"""Function used in the sending thread of sndrcv()"""
try:
i = 0
rec_time = timessent is not None
if verbose:
print("Begin emission:")
for p in tobesent:
# ... | def _sndrcv_snd(pks, timeout, inter, verbose, tobesent, hsent, timessent, stopevent): # noqa: E501
"""Function used in the sending thread of sndrcv()"""
try:
i = 0
rec_time = timessent is not None
if verbose:
print("Begin emission:")
for p in tobesent:
# ... | [
"Function",
"used",
"in",
"the",
"sending",
"thread",
"of",
"sndrcv",
"()"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L55-L90 | [
"def",
"_sndrcv_snd",
"(",
"pks",
",",
"timeout",
",",
"inter",
",",
"verbose",
",",
"tobesent",
",",
"hsent",
",",
"timessent",
",",
"stopevent",
")",
":",
"# noqa: E501",
"try",
":",
"i",
"=",
"0",
"rec_time",
"=",
"timessent",
"is",
"not",
"None",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _sndrcv_rcv | Function used to receive packets and check their hashret | scapy/sendrecv.py | def _sndrcv_rcv(pks, hsent, stopevent, nbrecv, notans, verbose, chainCC,
multi, _storage_policy=None):
"""Function used to receive packets and check their hashret"""
if not _storage_policy:
_storage_policy = lambda x, y: (x, y)
ans = []
def _get_pkt():
# SuperSocket.sele... | def _sndrcv_rcv(pks, hsent, stopevent, nbrecv, notans, verbose, chainCC,
multi, _storage_policy=None):
"""Function used to receive packets and check their hashret"""
if not _storage_policy:
_storage_policy = lambda x, y: (x, y)
ans = []
def _get_pkt():
# SuperSocket.sele... | [
"Function",
"used",
"to",
"receive",
"packets",
"and",
"check",
"their",
"hashret"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L93-L149 | [
"def",
"_sndrcv_rcv",
"(",
"pks",
",",
"hsent",
",",
"stopevent",
",",
"nbrecv",
",",
"notans",
",",
"verbose",
",",
"chainCC",
",",
"multi",
",",
"_storage_policy",
"=",
"None",
")",
":",
"if",
"not",
"_storage_policy",
":",
"_storage_policy",
"=",
"lambd... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sndrcv | Scapy raw function to send a packet and receive its answer.
WARNING: This is an internal function. Using sr/srp/sr1/srp is
more appropriate in many cases. | scapy/sendrecv.py | def sndrcv(pks, pkt, timeout=None, inter=0, verbose=None, chainCC=False,
retry=0, multi=False, rcv_pks=None, store_unanswered=True,
process=None, prebuild=False):
"""Scapy raw function to send a packet and receive its answer.
WARNING: This is an internal function. Using sr/srp/sr1/srp is
... | def sndrcv(pks, pkt, timeout=None, inter=0, verbose=None, chainCC=False,
retry=0, multi=False, rcv_pks=None, store_unanswered=True,
process=None, prebuild=False):
"""Scapy raw function to send a packet and receive its answer.
WARNING: This is an internal function. Using sr/srp/sr1/srp is
... | [
"Scapy",
"raw",
"function",
"to",
"send",
"a",
"packet",
"and",
"receive",
"its",
"answer",
".",
"WARNING",
":",
"This",
"is",
"an",
"internal",
"function",
".",
"Using",
"sr",
"/",
"srp",
"/",
"sr1",
"/",
"srp",
"is",
"more",
"appropriate",
"in",
"man... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L178-L269 | [
"def",
"sndrcv",
"(",
"pks",
",",
"pkt",
",",
"timeout",
"=",
"None",
",",
"inter",
"=",
"0",
",",
"verbose",
"=",
"None",
",",
"chainCC",
"=",
"False",
",",
"retry",
"=",
"0",
",",
"multi",
"=",
"False",
",",
"rcv_pks",
"=",
"None",
",",
"store_... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | send | Send packets at layer 3
send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501
[socket=None]) -> None | scapy/sendrecv.py | def send(x, inter=0, loop=0, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 3
send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501
[socket=None]) -> N... | def send(x, inter=0, loop=0, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 3
send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501
[socket=None]) -> N... | [
"Send",
"packets",
"at",
"layer",
"3",
"send",
"(",
"packets",
"[",
"inter",
"=",
"0",
"]",
"[",
"loop",
"=",
"0",
"]",
"[",
"count",
"=",
"None",
"]",
"[",
"verbose",
"=",
"conf",
".",
"verb",
"]",
"[",
"realtime",
"=",
"None",
"]",
"[",
"retu... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L316-L329 | [
"def",
"send",
"(",
"x",
",",
"inter",
"=",
"0",
",",
"loop",
"=",
"0",
",",
"count",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"realtime",
"=",
"None",
",",
"return_packets",
"=",
"False",
",",
"socket",
"=",
"None",
",",
"*",
"args",
",",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sendp | Send packets at layer 2
sendp(packets, [inter=0], [loop=0], [iface=None], [iface_hint=None], [count=None], [verbose=conf.verb], # noqa: E501
[realtime=None], [return_packets=False], [socket=None]) -> None | scapy/sendrecv.py | def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 2
sendp(packets, [inter=0], [loop=0], [iface=None], [iface_hint=None], [count=None], [verbose=conf.verb], # noqa: E501... | def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""Send packets at layer 2
sendp(packets, [inter=0], [loop=0], [iface=None], [iface_hint=None], [count=None], [verbose=conf.verb], # noqa: E501... | [
"Send",
"packets",
"at",
"layer",
"2",
"sendp",
"(",
"packets",
"[",
"inter",
"=",
"0",
"]",
"[",
"loop",
"=",
"0",
"]",
"[",
"iface",
"=",
"None",
"]",
"[",
"iface_hint",
"=",
"None",
"]",
"[",
"count",
"=",
"None",
"]",
"[",
"verbose",
"=",
"... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L333-L348 | [
"def",
"sendp",
"(",
"x",
",",
"inter",
"=",
"0",
",",
"loop",
"=",
"0",
",",
"iface",
"=",
"None",
",",
"iface_hint",
"=",
"None",
",",
"count",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"realtime",
"=",
"None",
",",
"return_packets",
"=",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sendpfast | Send packets at layer 2 using tcpreplay for performance
pps: packets per second
mpbs: MBits per second
realtime: use packet's timestamp, bending time with real-time value
loop: number of times to process the packet list
file_cache: cache packets in RAM instead of reading from disk at each iteration... | scapy/sendrecv.py | def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, replay_args=None, # noqa: E501
parse_results=False):
"""Send packets at layer 2 using tcpreplay for performance
pps: packets per second
mpbs: MBits per second
realtime: use packet's timestamp, bend... | def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, replay_args=None, # noqa: E501
parse_results=False):
"""Send packets at layer 2 using tcpreplay for performance
pps: packets per second
mpbs: MBits per second
realtime: use packet's timestamp, bend... | [
"Send",
"packets",
"at",
"layer",
"2",
"using",
"tcpreplay",
"for",
"performance",
"pps",
":",
"packets",
"per",
"second",
"mpbs",
":",
"MBits",
"per",
"second",
"realtime",
":",
"use",
"packet",
"s",
"timestamp",
"bending",
"time",
"with",
"real",
"-",
"t... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L352-L407 | [
"def",
"sendpfast",
"(",
"x",
",",
"pps",
"=",
"None",
",",
"mbps",
"=",
"None",
",",
"realtime",
"=",
"None",
",",
"loop",
"=",
"0",
",",
"file_cache",
"=",
"False",
",",
"iface",
"=",
"None",
",",
"replay_args",
"=",
"None",
",",
"# noqa: E501",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _parse_tcpreplay_result | Parse the output of tcpreplay and modify the results_dict to populate output information. # noqa: E501
Tested with tcpreplay v3.4.4
Tested with tcpreplay v4.1.2
:param stdout: stdout of tcpreplay subprocess call
:param stderr: stderr of tcpreplay subprocess call
:param argv: the command used in the... | scapy/sendrecv.py | def _parse_tcpreplay_result(stdout, stderr, argv):
"""
Parse the output of tcpreplay and modify the results_dict to populate output information. # noqa: E501
Tested with tcpreplay v3.4.4
Tested with tcpreplay v4.1.2
:param stdout: stdout of tcpreplay subprocess call
:param stderr: stderr of tcp... | def _parse_tcpreplay_result(stdout, stderr, argv):
"""
Parse the output of tcpreplay and modify the results_dict to populate output information. # noqa: E501
Tested with tcpreplay v3.4.4
Tested with tcpreplay v4.1.2
:param stdout: stdout of tcpreplay subprocess call
:param stderr: stderr of tcp... | [
"Parse",
"the",
"output",
"of",
"tcpreplay",
"and",
"modify",
"the",
"results_dict",
"to",
"populate",
"output",
"information",
".",
"#",
"noqa",
":",
"E501",
"Tested",
"with",
"tcpreplay",
"v3",
".",
"4",
".",
"4",
"Tested",
"with",
"tcpreplay",
"v4",
"."... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L410-L462 | [
"def",
"_parse_tcpreplay_result",
"(",
"stdout",
",",
"stderr",
",",
"argv",
")",
":",
"try",
":",
"results",
"=",
"{",
"}",
"stdout",
"=",
"plain_str",
"(",
"stdout",
")",
".",
"lower",
"(",
")",
"stderr",
"=",
"plain_str",
"(",
"stderr",
")",
".",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sr | Send and receive packets at layer 3 | scapy/sendrecv.py | def sr(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send and receive packets at layer 3"""
s = conf.L3socket(promisc=promisc, filter=filter,
iface=iface, nofilter=nofilter)
result = sndrcv(s, x, *args, **kargs)
s.close()
return result | def sr(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send and receive packets at layer 3"""
s = conf.L3socket(promisc=promisc, filter=filter,
iface=iface, nofilter=nofilter)
result = sndrcv(s, x, *args, **kargs)
s.close()
return result | [
"Send",
"and",
"receive",
"packets",
"at",
"layer",
"3"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L466-L472 | [
"def",
"sr",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"s",
"=",
"conf",
".",
"L3socket",
"(",
"promisc",
"=",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sr1 | Send packets at layer 3 and return only the first answer | scapy/sendrecv.py | def sr1(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send packets at layer 3 and return only the first answer"""
s = conf.L3socket(promisc=promisc, filter=filter,
nofilter=nofilter, iface=iface)
ans, _ = sndrcv(s, x, *args, **kargs)
s.close()
if len... | def sr1(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
"""Send packets at layer 3 and return only the first answer"""
s = conf.L3socket(promisc=promisc, filter=filter,
nofilter=nofilter, iface=iface)
ans, _ = sndrcv(s, x, *args, **kargs)
s.close()
if len... | [
"Send",
"packets",
"at",
"layer",
"3",
"and",
"return",
"only",
"the",
"first",
"answer"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L476-L485 | [
"def",
"sr1",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"s",
"=",
"conf",
".",
"L3socket",
"(",
"promisc",
"=",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srp | Send and receive packets at layer 2 | scapy/sendrecv.py | def srp(x, promisc=None, iface=None, iface_hint=None, filter=None,
nofilter=0, type=ETH_P_ALL, *args, **kargs):
"""Send and receive packets at layer 2"""
if iface is None and iface_hint is not None:
iface = conf.route.route(iface_hint)[0]
s = conf.L2socket(promisc=promisc, iface=iface,
... | def srp(x, promisc=None, iface=None, iface_hint=None, filter=None,
nofilter=0, type=ETH_P_ALL, *args, **kargs):
"""Send and receive packets at layer 2"""
if iface is None and iface_hint is not None:
iface = conf.route.route(iface_hint)[0]
s = conf.L2socket(promisc=promisc, iface=iface,
... | [
"Send",
"and",
"receive",
"packets",
"at",
"layer",
"2"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L489-L498 | [
"def",
"srp",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"iface_hint",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"type",
"=",
"ETH_P_ALL",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srp1 | Send and receive packets at layer 2 and return only the first answer | scapy/sendrecv.py | def srp1(*args, **kargs):
"""Send and receive packets at layer 2 and return only the first answer"""
ans, _ = srp(*args, **kargs)
if len(ans) > 0:
return ans[0][1]
else:
return None | def srp1(*args, **kargs):
"""Send and receive packets at layer 2 and return only the first answer"""
ans, _ = srp(*args, **kargs)
if len(ans) > 0:
return ans[0][1]
else:
return None | [
"Send",
"and",
"receive",
"packets",
"at",
"layer",
"2",
"and",
"return",
"only",
"the",
"first",
"answer"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L502-L508 | [
"def",
"srp1",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"ans",
",",
"_",
"=",
"srp",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
"if",
"len",
"(",
"ans",
")",
">",
"0",
":",
"return",
"ans",
"[",
"0",
"]",
"[",
"1",
"]",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srflood | Flood and receive packets at layer 3
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | scapy/sendrecv.py | def srflood(x, promisc=None, filter=None, iface=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: ... | def srflood(x, promisc=None, filter=None, iface=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: ... | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"3",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"unique",
":",
"only",
"consider",
"packets",
"whose",
"print",
"nofilter",
":",
"put",
"1",
"to",
"avoid",
"use",
"of",
"BPF",
"filte... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L673-L683 | [
"def",
"srflood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"s",
"=",
"conf",
".",
"L3socket",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sr1flood | Flood and receive packets at layer 3 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | scapy/sendrecv.py | def sr1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF ... | def sr1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 3 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF ... | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"3",
"and",
"return",
"only",
"the",
"first",
"answer",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"verbose",
":",
"set",
"verbosity",
"level",
"nofilter",
":",
"put",
"1",
"to",
"av... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L687-L700 | [
"def",
"sr1flood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"s",
"=",
"conf",
".",
"L3socket",
"("... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srpflood | Flood and receive packets at layer 2
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | scapy/sendrecv.py | def srpflood(x, promisc=None, filter=None, iface=None, iface_hint=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | def srpflood(x, promisc=None, filter=None, iface=None, iface_hint=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2
prn: function applied to packets received
unique: only consider packets whose print
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"2",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"unique",
":",
"only",
"consider",
"packets",
"whose",
"print",
"nofilter",
":",
"put",
"1",
"to",
"avoid",
"use",
"of",
"BPF",
"filte... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L704-L716 | [
"def",
"srpflood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"iface_hint",
"=",
"None",
",",
"nofilter",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"if",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srp1flood | Flood and receive packets at layer 2 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF filter
iface: listen answers only on the given interface | scapy/sendrecv.py | def srp1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | def srp1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2 and return only the first answer
prn: function applied to packets received
verbose: set verbosity level
nofilter: put 1 to avoid use of BPF filters
filter: provide a BPF... | [
"Flood",
"and",
"receive",
"packets",
"at",
"layer",
"2",
"and",
"return",
"only",
"the",
"first",
"answer",
"prn",
":",
"function",
"applied",
"to",
"packets",
"received",
"verbose",
":",
"set",
"verbosity",
"level",
"nofilter",
":",
"put",
"1",
"to",
"av... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L720-L733 | [
"def",
"srp1flood",
"(",
"x",
",",
"promisc",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"iface",
"=",
"None",
",",
"nofilter",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"s",
"=",
"conf",
".",
"L2socket",
"(... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | sniff | Sniff packets and return a list of packets.
Args:
count: number of packets to capture. 0 means infinity.
store: whether to store sniffed packets or discard them
prn: function to apply to each packet. If something is returned, it
is displayed.
--Ex: prn = lambda x: ... | scapy/sendrecv.py | def sniff(count=0, store=True, offline=None, prn=None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None,
stop_filter=None, iface=None, started_callback=None,
session=None, *arg, **karg):
"""Sniff packets and return a list of packets.
Args:
count: number of pac... | def sniff(count=0, store=True, offline=None, prn=None, lfilter=None,
L2socket=None, timeout=None, opened_socket=None,
stop_filter=None, iface=None, started_callback=None,
session=None, *arg, **karg):
"""Sniff packets and return a list of packets.
Args:
count: number of pac... | [
"Sniff",
"packets",
"and",
"return",
"a",
"list",
"of",
"packets",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L739-L895 | [
"def",
"sniff",
"(",
"count",
"=",
"0",
",",
"store",
"=",
"True",
",",
"offline",
"=",
"None",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
",",
"L2socket",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"opened_socket",
"=",
"None",
",",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | bridge_and_sniff | Forward traffic between interfaces if1 and if2, sniff and return
the exchanged packets.
Arguments:
if1, if2: the interfaces to use (interface names or opened sockets).
xfrm12: a function to call when forwarding a packet from if1 to
if2. If it returns True, the packet is forwarded as it. If it
returns... | scapy/sendrecv.py | def bridge_and_sniff(if1, if2, xfrm12=None, xfrm21=None, prn=None, L2socket=None, # noqa: E501
*args, **kargs):
"""Forward traffic between interfaces if1 and if2, sniff and return
the exchanged packets.
Arguments:
if1, if2: the interfaces to use (interface names or opened sockets).
xfrm... | def bridge_and_sniff(if1, if2, xfrm12=None, xfrm21=None, prn=None, L2socket=None, # noqa: E501
*args, **kargs):
"""Forward traffic between interfaces if1 and if2, sniff and return
the exchanged packets.
Arguments:
if1, if2: the interfaces to use (interface names or opened sockets).
xfrm... | [
"Forward",
"traffic",
"between",
"interfaces",
"if1",
"and",
"if2",
"sniff",
"and",
"return",
"the",
"exchanged",
"packets",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L899-L978 | [
"def",
"bridge_and_sniff",
"(",
"if1",
",",
"if2",
",",
"xfrm12",
"=",
"None",
",",
"xfrm21",
"=",
"None",
",",
"prn",
"=",
"None",
",",
"L2socket",
"=",
"None",
",",
"# noqa: E501",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"for",
"arg",
"in"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | tshark | Sniff packets and print them calling pkt.summary(), a bit like text wireshark | scapy/sendrecv.py | def tshark(*args, **kargs):
"""Sniff packets and print them calling pkt.summary(), a bit like text wireshark""" # noqa: E501
print("Capturing on '" + str(kargs.get('iface') if 'iface' in kargs else conf.iface) + "'") # noqa: E501
i = [0] # This should be a nonlocal variable, using a mutable object for Py... | def tshark(*args, **kargs):
"""Sniff packets and print them calling pkt.summary(), a bit like text wireshark""" # noqa: E501
print("Capturing on '" + str(kargs.get('iface') if 'iface' in kargs else conf.iface) + "'") # noqa: E501
i = [0] # This should be a nonlocal variable, using a mutable object for Py... | [
"Sniff",
"packets",
"and",
"print",
"them",
"calling",
"pkt",
".",
"summary",
"()",
"a",
"bit",
"like",
"text",
"wireshark"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sendrecv.py#L982-L991 | [
"def",
"tshark",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# noqa: E501",
"print",
"(",
"\"Capturing on '\"",
"+",
"str",
"(",
"kargs",
".",
"get",
"(",
"'iface'",
")",
"if",
"'iface'",
"in",
"kargs",
"else",
"conf",
".",
"iface",
")",
"+"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | ikev2scan | Send a IKEv2 SA to an IP and wait for answers. | scapy/contrib/ikev2.py | def ikev2scan(ip, **kwargs):
"""Send a IKEv2 SA to an IP and wait for answers."""
return sr(IP(dst=ip) / UDP() / IKEv2(init_SPI=RandString(8),
exch_type=34) / IKEv2_payload_SA(prop=IKEv2_payload_Proposal()), **kwargs) | def ikev2scan(ip, **kwargs):
"""Send a IKEv2 SA to an IP and wait for answers."""
return sr(IP(dst=ip) / UDP() / IKEv2(init_SPI=RandString(8),
exch_type=34) / IKEv2_payload_SA(prop=IKEv2_payload_Proposal()), **kwargs) | [
"Send",
"a",
"IKEv2",
"SA",
"to",
"an",
"IP",
"and",
"wait",
"for",
"answers",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ikev2.py#L799-L802 | [
"def",
"ikev2scan",
"(",
"ip",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"sr",
"(",
"IP",
"(",
"dst",
"=",
"ip",
")",
"/",
"UDP",
"(",
")",
"/",
"IKEv2",
"(",
"init_SPI",
"=",
"RandString",
"(",
"8",
")",
",",
"exch_type",
"=",
"34",
")",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _mib_register | Internal function used to register an OID and its name in a MIBDict | scapy/asn1/mib.py | def _mib_register(ident, value, the_mib, unresolved):
"""Internal function used to register an OID and its name in a MIBDict"""
if ident in the_mib or ident in unresolved:
return ident in the_mib
resval = []
not_resolved = 0
for v in value:
if _mib_re_integer.match(v):
re... | def _mib_register(ident, value, the_mib, unresolved):
"""Internal function used to register an OID and its name in a MIBDict"""
if ident in the_mib or ident in unresolved:
return ident in the_mib
resval = []
not_resolved = 0
for v in value:
if _mib_re_integer.match(v):
re... | [
"Internal",
"function",
"used",
"to",
"register",
"an",
"OID",
"and",
"its",
"name",
"in",
"a",
"MIBDict"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L91-L128 | [
"def",
"_mib_register",
"(",
"ident",
",",
"value",
",",
"the_mib",
",",
"unresolved",
")",
":",
"if",
"ident",
"in",
"the_mib",
"or",
"ident",
"in",
"unresolved",
":",
"return",
"ident",
"in",
"the_mib",
"resval",
"=",
"[",
"]",
"not_resolved",
"=",
"0"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | load_mib | Load the conf.mib dict from a list of filenames | scapy/asn1/mib.py | def load_mib(filenames):
"""Load the conf.mib dict from a list of filenames"""
the_mib = {'iso': ['1']}
unresolved = {}
for k in six.iterkeys(conf.mib):
_mib_register(conf.mib[k], k.split("."), the_mib, unresolved)
if isinstance(filenames, (str, bytes)):
filenames = [filenames]
... | def load_mib(filenames):
"""Load the conf.mib dict from a list of filenames"""
the_mib = {'iso': ['1']}
unresolved = {}
for k in six.iterkeys(conf.mib):
_mib_register(conf.mib[k], k.split("."), the_mib, unresolved)
if isinstance(filenames, (str, bytes)):
filenames = [filenames]
... | [
"Load",
"the",
"conf",
".",
"mib",
"dict",
"from",
"a",
"list",
"of",
"filenames"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L131-L162 | [
"def",
"load_mib",
"(",
"filenames",
")",
":",
"the_mib",
"=",
"{",
"'iso'",
":",
"[",
"'1'",
"]",
"}",
"unresolved",
"=",
"{",
"}",
"for",
"k",
"in",
"six",
".",
"iterkeys",
"(",
"conf",
".",
"mib",
")",
":",
"_mib_register",
"(",
"conf",
".",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MIBDict._findroot | Internal MIBDict function used to find a partial OID | scapy/asn1/mib.py | def _findroot(self, x):
"""Internal MIBDict function used to find a partial OID"""
if x.startswith("."):
x = x[1:]
if not x.endswith("."):
x += "."
max = 0
root = "."
root_key = ""
for k in six.iterkeys(self):
if x.startswith(k ... | def _findroot(self, x):
"""Internal MIBDict function used to find a partial OID"""
if x.startswith("."):
x = x[1:]
if not x.endswith("."):
x += "."
max = 0
root = "."
root_key = ""
for k in six.iterkeys(self):
if x.startswith(k ... | [
"Internal",
"MIBDict",
"function",
"used",
"to",
"find",
"a",
"partial",
"OID"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L36-L51 | [
"def",
"_findroot",
"(",
"self",
",",
"x",
")",
":",
"if",
"x",
".",
"startswith",
"(",
"\".\"",
")",
":",
"x",
"=",
"x",
"[",
"1",
":",
"]",
"if",
"not",
"x",
".",
"endswith",
"(",
"\".\"",
")",
":",
"x",
"+=",
"\".\"",
"max",
"=",
"0",
"r... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MIBDict._oid | Parse the OID id/OID generator, and return real OID | scapy/asn1/mib.py | def _oid(self, x):
"""Parse the OID id/OID generator, and return real OID"""
xl = x.strip(".").split(".")
p = len(xl) - 1
while p >= 0 and _mib_re_integer.match(xl[p]):
p -= 1
if p != 0 or xl[p] not in six.itervalues(self.__dict__):
return x
xl[p] ... | def _oid(self, x):
"""Parse the OID id/OID generator, and return real OID"""
xl = x.strip(".").split(".")
p = len(xl) - 1
while p >= 0 and _mib_re_integer.match(xl[p]):
p -= 1
if p != 0 or xl[p] not in six.itervalues(self.__dict__):
return x
xl[p] ... | [
"Parse",
"the",
"OID",
"id",
"/",
"OID",
"generator",
"and",
"return",
"real",
"OID"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1/mib.py#L58-L67 | [
"def",
"_oid",
"(",
"self",
",",
"x",
")",
":",
"xl",
"=",
"x",
".",
"strip",
"(",
"\".\"",
")",
".",
"split",
"(",
"\".\"",
")",
"p",
"=",
"len",
"(",
"xl",
")",
"-",
"1",
"while",
"p",
">=",
"0",
"and",
"_mib_re_integer",
".",
"match",
"(",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACControl._get_underlayers_size | get the total size of all under layers
:return: number of bytes | scapy/contrib/mac_control.py | def _get_underlayers_size(self):
"""
get the total size of all under layers
:return: number of bytes
"""
under_layer = self.underlayer
under_layers_size = 0
while under_layer and isinstance(under_layer, Dot1Q):
under_layers_size += 4
und... | def _get_underlayers_size(self):
"""
get the total size of all under layers
:return: number of bytes
"""
under_layer = self.underlayer
under_layers_size = 0
while under_layer and isinstance(under_layer, Dot1Q):
under_layers_size += 4
und... | [
"get",
"the",
"total",
"size",
"of",
"all",
"under",
"layers",
":",
"return",
":",
"number",
"of",
"bytes"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L103-L121 | [
"def",
"_get_underlayers_size",
"(",
"self",
")",
":",
"under_layer",
"=",
"self",
".",
"underlayer",
"under_layers_size",
"=",
"0",
"while",
"under_layer",
"and",
"isinstance",
"(",
"under_layer",
",",
"Dot1Q",
")",
":",
"under_layers_size",
"+=",
"4",
"under_l... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACControl.post_build | add padding to the frame if required.
note that padding is only added if pay is None/empty. this allows us to add # noqa: E501
any payload after the MACControl* PDU if needed (piggybacking). | scapy/contrib/mac_control.py | def post_build(self, pkt, pay):
"""
add padding to the frame if required.
note that padding is only added if pay is None/empty. this allows us to add # noqa: E501
any payload after the MACControl* PDU if needed (piggybacking).
"""
if not pay:
under_layers_s... | def post_build(self, pkt, pay):
"""
add padding to the frame if required.
note that padding is only added if pay is None/empty. this allows us to add # noqa: E501
any payload after the MACControl* PDU if needed (piggybacking).
"""
if not pay:
under_layers_s... | [
"add",
"padding",
"to",
"the",
"frame",
"if",
"required",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L123-L139 | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"if",
"not",
"pay",
":",
"under_layers_size",
"=",
"self",
".",
"_get_underlayers_size",
"(",
")",
"frame_size",
"=",
"(",
"len",
"(",
"pkt",
")",
"+",
"under_layers_size",
")",
"if",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACControlPause.get_pause_time | get pause time for given link speed in seconds
:param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
:return: pause time in seconds
:raises MACControlInvalidSpeedException: on invalid speed selector | scapy/contrib/mac_control.py | def get_pause_time(self, speed=ETHER_SPEED_MBIT_1000):
"""
get pause time for given link speed in seconds
:param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
:return: pause time in seconds
:raises MACControlInvalidSpeed... | def get_pause_time(self, speed=ETHER_SPEED_MBIT_1000):
"""
get pause time for given link speed in seconds
:param speed: select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
:return: pause time in seconds
:raises MACControlInvalidSpeed... | [
"get",
"pause",
"time",
"for",
"given",
"link",
"speed",
"in",
"seconds"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/mac_control.py#L152-L169 | [
"def",
"get_pause_time",
"(",
"self",
",",
"speed",
"=",
"ETHER_SPEED_MBIT_1000",
")",
":",
"try",
":",
"return",
"self",
".",
"pause_time",
"*",
"{",
"ETHER_SPEED_MBIT_10",
":",
"(",
"0.0000001",
"*",
"512",
")",
",",
"ETHER_SPEED_MBIT_100",
":",
"(",
"0.00... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | rdcandump | Read a candump log file and return a packet list
count: read only <count> packets
is_not_log_file_format: read input with candumps stdout format
interfaces: return only packets from a specified interface | scapy/layers/can.py | def rdcandump(filename, count=None,
is_not_log_file_format=False,
interface=None):
"""Read a candump log file and return a packet list
count: read only <count> packets
is_not_log_file_format: read input with candumps stdout format
interfaces: return only packets from a specified interfa... | def rdcandump(filename, count=None,
is_not_log_file_format=False,
interface=None):
"""Read a candump log file and return a packet list
count: read only <count> packets
is_not_log_file_format: read input with candumps stdout format
interfaces: return only packets from a specified interfa... | [
"Read",
"a",
"candump",
"log",
"file",
"and",
"return",
"a",
"packet",
"list"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L87-L147 | [
"def",
"rdcandump",
"(",
"filename",
",",
"count",
"=",
"None",
",",
"is_not_log_file_format",
"=",
"False",
",",
"interface",
"=",
"None",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"filename",
",",
"six",
".",
"string_types",
")",
":",
"file",
"=",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | CAN.inv_endianness | Invert the order of the first four bytes of a CAN packet
This method is meant to be used specifically to convert a CAN packet
between the pcap format and the socketCAN format
:param pkt: str of the CAN packet
:return: packet str with the first four bytes swapped | scapy/layers/can.py | def inv_endianness(pkt):
""" Invert the order of the first four bytes of a CAN packet
This method is meant to be used specifically to convert a CAN packet
between the pcap format and the socketCAN format
:param pkt: str of the CAN packet
:return: packet str with the first four ... | def inv_endianness(pkt):
""" Invert the order of the first four bytes of a CAN packet
This method is meant to be used specifically to convert a CAN packet
between the pcap format and the socketCAN format
:param pkt: str of the CAN packet
:return: packet str with the first four ... | [
"Invert",
"the",
"order",
"of",
"the",
"first",
"four",
"bytes",
"of",
"a",
"CAN",
"packet"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L45-L56 | [
"def",
"inv_endianness",
"(",
"pkt",
")",
":",
"len_partial",
"=",
"len",
"(",
"pkt",
")",
"-",
"4",
"# len of the packet, CAN ID excluded",
"return",
"struct",
".",
"pack",
"(",
"'<I{}s'",
".",
"format",
"(",
"len_partial",
")",
",",
"*",
"struct",
".",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | CAN.post_build | Implements the swap-bytes functionality when building
this is based on a copy of the Packet.self_build default method.
The goal is to affect only the CAN layer data and keep
under layers (e.g LinuxCooked) unchanged | scapy/layers/can.py | def post_build(self, pkt, pay):
""" Implements the swap-bytes functionality when building
this is based on a copy of the Packet.self_build default method.
The goal is to affect only the CAN layer data and keep
under layers (e.g LinuxCooked) unchanged
"""
if conf.contribs... | def post_build(self, pkt, pay):
""" Implements the swap-bytes functionality when building
this is based on a copy of the Packet.self_build default method.
The goal is to affect only the CAN layer data and keep
under layers (e.g LinuxCooked) unchanged
"""
if conf.contribs... | [
"Implements",
"the",
"swap",
"-",
"bytes",
"functionality",
"when",
"building"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/can.py#L68-L77 | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"if",
"conf",
".",
"contribs",
"[",
"'CAN'",
"]",
"[",
"'swap-bytes'",
"]",
":",
"return",
"CAN",
".",
"inv_endianness",
"(",
"pkt",
")",
"+",
"pay",
"return",
"pkt",
"+",
"pay"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | pkt2uptime | Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
pkt2uptime(pkt, [HZ=100]) | scapy/modules/p0f.py | def pkt2uptime(pkt, HZ=100):
"""Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
pkt2uptime(pkt, [HZ=100])"""
if not isinstance(pkt, Packet):
raise TypeError("Not a TCP packet")
if isinstance(pkt, NoPayload):
raise TypeError("Not a TCP packet")... | def pkt2uptime(pkt, HZ=100):
"""Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
pkt2uptime(pkt, [HZ=100])"""
if not isinstance(pkt, Packet):
raise TypeError("Not a TCP packet")
if isinstance(pkt, NoPayload):
raise TypeError("Not a TCP packet")... | [
"Calculate",
"the",
"date",
"the",
"machine",
"which",
"emitted",
"the",
"packet",
"booted",
"using",
"TCP",
"timestamp",
"#",
"noqa",
":",
"E501",
"pkt2uptime",
"(",
"pkt",
"[",
"HZ",
"=",
"100",
"]",
")"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/p0f.py#L345-L360 | [
"def",
"pkt2uptime",
"(",
"pkt",
",",
"HZ",
"=",
"100",
")",
":",
"if",
"not",
"isinstance",
"(",
"pkt",
",",
"Packet",
")",
":",
"raise",
"TypeError",
"(",
"\"Not a TCP packet\"",
")",
"if",
"isinstance",
"(",
"pkt",
",",
"NoPayload",
")",
":",
"raise... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | p0f_impersonate | Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also None,
we use a local signature (using p0f_getlocalsigs). If signature is
specified (as a tuple), we use the signature.
For now, only T... | scapy/modules/p0f.py | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | [
"Modifies",
"pkt",
"so",
"that",
"p0f",
"will",
"think",
"it",
"has",
"been",
"sent",
"by",
"a",
"specific",
"OS",
".",
"If",
"osdetails",
"is",
"None",
"then",
"we",
"randomly",
"pick",
"up",
"a",
"personality",
"matching",
"osgenre",
".",
"If",
"osgenr... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/p0f.py#L363-L566 | [
"def",
"p0f_impersonate",
"(",
"pkt",
",",
"osgenre",
"=",
"None",
",",
"osdetails",
"=",
"None",
",",
"signature",
"=",
"None",
",",
"extrahops",
"=",
"0",
",",
"mtu",
"=",
"1500",
",",
"uptime",
"=",
"None",
")",
":",
"pkt",
"=",
"pkt",
".",
"cop... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | IODControlReq.get_response | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | scapy/contrib/pnio_rpc.py | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODControlRes()
for field in ["ARUUID", "SessionKey", "AlarmSequenceNumber"]:
res.setfieldval(field, self.getfieldval(f... | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODControlRes()
for field in ["ARUUID", "SessionKey", "AlarmSequenceNumber"]:
res.setfieldval(field, self.getfieldval(f... | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L385-L394 | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IODControlRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"ARUUID\"",
",",
"\"SessionKey\"",
",",
"\"AlarmSequenceNumber\"",
"]",
":",
"res",
".",
"setfieldval",
"(",
"field",
",",
"self",
".",
"getfi... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | IODWriteReq.get_response | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | scapy/contrib/pnio_rpc.py | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
r... | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
r... | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L445-L453 | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IODWriteRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"seqNum\"",
",",
"\"ARUUID\"",
",",
"\"API\"",
",",
"\"slotNumber\"",
",",
"\"subslotNumber\"",
",",
"\"index\"",
"]",
":",
"res",
".",
"setfiel... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | PadFieldWithLen.i2len | get the length of the field, including the padding length | scapy/contrib/pnio_rpc.py | def i2len(self, pkt, val):
"""get the length of the field, including the padding length"""
fld_len = self._fld.i2len(pkt, val)
return fld_len + self.padlen(fld_len) | def i2len(self, pkt, val):
"""get the length of the field, including the padding length"""
fld_len = self._fld.i2len(pkt, val)
return fld_len + self.padlen(fld_len) | [
"get",
"the",
"length",
"of",
"the",
"field",
"including",
"the",
"padding",
"length"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L529-L532 | [
"def",
"i2len",
"(",
"self",
",",
"pkt",
",",
"val",
")",
":",
"fld_len",
"=",
"self",
".",
"_fld",
".",
"i2len",
"(",
"pkt",
",",
"val",
")",
"return",
"fld_len",
"+",
"self",
".",
"padlen",
"(",
"fld_len",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | IODWriteMultipleReq.get_response | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | scapy/contrib/pnio_rpc.py | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteMultipleRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
... | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IODWriteMultipleRes()
for field in ["seqNum", "ARUUID", "API", "slotNumber",
"subslotNumber", "index"]:
... | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L580-L594 | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IODWriteMultipleRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"seqNum\"",
",",
"\"ARUUID\"",
",",
"\"API\"",
",",
"\"slotNumber\"",
",",
"\"subslotNumber\"",
",",
"\"index\"",
"]",
":",
"res",
".",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | ARBlockReq.get_response | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | scapy/contrib/pnio_rpc.py | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = ARBlockRes()
for field in ["ARType", "ARUUID", "SessionKey"]:
res.setfieldval(field, self.getfieldval(field))
r... | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = ARBlockRes()
for field in ["ARType", "ARUUID", "SessionKey"]:
res.setfieldval(field, self.getfieldval(field))
r... | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L665-L672 | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"ARBlockRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"ARType\"",
",",
"\"ARUUID\"",
",",
"\"SessionKey\"",
"]",
":",
"res",
".",
"setfieldval",
"(",
"field",
",",
"self",
".",
"getfieldval",
"(",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | IOCRBlockReq.get_response | Generate the response block of this request.
Careful: it only sets the fields which can be set from the request | scapy/contrib/pnio_rpc.py | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IOCRBlockRes()
for field in ["IOCRType", "IOCRReference", "FrameID"]:
res.setfieldval(field, self.getfieldval(field))
... | def get_response(self):
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = IOCRBlockRes()
for field in ["IOCRType", "IOCRReference", "FrameID"]:
res.setfieldval(field, self.getfieldval(field))
... | [
"Generate",
"the",
"response",
"block",
"of",
"this",
"request",
".",
"Careful",
":",
"it",
"only",
"sets",
"the",
"fields",
"which",
"can",
"be",
"set",
"from",
"the",
"request"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L757-L764 | [
"def",
"get_response",
"(",
"self",
")",
":",
"res",
"=",
"IOCRBlockRes",
"(",
")",
"for",
"field",
"in",
"[",
"\"IOCRType\"",
",",
"\"IOCRReference\"",
",",
"\"FrameID\"",
"]",
":",
"res",
".",
"setfieldval",
"(",
"field",
",",
"self",
".",
"getfieldval",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | PNIOServiceReqPDU.can_handle | heuristical guess_payload_class | scapy/contrib/pnio_rpc.py | def can_handle(cls, pkt, rpc):
"""heuristical guess_payload_class"""
# type = 0 => request
if rpc.getfieldval("type") == 0 and \
str(rpc.object_uuid).startswith("dea00000-6c97-11d1-8271-"):
return True
return False | def can_handle(cls, pkt, rpc):
"""heuristical guess_payload_class"""
# type = 0 => request
if rpc.getfieldval("type") == 0 and \
str(rpc.object_uuid).startswith("dea00000-6c97-11d1-8271-"):
return True
return False | [
"heuristical",
"guess_payload_class"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L969-L975 | [
"def",
"can_handle",
"(",
"cls",
",",
"pkt",
",",
"rpc",
")",
":",
"# type = 0 => request",
"if",
"rpc",
".",
"getfieldval",
"(",
"\"type\"",
")",
"==",
"0",
"and",
"str",
"(",
"rpc",
".",
"object_uuid",
")",
".",
"startswith",
"(",
"\"dea00000-6c97-11d1-8... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACsecSA.make_iv | generate an IV for the packet | scapy/contrib/macsec.py | def make_iv(self, pkt):
"""generate an IV for the packet"""
if self.xpn_en:
tmp_pn = (self.pn & 0xFFFFFFFF00000000) | (pkt[MACsec].pn & 0xFFFFFFFF) # noqa: E501
tmp_iv = self.ssci + struct.pack('!Q', tmp_pn)
return bytes(bytearray([a ^ b for a, b in zip(bytearray(tmp... | def make_iv(self, pkt):
"""generate an IV for the packet"""
if self.xpn_en:
tmp_pn = (self.pn & 0xFFFFFFFF00000000) | (pkt[MACsec].pn & 0xFFFFFFFF) # noqa: E501
tmp_iv = self.ssci + struct.pack('!Q', tmp_pn)
return bytes(bytearray([a ^ b for a, b in zip(bytearray(tmp... | [
"generate",
"an",
"IV",
"for",
"the",
"packet"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L82-L89 | [
"def",
"make_iv",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"self",
".",
"xpn_en",
":",
"tmp_pn",
"=",
"(",
"self",
".",
"pn",
"&",
"0xFFFFFFFF00000000",
")",
"|",
"(",
"pkt",
"[",
"MACsec",
"]",
".",
"pn",
"&",
"0xFFFFFFFF",
")",
"# noqa: E501",
"t... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACsecSA.split_pkt | split the packet into associated data, plaintext or ciphertext, and
optional ICV | scapy/contrib/macsec.py | def split_pkt(pkt, assoclen, icvlen=0):
"""
split the packet into associated data, plaintext or ciphertext, and
optional ICV
"""
data = raw(pkt)
assoc = data[:assoclen]
if icvlen:
icv = data[-icvlen:]
enc = data[assoclen:-icvlen]
el... | def split_pkt(pkt, assoclen, icvlen=0):
"""
split the packet into associated data, plaintext or ciphertext, and
optional ICV
"""
data = raw(pkt)
assoc = data[:assoclen]
if icvlen:
icv = data[-icvlen:]
enc = data[assoclen:-icvlen]
el... | [
"split",
"the",
"packet",
"into",
"associated",
"data",
"plaintext",
"or",
"ciphertext",
"and",
"optional",
"ICV"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L92-L105 | [
"def",
"split_pkt",
"(",
"pkt",
",",
"assoclen",
",",
"icvlen",
"=",
"0",
")",
":",
"data",
"=",
"raw",
"(",
"pkt",
")",
"assoc",
"=",
"data",
"[",
":",
"assoclen",
"]",
"if",
"icvlen",
":",
"icv",
"=",
"data",
"[",
"-",
"icvlen",
":",
"]",
"en... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACsecSA.encap | encapsulate a frame using this Secure Association | scapy/contrib/macsec.py | def encap(self, pkt):
"""encapsulate a frame using this Secure Association"""
if pkt.name != Ether().name:
raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet') # noqa: E501
hdr = copy.deepcopy(pkt)
payload = hdr.payload
del hdr.payload
tag... | def encap(self, pkt):
"""encapsulate a frame using this Secure Association"""
if pkt.name != Ether().name:
raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet') # noqa: E501
hdr = copy.deepcopy(pkt)
payload = hdr.payload
del hdr.payload
tag... | [
"encapsulate",
"a",
"frame",
"using",
"this",
"Secure",
"Association"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L123-L136 | [
"def",
"encap",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"pkt",
".",
"name",
"!=",
"Ether",
"(",
")",
".",
"name",
":",
"raise",
"TypeError",
"(",
"'cannot encapsulate packet in MACsec, must be Ethernet'",
")",
"# noqa: E501",
"hdr",
"=",
"copy",
".",
"deepc... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACsecSA.decap | decapsulate a MACsec frame | scapy/contrib/macsec.py | def decap(self, orig_pkt):
"""decapsulate a MACsec frame"""
if orig_pkt.name != Ether().name or orig_pkt.payload.name != MACsec().name: # noqa: E501
raise TypeError('cannot decapsulate MACsec packet, must be Ethernet/MACsec') # noqa: E501
packet = copy.deepcopy(orig_pkt)
pr... | def decap(self, orig_pkt):
"""decapsulate a MACsec frame"""
if orig_pkt.name != Ether().name or orig_pkt.payload.name != MACsec().name: # noqa: E501
raise TypeError('cannot decapsulate MACsec packet, must be Ethernet/MACsec') # noqa: E501
packet = copy.deepcopy(orig_pkt)
pr... | [
"decapsulate",
"a",
"MACsec",
"frame"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L140-L151 | [
"def",
"decap",
"(",
"self",
",",
"orig_pkt",
")",
":",
"if",
"orig_pkt",
".",
"name",
"!=",
"Ether",
"(",
")",
".",
"name",
"or",
"orig_pkt",
".",
"payload",
".",
"name",
"!=",
"MACsec",
"(",
")",
".",
"name",
":",
"# noqa: E501",
"raise",
"TypeErro... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACsecSA.encrypt | encrypt a MACsec frame for this Secure Association | scapy/contrib/macsec.py | def encrypt(self, orig_pkt, assoclen=None):
"""encrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
del hdr[MACsec].type
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
... | def encrypt(self, orig_pkt, assoclen=None):
"""encrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
del hdr[MACsec].type
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
... | [
"encrypt",
"a",
"MACsec",
"frame",
"for",
"this",
"Secure",
"Association"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L153-L178 | [
"def",
"encrypt",
"(",
"self",
",",
"orig_pkt",
",",
"assoclen",
"=",
"None",
")",
":",
"hdr",
"=",
"copy",
".",
"deepcopy",
"(",
"orig_pkt",
")",
"del",
"hdr",
"[",
"MACsec",
"]",
".",
"payload",
"del",
"hdr",
"[",
"MACsec",
"]",
".",
"type",
"pkt... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | MACsecSA.decrypt | decrypt a MACsec frame for this Secure Association | scapy/contrib/macsec.py | def decrypt(self, orig_pkt, assoclen=None):
"""decrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
hdrlen = NOSCI_LE... | def decrypt(self, orig_pkt, assoclen=None):
"""decrypt a MACsec frame for this Secure Association"""
hdr = copy.deepcopy(orig_pkt)
del hdr[MACsec].payload
pktlen = len(orig_pkt)
if self.send_sci:
hdrlen = NOSCI_LEN + SCI_LEN
else:
hdrlen = NOSCI_LE... | [
"decrypt",
"a",
"MACsec",
"frame",
"for",
"this",
"Secure",
"Association"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/macsec.py#L180-L207 | [
"def",
"decrypt",
"(",
"self",
",",
"orig_pkt",
",",
"assoclen",
"=",
"None",
")",
":",
"hdr",
"=",
"copy",
".",
"deepcopy",
"(",
"orig_pkt",
")",
"del",
"hdr",
"[",
"MACsec",
"]",
".",
"payload",
"pktlen",
"=",
"len",
"(",
"orig_pkt",
")",
"if",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srbt | send and receive using a bluetooth socket | scapy/layers/bluetooth.py | def srbt(bt_address, pkts, inter=0.1, *args, **kargs):
"""send and receive using a bluetooth socket"""
if "port" in kargs:
s = conf.BTsocket(bt_address=bt_address, port=kargs.pop("port"))
else:
s = conf.BTsocket(bt_address=bt_address)
a, b = sndrcv(s, pkts, inter=inter, *args, **kargs)
... | def srbt(bt_address, pkts, inter=0.1, *args, **kargs):
"""send and receive using a bluetooth socket"""
if "port" in kargs:
s = conf.BTsocket(bt_address=bt_address, port=kargs.pop("port"))
else:
s = conf.BTsocket(bt_address=bt_address)
a, b = sndrcv(s, pkts, inter=inter, *args, **kargs)
... | [
"send",
"and",
"receive",
"using",
"a",
"bluetooth",
"socket"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/bluetooth.py#L1458-L1466 | [
"def",
"srbt",
"(",
"bt_address",
",",
"pkts",
",",
"inter",
"=",
"0.1",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"\"port\"",
"in",
"kargs",
":",
"s",
"=",
"conf",
".",
"BTsocket",
"(",
"bt_address",
"=",
"bt_address",
",",
"port",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | srbt1 | send and receive 1 packet using a bluetooth socket | scapy/layers/bluetooth.py | def srbt1(bt_address, pkts, *args, **kargs):
"""send and receive 1 packet using a bluetooth socket"""
a, b = srbt(bt_address, pkts, *args, **kargs)
if len(a) > 0:
return a[0][1] | def srbt1(bt_address, pkts, *args, **kargs):
"""send and receive 1 packet using a bluetooth socket"""
a, b = srbt(bt_address, pkts, *args, **kargs)
if len(a) > 0:
return a[0][1] | [
"send",
"and",
"receive",
"1",
"packet",
"using",
"a",
"bluetooth",
"socket"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/bluetooth.py#L1470-L1474 | [
"def",
"srbt1",
"(",
"bt_address",
",",
"pkts",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"a",
",",
"b",
"=",
"srbt",
"(",
"bt_address",
",",
"pkts",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
"if",
"len",
"(",
"a",
")",
">",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | EIR_Manufacturer_Specific_Data.register_magic_payload | Registers a payload type that uses magic data.
Traditional payloads require registration of a Bluetooth Company ID
(requires company membership of the Bluetooth SIG), or a Bluetooth
Short UUID (requires a once-off payment).
There are alternatives which don't require registration (such ... | scapy/layers/bluetooth.py | def register_magic_payload(cls, payload_cls, magic_check=None):
"""
Registers a payload type that uses magic data.
Traditional payloads require registration of a Bluetooth Company ID
(requires company membership of the Bluetooth SIG), or a Bluetooth
Short UUID (requires a once-o... | def register_magic_payload(cls, payload_cls, magic_check=None):
"""
Registers a payload type that uses magic data.
Traditional payloads require registration of a Bluetooth Company ID
(requires company membership of the Bluetooth SIG), or a Bluetooth
Short UUID (requires a once-o... | [
"Registers",
"a",
"payload",
"type",
"that",
"uses",
"magic",
"data",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/bluetooth.py#L707-L744 | [
"def",
"register_magic_payload",
"(",
"cls",
",",
"payload_cls",
",",
"magic_check",
"=",
"None",
")",
":",
"if",
"magic_check",
"is",
"None",
":",
"if",
"hasattr",
"(",
"payload_cls",
",",
"\"magic_check\"",
")",
":",
"magic_check",
"=",
"payload_cls",
".",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SOMEIP._is_tp | Returns true if pkt is using SOMEIP-TP, else returns false. | scapy/contrib/automotive/someip.py | def _is_tp(pkt):
"""Returns true if pkt is using SOMEIP-TP, else returns false."""
tp = [SOMEIP.TYPE_TP_REQUEST, SOMEIP.TYPE_TP_REQUEST_NO_RET,
SOMEIP.TYPE_TP_NOTIFICATION, SOMEIP.TYPE_TP_RESPONSE,
SOMEIP.TYPE_TP_ERROR]
if isinstance(pkt, Packet):
return ... | def _is_tp(pkt):
"""Returns true if pkt is using SOMEIP-TP, else returns false."""
tp = [SOMEIP.TYPE_TP_REQUEST, SOMEIP.TYPE_TP_REQUEST_NO_RET,
SOMEIP.TYPE_TP_NOTIFICATION, SOMEIP.TYPE_TP_RESPONSE,
SOMEIP.TYPE_TP_ERROR]
if isinstance(pkt, Packet):
return ... | [
"Returns",
"true",
"if",
"pkt",
"is",
"using",
"SOMEIP",
"-",
"TP",
"else",
"returns",
"false",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/someip.py#L179-L188 | [
"def",
"_is_tp",
"(",
"pkt",
")",
":",
"tp",
"=",
"[",
"SOMEIP",
".",
"TYPE_TP_REQUEST",
",",
"SOMEIP",
".",
"TYPE_TP_REQUEST_NO_RET",
",",
"SOMEIP",
".",
"TYPE_TP_NOTIFICATION",
",",
"SOMEIP",
".",
"TYPE_TP_RESPONSE",
",",
"SOMEIP",
".",
"TYPE_TP_ERROR",
"]",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SOMEIP.fragment | Fragment SOME/IP-TP | scapy/contrib/automotive/someip.py | def fragment(self, fragsize=1392):
"""Fragment SOME/IP-TP"""
fnb = 0
fl = self
lst = list()
while fl.underlayer is not None:
fnb += 1
fl = fl.underlayer
for p in fl:
s = raw(p[fnb].payload)
nb = (len(s) + fragsize) // frags... | def fragment(self, fragsize=1392):
"""Fragment SOME/IP-TP"""
fnb = 0
fl = self
lst = list()
while fl.underlayer is not None:
fnb += 1
fl = fl.underlayer
for p in fl:
s = raw(p[fnb].payload)
nb = (len(s) + fragsize) // frags... | [
"Fragment",
"SOME",
"/",
"IP",
"-",
"TP"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/someip.py#L190-L216 | [
"def",
"fragment",
"(",
"self",
",",
"fragsize",
"=",
"1392",
")",
":",
"fnb",
"=",
"0",
"fl",
"=",
"self",
"lst",
"=",
"list",
"(",
")",
"while",
"fl",
".",
"underlayer",
"is",
"not",
"None",
":",
"fnb",
"+=",
"1",
"fl",
"=",
"fl",
".",
"under... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _next_radiotap_extpm | Generates the next RadioTapExtendedPresenceMask | scapy/layers/dot11.py | def _next_radiotap_extpm(pkt, lst, cur, s):
"""Generates the next RadioTapExtendedPresenceMask"""
if cur is None or (cur.present and cur.present.Ext):
st = len(lst) + (cur is not None)
return lambda *args: RadioTapExtendedPresenceMask(*args, index=st)
return None | def _next_radiotap_extpm(pkt, lst, cur, s):
"""Generates the next RadioTapExtendedPresenceMask"""
if cur is None or (cur.present and cur.present.Ext):
st = len(lst) + (cur is not None)
return lambda *args: RadioTapExtendedPresenceMask(*args, index=st)
return None | [
"Generates",
"the",
"next",
"RadioTapExtendedPresenceMask"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot11.py#L140-L145 | [
"def",
"_next_radiotap_extpm",
"(",
"pkt",
",",
"lst",
",",
"cur",
",",
"s",
")",
":",
"if",
"cur",
"is",
"None",
"or",
"(",
"cur",
".",
"present",
"and",
"cur",
".",
"present",
".",
"Ext",
")",
":",
"st",
"=",
"len",
"(",
"lst",
")",
"+",
"(",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _Dot11NetStats.network_stats | Return a dictionary containing a summary of the Dot11
elements fields | scapy/layers/dot11.py | def network_stats(self):
"""Return a dictionary containing a summary of the Dot11
elements fields
"""
summary = {}
crypto = set()
akmsuite_types = {
0x00: "Reserved",
0x01: "802.1X",
0x02: "PSK"
}
p = self.payload
... | def network_stats(self):
"""Return a dictionary containing a summary of the Dot11
elements fields
"""
summary = {}
crypto = set()
akmsuite_types = {
0x00: "Reserved",
0x01: "802.1X",
0x02: "PSK"
}
p = self.payload
... | [
"Return",
"a",
"dictionary",
"containing",
"a",
"summary",
"of",
"the",
"Dot11",
"elements",
"fields"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot11.py#L619-L670 | [
"def",
"network_stats",
"(",
"self",
")",
":",
"summary",
"=",
"{",
"}",
"crypto",
"=",
"set",
"(",
")",
"akmsuite_types",
"=",
"{",
"0x00",
":",
"\"Reserved\"",
",",
"0x01",
":",
"\"802.1X\"",
",",
"0x02",
":",
"\"PSK\"",
"}",
"p",
"=",
"self",
".",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | get_alias_address | Get the correct source IP address of an interface alias | scapy/arch/linux.py | def get_alias_address(iface_name, ip_mask, gw_str, metric):
"""
Get the correct source IP address of an interface alias
"""
# Detect the architecture
if scapy.consts.IS_64BITS:
offset, name_len = 16, 40
else:
offset, name_len = 32, 32
# Retrieve interfaces structures
sc... | def get_alias_address(iface_name, ip_mask, gw_str, metric):
"""
Get the correct source IP address of an interface alias
"""
# Detect the architecture
if scapy.consts.IS_64BITS:
offset, name_len = 16, 40
else:
offset, name_len = 32, 32
# Retrieve interfaces structures
sc... | [
"Get",
"the",
"correct",
"source",
"IP",
"address",
"of",
"an",
"interface",
"alias"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L153-L201 | [
"def",
"get_alias_address",
"(",
"iface_name",
",",
"ip_mask",
",",
"gw_str",
",",
"metric",
")",
":",
"# Detect the architecture",
"if",
"scapy",
".",
"consts",
".",
"IS_64BITS",
":",
"offset",
",",
"name_len",
"=",
"16",
",",
"40",
"else",
":",
"offset",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | in6_getifaddr | Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system. | scapy/arch/linux.py | def in6_getifaddr():
"""
Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system.
"""
ret = []
try:
fdesc = open... | def in6_getifaddr():
"""
Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system.
"""
ret = []
try:
fdesc = open... | [
"Returns",
"a",
"list",
"of",
"3",
"-",
"tuples",
"of",
"the",
"form",
"(",
"addr",
"scope",
"iface",
")",
"where",
"addr",
"is",
"the",
"address",
"of",
"scope",
"scope",
"associated",
"to",
"the",
"interface",
"ifcace",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L276-L301 | [
"def",
"in6_getifaddr",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"fdesc",
"=",
"open",
"(",
"\"/proc/net/if_inet6\"",
",",
"\"rb\"",
")",
"except",
"IOError",
":",
"return",
"ret",
"for",
"line",
"in",
"fdesc",
":",
"# addr, index, plen, scope, flags... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | get_iface_mode | Return the interface mode.
params:
- iface: the iwconfig interface | scapy/arch/linux.py | def get_iface_mode(iface):
"""Return the interface mode.
params:
- iface: the iwconfig interface
"""
p = subprocess.Popen(["iwconfig", iface], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output, err = p.communicate()
match = re.search(br"mode:([a-zA-Z]*)", out... | def get_iface_mode(iface):
"""Return the interface mode.
params:
- iface: the iwconfig interface
"""
p = subprocess.Popen(["iwconfig", iface], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output, err = p.communicate()
match = re.search(br"mode:([a-zA-Z]*)", out... | [
"Return",
"the",
"interface",
"mode",
".",
"params",
":",
"-",
"iface",
":",
"the",
"iwconfig",
"interface"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L386-L397 | [
"def",
"get_iface_mode",
"(",
"iface",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"iwconfig\"",
",",
"iface",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"output",
",",
"err... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | set_iface_monitor | Sets the monitor mode (or remove it) from an interface.
params:
- iface: the iwconfig interface
- monitor: True if the interface should be set in monitor mode,
False if it should be in managed mode | scapy/arch/linux.py | def set_iface_monitor(iface, monitor):
"""Sets the monitor mode (or remove it) from an interface.
params:
- iface: the iwconfig interface
- monitor: True if the interface should be set in monitor mode,
False if it should be in managed mode
"""
mode = get_iface_mode(iface)
i... | def set_iface_monitor(iface, monitor):
"""Sets the monitor mode (or remove it) from an interface.
params:
- iface: the iwconfig interface
- monitor: True if the interface should be set in monitor mode,
False if it should be in managed mode
"""
mode = get_iface_mode(iface)
i... | [
"Sets",
"the",
"monitor",
"mode",
"(",
"or",
"remove",
"it",
")",
"from",
"an",
"interface",
".",
"params",
":",
"-",
"iface",
":",
"the",
"iwconfig",
"interface",
"-",
"monitor",
":",
"True",
"if",
"the",
"interface",
"should",
"be",
"set",
"in",
"mon... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L400-L431 | [
"def",
"set_iface_monitor",
"(",
"iface",
",",
"monitor",
")",
":",
"mode",
"=",
"get_iface_mode",
"(",
"iface",
")",
"if",
"mode",
"==",
"\"unknown\"",
":",
"warning",
"(",
"\"Could not parse iwconfig !\"",
")",
"current_monitor",
"=",
"mode",
"==",
"\"monitor\... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | L2Socket.recv_raw | Receives a packet, then returns a tuple containing (cls, pkt_data, time) | scapy/arch/linux.py | def recv_raw(self, x=MTU):
"""Receives a packet, then returns a tuple containing (cls, pkt_data, time)""" # noqa: E501
pkt, sa_ll = self.ins.recvfrom(x)
if self.outs and sa_ll[2] == socket.PACKET_OUTGOING:
return None, None, None
ts = get_last_packet_timestamp(self.ins)
... | def recv_raw(self, x=MTU):
"""Receives a packet, then returns a tuple containing (cls, pkt_data, time)""" # noqa: E501
pkt, sa_ll = self.ins.recvfrom(x)
if self.outs and sa_ll[2] == socket.PACKET_OUTGOING:
return None, None, None
ts = get_last_packet_timestamp(self.ins)
... | [
"Receives",
"a",
"packet",
"then",
"returns",
"a",
"tuple",
"containing",
"(",
"cls",
"pkt_data",
"time",
")"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/linux.py#L484-L490 | [
"def",
"recv_raw",
"(",
"self",
",",
"x",
"=",
"MTU",
")",
":",
"# noqa: E501",
"pkt",
",",
"sa_ll",
"=",
"self",
".",
"ins",
".",
"recvfrom",
"(",
"x",
")",
"if",
"self",
".",
"outs",
"and",
"sa_ll",
"[",
"2",
"]",
"==",
"socket",
".",
"PACKET_O... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | isBPFSocket | Return True is obj is a BPF Super Socket | scapy/arch/bpf/supersocket.py | def isBPFSocket(obj):
"""Return True is obj is a BPF Super Socket"""
return isinstance(obj, L2bpfListenSocket) or isinstance(obj, L2bpfListenSocket) or isinstance(obj, L3bpfSocket) | def isBPFSocket(obj):
"""Return True is obj is a BPF Super Socket"""
return isinstance(obj, L2bpfListenSocket) or isinstance(obj, L2bpfListenSocket) or isinstance(obj, L3bpfSocket) | [
"Return",
"True",
"is",
"obj",
"is",
"a",
"BPF",
"Super",
"Socket"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L364-L366 | [
"def",
"isBPFSocket",
"(",
"obj",
")",
":",
"return",
"isinstance",
"(",
"obj",
",",
"L2bpfListenSocket",
")",
"or",
"isinstance",
"(",
"obj",
",",
"L2bpfListenSocket",
")",
"or",
"isinstance",
"(",
"obj",
",",
"L3bpfSocket",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | bpf_select | A call to recv() can return several frames. This functions hides the fact
that some frames are read from the internal buffer. | scapy/arch/bpf/supersocket.py | def bpf_select(fds_list, timeout=None):
"""A call to recv() can return several frames. This functions hides the fact
that some frames are read from the internal buffer."""
# Check file descriptors types
bpf_scks_buffered = list()
select_fds = list()
for tmp_fd in fds_list:
# Specif... | def bpf_select(fds_list, timeout=None):
"""A call to recv() can return several frames. This functions hides the fact
that some frames are read from the internal buffer."""
# Check file descriptors types
bpf_scks_buffered = list()
select_fds = list()
for tmp_fd in fds_list:
# Specif... | [
"A",
"call",
"to",
"recv",
"()",
"can",
"return",
"several",
"frames",
".",
"This",
"functions",
"hides",
"the",
"fact",
"that",
"some",
"frames",
"are",
"read",
"from",
"the",
"internal",
"buffer",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L369-L394 | [
"def",
"bpf_select",
"(",
"fds_list",
",",
"timeout",
"=",
"None",
")",
":",
"# Check file descriptors types",
"bpf_scks_buffered",
"=",
"list",
"(",
")",
"select_fds",
"=",
"list",
"(",
")",
"for",
"tmp_fd",
"in",
"fds_list",
":",
"# Specific BPF sockets: get buf... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _L2bpfSocket.set_promisc | Set the interface in promiscuous mode | scapy/arch/bpf/supersocket.py | def set_promisc(self, value):
"""Set the interface in promiscuous mode"""
try:
fcntl.ioctl(self.ins, BIOCPROMISC, struct.pack('i', value))
except IOError:
raise Scapy_Exception("Cannot set promiscuous mode on interface "
"(%s)!" % self.i... | def set_promisc(self, value):
"""Set the interface in promiscuous mode"""
try:
fcntl.ioctl(self.ins, BIOCPROMISC, struct.pack('i', value))
except IOError:
raise Scapy_Exception("Cannot set promiscuous mode on interface "
"(%s)!" % self.i... | [
"Set",
"the",
"interface",
"in",
"promiscuous",
"mode"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L118-L125 | [
"def",
"set_promisc",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCPROMISC",
",",
"struct",
".",
"pack",
"(",
"'i'",
",",
"value",
")",
")",
"except",
"IOError",
":",
"raise",
"Scapy_Excep... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _L2bpfSocket.guess_cls | Guess the packet class that must be used on the interface | scapy/arch/bpf/supersocket.py | def guess_cls(self):
"""Guess the packet class that must be used on the interface"""
# Get the data link type
try:
ret = fcntl.ioctl(self.ins, BIOCGDLT, struct.pack('I', 0))
ret = struct.unpack('I', ret)[0]
except IOError:
cls = conf.default_l2
... | def guess_cls(self):
"""Guess the packet class that must be used on the interface"""
# Get the data link type
try:
ret = fcntl.ioctl(self.ins, BIOCGDLT, struct.pack('I', 0))
ret = struct.unpack('I', ret)[0]
except IOError:
cls = conf.default_l2
... | [
"Guess",
"the",
"packet",
"class",
"that",
"must",
"be",
"used",
"on",
"the",
"interface"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L134-L152 | [
"def",
"guess_cls",
"(",
"self",
")",
":",
"# Get the data link type",
"try",
":",
"ret",
"=",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCGDLT",
",",
"struct",
".",
"pack",
"(",
"'I'",
",",
"0",
")",
")",
"ret",
"=",
"struct",
".",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _L2bpfSocket.set_nonblock | Set the non blocking flag on the socket | scapy/arch/bpf/supersocket.py | def set_nonblock(self, set_flag=True):
"""Set the non blocking flag on the socket"""
# Get the current flags
if self.fd_flags is None:
try:
self.fd_flags = fcntl.fcntl(self.ins, fcntl.F_GETFL)
except IOError:
warning("Cannot get flags on t... | def set_nonblock(self, set_flag=True):
"""Set the non blocking flag on the socket"""
# Get the current flags
if self.fd_flags is None:
try:
self.fd_flags = fcntl.fcntl(self.ins, fcntl.F_GETFL)
except IOError:
warning("Cannot get flags on t... | [
"Set",
"the",
"non",
"blocking",
"flag",
"on",
"the",
"socket"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L154-L175 | [
"def",
"set_nonblock",
"(",
"self",
",",
"set_flag",
"=",
"True",
")",
":",
"# Get the current flags",
"if",
"self",
".",
"fd_flags",
"is",
"None",
":",
"try",
":",
"self",
".",
"fd_flags",
"=",
"fcntl",
".",
"fcntl",
"(",
"self",
".",
"ins",
",",
"fcn... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _L2bpfSocket.get_stats | Get received / dropped statistics | scapy/arch/bpf/supersocket.py | def get_stats(self):
"""Get received / dropped statistics"""
try:
ret = fcntl.ioctl(self.ins, BIOCGSTATS, struct.pack("2I", 0, 0))
return struct.unpack("2I", ret)
except IOError:
warning("Unable to get stats from BPF !")
return (None, None) | def get_stats(self):
"""Get received / dropped statistics"""
try:
ret = fcntl.ioctl(self.ins, BIOCGSTATS, struct.pack("2I", 0, 0))
return struct.unpack("2I", ret)
except IOError:
warning("Unable to get stats from BPF !")
return (None, None) | [
"Get",
"received",
"/",
"dropped",
"statistics"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L177-L185 | [
"def",
"get_stats",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCGSTATS",
",",
"struct",
".",
"pack",
"(",
"\"2I\"",
",",
"0",
",",
"0",
")",
")",
"return",
"struct",
".",
"unpack",
"(",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _L2bpfSocket.get_blen | Get the BPF buffer length | scapy/arch/bpf/supersocket.py | def get_blen(self):
"""Get the BPF buffer length"""
try:
ret = fcntl.ioctl(self.ins, BIOCGBLEN, struct.pack("I", 0))
return struct.unpack("I", ret)[0]
except IOError:
warning("Unable to get the BPF buffer length")
return | def get_blen(self):
"""Get the BPF buffer length"""
try:
ret = fcntl.ioctl(self.ins, BIOCGBLEN, struct.pack("I", 0))
return struct.unpack("I", ret)[0]
except IOError:
warning("Unable to get the BPF buffer length")
return | [
"Get",
"the",
"BPF",
"buffer",
"length"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L187-L195 | [
"def",
"get_blen",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"fcntl",
".",
"ioctl",
"(",
"self",
".",
"ins",
",",
"BIOCGBLEN",
",",
"struct",
".",
"pack",
"(",
"\"I\"",
",",
"0",
")",
")",
"return",
"struct",
".",
"unpack",
"(",
"\"I\"",
","... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _L2bpfSocket.close | Close the Super Socket | scapy/arch/bpf/supersocket.py | def close(self):
"""Close the Super Socket"""
if not self.closed and self.ins is not None:
os.close(self.ins)
self.closed = True
self.ins = None | def close(self):
"""Close the Super Socket"""
if not self.closed and self.ins is not None:
os.close(self.ins)
self.closed = True
self.ins = None | [
"Close",
"the",
"Super",
"Socket"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L201-L207 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"closed",
"and",
"self",
".",
"ins",
"is",
"not",
"None",
":",
"os",
".",
"close",
"(",
"self",
".",
"ins",
")",
"self",
".",
"closed",
"=",
"True",
"self",
".",
"ins",
"=",
"None... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | L2bpfListenSocket.extract_frames | Extract all frames from the buffer and stored them in the received list. | scapy/arch/bpf/supersocket.py | def extract_frames(self, bpf_buffer):
"""Extract all frames from the buffer and stored them in the received list.""" # noqa: E501
# Ensure that the BPF buffer contains at least the header
len_bb = len(bpf_buffer)
if len_bb < 20: # Note: 20 == sizeof(struct bfp_hdr)
return
... | def extract_frames(self, bpf_buffer):
"""Extract all frames from the buffer and stored them in the received list.""" # noqa: E501
# Ensure that the BPF buffer contains at least the header
len_bb = len(bpf_buffer)
if len_bb < 20: # Note: 20 == sizeof(struct bfp_hdr)
return
... | [
"Extract",
"all",
"frames",
"from",
"the",
"buffer",
"and",
"stored",
"them",
"in",
"the",
"received",
"list",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L249-L287 | [
"def",
"extract_frames",
"(",
"self",
",",
"bpf_buffer",
")",
":",
"# noqa: E501",
"# Ensure that the BPF buffer contains at least the header",
"len_bb",
"=",
"len",
"(",
"bpf_buffer",
")",
"if",
"len_bb",
"<",
"20",
":",
"# Note: 20 == sizeof(struct bfp_hdr)",
"return",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | L2bpfListenSocket.recv | Receive a frame from the network | scapy/arch/bpf/supersocket.py | def recv(self, x=BPF_BUFFER_LENGTH):
"""Receive a frame from the network"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Get data from BPF
try:
bpf_buffer = os.read(self.ins, x)
except EnvironmentError as... | def recv(self, x=BPF_BUFFER_LENGTH):
"""Receive a frame from the network"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Get data from BPF
try:
bpf_buffer = os.read(self.ins, x)
except EnvironmentError as... | [
"Receive",
"a",
"frame",
"from",
"the",
"network"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L289-L306 | [
"def",
"recv",
"(",
"self",
",",
"x",
"=",
"BPF_BUFFER_LENGTH",
")",
":",
"if",
"self",
".",
"buffered_frames",
"(",
")",
":",
"# Get a frame from the buffer",
"return",
"self",
".",
"get_frame",
"(",
")",
"# Get data from BPF",
"try",
":",
"bpf_buffer",
"=",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | L2bpfSocket.nonblock_recv | Non blocking receive | scapy/arch/bpf/supersocket.py | def nonblock_recv(self):
"""Non blocking receive"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Set the non blocking flag, read from the socket, and unset the flag
self.set_nonblock(True)
pkt = L2bpfListenSocket.rec... | def nonblock_recv(self):
"""Non blocking receive"""
if self.buffered_frames():
# Get a frame from the buffer
return self.get_frame()
# Set the non blocking flag, read from the socket, and unset the flag
self.set_nonblock(True)
pkt = L2bpfListenSocket.rec... | [
"Non",
"blocking",
"receive"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L316-L327 | [
"def",
"nonblock_recv",
"(",
"self",
")",
":",
"if",
"self",
".",
"buffered_frames",
"(",
")",
":",
"# Get a frame from the buffer",
"return",
"self",
".",
"get_frame",
"(",
")",
"# Set the non blocking flag, read from the socket, and unset the flag",
"self",
".",
"set_... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | L3bpfSocket.get_frame | Get a frame or packet from the received list | scapy/arch/bpf/supersocket.py | def get_frame(self):
"""Get a frame or packet from the received list"""
pkt = super(L3bpfSocket, self).get_frame()
if pkt is not None:
return pkt.payload | def get_frame(self):
"""Get a frame or packet from the received list"""
pkt = super(L3bpfSocket, self).get_frame()
if pkt is not None:
return pkt.payload | [
"Get",
"a",
"frame",
"or",
"packet",
"from",
"the",
"received",
"list"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L332-L336 | [
"def",
"get_frame",
"(",
"self",
")",
":",
"pkt",
"=",
"super",
"(",
"L3bpfSocket",
",",
"self",
")",
".",
"get_frame",
"(",
")",
"if",
"pkt",
"is",
"not",
"None",
":",
"return",
"pkt",
".",
"payload"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | L3bpfSocket.send | Send a packet | scapy/arch/bpf/supersocket.py | def send(self, pkt):
"""Send a packet"""
# Use the routing table to find the output interface
iff = pkt.route()[0]
if iff is None:
iff = conf.iface
# Assign the network interface to the BPF handle
if self.assigned_interface != iff:
try:
... | def send(self, pkt):
"""Send a packet"""
# Use the routing table to find the output interface
iff = pkt.route()[0]
if iff is None:
iff = conf.iface
# Assign the network interface to the BPF handle
if self.assigned_interface != iff:
try:
... | [
"Send",
"a",
"packet"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L338-L359 | [
"def",
"send",
"(",
"self",
",",
"pkt",
")",
":",
"# Use the routing table to find the output interface",
"iff",
"=",
"pkt",
".",
"route",
"(",
")",
"[",
"0",
"]",
"if",
"iff",
"is",
"None",
":",
"iff",
"=",
"conf",
".",
"iface",
"# Assign the network interf... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _SSLv2Handshake.tls_session_update | Covers both post_build- and post_dissection- context updates. | scapy/layers/tls/handshake_sslv2.py | def tls_session_update(self, msg_str):
"""
Covers both post_build- and post_dissection- context updates.
"""
self.tls_session.handshake_messages.append(msg_str)
self.tls_session.handshake_messages_parsed.append(self) | def tls_session_update(self, msg_str):
"""
Covers both post_build- and post_dissection- context updates.
"""
self.tls_session.handshake_messages.append(msg_str)
self.tls_session.handshake_messages_parsed.append(self) | [
"Covers",
"both",
"post_build",
"-",
"and",
"post_dissection",
"-",
"context",
"updates",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake_sslv2.py#L52-L57 | [
"def",
"tls_session_update",
"(",
"self",
",",
"msg_str",
")",
":",
"self",
".",
"tls_session",
".",
"handshake_messages",
".",
"append",
"(",
"msg_str",
")",
"self",
".",
"tls_session",
".",
"handshake_messages_parsed",
".",
"append",
"(",
"self",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SSLv2ServerHello.tls_session_update | XXX Something should be done about the session ID here. | scapy/layers/tls/handshake_sslv2.py | def tls_session_update(self, msg_str):
"""
XXX Something should be done about the session ID here.
"""
super(SSLv2ServerHello, self).tls_session_update(msg_str)
s = self.tls_session
client_cs = s.sslv2_common_cs
css = [cs for cs in client_cs if cs in self.ciphers... | def tls_session_update(self, msg_str):
"""
XXX Something should be done about the session ID here.
"""
super(SSLv2ServerHello, self).tls_session_update(msg_str)
s = self.tls_session
client_cs = s.sslv2_common_cs
css = [cs for cs in client_cs if cs in self.ciphers... | [
"XXX",
"Something",
"should",
"be",
"done",
"about",
"the",
"session",
"ID",
"here",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake_sslv2.py#L186-L199 | [
"def",
"tls_session_update",
"(",
"self",
",",
"msg_str",
")",
":",
"super",
"(",
"SSLv2ServerHello",
",",
"self",
")",
".",
"tls_session_update",
"(",
"msg_str",
")",
"s",
"=",
"self",
".",
"tls_session",
"client_cs",
"=",
"s",
".",
"sslv2_common_cs",
"css"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _get_values | Generate a range object from (start, stop[, step]) tuples, or
return value. | scapy/base_classes.py | def _get_values(value):
"""Generate a range object from (start, stop[, step]) tuples, or
return value.
"""
if (isinstance(value, tuple) and (2 <= len(value) <= 3) and
all(hasattr(i, "__int__") for i in value)):
# We use values[1] + 1 as stop value for (x)range to maintain
# ... | def _get_values(value):
"""Generate a range object from (start, stop[, step]) tuples, or
return value.
"""
if (isinstance(value, tuple) and (2 <= len(value) <= 3) and
all(hasattr(i, "__int__") for i in value)):
# We use values[1] + 1 as stop value for (x)range to maintain
# ... | [
"Generate",
"a",
"range",
"object",
"from",
"(",
"start",
"stop",
"[",
"step",
"]",
")",
"tuples",
"or",
"return",
"value",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L39-L50 | [
"def",
"_get_values",
"(",
"value",
")",
":",
"if",
"(",
"isinstance",
"(",
"value",
",",
"tuple",
")",
"and",
"(",
"2",
"<=",
"len",
"(",
"value",
")",
"<=",
"3",
")",
"and",
"all",
"(",
"hasattr",
"(",
"i",
",",
"\"__int__\"",
")",
"for",
"i",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _CanvasDumpExtended.psdump | psdump(filename=None, layer_shift=0, rebuild=1)
Creates an EPS file describing a packet. If filename is not provided a
temporary file is created and gs is called.
:param filename: the file's filename | scapy/base_classes.py | def psdump(self, filename=None, **kargs):
"""
psdump(filename=None, layer_shift=0, rebuild=1)
Creates an EPS file describing a packet. If filename is not provided a
temporary file is created and gs is called.
:param filename: the file's filename
"""
from scapy.c... | def psdump(self, filename=None, **kargs):
"""
psdump(filename=None, layer_shift=0, rebuild=1)
Creates an EPS file describing a packet. If filename is not provided a
temporary file is created and gs is called.
:param filename: the file's filename
"""
from scapy.c... | [
"psdump",
"(",
"filename",
"=",
"None",
"layer_shift",
"=",
"0",
"rebuild",
"=",
"1",
")"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L305-L327 | [
"def",
"psdump",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"from",
"scapy",
".",
"config",
"import",
"conf",
"from",
"scapy",
".",
"utils",
"import",
"get_temp_file",
",",
"ContextManagerSubprocess",
"canvas",
"=",
"self"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _CanvasDumpExtended.pdfdump | pdfdump(filename=None, layer_shift=0, rebuild=1)
Creates a PDF file describing a packet. If filename is not provided a
temporary file is created and xpdf is called.
:param filename: the file's filename | scapy/base_classes.py | def pdfdump(self, filename=None, **kargs):
"""
pdfdump(filename=None, layer_shift=0, rebuild=1)
Creates a PDF file describing a packet. If filename is not provided a
temporary file is created and xpdf is called.
:param filename: the file's filename
"""
from scap... | def pdfdump(self, filename=None, **kargs):
"""
pdfdump(filename=None, layer_shift=0, rebuild=1)
Creates a PDF file describing a packet. If filename is not provided a
temporary file is created and xpdf is called.
:param filename: the file's filename
"""
from scap... | [
"pdfdump",
"(",
"filename",
"=",
"None",
"layer_shift",
"=",
"0",
"rebuild",
"=",
"1",
")"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L329-L352 | [
"def",
"pdfdump",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"from",
"scapy",
".",
"config",
"import",
"conf",
"from",
"scapy",
".",
"utils",
"import",
"get_temp_file",
",",
"ContextManagerSubprocess",
"canvas",
"=",
"self... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _CanvasDumpExtended.svgdump | svgdump(filename=None, layer_shift=0, rebuild=1)
Creates an SVG file describing a packet. If filename is not provided a
temporary file is created and gs is called.
:param filename: the file's filename | scapy/base_classes.py | def svgdump(self, filename=None, **kargs):
"""
svgdump(filename=None, layer_shift=0, rebuild=1)
Creates an SVG file describing a packet. If filename is not provided a
temporary file is created and gs is called.
:param filename: the file's filename
"""
from scapy... | def svgdump(self, filename=None, **kargs):
"""
svgdump(filename=None, layer_shift=0, rebuild=1)
Creates an SVG file describing a packet. If filename is not provided a
temporary file is created and gs is called.
:param filename: the file's filename
"""
from scapy... | [
"svgdump",
"(",
"filename",
"=",
"None",
"layer_shift",
"=",
"0",
"rebuild",
"=",
"1",
")"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L354-L377 | [
"def",
"svgdump",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"from",
"scapy",
".",
"config",
"import",
"conf",
"from",
"scapy",
".",
"utils",
"import",
"get_temp_file",
",",
"ContextManagerSubprocess",
"canvas",
"=",
"self... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | get_long_description | Extract description from README.md, for PyPI's usage | setup.py | def get_long_description():
"""Extract description from README.md, for PyPI's usage"""
try:
fpath = os.path.join(os.path.dirname(__file__), "README.md")
with io.open(fpath, encoding="utf-8") as f:
readme = f.read()
desc = readme.partition("<!-- start_ppi_description -->")... | def get_long_description():
"""Extract description from README.md, for PyPI's usage"""
try:
fpath = os.path.join(os.path.dirname(__file__), "README.md")
with io.open(fpath, encoding="utf-8") as f:
readme = f.read()
desc = readme.partition("<!-- start_ppi_description -->")... | [
"Extract",
"description",
"from",
"README",
".",
"md",
"for",
"PyPI",
"s",
"usage"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/setup.py#L15-L25 | [
"def",
"get_long_description",
"(",
")",
":",
"try",
":",
"fpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"README.md\"",
")",
"with",
"io",
".",
"open",
"(",
"fpath",
",",
"encoding",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _CDPChecksum._check_len | Check for odd packet length and pad according to Cisco spec.
This padding is only used for checksum computation. The original
packet should not be altered. | scapy/contrib/cdp.py | def _check_len(self, pkt):
"""Check for odd packet length and pad according to Cisco spec.
This padding is only used for checksum computation. The original
packet should not be altered."""
if len(pkt) % 2:
last_chr = pkt[-1]
if last_chr <= b'\x80':
... | def _check_len(self, pkt):
"""Check for odd packet length and pad according to Cisco spec.
This padding is only used for checksum computation. The original
packet should not be altered."""
if len(pkt) % 2:
last_chr = pkt[-1]
if last_chr <= b'\x80':
... | [
"Check",
"for",
"odd",
"packet",
"length",
"and",
"pad",
"according",
"to",
"Cisco",
"spec",
".",
"This",
"padding",
"is",
"only",
"used",
"for",
"checksum",
"computation",
".",
"The",
"original",
"packet",
"should",
"not",
"be",
"altered",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/cdp.py#L355-L366 | [
"def",
"_check_len",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"len",
"(",
"pkt",
")",
"%",
"2",
":",
"last_chr",
"=",
"pkt",
"[",
"-",
"1",
"]",
"if",
"last_chr",
"<=",
"b'\\x80'",
":",
"return",
"pkt",
"[",
":",
"-",
"1",
"]",
"+",
"b'\\x00'",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _legacy_pkcs1_v1_5_encode_md5_sha1 | Legacy method for PKCS1 v1.5 encoding with MD5-SHA1 hash. | scapy/layers/tls/crypto/pkcs1.py | def _legacy_pkcs1_v1_5_encode_md5_sha1(M, emLen):
"""
Legacy method for PKCS1 v1.5 encoding with MD5-SHA1 hash.
"""
M = bytes_encode(M)
md5_hash = hashes.Hash(_get_hash("md5"), backend=default_backend())
md5_hash.update(M)
sha1_hash = hashes.Hash(_get_hash("sha1"), backend=default_backend())... | def _legacy_pkcs1_v1_5_encode_md5_sha1(M, emLen):
"""
Legacy method for PKCS1 v1.5 encoding with MD5-SHA1 hash.
"""
M = bytes_encode(M)
md5_hash = hashes.Hash(_get_hash("md5"), backend=default_backend())
md5_hash.update(M)
sha1_hash = hashes.Hash(_get_hash("sha1"), backend=default_backend())... | [
"Legacy",
"method",
"for",
"PKCS1",
"v1",
".",
"5",
"encoding",
"with",
"MD5",
"-",
"SHA1",
"hash",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/pkcs1.py#L72-L87 | [
"def",
"_legacy_pkcs1_v1_5_encode_md5_sha1",
"(",
"M",
",",
"emLen",
")",
":",
"M",
"=",
"bytes_encode",
"(",
"M",
")",
"md5_hash",
"=",
"hashes",
".",
"Hash",
"(",
"_get_hash",
"(",
"\"md5\"",
")",
",",
"backend",
"=",
"default_backend",
"(",
")",
")",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | dhcp_request | Send a DHCP discover request and return the answer | scapy/layers/dhcp.py | def dhcp_request(iface=None, **kargs):
"""Send a DHCP discover request and return the answer"""
if conf.checkIPaddr != 0:
warning("conf.checkIPaddr is not 0, I may not be able to match the answer") # noqa: E501
if iface is None:
iface = conf.iface
fam, hw = get_if_raw_hwaddr(iface)
... | def dhcp_request(iface=None, **kargs):
"""Send a DHCP discover request and return the answer"""
if conf.checkIPaddr != 0:
warning("conf.checkIPaddr is not 0, I may not be able to match the answer") # noqa: E501
if iface is None:
iface = conf.iface
fam, hw = get_if_raw_hwaddr(iface)
... | [
"Send",
"a",
"DHCP",
"discover",
"request",
"and",
"return",
"the",
"answer"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dhcp.py#L347-L355 | [
"def",
"dhcp_request",
"(",
"iface",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"conf",
".",
"checkIPaddr",
"!=",
"0",
":",
"warning",
"(",
"\"conf.checkIPaddr is not 0, I may not be able to match the answer\"",
")",
"# noqa: E501",
"if",
"iface",
"is",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | apply_ipython_style | Updates the specified IPython console shell with
the conf.color_theme scapy theme. | scapy/themes.py | def apply_ipython_style(shell):
"""Updates the specified IPython console shell with
the conf.color_theme scapy theme."""
try:
from IPython.terminal.prompts import Prompts, Token
except Exception:
from scapy.error import log_loading
log_loading.warning(
"IPython too ol... | def apply_ipython_style(shell):
"""Updates the specified IPython console shell with
the conf.color_theme scapy theme."""
try:
from IPython.terminal.prompts import Prompts, Token
except Exception:
from scapy.error import log_loading
log_loading.warning(
"IPython too ol... | [
"Updates",
"the",
"specified",
"IPython",
"console",
"shell",
"with",
"the",
"conf",
".",
"color_theme",
"scapy",
"theme",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/themes.py#L328-L397 | [
"def",
"apply_ipython_style",
"(",
"shell",
")",
":",
"try",
":",
"from",
"IPython",
".",
"terminal",
".",
"prompts",
"import",
"Prompts",
",",
"Token",
"except",
"Exception",
":",
"from",
"scapy",
".",
"error",
"import",
"log_loading",
"log_loading",
".",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableObject._wait_non_ressources | This get started as a thread, and waits for the data lock to be freed then advertise itself to the SelectableSelector using the callback | scapy/automaton.py | def _wait_non_ressources(self, callback):
"""This get started as a thread, and waits for the data lock to be freed then advertise itself to the SelectableSelector using the callback""" # noqa: E501
self.trigger = threading.Lock()
self.was_ended = False
self.trigger.acquire()
sel... | def _wait_non_ressources(self, callback):
"""This get started as a thread, and waits for the data lock to be freed then advertise itself to the SelectableSelector using the callback""" # noqa: E501
self.trigger = threading.Lock()
self.was_ended = False
self.trigger.acquire()
sel... | [
"This",
"get",
"started",
"as",
"a",
"thread",
"and",
"waits",
"for",
"the",
"data",
"lock",
"to",
"be",
"freed",
"then",
"advertise",
"itself",
"to",
"the",
"SelectableSelector",
"using",
"the",
"callback"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L87-L94 | [
"def",
"_wait_non_ressources",
"(",
"self",
",",
"callback",
")",
":",
"# noqa: E501",
"self",
".",
"trigger",
"=",
"threading",
".",
"Lock",
"(",
")",
"self",
".",
"was_ended",
"=",
"False",
"self",
".",
"trigger",
".",
"acquire",
"(",
")",
"self",
".",... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableObject.wait_return | Entry point of SelectableObject: register the callback | scapy/automaton.py | def wait_return(self, callback):
"""Entry point of SelectableObject: register the callback"""
if self.check_recv():
return callback(self)
_t = threading.Thread(target=self._wait_non_ressources, args=(callback,)) # noqa: E501
_t.setDaemon(True)
_t.start() | def wait_return(self, callback):
"""Entry point of SelectableObject: register the callback"""
if self.check_recv():
return callback(self)
_t = threading.Thread(target=self._wait_non_ressources, args=(callback,)) # noqa: E501
_t.setDaemon(True)
_t.start() | [
"Entry",
"point",
"of",
"SelectableObject",
":",
"register",
"the",
"callback"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L96-L102 | [
"def",
"wait_return",
"(",
"self",
",",
"callback",
")",
":",
"if",
"self",
".",
"check_recv",
"(",
")",
":",
"return",
"callback",
"(",
"self",
")",
"_t",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_wait_non_ressources",
",",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableObject.call_release | DEV: Must be call when the object becomes ready to read.
Relesases the lock of _wait_non_ressources | scapy/automaton.py | def call_release(self, arborted=False):
"""DEV: Must be call when the object becomes ready to read.
Relesases the lock of _wait_non_ressources"""
self.was_ended = arborted
try:
self.trigger.release()
except (threading.ThreadError, AttributeError):
pass | def call_release(self, arborted=False):
"""DEV: Must be call when the object becomes ready to read.
Relesases the lock of _wait_non_ressources"""
self.was_ended = arborted
try:
self.trigger.release()
except (threading.ThreadError, AttributeError):
pass | [
"DEV",
":",
"Must",
"be",
"call",
"when",
"the",
"object",
"becomes",
"ready",
"to",
"read",
".",
"Relesases",
"the",
"lock",
"of",
"_wait_non_ressources"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L104-L111 | [
"def",
"call_release",
"(",
"self",
",",
"arborted",
"=",
"False",
")",
":",
"self",
".",
"was_ended",
"=",
"arborted",
"try",
":",
"self",
".",
"trigger",
".",
"release",
"(",
")",
"except",
"(",
"threading",
".",
"ThreadError",
",",
"AttributeError",
"... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableSelector._release_all | Releases all locks to kill all threads | scapy/automaton.py | def _release_all(self):
"""Releases all locks to kill all threads"""
for i in self.inputs:
i.call_release(True)
self.available_lock.release() | def _release_all(self):
"""Releases all locks to kill all threads"""
for i in self.inputs:
i.call_release(True)
self.available_lock.release() | [
"Releases",
"all",
"locks",
"to",
"kill",
"all",
"threads"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L123-L127 | [
"def",
"_release_all",
"(",
"self",
")",
":",
"for",
"i",
"in",
"self",
".",
"inputs",
":",
"i",
".",
"call_release",
"(",
"True",
")",
"self",
".",
"available_lock",
".",
"release",
"(",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableSelector._timeout_thread | Timeout before releasing every thing, if nothing was returned | scapy/automaton.py | def _timeout_thread(self, remain):
"""Timeout before releasing every thing, if nothing was returned"""
time.sleep(remain)
if not self._ended:
self._ended = True
self._release_all() | def _timeout_thread(self, remain):
"""Timeout before releasing every thing, if nothing was returned"""
time.sleep(remain)
if not self._ended:
self._ended = True
self._release_all() | [
"Timeout",
"before",
"releasing",
"every",
"thing",
"if",
"nothing",
"was",
"returned"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L129-L134 | [
"def",
"_timeout_thread",
"(",
"self",
",",
"remain",
")",
":",
"time",
".",
"sleep",
"(",
"remain",
")",
"if",
"not",
"self",
".",
"_ended",
":",
"self",
".",
"_ended",
"=",
"True",
"self",
".",
"_release_all",
"(",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableSelector._exit_door | This function is passed to each SelectableObject as a callback
The SelectableObjects have to call it once there are ready | scapy/automaton.py | def _exit_door(self, _input):
"""This function is passed to each SelectableObject as a callback
The SelectableObjects have to call it once there are ready"""
self.results.append(_input)
if self._ended:
return
self._ended = True
self._release_all() | def _exit_door(self, _input):
"""This function is passed to each SelectableObject as a callback
The SelectableObjects have to call it once there are ready"""
self.results.append(_input)
if self._ended:
return
self._ended = True
self._release_all() | [
"This",
"function",
"is",
"passed",
"to",
"each",
"SelectableObject",
"as",
"a",
"callback",
"The",
"SelectableObjects",
"have",
"to",
"call",
"it",
"once",
"there",
"are",
"ready"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L136-L143 | [
"def",
"_exit_door",
"(",
"self",
",",
"_input",
")",
":",
"self",
".",
"results",
".",
"append",
"(",
"_input",
")",
"if",
"self",
".",
"_ended",
":",
"return",
"self",
".",
"_ended",
"=",
"True",
"self",
".",
"_release_all",
"(",
")"
] | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | SelectableSelector.process | Entry point of SelectableSelector | scapy/automaton.py | def process(self):
"""Entry point of SelectableSelector"""
if WINDOWS:
select_inputs = []
for i in self.inputs:
if not isinstance(i, SelectableObject):
warning("Unknown ignored object type: %s", type(i))
elif i.__selectable_forc... | def process(self):
"""Entry point of SelectableSelector"""
if WINDOWS:
select_inputs = []
for i in self.inputs:
if not isinstance(i, SelectableObject):
warning("Unknown ignored object type: %s", type(i))
elif i.__selectable_forc... | [
"Entry",
"point",
"of",
"SelectableSelector"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L153-L179 | [
"def",
"process",
"(",
"self",
")",
":",
"if",
"WINDOWS",
":",
"select_inputs",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".",
"inputs",
":",
"if",
"not",
"isinstance",
"(",
"i",
",",
"SelectableObject",
")",
":",
"warning",
"(",
"\"Unknown ignored object... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _version_checker | Checks that module has a higher version that minver.
params:
- module: a module to test
- minver: a tuple of versions | scapy/config.py | def _version_checker(module, minver):
"""Checks that module has a higher version that minver.
params:
- module: a module to test
- minver: a tuple of versions
"""
# We could use LooseVersion, but distutils imports imp which is deprecated
version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-... | def _version_checker(module, minver):
"""Checks that module has a higher version that minver.
params:
- module: a module to test
- minver: a tuple of versions
"""
# We could use LooseVersion, but distutils imports imp which is deprecated
version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-... | [
"Checks",
"that",
"module",
"has",
"a",
"higher",
"version",
"that",
"minver",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L356-L370 | [
"def",
"_version_checker",
"(",
"module",
",",
"minver",
")",
":",
"# We could use LooseVersion, but distutils imports imp which is deprecated",
"version_regexp",
"=",
"r'[a-z]?((?:\\d|\\.)+\\d+)(?:\\.dev[0-9]+)?'",
"version_tags",
"=",
"re",
".",
"match",
"(",
"version_regexp",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | isCryptographyAdvanced | Check if the cryptography library is present, and if it supports X25519,
ChaCha20Poly1305 and such (v2.0 or later). | scapy/config.py | def isCryptographyAdvanced():
"""
Check if the cryptography library is present, and if it supports X25519,
ChaCha20Poly1305 and such (v2.0 or later).
"""
try:
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey # noqa: E501
X25519PrivateKey.generate()
e... | def isCryptographyAdvanced():
"""
Check if the cryptography library is present, and if it supports X25519,
ChaCha20Poly1305 and such (v2.0 or later).
"""
try:
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey # noqa: E501
X25519PrivateKey.generate()
e... | [
"Check",
"if",
"the",
"cryptography",
"library",
"is",
"present",
"and",
"if",
"it",
"supports",
"X25519",
"ChaCha20Poly1305",
"and",
"such",
"(",
"v2",
".",
"0",
"or",
"later",
")",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L396-L407 | [
"def",
"isCryptographyAdvanced",
"(",
")",
":",
"try",
":",
"from",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"asymmetric",
".",
"x25519",
"import",
"X25519PrivateKey",
"# noqa: E501",
"X25519PrivateKey",
".",
"generate",
"(",
")",
"except",
"Exceptio... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _prompt_changer | Change the current prompt theme | scapy/config.py | def _prompt_changer(attr, val):
"""Change the current prompt theme"""
try:
sys.ps1 = conf.color_theme.prompt(conf.prompt)
except Exception:
pass
try:
apply_ipython_style(get_ipython())
except NameError:
pass | def _prompt_changer(attr, val):
"""Change the current prompt theme"""
try:
sys.ps1 = conf.color_theme.prompt(conf.prompt)
except Exception:
pass
try:
apply_ipython_style(get_ipython())
except NameError:
pass | [
"Change",
"the",
"current",
"prompt",
"theme"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L419-L428 | [
"def",
"_prompt_changer",
"(",
"attr",
",",
"val",
")",
":",
"try",
":",
"sys",
".",
"ps1",
"=",
"conf",
".",
"color_theme",
".",
"prompt",
"(",
"conf",
".",
"prompt",
")",
"except",
"Exception",
":",
"pass",
"try",
":",
"apply_ipython_style",
"(",
"ge... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | _set_conf_sockets | Populate the conf.L2Socket and conf.L3Socket
according to the various use_* parameters | scapy/config.py | def _set_conf_sockets():
"""Populate the conf.L2Socket and conf.L3Socket
according to the various use_* parameters
"""
if conf.use_bpf and not BSD:
Interceptor.set_from_hook(conf, "use_bpf", False)
raise ScapyInvalidPlatformException("BSD-like (OSX, *BSD...) only !")
if conf.use_winp... | def _set_conf_sockets():
"""Populate the conf.L2Socket and conf.L3Socket
according to the various use_* parameters
"""
if conf.use_bpf and not BSD:
Interceptor.set_from_hook(conf, "use_bpf", False)
raise ScapyInvalidPlatformException("BSD-like (OSX, *BSD...) only !")
if conf.use_winp... | [
"Populate",
"the",
"conf",
".",
"L2Socket",
"and",
"conf",
".",
"L3Socket",
"according",
"to",
"the",
"various",
"use_",
"*",
"parameters"
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L431-L482 | [
"def",
"_set_conf_sockets",
"(",
")",
":",
"if",
"conf",
".",
"use_bpf",
"and",
"not",
"BSD",
":",
"Interceptor",
".",
"set_from_hook",
"(",
"conf",
",",
"\"use_bpf\"",
",",
"False",
")",
"raise",
"ScapyInvalidPlatformException",
"(",
"\"BSD-like (OSX, *BSD...) on... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | crypto_validator | This a decorator to be used for any method relying on the cryptography library. # noqa: E501
Its behaviour depends on the 'crypto_valid' attribute of the global 'conf'. | scapy/config.py | def crypto_validator(func):
"""
This a decorator to be used for any method relying on the cryptography library. # noqa: E501
Its behaviour depends on the 'crypto_valid' attribute of the global 'conf'.
"""
def func_in(*args, **kwargs):
if not conf.crypto_valid:
raise ImportError(... | def crypto_validator(func):
"""
This a decorator to be used for any method relying on the cryptography library. # noqa: E501
Its behaviour depends on the 'crypto_valid' attribute of the global 'conf'.
"""
def func_in(*args, **kwargs):
if not conf.crypto_valid:
raise ImportError(... | [
"This",
"a",
"decorator",
"to",
"be",
"used",
"for",
"any",
"method",
"relying",
"on",
"the",
"cryptography",
"library",
".",
"#",
"noqa",
":",
"E501",
"Its",
"behaviour",
"depends",
"on",
"the",
"crypto_valid",
"attribute",
"of",
"the",
"global",
"conf",
... | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L640-L650 | [
"def",
"crypto_validator",
"(",
"func",
")",
":",
"def",
"func_in",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"conf",
".",
"crypto_valid",
":",
"raise",
"ImportError",
"(",
"\"Cannot execute crypto-related method! \"",
"\"Please install p... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | PacketList.filter | Returns a packet list filtered by a truth function. This truth
function has to take a packet as the only argument and return a boolean value. | scapy/plist.py | def filter(self, func):
"""Returns a packet list filtered by a truth function. This truth
function has to take a packet as the only argument and return a boolean value.""" # noqa: E501
return self.__class__([x for x in self.res if func(x)],
name="filtered %s" % sel... | def filter(self, func):
"""Returns a packet list filtered by a truth function. This truth
function has to take a packet as the only argument and return a boolean value.""" # noqa: E501
return self.__class__([x for x in self.res if func(x)],
name="filtered %s" % sel... | [
"Returns",
"a",
"packet",
"list",
"filtered",
"by",
"a",
"truth",
"function",
".",
"This",
"truth",
"function",
"has",
"to",
"take",
"a",
"packet",
"as",
"the",
"only",
"argument",
"and",
"return",
"a",
"boolean",
"value",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L163-L167 | [
"def",
"filter",
"(",
"self",
",",
"func",
")",
":",
"# noqa: E501",
"return",
"self",
".",
"__class__",
"(",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"res",
"if",
"func",
"(",
"x",
")",
"]",
",",
"name",
"=",
"\"filtered %s\"",
"%",
"self",
".",
... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
train | PacketList.plot | Applies a function to each packet to get a value that will be plotted
with matplotlib. A list of matplotlib.lines.Line2D is returned.
lfilter: a truth function that decides whether a packet must be plotted | scapy/plist.py | def plot(self, f, lfilter=None, plot_xy=False, **kargs):
"""Applies a function to each packet to get a value that will be plotted
with matplotlib. A list of matplotlib.lines.Line2D is returned.
lfilter: a truth function that decides whether a packet must be plotted
"""
# Python... | def plot(self, f, lfilter=None, plot_xy=False, **kargs):
"""Applies a function to each packet to get a value that will be plotted
with matplotlib. A list of matplotlib.lines.Line2D is returned.
lfilter: a truth function that decides whether a packet must be plotted
"""
# Python... | [
"Applies",
"a",
"function",
"to",
"each",
"packet",
"to",
"get",
"a",
"value",
"that",
"will",
"be",
"plotted",
"with",
"matplotlib",
".",
"A",
"list",
"of",
"matplotlib",
".",
"lines",
".",
"Line2D",
"is",
"returned",
"."
] | secdev/scapy | python | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L182-L211 | [
"def",
"plot",
"(",
"self",
",",
"f",
",",
"lfilter",
"=",
"None",
",",
"plot_xy",
"=",
"False",
",",
"*",
"*",
"kargs",
")",
":",
"# Python 2 backward compatibility",
"f",
"=",
"lambda_tuple_converter",
"(",
"f",
")",
"lfilter",
"=",
"lambda_tuple_converter... | 3ffe757c184017dd46464593a8f80f85abc1e79a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.