Port Scanner to CSV


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.