zoukankan      html  css  js  c++  java
  • arping

    arping实现了简单的二层发现,即基于物理层和链路层的发现。由于没有ip层的参与,所以是不可路由的。优点是速度快,准确性高;缺点是不可路由,无法发现局域网以外的主机。

    命令基本格式:arping 192.168.1.1 -c n

    -c参数指定发送arp数据包的个数。

    arping命令无法一次性实现多个ip的扫描,但是可以配合shell脚本实现整个局域网的扫描。

     1 #!/bin/bash
     2 if [ "$#" -ne 1 ];then
     3     echo "Usage ./arping.sh [interface]"
     4     echo "Example: ./arping.sh eth0"
     5     echo "Example will perform an ARP scan of the loal subnet to while eth0 is assigned"
     6     exit
     7 fi
     8 interface=$1
     9 prefix=$(ifconfig $interface | grep "inet" | grep "broadcast" | cut -d " " -f 10 | cut -d "." -f 1-3)
    10 for addr in $(seq 1 254);do
    11     arping -c 1 $prefix.$addr | grep "Unicast" | cut -d " " -f 4
    12 done
    查看代码

    其中取出本地ip时要注意根据ifconfig eth0的输出来定制切割语句。

  • 相关阅读:
    Python数据结构之字符串
    Python中的logging模块
    Python资源大全中文版
    test
    Python数据结构之元组
    Python之StringIO和BytesIO
    Python标准库之pathlib
    Ubuntu下安装pyenv管理多版本python
    生成器 Generator
    CIDR网段格式
  • 原文地址:https://www.cnblogs.com/angiejc/p/9383798.html
Copyright © 2011-2022 走看看