* Added the ability to add new root passwords to data/pass.db (anydbm). This

is utilized by the passwd command.
 * New kippo.cfg entries: data_path & txtcmds_path


git-svn-id: https://kippo.googlecode.com/svn/trunk@103 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
desaster
2010-04-14 09:26:04 +00:00
parent bcab01d492
commit 7f8f5d2ed9
3 changed files with 27 additions and 9 deletions

View File

@@ -4,6 +4,8 @@ hostname = sales
log_path = log log_path = log
download_path = dl download_path = dl
contents_path = honeyfs contents_path = honeyfs
data_path = data
txtcmds_path = txtcmds
filesystem_file = fs.pickle filesystem_file = fs.pickle
public_key = public.key public_key = public.key
private_key = private.key private_key = private.key

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2009 Upi Tamminen <desaster@gmail.com> # Copyright (c) 2009 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information # See the COPYRIGHT file for more information
import os, time import os, time, anydbm
from kippo.core.honeypot import HoneyPotCommand from kippo.core.honeypot import HoneyPotCommand
from kippo.core.fs import * from kippo.core.fs import *
from twisted.internet import reactor from twisted.internet import reactor
@@ -23,8 +23,8 @@ class command_cat(HoneyPotCommand):
return return
f = self.fs.getfile(path) f = self.fs.getfile(path)
realfile = self.fs.realfile(f, realfile = self.fs.realfile(f, '%s/%s' % \
'%s/%s' % (config().get('honeypot', 'contents_path'), path)) (self.honeypot.env.cfg.get('honeypot', 'contents_path'), path))
if realfile: if realfile:
f = file(realfile, 'rb') f = file(realfile, 'rb')
self.write(f.read()) self.write(f.read())
@@ -235,14 +235,19 @@ class command_passwd(HoneyPotCommand):
def finish(self): def finish(self):
self.honeypot.password_input = False self.honeypot.password_input = False
self.writeln('Sorry, passwords do not match')
self.writeln( data_path = self.honeypot.env.cfg.get('honeypot', 'data_path')
'passwd: Authentication information cannot be recovered') passdb = anydbm.open('%s/pass.db' % (data_path,), 'c')
self.writeln('passwd: password unchanged') if len(self.password) and self.password not in passdb:
passdb[self.password] = None
passdb.close()
self.writeln('passwd: password updated successfully')
self.exit() self.exit()
def lineReceived(self, line): def lineReceived(self, line):
print 'INPUT (passwd):', line print 'INPUT (passwd):', line
self.password = line.strip()
self.callbacks.pop(0)() self.callbacks.pop(0)()
commands['/usr/bin/passwd'] = command_passwd commands['/usr/bin/passwd'] = command_passwd

View File

@@ -11,7 +11,7 @@ from twisted.internet import reactor, protocol, defer
from twisted.python import failure, log from twisted.python import failure, log
from zope.interface import implements from zope.interface import implements
from copy import deepcopy, copy from copy import deepcopy, copy
import sys, os, random, pickle, time, stat, shlex import sys, os, random, pickle, time, stat, shlex, anydbm
from kippo.core import ttylog, fs from kippo.core import ttylog, fs
from kippo.core.config import config from kippo.core.config import config
@@ -96,6 +96,7 @@ class HoneyPotShell(object):
self.honeypot.setTypeoverMode() self.honeypot.setTypeoverMode()
obj.start() obj.start()
else: else:
print 'Command not found: %s' % (cmd,)
if len(i): if len(i):
self.honeypot.writeln('bash: %s: command not found' % cmd) self.honeypot.writeln('bash: %s: command not found' % cmd)
if len(self.cmdpending): if len(self.cmdpending):
@@ -177,7 +178,8 @@ class HoneyPotProtocol(recvline.HistoricRecvLine):
if self.fs.exists(i): if self.fs.exists(i):
path = i path = i
break break
txt = os.path.abspath('txtcmds/%s' % (path,)) txt = os.path.abspath('%s/%s' % \
(self.env.cfg.get('honeypot', 'txtcmds_path'), path))
if os.path.exists(txt): if os.path.exists(txt):
return self.txtcmd(txt) return self.txtcmd(txt)
if path in self.commands: if path in self.commands:
@@ -326,7 +328,16 @@ class HoneypotPasswordChecker:
self.users = users self.users = users
def requestAvatarId(self, credentials): def requestAvatarId(self, credentials):
data_path = config().get('honeypot', 'data_path')
passdb = anydbm.open('%s/pass.db' % (data_path,), 'c')
success = False
if (credentials.username, credentials.password) in self.users: if (credentials.username, credentials.password) in self.users:
success = True
elif credentials.username == 'root' and \
credentials.password in passdb:
success = True
passdb.close()
if success:
print 'login attempt [%s/%s] succeeded' % \ print 'login attempt [%s/%s] succeeded' % \
(credentials.username, credentials.password) (credentials.username, credentials.password)
return defer.succeed(credentials.username) return defer.succeed(credentials.username)