本文整理汇总了Python中scapy.packet.bind_layers函数的典型用法代码示例。如果您正苦于以下问题:Python bind_layers函数的具体用法?Python bind_layers怎么用?Python bind_layers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bind_layers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TEXT_MESSAGE_TRANSFER
#!/usr/bin/env python
# Text message transfer SDU
from scapy.packet import Packet, bind_layers
from scapy.fields import BitField, ConditionalField
from .sdstl import SDS_TRANSFER
# Table 446: Text message transfer SDU contents
class TEXT_MESSAGE_TRANSFER(Packet):
name = 'Text Message Transfer SDU'
fields_desc = [
BitField('tstp_used', 0, 1),
BitField('text_coding', 0, 7),
ConditionalField(BitField('timestamp', 0, 24), lambda pkt: pkt.tstp_used == 1),
]
# FIXME : this is just wrong. We should rely on the value of D_SDS_DATA.proto
# but Scapy does not allow us to use the fields of an "ancestor" layer.
bind_layers(SDS_TRANSFER, TEXT_MESSAGE_TRANSFER)
开发者ID:Tim---,项目名称:scapy-tetra,代码行数:21,代码来源:textmsg.py
示例2: ShortField
ShortField('reserved', None),
XIntField('spi', 0x0),
IntField('seq', 0),
StrField('icv', None),
StrField('padding', None),
]
overload_fields = {
IP: {'proto': socket.IPPROTO_AH},
IPv6: {'nh': socket.IPPROTO_AH},
IPv6ExtHdrHopByHop: {'nh': socket.IPPROTO_AH},
IPv6ExtHdrDestOpt: {'nh': socket.IPPROTO_AH},
IPv6ExtHdrRouting: {'nh': socket.IPPROTO_AH},
}
bind_layers(IP, AH, proto=socket.IPPROTO_AH)
bind_layers(IPv6, AH, nh=socket.IPPROTO_AH)
#------------------------------------------------------------------------------
class ESP(Packet):
"""
Encapsulated Security Payload
See https://tools.ietf.org/rfc/rfc4303.txt
"""
name = 'ESP'
fields_desc = [
XIntField('spi', 0x0),
IntField('seq', 0),
StrField('data', None),
开发者ID:AntonRobbins,项目名称:scapy,代码行数:31,代码来源:ipsec.py
示例3: EtherIP
# This file is part of Scapy
# Scapy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# any later version.
#
# Scapy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Scapy. If not, see <http://www.gnu.org/licenses/>.
# scapy.contrib.description = EtherIP
# scapy.contrib.status = loads
from scapy.fields import BitField
from scapy.packet import Packet, bind_layers
from scapy.layers.inet import IP
from scapy.layers.l2 import Ether
class EtherIP(Packet):
name = "EtherIP / RFC 3378"
fields_desc = [ BitField("version", 3, 4),
BitField("reserved", 0, 12)]
bind_layers( IP, EtherIP, frag=0, proto=0x61)
bind_layers( EtherIP, Ether)
开发者ID:6WIND,项目名称:scapy,代码行数:29,代码来源:etherip.py
示例4: warning
if self.has_ifindex and self.ifindex is None:
warning('has_ifindex set but ifindex is not set.')
if self.has_ipaddr and self.afi is None:
warning('has_ipaddr set but afi is not set.')
if self.has_ipaddr and self.ip4 is None and self.ip6 is None:
warning('has_ipaddr set but ip4 or ip6 is not set.')
if self.has_ifname and self.ifname is None:
warning('has_ifname set but ifname is not set.')
if self.has_mtu and self.mtu is None:
warning('has_mtu set but mtu is not set.')
return ICMPExtensionObject.self_build(self, field_pos_list=field_pos_list)
# Add the post_dissection() method to the existing ICMPv4 and
# ICMPv6 error messages
scapy.layers.inet.ICMPerror.post_dissection = ICMPExtension_post_dissection
scapy.layers.inet.TCPerror.post_dissection = ICMPExtension_post_dissection
scapy.layers.inet.UDPerror.post_dissection = ICMPExtension_post_dissection
scapy.layers.inet6.ICMPv6DestUnreach.post_dissection = ICMPExtension_post_dissection
scapy.layers.inet6.ICMPv6TimeExceeded.post_dissection = ICMPExtension_post_dissection
# ICMPExtensionHeader looks at fields from the upper layer object when
# determining which upper layer to use.
bind_layers(ICMPExtensionHeader, ICMPExtensionMPLS,
classnum=1, classtype=1)
bind_layers(ICMPExtensionHeader, ICMPExtensionInterfaceInformation, classnum=2)
开发者ID:Osso,项目名称:scapy,代码行数:29,代码来源:icmp_extensions.py
示例5: range
g_log_loading.info(_crypto_loading_failure_message)
return None
packed_hdr = struct.pack("!B", self.code)
packed_hdr += struct.pack("!B", self.id)
packed_hdr += struct.pack("!H", self.len)
packed_attrs = ''
for index in range(0, len(self.attributes)):
packed_attrs = packed_attrs + str(self.attributes[index])
packed_data = packed_hdr + packed_request_auth + packed_attrs +\
shared_secret
digest = hashes.Hash(hashes.MD5(), backend=default_backend())
digest.update(packed_data)
return digest.finalize()
def post_build(self, p, pay):
p += pay
length = self.len
if length is None:
length = len(p)
p = p[:2] + struct.pack("!H", length) + p[4:]
return p
bind_layers(UDP, Radius, sport=1812)
bind_layers(UDP, Radius, dport=1812)
bind_layers(UDP, Radius, sport=1813)
bind_layers(UDP, Radius, dport=1813)
开发者ID:thibaultdelmas,项目名称:scapy,代码行数:30,代码来源:radius.py
示例6: X3BytesField
X3BytesField("vni", 0),
XByteField("reserved2", 0x00),
GENEVEOptionsField("options", "")]
def post_build(self, p, pay):
p += pay
optionlen = self.optionlen
if optionlen is None:
optionlen = (len(self.options) + 3) // 4
p = chb(optionlen & 0x2f | orb(p[0]) & 0xc0) + p[1:]
return p
def answers(self, other):
if isinstance(other, GENEVE):
if ((self.proto == other.proto) and (self.vni == other.vni)):
return self.payload.answers(other.payload)
else:
return self.payload.answers(other)
return 0
def mysummary(self):
return self.sprintf("GENEVE (vni=%GENEVE.vni%,"
"optionlen=%GENEVE.optionlen%,"
"proto=%GENEVE.proto%)")
bind_layers(UDP, GENEVE, dport=6081)
bind_layers(GENEVE, Ether, proto=0x6558)
bind_layers(GENEVE, IP, proto=0x0800)
bind_layers(GENEVE, IPv6, proto=0x86dd)
开发者ID:plorinquer,项目名称:scapy,代码行数:30,代码来源:geneve.py
示例7: guess_payload_class
def guess_payload_class(self, payload):
''' Decides if the payload is an HTTP Request or Response, or
something else '''
try:
prog = re.compile(
r"^(?:OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT) "
r"(?:.+?) "
r"HTTP/\d\.\d$"
)
crlfIndex = payload.index("\r\n".encode())
req = payload[:crlfIndex].decode("utf-8")
result = prog.match(req)
if result:
return HTTPRequest
else:
prog = re.compile(r"^HTTP/\d\.\d \d\d\d .*$")
result = prog.match(req)
if result:
return HTTPResponse
except:
pass
return Packet.guess_payload_class(self, payload)
bind_layers(TCP, HTTP, dport=80)
bind_layers(TCP, HTTP, sport=80)
#For Proxy
bind_layers(TCP, HTTP, sport=8080)
bind_layers(TCP, HTTP, dport=8080)
开发者ID:noscripter,项目名称:scapy-http,代码行数:29,代码来源:http.py
示例8: default_payload_class
def default_payload_class(self, payload):
return conf.padding_layer
class IGMPv3mr(Packet):
"""IGMP Membership Report extension for IGMPv3.
Payload of IGMPv3 when type=0x22"""
name = "IGMPv3mr"
fields_desc = [XShortField("res2", 0),
FieldLenField("numgrp", None, count_of="records"),
PacketListField("records", [], IGMPv3gr, count_from=lambda x: x.numgrp)] # noqa: E501
class IGMPv3mra(Packet):
"""IGMP Multicas Router Advertisement extension for IGMPv3.
Payload of IGMPv3 when type=0x30"""
name = "IGMPv3mra"
fields_desc = [ShortField("qryIntvl", 0),
ShortField("robust", 0)]
bind_layers(IP, IGMPv3, frag=0,
proto=2,
ttl=1,
tos=0xc0,
dst='224.0.0.22')
bind_layers(IGMPv3, IGMPv3mq, type=0x11)
bind_layers(IGMPv3, IGMPv3mr, type=0x22, mrcode=0x0)
bind_layers(IGMPv3, IGMPv3mra, type=0x30)
开发者ID:commial,项目名称:scapy,代码行数:30,代码来源:igmpv3.py
示例9: Read10
class Read10(Packet):
name = "Read(10) "
fields_desc = [ XByteField("Reserved1", 0),
XIntField("LogicalBlockAddr", 0),
XByteField("Reserved2", 0),
ShortField("TransferLength", 1), # Number of blocks
XByteField("Control", 0) ]
class ReadTOC(Packet):
name = "ReadTOC "
fields_desc = [ ByteEnumField("MSF", 0, {0:"", 2:""}),
XByteField("Format-A", 0),
XByteField("Reserved1", 0),
XByteField("Reserved2", 0),
XByteField("Reserved3", 0),
XByteField("Reserved4", 0),
ShortField("AllocationLength", 12),
XByteField("Format-B", 0x40)]
bind_layers(SCSICmd, RequestSense, {"OperationCode":0x03})
bind_layers(SCSICmd, FormatUnit, {"OperationCode":0x04})
bind_layers(SCSICmd, Read6, {"OperationCode":0x0A})
bind_layers(SCSICmd, Inquiry, {"OperationCode":0x12})
bind_layers(SCSICmd, ReadCapacity10, {"OperationCode":0x25})
bind_layers(SCSICmd, Read10, {"OperationCode":0x28})
bind_layers(SCSICmd, ReadTOC, {"OperationCode":0x43})
开发者ID:0xroot,项目名称:usb-device-fuzzing,代码行数:28,代码来源:SCSI.py
示例10: isinstance
isinstance(other, TFTP_WRQ) or
isinstance(other, TFTP_ACK))
def mysummary(self):
return self.sprintf("ERROR %errorcode%: %errormsg%"), [UDP]
class TFTP_OACK(Packet):
name = "TFTP Option Ack"
fields_desc = []
def answers(self, other):
return isinstance(other, TFTP_WRQ) or isinstance(other, TFTP_RRQ)
bind_layers(UDP, TFTP, dport=69)
bind_layers(TFTP, TFTP_RRQ, op=1)
bind_layers(TFTP, TFTP_WRQ, op=2)
bind_layers(TFTP, TFTP_DATA, op=3)
bind_layers(TFTP, TFTP_ACK, op=4)
bind_layers(TFTP, TFTP_ERROR, op=5)
bind_layers(TFTP, TFTP_OACK, op=6)
bind_layers(TFTP_RRQ, TFTP_Options)
bind_layers(TFTP_WRQ, TFTP_Options)
bind_layers(TFTP_OACK, TFTP_Options)
class TFTP_read(Automaton):
def parse_args(self, filename, server, sport=None, port=69, **kargs):
Automaton.parse_args(self, **kargs)
self.filename = filename
开发者ID:commial,项目名称:scapy,代码行数:31,代码来源:tftp.py
示例11: len
# Setting length of packet to obfuscate if not filled by user
if self.length is None and pay:
p = p[:-4] + struct.pack('!I', len(pay))
if self.flags == 0:
pay = obfuscate(pay, SECRET, self.session_id, self.version, self.seq) # noqa: E501
return p + pay
return p
def hashret(self):
return struct.pack('I', self.session_id)
def answers(self, other):
return (isinstance(other, TacacsHeader) and
self.seq == other.seq + 1 and
self.type == other.type and
self.session_id == other.session_id)
bind_layers(TCP, TacacsHeader, dport=49)
bind_layers(TCP, TacacsHeader, sport=49)
bind_layers(TacacsHeader, TacacsAuthenticationStart, type=1, dport=49)
bind_layers(TacacsHeader, TacacsAuthenticationReply, type=1, sport=49)
if __name__ == '__main__':
from scapy.main import interact
interact(mydict=globals(), mybanner='tacacs+')
开发者ID:plorinquer,项目名称:scapy,代码行数:30,代码来源:tacacs.py
示例12: ByteEnumField
ByteEnumField("descr", None, _tls_alert_description)]
def post_dissection_tls_session_update(self, msg_str):
pass
def post_build_tls_session_update(self, msg_str):
pass
###############################################################################
# TLS Application Data #
###############################################################################
class TLSApplicationData(_GenericTLSSessionInheritance):
name = "TLS Application Data"
fields_desc = [StrField("data", "")]
def post_dissection_tls_session_update(self, msg_str):
pass
def post_build_tls_session_update(self, msg_str):
pass
###############################################################################
# Bindings #
###############################################################################
bind_layers(TCP, TLS, sport=443)
bind_layers(TCP, TLS, dport=443)
开发者ID:commial,项目名称:scapy,代码行数:30,代码来源:record.py
示例13: MPLS
# Imported from scapy at revision 1270:113ef25f9583
# This file is not included in the Ubuntu packages of scapy, so it is checked
# in to our repo to simplify installation. This file is under the GPLv2.
# http://trac.secdev.org/scapy/ticket/31
# scapy.contrib.description = MPLS
# scapy.contrib.status = loads
from scapy.packet import Packet,bind_layers
from scapy.fields import BitField,ByteField
from scapy.layers.l2 import Ether
class MPLS(Packet):
name = "MPLS"
fields_desc = [ BitField("label", 3, 20),
BitField("cos", 0, 3),
BitField("s", 1, 1),
ByteField("ttl", 0) ]
bind_layers(Ether, MPLS, type=0x8847)
# Not in upstream scapy
bind_layers(MPLS, MPLS, s=0)
开发者ID:CPqD,项目名称:oftest,代码行数:24,代码来源:mpls.py
示例14: GTPSupportedExtensionHeadersNotification
class GTPSupportedExtensionHeadersNotification(Packet):
name = "GTP Supported Extension Headers Notification"
fields_desc = [PacketListField("IE_list", [IE_ExtensionHeaderList(),
], IE_Dispatcher)]
class GTPmorethan1500(Packet):
# 3GPP TS 29.060 V9.1.0 (2009-12)
name = "GTP More than 1500"
fields_desc = [ByteEnumField("IE_Cause", "Cause", IEType),
BitField("IE", 1, 12000), ]
# Bind GTP-C
bind_layers(UDP, GTPHeader, dport=2123)
bind_layers(UDP, GTPHeader, sport=2123)
bind_layers(GTPHeader, GTPEchoRequest, gtp_type=1, S=1)
bind_layers(GTPHeader, GTPEchoResponse, gtp_type=2, S=1)
bind_layers(GTPHeader, GTPCreatePDPContextRequest, gtp_type=16)
bind_layers(GTPHeader, GTPCreatePDPContextResponse, gtp_type=17)
bind_layers(GTPHeader, GTPUpdatePDPContextRequest, gtp_type=18)
bind_layers(GTPHeader, GTPUpdatePDPContextResponse, gtp_type=19)
bind_layers(GTPHeader, GTPDeletePDPContextRequest, gtp_type=20)
bind_layers(GTPHeader, GTPDeletePDPContextResponse, gtp_type=21)
bind_layers(GTPHeader, GTPPDUNotificationRequest, gtp_type=27)
bind_layers(GTPHeader, GTPSupportedExtensionHeadersNotification, gtp_type=31, S=1) # noqa: E501
bind_layers(GTPHeader, GTP_UDPPort_ExtensionHeader, next_ex=64, E=1)
bind_layers(GTPHeader, GTP_PDCP_PDU_ExtensionHeader, next_ex=192, E=1)
# Bind GTP-U
开发者ID:plorinquer,项目名称:scapy,代码行数:30,代码来源:gtp.py
示例15: _ISIS_PSNP_Base
class _ISIS_PSNP_Base(_ISIS_PduBase):
fields_desc = [
_ISIS_PduLengthField(),
ISIS_NodeIdField("sourceid", "0102.0304.0506.00"),
_ISIS_TlvListField()
]
class ISIS_L1_PSNP(_ISIS_PSNP_Base):
name = "ISIS L1 Partial Sequence Number Packet"
def answers(self, other):
return _snp_answers(self, other, "ISIS_L1_LSP")
class ISIS_L2_PSNP(_ISIS_PSNP_Base):
name = "ISIS L2 Partial Sequence Number Packet"
def answers(self, other):
return _snp_answers(self, other, "ISIS_L2_LSP")
register_cln_protocol(0x83, ISIS_CommonHdr)
bind_layers(ISIS_CommonHdr, ISIS_L1_LAN_Hello, hdrlen=27, pdutype=15)
bind_layers(ISIS_CommonHdr, ISIS_L2_LAN_Hello, hdrlen=27, pdutype=16)
bind_layers(ISIS_CommonHdr, ISIS_P2P_Hello, hdrlen=20, pdutype=17)
bind_layers(ISIS_CommonHdr, ISIS_L1_LSP, hdrlen=27, pdutype=18)
bind_layers(ISIS_CommonHdr, ISIS_L2_LSP, hdrlen=27, pdutype=20)
bind_layers(ISIS_CommonHdr, ISIS_L1_CSNP, hdrlen=33, pdutype=24)
bind_layers(ISIS_CommonHdr, ISIS_L2_CSNP, hdrlen=33, pdutype=25)
bind_layers(ISIS_CommonHdr, ISIS_L1_PSNP, hdrlen=17, pdutype=26)
bind_layers(ISIS_CommonHdr, ISIS_L2_PSNP, hdrlen=17, pdutype=27)
开发者ID:security-geeks,项目名称:scapy,代码行数:31,代码来源:isis.py
示例16: RIPng
# scapy.contrib.status = loads
from scapy.packet import Packet, bind_layers
from scapy.fields import ByteEnumField, ByteField, IP6Field, ShortField
from scapy.layers.inet import UDP
class RIPng(Packet):
name = "RIPng header"
fields_desc = [
ByteEnumField("cmd", 1, {1: "req", 2: "resp"}),
ByteField("ver", 1),
ShortField("null", 0)
]
class RIPngEntry(Packet):
name = "RIPng entry"
fields_desc = [
IP6Field("prefix_or_nh", "::"),
ShortField("routetag", 0),
ByteField("prefixlen", 0),
ByteEnumField("metric", 1, {16: "Unreach",
255: "next-hop entry"})
]
bind_layers(UDP, RIPng, sport=521, dport=521)
bind_layers(RIPng, RIPngEntry)
bind_layers(RIPngEntry, RIPngEntry)
开发者ID:commial,项目名称:scapy,代码行数:30,代码来源:ripng.py
示例17: elif
return False
elif ((self.type == 0x17) and isValidMCAddr(gaddr)):
underlayer.dst = "224.0.0.2" # IP rule 2 # noqa: E501
elif ((self.type == 0x12) or (self.type == 0x16)) and (isValidMCAddr(gaddr)): # noqa: E501
underlayer.dst = gaddr # IP rule 3b # noqa: E501
else:
warning("Invalid IGMP Type detected !")
return False
if not any(isinstance(x, IPOption_Router_Alert) for x in underlayer.options): # noqa: E501
underlayer.options.append(IPOption_Router_Alert())
_root = self.firstlayer()
if _root.haslayer(Ether):
# Force recalculate Ether dst
_root[Ether].dst = getmacbyip(underlayer.dst) # Ether rule 1 # noqa: E501
from scapy.contrib.igmpv3 import IGMPv3
if isinstance(self, IGMPv3):
self.encode_maxrespcode()
return True
def mysummary(self):
"""Display a summary of the IGMP object."""
if isinstance(self.underlayer, IP):
return self.underlayer.sprintf("IGMP: %IP.src% > %IP.dst% %IGMP.type% %IGMP.gaddr%") # noqa: E501
else:
return self.sprintf("IGMP %IGMP.type% %IGMP.gaddr%")
bind_layers(IP, IGMP, frag=0,
proto=2,
ttl=1)
开发者ID:plorinquer,项目名称:scapy,代码行数:30,代码来源:igmp.py
示例18: Skinny
0x012E: "UnSubscribeDtmfPayloadErrMessage",
0x012F: "ServiceURLStatMessage",
0x0130: "CallSelectStatMessage",
0x0131: "OpenMultiMediaChannelMessage",
0x0132: "StartMultiMediaTransmission",
0x0133: "StopMultiMediaTransmission",
0x0134: "MiscellaneousCommandMessage",
0x0135: "FlowControlCommandMessage",
0x0136: "CloseMultiMediaReceiveChannel",
0x0137: "CreateConferenceReqMessage",
0x0138: "DeleteConferenceReqMessage",
0x0139: "ModifyConferenceReqMessage",
0x013A: "AddParticipantReqMessage",
0x013B: "DropParticipantReqMessage",
0x013C: "AuditConferenceReqMessage",
0x013D: "AuditParticipantReqMessage",
0x013F: "UserToDeviceDataVersion1Message",
}
class Skinny(Packet):
name = "Skinny"
fields_desc = [LEIntField("len", 0),
LEIntField("res", 0),
LEIntEnumField("msg", 0, skinny_messages)]
bind_layers(TCP, Skinny, dport=2000)
bind_layers(TCP, Skinny, sport=2000)
bind_layers(TCP, Skinny, dport=2000, sport=2000)
开发者ID:segment-routing,项目名称:scapy,代码行数:30,代码来源:skinny.py
示例19: bind_layers
## GNU General Public License for more details.
##==============
# Standard imports
import logging
from optparse import OptionParser, OptionGroup
# External imports
from scapy.config import conf
from scapy.packet import bind_layers, Raw
# Custom imports
from pysap.SAPMS import SAPMS
from pysap.SAPNI import SAPNI, SAPNIStreamSocket
# Bind SAP NI with MS packets
bind_layers(SAPNI, SAPMS, )
# Set the verbosity to 0
conf.verb = 0
# Command line options parser
def parse_options():
description = \
"""This example script connects with the Message Server service and sends
a message to another client.
"""
epilog = \
开发者ID:jcmuniz,项目名称:pysap,代码行数:31,代码来源:ms_messager.py
示例20: IrLAPHead
# IR
class IrLAPHead(Packet):
name = "IrDA Link Access Protocol Header"
fields_desc = [XBitField("Address", 0x7f, 7),
BitEnumField("Type", 1, 1, {"Response": 0,
"Command": 1})]
class IrLAPCommand(Packet):
name = "IrDA Link Access Protocol Command"
fields_desc = [XByteField("Control", 0),
XByteField("Format identifier", 0),
XIntField("Source address", 0),
XIntField("Destination address", 0xffffffff),
XByteField("Discovery flags", 0x1),
ByteEnumField("Slot number", 255, {"final": 255}),
XByteField("Version", 0)]
class IrLMP(Packet):
name = "IrDA Link Management Protocol"
fields_desc = [XShortField("Service hints", 0),
XByteField("Character set", 0),
StrField("Device name", "")]
bind_layers(CookedLinux, IrLAPHead, proto=23)
bind_layers(IrLAPHead, IrLAPCommand, Type=1)
bind_layers(IrLAPCommand, IrLMP,)
开发者ID:commial,项目名称:scapy,代码行数:30,代码来源:ir.py
注:本文中的scapy.packet.bind_layers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论