NMAP: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Scan subnet<ref>https://unix.stackexchange.com/questions/585775/nmap-output-with-awk-to-table</ref> == <syntaxhighlight lang="bash"> $sudo nmap -sP 192.168.1.0/24 | awk '{a=0;b=2;c=3;d=4;e=5;f=6} function out() { if (state=="up") { printf "%s \t%s \t%s \t%s\n", ip, mac, name, name2; ip=""; mac=""; name=""; state=""; name2="" } } /Nmap scan report/ { out(); name=$e; ip = substr($f,2,length($f)-2); if (ip=="") { ip=name; name="" } } /Host is/ { state=$c } /MAC Addr...") |
No edit summary |
||
Line 1: | Line 1: | ||
== Scan subnet<ref>https://unix.stackexchange.com/questions/585775/nmap-output-with-awk-to-table</ref> == | == Scan subnet<ref>https://unix.stackexchange.com/questions/585775/nmap-output-with-awk-to-table</ref> == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$sudo nmap -sP 192.168.1.0/24 | awk '{a=0;b=2;c=3;d=4;e=5;f=6} function out() { if (state=="up") { printf "%s \t%s \t%s \t%s\n", ip, mac, name, name2; ip=""; mac=""; name=""; state=""; name2="" } } /Nmap scan report/ { out(); name=$e; ip = substr($f,2,length($f)-2); if (ip=="") { ip=name; name="" } } /Host is/ { state=$c } /MAC Address/ { mac=$c; name2=substr($a,index($a,$d)) } END { out() }' | $sudo nmap -sP 192.168.1.0/24 10.230.200.0/26 | awk '{a=0;b=2;c=3;d=4;e=5;f=6} function out() { if (state=="up") { printf "%s \t%s \t%s \t%s\n", ip, mac, name, name2; ip=""; mac=""; name=""; state=""; name2="" } } /Nmap scan report/ { out(); name=$e; ip = substr($f,2,length($f)-2); if (ip=="") { ip=name; name="" } } /Host is/ { state=$c } /MAC Address/ { mac=$c; name2=substr($a,index($a,$d)) } END { out() }' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== References == | == References == | ||
<references /> | <references /> |
Latest revision as of 08:04, 20 January 2025
Scan subnet[1]
$sudo nmap -sP 192.168.1.0/24 10.230.200.0/26 | awk '{a=0;b=2;c=3;d=4;e=5;f=6} function out() { if (state=="up") { printf "%s \t%s \t%s \t%s\n", ip, mac, name, name2; ip=""; mac=""; name=""; state=""; name2="" } } /Nmap scan report/ { out(); name=$e; ip = substr($f,2,length($f)-2); if (ip=="") { ip=name; name="" } } /Host is/ { state=$c } /MAC Address/ { mac=$c; name2=substr($a,index($a,$d)) } END { out() }'