Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Active information collection-layer 2 discovery (shell script)

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Second-level discovery

Principle: use the ARP protocol to broadcast in the network segment to see if there is a return packet, and if so, prove that the host is alive

Advantages: fast and reliable scanning

Disadvantages: non-routable, only hosts within the same network segment can be found

Environment

Kali 2.0

Using arping command combined with script to realize host discovery

Script 1 (network interface) #! / bin/bash#Author:Taoif [$#-ne 1]; then echo "Usage. / arp.sh [interface]" exitfiintface=$1ipd=$ (ifconfig eth0 | grep 'netmask' | cut-d'-f 10 | cut-d'.'- f 1-3) for num in $(seq 1 255) Do ip=$ipd.$num arping-c 1$ ip | grep bytes | cut-d''- f 5 | cut-d'('- f 2 | cut-d')'- f 1done

One effect of the script:

Script 2 (network interface, no parameters) #! / bin/bash#Author:Taointerface=$ (ifconfig | head-1 | awk-F ":"'{print $1}') ip=$ (ifconfig $interface | grep "netmask" | awk'{print $2}'| cut-d'.'- f 1-3) for i in `seq 1 254`; do arping-c 1$ ip.$i | grep from | cut-d ""-f 5 | cut-d "("-f 2 | cut-d ")"-f 1done > alive.txt "

Note: the above script results will be input to the alive.txt file

Script two-effect picture:

Script 3 (IP) #! / bin/bash#Author:Taofile=$1for I in $(cat $1); do arping-c 1$ I | grep from | cut-d ""-f 5 | cut-d "("-f 2 | cut-d ")"-f 1done > $1-alive.txt

Note: the above script results will be entered into the file name + alive.txt file you passed.

Summary: the script is more or less the same. Record it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 219

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report