在之前的IoT安全测试之设备通信测试方法和IoT安全测试之测试环境说明两篇文章中,描述了IoT安全测试的测试环境以及设备通信测试方法,在此基础上又重新编写了测试环境代码。
iot-security是一款IoT安全测试系统,方便快速接入各种设备,进行安全测试。
一、功能特点
快速搭建测试环境
实时查看设备状态(是否在线、IP地址、MAC、用户等信息)
随时添加新设备进行测试(固定IP配置、设备标识)
快速配置代理规则(添加、删除)
二、初始化
配置使用kali作为代理路由器。我们需要一个无线网卡,作为嵌入式设备或手机等终端的接入点。
1、安装必须的组件(建议使用最新版的kali,只需要安装hostapd)
$ apt-get install dnsmasq hostapd
2、不使用Networkmanager接管wlan接口,添加接口MAC地址(或者设备名)到/etc/NetworkManager/NetworkManager.conf文件,然后重启网络服务。
[keyfile]
unmanaged-devices=mac:d8:eb:97:b6:ce:12;mac:56:6b:a2:90:c4:b9
[keyfile]
unmanaged-devices=interface-name:wlan0
3、重启网络服务
$ /etc/init.d/networking restart
三、使用方法
1、启动基础环境(启动wifi热点、启动dhcp等)
$ ./monitor.sh
input 1 : Show Monitor Status
input 2 : Start Monitor
input 3 : Stop Monitor
input 4 : Debug
input 0 : Exit
2、配置代理规则(添加设备、添加修改规则等)
$ ./proxy.sh
input 1 : Show proxy status
input 2 : Add proxy rules
input 3 : Clear proxy rules
input 4 : Add new device
input 0 : Exit
四、配置基础环境(可选)
系统初始化完毕即可正常使用。如果需要修改网络参数、wifi、dhcp等配置信息,可以参考以下部分。
1、配置wifi(ssid、密码等),修改配置文件./CONF/hostapd.conf。(ssid)为提供的接入点名称,(wpa_passphrase)为密码。
# create a wireless network with this interface; change it if your wireless card is not wlan0
interface=wlan0
# create a wireless network with this interface; change it if your wireless card is not wlan1
interface=wlan0
ssid=SecMonitor
# Change the passphrase to something you like
wpa_passphrase=123456789
driver=nl80211
auth_algs=3
channel=7
driver=nl80211
hw_mode=g
logger_stdout=-1
logger_stdout_level=2
max_num_sta=5
rsn_pairwise=CCMP
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
2、修改dnsmasq配置,修改配置文件./CONF/dnsmasq.conf
no-hosts
# listen to this interface; change it if a different bridge name was chosen in the overall script file
interface=wlan0
# except this interface
except-interface=lo
# listen address
listen-address=10.43.0.1
# give ip addresses in 10-100, lease is valid for 8 hours
dhcp-range=10.43.0.100,10.43.0.254,8h
# dhcp hostsfile
dhcp-hostsfile=/opt/seclab/CONF/dhcphosts
# dhcp optsfile
dhcp-optsfile=/opt/seclab/CONF/optsfile
# router
dhcp-option=3,10.43.0.1
# dns server
dhcp-option=6,10.43.0.1
# upstream DNS server
server=8.8.8.8
log-queries=extra
log-dhcp
log-facility=/var/log/dnsmasq.log
# include addresses
address=/attacker.com/10.43.0.1
3、修改网络配置(默认配置使用网段10.43.0.0/24,wifi网关地址10.43.0.1)。如需修改IP地址信息,需同时修改文件monitor.sh和./CONF/dnsmasq.conf相关配置。
修改monitor.sh文件中的相关配置:
# Network address range we use for our monitor network (please change IP address in file dnsmasq.conf and dhsphostfile in dir ./CONF/)
MONITOR_NETWORK=10.43.0.0/24
# The address we assign to our router, dhcp, and dns server.
MONITOR_MAIN=10.43.0.1/24
修改./CONF/dnsmasq.conf文件中的相关配置:
# listen address
listen-address=10.43.0.1
# give ip addresses in 10-100, lease is valid for 8 hours
dhcp-range=10.43.0.100,10.43.0.254,8h
# dhcp hostsfile
dhcp-hostsfile=/opt/seclab/CONF/dhcphosts
# dhcp optsfile
dhcp-optsfile=/opt/seclab/CONF/optsfile
# router
dhcp-option=3,10.43.0.1
# dns server
dhcp-option=6,10.43.0.1
五、源码结构
├── ArpList // 存储arp信息
├── CONF // 配置文件目录
│ ├── dhcphosts // dhcphosts配置
│ ├── dnsmasq.conf // dnsmasq配置文件
│ ├── hostapd.conf // hostapd配置文件(ssid、密码等)
│ └── optsfile // dnsmasq option配置文件
├── DeviceInfo // 标识设备信息(MAC、设备名、用户、备注等)
├── monitor.sh // 环境配置(启动、停止、监控、调试)
├── proxy.sh // 代理规则配置(设备、规则修改查看)
└── README.md
另外,我创建了一个知识星球,定位为对物联网安全感兴趣的朋友。内容除了物联网安全资讯报告等,主要和大家交流物联网安全测试经验,纯干货,欢迎加入。