From 16989baa5ff639e8faa3d2f5faad61f1b5f2ab09 Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Fri, 8 Jan 2010 22:23:41 +0100 Subject: [PATCH] Temporary code to randomly insult user when vi is started multiple times --- aha/aha.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aha/aha.py b/aha/aha.py index 361bb77001d..1516de67dfd 100644 --- a/aha/aha.py +++ b/aha/aha.py @@ -2,7 +2,7 @@ #Core of the adaptive honeypot alternative # (c) Gerard Wagener #License GPL -import os,sys +import os,sys,random from pyinotify import * from ctypes import * KERNEL_OUT="/home/gerard/kernel/linux-2.6/out" @@ -22,7 +22,6 @@ class KERNEL_ERRORS(): self.evec = (EPERM,ENOENT,EIO,ENOMEM,EACESS,EFAULT,EPIPE,ETXTBSY) - class ReplyMessage(Structure): _fields_ = [ ("block" , c_int), ("exitcode" , c_int), ("substitue" ,c_int),("insult" , c_int) ] @@ -61,15 +60,21 @@ class KernelEvents(ProcessEvent): return msg def decision(self,filekey,msg): + insultmaxidx = 3 print msg try: command = msg['file'][0] print "Got command: ",command - if msg['file'][0] == '/usr/bin/vi': + if msg['file'][0] == '/usr/bin/bvi': self.create_message(filekey, block=1, exitcode=KERNEL_ERRORS.ENOMEM, insult = 0, substitue=0) return + if msg['file'][0] == '/usr/bin/vi': + # The index 0 is reserved + idx = random.randint(1,insultmaxidx) + self.create_message(filekey, block=0, exitcode=0, insult=idx, substitue=0) + return except KeyError,e: pass except IndexError,w: