The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to Scan proclog files deeprajn95 Shell Programming and Scripting 3 05-12-2008 03:25 AM
Port Scan Attack Detector 2.1.2 (Default branch) iBot Software Releases - RSS News 0 04-04-2008 09:00 AM
Port Scan Attack Detector 2.1.1 (Default branch) iBot Software Releases - RSS News 0 01-26-2008 06:10 AM
Please let me know Regarding Port Scan myramkumar UNIX for Advanced & Expert Users 7 05-17-2007 08:11 AM
unix program that can port scan a c block of ips for proxies user UNIX for Dummies Questions & Answers 1 07-11-2005 11:01 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-30-2008
Registered User
 

Join Date: Dec 2007
Posts: 11
port scan shell script

Hi,

Can any one please suggest me commands for making port scan shell script.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-30-2008
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,128
port scan is not usually a good thing , why do you need this ?
Reply With Quote
  #3 (permalink)  
Old 01-31-2008
Registered User
 

Join Date: Dec 2007
Posts: 11
Hi,

I need this for monitoring the server ports. If any of the port seems to be down then send the alert using mail or message
Reply With Quote
  #4 (permalink)  
Old 01-31-2008
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,128
I got this little script from Ghostdog74 from our forum, modified it a bit to suit my needs :
Code:
#!/usr/bin/python

import socket
import sys

if ( len(sys.argv) != 2 ):
    print "Usage: " + sys.argv[0] + " you must enter IP or FQDN as argument"
    sys.exit(1)

remote_host = sys.argv[1]

for remote_port in [21,22,23,80,139,139,389,443,445,3128,3306,3389]:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(20)
        try:
                sock.connect((remote_host, remote_port))
        except Exception,e:
                print "%d closed " % remote_port
        else:
                print "%d open" % remote_port
        sock.close()
- change the ports as you wish.
Implementing nmap for ports monitoring is also good idea.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0