乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      用scapy在python中編寫一個以太網(wǎng)橋

       印度阿三17 2019-09-02

      我想做這樣的事情:

                  10.1.1.0/24          10.1.2.0/24
      
       ------------         ------------         ------------ 
      |            |       |            |       |            |
      |            |       |            |       |            |
      |     A    d  -------  e   B    f  -------  g   C      |
      |            |       |            |       |            |
      |            |       |            |       |            |
       ------------         ------------         ------------ 
      
          d              e           f           g
          10.1.1.1       10.1.1.2    10.1.2.1    10.1.2.2
      

      這樣Acan就可以通過B向C發(fā)送數(shù)據(jù)包了.

      我嘗試通過在B上運行一個可以嗅探端口e和f的scapy程序來構建這個東西,并且在每種情況下修改數(shù)據(jù)包中的目標IP和MAC地址,然后通過另一個接口發(fā)送它.就像是:

      my_macs = [get_if_hwaddr(i) for i in get_if_list()]
      pktcnt = 0
      dest_mac_address = discover_mac_for_ip(dest_ip) # 
      output_mac = get_if_hwaddr(output_interface)
      
      def process_packet(pkt):
          # ignore packets that were sent from one of our own interfaces
          if pkt[Ether].src in my_macs:
              return
      
          pktcnt  = 1
          p = pkt.copy()
          # if this packet has an IP layer, change the dst field
          # to our final destination
          if IP in p:
              p[IP].dst = dest_ip
      
          # if this packet has an ethernet layer, change the dst field
          # to our final destination. We have to worry about this since
          # we're using sendp (rather than send) to send the packet.  We
          # also don't fiddle with it if it's a broadcast address.
          if Ether in p        and p[Ether].dst != 'ff:ff:ff:ff:ff:ff':
              p[Ether].dst = dest_mac_address
              p[Ether].src = output_mac
      
          # use sendp to avoid ARP'ing and stuff
          sendp(p, iface=output_interface)
      
      sniff(iface=input_interface, prn=process_packet)
      

      然而,當我運行這個東西(完整源碼here)時,各種瘋狂的事情開始發(fā)生……一些數(shù)據(jù)包通過,我甚至得到一些響應(用ping測試)但是有一些類型的反饋循環(huán)導致要發(fā)送一堆重復的數(shù)據(jù)包……

      有什么想法在這里發(fā)生了什么?嘗試這樣做是否很瘋狂?

      我有點懷疑反饋循環(huán)是由于B正在對數(shù)據(jù)包進行自己的一些處理這一事實…有什么方法可以阻止操作系統(tǒng)在我嗅探后處理數(shù)據(jù)包?

      解決方法:

      這樣做有點瘋狂,但花費你的時間并不是一種糟糕的方式.你會學到很多有趣的東西.然而,您可能想要考慮將數(shù)據(jù)包掛得更低 – 我不認為scapy能夠實際攔截數(shù)據(jù)包 – 所有l(wèi)ibpcap都設置為promisc并讓你看到一切,所以你和內核都得到了相同的東西.如果您轉身并重新發(fā)送,那可能是您的數(shù)據(jù)包風暴的原因.

      但是,您可以設置一些創(chuàng)意防火墻規(guī)則,將每個接口彼此分開并以此方式處理數(shù)據(jù)包,或者使用類似divert sockets的內容來實際將數(shù)據(jù)包從內核中分離出來,以便您可以使用它們.

      來源:https://www./content-1-435101.html

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多