Guest User

Monitoramento de portas

a guest
Nov 18th, 2013
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/bash
  2. # Shell script para pegar as portas abertas de um servidor e comparar se ouve alguma modificação
  3. # nelas em um determinado período de tempo
  4. # Definição de variáveis
  5. HOST=127.0.0.1
  6. TEMP=/home/andrade/tmp
  7. DBPORTAS=/home/andrade/portas
  8. # Checa as portas abertas no momento da 1 até a 65000
  9. nmap -p 0-65000 $HOST | grep open | cut -d" " -f1 > $TEMP/$HOST
  10. # Faz a comparação e retorna as portas modificadas
  11. diff -abiu $TEMP/$HOST $DBPORTAS/$HOST | grep tcp | grep [+-] | sort | sed -e 's/+/Porta aberta /' | sed -e 's/-/Porta fechada /' > $TEMP/$HOST.diff
  12. cat $TEMP/$HOST > $DBPORTAS/$HOST
Advertisement
Add Comment
Please, Sign In to add comment