#IDS.py
Language:
PythonWritten by
doug on 2008-01-29 23:24:32
import socket, sys, datetime
from threading import Thread
ports = [21, 25, 81, 443, 8000, 8080, 31337, 3000] outputfilename = "";
class listenThread ( Thread ):
def __init__ ( self, port ):
self.port = port
Thread.__init__ ( self )
def run ( self ):
self.listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
self.listener.bind((socket.gethostname(), self.port));
self.listener.listen(5);
print "=[listening on " + socket.gethostname() + ":" + str(self.port) + "]=";
while 1:
(self.clientsocket, self.address) = self.listener.accept();
print "=[connection: " + self.address[0] + ":" + str(self.address[1]) + "]=";
outputfile = open(outputfilename, 'a')
outputfile.write(str(datetime.datetime.today().ctime()) + " >>>> =[connection: " + self.address[0] + ":" + str(self.address[1]) + "]=\n");
outputfile.close()
self.clientsocket.close();
j = 0
while j < len(ports):
listenThread(ports[j]).start()
j = j + 1
i = 1
j = 0
while i < len(sys.argv):
go = 1
j = 0
if sys.argv[i] == "-f":
i = i + 1
if i < len(sys.argv):
outputfilename = sys.argv[i]
else:
print "missing arguement after -f"
while j < len(ports):
if int(sys.argv[i]) == int(ports[j]):
go = 0
print "port " + str(ports[j]) + " is already been configured to open"
break
j = j + 1
if go:
listenThread(int(sys.argv[i])).start()
i = i + 1