#!/usr/bin/env bash nokey() { echo "Ключ --all выводит IP-адреса и символьные имена всех узлов в текущей подсети" echo "Ключ --target=XXXX выводит список открытых системных портов TCP" } all() { local net="$1" nbtscan -k "${net}/24" } target() { local ip="$1" nbtscan"$ip" } main() { if [ "$#" = 0 ]; then nokey else case "$1" in --all) all "$2" ;; --target) target "$2" ;; esac fi } main "$@" # End of script_name
I do not understand why so bother with the trabalian task. For myself, I discovered the -oG key in nmap immediately preparing output for mapping (grep, awk)
~$ nmap -oG - 172.16.31.76/24 # Nmap 7.40 scan initiated Wed Jul 12 22:25:36 2017 as: nmap -oG - 172.16.31.76/24 Host: 172.16.31.1 () Status: Up Host: 172.16.31.1 () Status: Up Host: 172.16.31.21 () Status: Up Host: 172.16.31.21 () Status: Up Host: 172.16.31.76 () Status: Up Host: 172.16.31.76 () Status: Up Host: 172.16.31.106 () Status: Up Host: 172.16.31.106 () Status: Up # Nmap done at Wed Jul 12 22:25:41 2017 -- 256 IP addresses (4 hosts up) scanned in 4.97 seconds
awkto work with columns. 2. apply something likenmap- Mike-eoption of the nbtscan program - output "in the format / etc / hosts", i.e., only the name and ip-address. - aleksandr barakin