-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnmap2csv.bash
More file actions
27 lines (23 loc) · 803 Bytes
/
nmap2csv.bash
File metadata and controls
27 lines (23 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
#
# $Id: nmap2csv.bash,v 1.1 2013/05/01 21:08:16 decal Exp $
#
# Script for: Extracting DNS hostnames and numeric IP addresses from default
# NMap (port scanner) output for live hosts and writen them to a CSV file.
#
# Written by: Derek Callaway <decal [at] ethernet [dot] org>
#
# Testing on: GNU bash, version 4.2.0(1)-release (x86_64--netbsd)
#
# References: http://insecure.org/nmap
#
################################################################################
if [ ! $1 ];
then echo "usage: $0 INPUT"
echo " INPUT path to input file (typical nmap text output)"
exit -1
fi
egrep -iB1 '^host is up' $1 |grep -i '^nmap scan report for ' |\
awk '{print $5 " " $6}' | tr -d ')' | sed 's! (!,!g' |\
awk -F, '{print($2 "," $1);}' | sed -r 's|^[,]+||g'
exit 0