Posted By

blackthorne on 03/29/10


Tagged

network tcp scanner nmap portscan blackthorne


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

blackthorne
IsraelTorres


Port Scanner to CSV


 / Published in: Bash
 

requires nmap ./scanner.sh ip_addr output shall generate a CSV file named output.csv with the results of the port scan

  1. #!/usr/bin/env /bin/bash
  2. LOG_FILE=$2
  3. TARGET=$1
  4. CSV_FILE="$LOG_FILE.csv"
  5. echo "Porto,Serviço" > $CSV_FILE
  6. nmap -v -sS $TARGET > $LOG_FILE
  7. CUTLINE=`grep -n "PORT" $LOG_FILE | cut -d':' -f1`
  8. let CUTLINE=CUTLINE+1
  9. ENDLINE=`grep -nw "^$" $LOG_FILE|tail -n 1|cut -d ':' -f1`
  10. let ENDLINE=ENDLINE-1
  11. sed -n "${CUTLINE},${ENDLINE}p" $LOG_FILE|awk '{print $1","$3}' >> $CSV_FILE
  12. echo "done"

Report this snippet  

You need to login to post a comment.