只是想嘗試和幫助這裏。我沒有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