Advertisement
opexxx

nmap2csv.bash

Feb 9th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.81 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # $Id: nmap2csv.bash,v 1.1 2013/05/01 21:08:16 decal Exp $
  4. #
  5. # Script for: Extracting DNS hostnames and numeric IP addresses from default
  6. # NMap (port scanner) output for live hosts and writen them to a CSV file.
  7. #
  8. # Written by: Derek Callaway <decal [at] ethernet [dot] org>
  9. #
  10. # Testing on: GNU bash, version 4.2.0(1)-release (x86_64--netbsd)
  11. #
  12. # References: http://insecure.org/nmap
  13. #
  14. ################################################################################
  15.  
  16. if [ ! $1 ];
  17.   then echo "usage: $0 INPUT"
  18.   echo      "  INPUT  path to input file (typical nmap text output)"
  19.  
  20.   exit -1
  21. fi
  22.  
  23. egrep -iB1 '^host is up' $1 |grep -i '^nmap scan report for ' |\
  24.   awk '{print $5 " " $6}' | tr -d ')' | sed 's! (!,!g' |\
  25.   awk -F, '{print($2 "," $1);}' | sed -r 's|^[,]+||g'
  26.  
  27. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement