当前位置:网站首页>在mininet中测试arp欺骗
在mininet中测试arp欺骗
2022-08-02 14:12:00 【Soonyang Zhang】
我本来只用给出测试的拓补,以及仿真中使用的命令,本篇博客就算完事。最近csdn的博客系统,好像不允许发布全是英文内容的博客。所以,我要写点废话,便于在此记录我的所学。
测试使用的拓补,2h1s.py
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.link import TCLink
import time
import datetime
import subprocess
import os,signal
import sys
# https://segmentfault.com/a/1190000009562333
# arpspoof -i h2-eth0 -t 10.0.1.1 10.0.1.3
#
# h1----s1----h2------h3
#
bottleneckbw=6
nonbottlebw=500;
buffer_size =bottleneckbw*1000*30/(1500*8)
net = Mininet( cleanup=True )
h1 = net.addHost('h1',ip='10.0.1.1')
h2 = net.addHost('h2',ip='10.0.1.2')
h3 = net.addHost('h3',ip='10.0.2.2')
s1 = net.addSwitch( 's1' )
c0 = net.addController('c0')
net.addLink(h1,s1,intfName1='h1-eth0',intfName2='s1-eth0',cls=TCLink , bw=nonbottlebw, delay='10ms', max_queue_size=10*buffer_size)
net.addLink(s1,h2,intfName1='s1-eth1',intfName2='h2-eth0',cls=TCLink , bw=bottleneckbw, delay='10ms', max_queue_size=buffer_size)
net.addLink(h2,h3,intfName1='h2-eth1',intfName2='h3-eth0',cls=TCLink , bw=nonbottlebw, delay='50ms', max_queue_size=buffer_size)
net.build()
h1.cmd("ifconfig h1-eth0 10.0.1.1/24")
h1.cmd("route add default gw 10.0.1.3 dev h1-eth0")
h1.cmd('sysctl net.ipv4.ip_forward=1')
h2.cmd("ifconfig h2-eth0 10.0.1.2/24")
h2.cmd("ifconfig h2-eth1 10.0.2.1/24")
h2.cmd("ip route add to 10.0.2.0/24 via 10.0.2.2")
h2.cmd("ip route add to 10.0.1.0/24 via 10.0.1.1")
h2.cmd('sysctl net.ipv4.ip_forward=1')
h3.cmd("ifconfig h3-eth0 10.0.2.2/24")
h3.cmd("route add default gw 10.0.2.1 dev h3-eth0")
h3.cmd('sysctl net.ipv4.ip_forward=1')
net.start()
time.sleep(1)
CLI(net)
net.stop()
参考[1]安装可以arp欺骗的软件。
sudo apt-get install dsniff
启动mininet。
sudo su
xxxxx
python 2h1s.py
测试h1 ping h3。
xterm h1
ping 10.0.2.2
h1需要获取gateway的mac地址。h1的gateway为10.0.1.3。这个地址在这个微型网络中不存在。h1发送的arp包能够被h2截获,从而进行arp欺骗。h2可以向h1返回h2-eth0的mac地址。
xterm h2
arpspoof -i h2-eth0 -t 10.0.1.1 10.0.1.3
测试h1 ping h3。 成功。
如果你想实现一个arp欺骗的工具,在daemon模下,就必须开启网卡的混杂模式[2]。否则,主机网卡是不能向应用提交非本机IP的数据包的。可以参考[3]的实现。
ifr.ifr_flags = ifr.ifr_flags | IFF_PROMISC;
if (ioctl (sock, SIOCGIFFLAGS, &ifr) < 0) {
perror("ioctl");
exit(1);
}
参考:
[1] 局域网ARP欺骗原理详解
[2] 混杂模式介绍
[3] arproxy
边栏推荐
猜你喜欢
Installation and configuration of Spark and related ecological components - quick recall
Flink + sklearn - use JPMML implement flink deployment on machine learning model
深入理解Mysql索引底层数据结构与算法
第二十七章:时间复杂度与优化
Introduction to in-order traversal (non-recursive, recursive) after binary tree traversal
Introduction to C language function parameter passing mode
5款最好用的免费3D建模软件(附下载链接)
泰伯效应的建模
光波导k域布局可视化(“神奇的圆环”)
5. Transaction management
随机推荐
Qt | 显示网络图片 QNetworkAccessManager
2. Log out, log in state examination, verification code
第三十一章:二叉树的概念与性质
Ubuntu通过apt安装Mysql
shader入门精要3
LeetCode 2343. 裁剪数字后查询第 K 小的数字 暴力+语法考察
px和em和rem的区别
第三十章:普通树的存储和遍历
二叉树创建之层次法入门详解
Codeforces Round #605 (Div. 3)
光导布局设计工具
word方框怎么打勾?
1. Development community homepage, register
pygame image rotate continuously
MMD->Unity一站式解决方案
Open the door of electricity "Circuit" (1): voltage, current, reference direction
5. Transaction management
Software Testing Basics (Back)
3.用户上传头像
Problems related to prime numbers - small notes