只是想尝试和帮助这里。我没有BGP类型数据包的经验,但是...我从您提供的链接复制了bgp.py文件到scapy /图层中。使用LS(),我发现:
BGPAuthenticationData : BGP Authentication Data
BGPErrorSubcodes : BGP Error Subcodes
BGPHeader : BGP header
BGPNotification : BGP Notification fields
BGPOpen : BGP Open Header
BGPOptionalParameter : BGP Optional Parameters
BGPPathAttribute : BGP Attribute fields
BGPUpdate : BGP Update fields
然后我可以使用Say LS(BGPUpdate)来显示这一点:
withdrawn_len : ShortField = (None)
withdrawn : FieldListField = ([])
tp_len : ShortField = (None)
total_path : PacketListField = ([])
nlri : FieldListField = ([])
,并能够创建这个包:
pkt = pkt = IP()/TCP()/BGPUpdate()
pkt.show()
###[ IP ]###
version = 4
ihl = None
tos = 0x0
len = None
id = 1
flags =
frag = 0
ttl = 64
proto = tcp
chksum = None
src = 127.0.0.1
dst = 127.0.0.1
\options \
###[ TCP ]###
sport = ftp_data
dport = http
seq = 0
ack = 0
dataofs = None
reserved = 0
flags = S
window = 8192
chksum = None
urgptr = 0
options = {}
###[ BGP Update fields ]###
withdrawn_len= None
withdrawn = []
tp_len = None
\total_path\
nlri = []
我不确定所有不同类型的BGP层/数据包是用于或将设置社区号码的。可能在BGPPathAttribute(type = x)中。类型5是“LOCAL_PREF”,可能对应于社区值。试试这个Link.
pkt = BGPPathAttribute(type=5)
pkt.show()
###[ BGP Attribute fields ]###
flags = Transitive
type = LOCAL_PREF
attr_len = None
value = ''
无论如何,希望有所帮助。
编辑: 忘记。我还将“bgp”添加到scapy/config.py的load_layers部分。 373行。像这样:
load_layers = ["l2", "inet", "dhcp", "dns", "dot11", "gprs", "hsrp", "inet6", "ir", "isakmp", "l2tp",
"mgcp", "mobileip", "netbios", "netflow", "ntp", "ppp", "radius", "rip", "rtp",
"sebek", "skinny", "smb", "snmp", "tftp", "x509", "bluetooth", "dhcp6", "llmnr", "sctp", "vrrp",
"ipsec","bgp"]
BGP使用TCP,所以它不像OSPF那样是数据包。 BGP数据报包含在TCP段中。 –
感谢您的回复!我将bgp.py文件移动到我的scapy图层文件夹中,但是当我使用ls()时它没有显示出来。我错过了什么步骤,比如重建? –
@JamesButler对不起。编辑我的答案。 – Noob123