免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

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

我想做這樣的事情:

            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程序來構(gòu)建這個東西,并且在每種情況下修改數(shù)據(jù)包中的目標(biāo)IP和MAC地址,然后通過另一個接口發(fā)送它.就像是:

my_macs = [get_if_hwaddr(i) for i in get_if_list()]pktcnt = 0dest_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)

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

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

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

解決方法:

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

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

來源:https://www.icode9.com/content-1-435101.html
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
盤點一款Python發(fā)包收包利器——scapy
linux下網(wǎng)絡(luò)監(jiān)聽與發(fā)送數(shù)據(jù)包的方法(即libpcap、libnet兩種類庫的使用方法)
Linux下抓包工具tcpdump使用介紹
python scapy網(wǎng)絡(luò)嗅探
學(xué)習(xí)tcpdump
tcpdump 使用詳解
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服