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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Open Ports on System aldowsary AIX 2 11-26-2006 01:38 AM
determining open ports matrixmadhan UNIX for Advanced & Expert Users 7 07-18-2005 04:17 AM
How To Open Ports in RedHat ? Sirius Linux 7 09-06-2003 09:48 AM
inet services, open ports etc sTorm UNIX for Dummies Questions & Answers 4 02-05-2002 10:29 AM
closing open ports LowOrderBit Security 10 09-28-2001 02:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-02-2005
MorchiuS MorchiuS is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 1
Question Check open ports every ...

Hello, i need a script (bash type maybe?..), which would check open ports on 127.0.0.1 and then compare open ports with "registered/allowed" port list and try to kill the program who uses unregistered ports. It would be great that script would be started lets say every 5 or 10 minutes.

You see i would like to have some kind of script which would allow me to control other users that they don't leave their psybnc, eggdrops and so on.

Thanks...
  #2 (permalink)  
Old 08-03-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
You could use the 'lsof' command to check what process is listening on a particular port, but it is a bit slow so you wont be able to run the script every 5 minutes (all the ports wont be scanned by then).
  #3 (permalink)  
Old 08-03-2005
vertigo23's Avatar
vertigo23 vertigo23 is offline
Registered User
  
 

Join Date: Jul 2005
Location: SF, CA
Posts: 73
Here ya go

Provided you have netcat installed, this should run pretty quickly.


Code:
for port in {1..65536}; do
    nc -zv 127.0.0.1 $port 2>&1
done | grep open

Netstat will also tell you what programs have open listening tcp ports. On a linux system, it would go something like this:


Code:
netstat -l -t -p


Last edited by vertigo23; 08-03-2005 at 05:23 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0