使用树莓派(Raspberry Pi)进行数据包嗅探

 +-----------+           +-----------+          +------------+
 |           |           |           |          |            |
 |           |   ETH1    | RASPBERRY |   ETH0   |            |
 |  LAPTOP   +-----------+    PI     +----------+     PC     |
 |           |           |           |          |            |
 |           |           |           |          |            |
 +-----------+           +-----------+          +------------+

我打算详细介绍如何设置树莓派以在两个网络设备之间执行数据包嗅探。其中解释了它的工作原理,下面将分别设置网络桥和转储数据包的shell脚本和python脚本。

网络布局:
Raspberry Pi位于中间,每个设备之间传输的所有数据都被它捕获。第二个USB转以太网适配器用于提供第二个接口。我使用的适配器是USB到快速每秒10100 Mbps网络LAN适配器Vista Linux 27723。

当Raspberry pi启动时,进行加载两个脚本。首先是下面的这个shell脚本:


ifconfig eth0 0.0.0.0
ifconfig eth1 0.0.0.0
brctl addbr bridge0
brctl addif bridge0 eth0
brctl addif bridge0 eth1
dhclient bridge0
ifconfig bridge0 up

该脚本从eth0和eth1中删除了IP地址。然后,它创建一个称为bridge0的桥。将接口添加到bridge0并启动网桥.shell脚本还为网桥接口分配网络地址以允许网络连接。(dhclient桥0)

在上述脚本之后的第二个脚本是下面的python脚本。它实现了Python Dropbox Uploader扩展,可在此处下载

import subprocess
from dbupload import upload_file #Used for Dropbox uploading
from datetime import datetime # Used the genreate the filename
count = 0 #Counts the number of files that have been dumped
while True:
    count = count + 1
    fileName = str(datetime.now().day) + "-" + str(datetime.now().month) + "-" + str(datetime.now().year) + " AT " + str(datetime.now().hour) + "-" + str(datetime.now().minute)
    tcpDumpProcess = subprocess.Popen(["tcpdump", "-Z", "root", "-w", fileName, "-i", "bridge0", "-G", "60", "-W", "1"]) #Sets up the TCPDump command
    tcpDumpProcess.communicate() #Runs the TCPDump command
    print "Currently dumping file number " + str(count) + "."
    upload_file(fileName,"/",fileName, "YOUR_EMAIL","YOUR_PASSWORD") #Uploads the dump file to dropbox
    print "File uploaded Successfully"

只需将网络设置添加到网桥接口,即可在Raspberry Pi上配置Internet连接。在我的情况下,我使用DHCP通过将dhclient bridge0添加到Shell脚本来自动执行此操作。

将这两个文件保存到树莓派上并在启动时从rc.local文件执行,这将使树莓派自动捕获两个设备之间的网络流量。

关注:Hunter网络安全 获取更多资讯
网站:bbs.kylzrv.com
CTF团队:Hunter网络安全
文章:Xtrato
排版:Hunter-匿名者

你可能感兴趣的:(技术,硬件,安全,其他,经验分享,raspberry,pi)