我试图使用Scapy发送有BGP层的包
我目前被困在这个问题的一个基本部分,因为我无法设置BGP层。我按照指示设置常规的IP和TCP层。在
例如:
>>a=IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=179,dport=50)
但当我这样做时,问题就出现了:
^{pr2}$我在scapygithub(https://github.com/secdev/scapy/blob/9201f1cf1318edd5768d7e2ee968b7fba0a24c5e/scapy/contrib/bgp.py)的contrib文件中看到了BGP实现,所以我认为Scapy确实支持BGP实现
我是网络新手,所以我想知道你是否可以帮我设置BGP层
感谢您抽出时间来阅读这篇文章!在
只是想在这里帮忙。我对BGP类型的数据包没有经验,但是。。。我复制了bgp.py公司从你提供的链接文件到scapy/layers。使用ls()我发现了以下内容:
然后我可以使用say ls(bgpudate)来显示:
^{pr2}$并且能够创建这个包:
我不确定所有不同类型的BGP层/包用于什么目的,也不知道社区号码将设置在哪里。可能在bgpathattribute(type=x)中。类型5是“LOCAL_PREF”,可能与社区值相对应。试试这个Link.
不管怎样,希望这能有所帮助。在
编辑: 忘记。我还将“bgp”添加到scapy的load_layers部分/配置.py. 第373行。像这样:
我们需要一个使用scapy的BGP层。当BGP通过TCP传输时。所以我们必须有一个已建立的(3 way handshake)tcp套接字。TCP通过IP传输。因此,我们可以用下面的格式表示完整的数据包。在
packet = IP Layer / TCP Layer / BGP Layer
但是BGP本身分为两部分,BGP头和BGP有效负载(例如:OPEN,UPDATE,etc)。所以上面的层表示如下。在
packet = IP Layer / TCP Layer / BGP Header / BGP payload
这里的BGP头指定了BGP的身份验证、长度和类型有效载荷。到我们可以做以下练习。(我假设您已经建立了TCP套接字。)
使用以下变量值(例如目的)。在
^{pr2}$输出如下。在
相关问题 更多 >
编程相关推荐