Open port scanner for Solaris
Running out of ideas to convince you about giving me your BitCoins, but if this helped you in any way and you have some spare BitCoins, you may donate them to me - 16tb2Rgn4uDptrEuR94BkhQAZNgfoMj3ugports.sh will report all open ports and will attempt to find the process linked to the open port.
The script will check the /etc/services file to check if there is an entry in the file for the open port.
- Usage
- Copy the code below and by using vi, create a file called ports.sh in /opt/temp'
- Save the file ports.sh by using vi command :wq!
- Change the permissions on ports.sh with chmod +x ports.sh
- Execute ports.sh with ./ports.sh
# King Rat 2014/03/21 # # This script will scan for open ports, tie it to the PID and checks if there is an entry in /etc/service #!/bin/bash echo " " echo " " echo "---------------------------------------------------------------------" echo "Open ports scanner" echo "---------------------------------------------------------------------" echo -e "PID\tProcess Name and Port" echo -e "PID\tProcess Name and Port" > ports echo "_________________________________________________________" echo "_________________________________________________________" >> ports for proc in `ptree -a | sort -n | awk '/ptree/ {next} {print $1};'`; do out=`pfiles $proc 2>/dev/null| egrep "port:"` if [ ! -z "$out" ]; then name=`ps -fo comm= -p $proc` echo -e "$proc\t$name\n$out" echo -e "$proc\t$name\n$out" >> ports echo "_________________________________________________________" >> ports echo " ";echo "................................................" arr=$(echo $out | tr ":" "\n") for x in $arr; do if [[ `echo $x | sed 's/^[-+0-9][0-9]*//' | wc -c` -eq 1 ]]; then if [ `cat /etc/services | grep -w $x | wc -l` -ge 1 ]; then nns=`cat /etc/services | grep -w $x` nns="/etc/services entry for Port"$x" ------- "$nns echo $nns else echo "/etc/services entry for Port "$x" ------- !! not found" fi fi done echo "___________________________________________________________" echo " "; echo " " echo -e "PID\tProcess Name and Port" echo "___________________________________________________________" fi done echo "Open port scanner was executed"
No comments:
Post a Comment
Note: only a member of this blog may post a comment.