2009-11-20 16:48:45 +01:00
|
|
|
# Copyright (c) 2009 Upi Tamminen <desaster@gmail.com>
|
|
|
|
# See the COPYRIGHT file for more information
|
|
|
|
|
2010-04-12 19:08:03 +02:00
|
|
|
import sys, os
|
2009-11-22 01:05:06 +01:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
import os, inspect
|
|
|
|
# this is when just running on win32
|
|
|
|
sys.path.insert(0, os.path.abspath(os.getcwd()))
|
|
|
|
# and this is when running as a service
|
2009-11-22 01:49:53 +01:00
|
|
|
#os.chdir(os.path.dirname(inspect.getfile(inspect.currentframe())))
|
|
|
|
|
2009-11-22 02:01:36 +01:00
|
|
|
from twisted.internet import reactor, defer
|
2009-11-22 01:49:53 +01:00
|
|
|
from twisted.application import internet, service
|
|
|
|
from twisted.cred import portal
|
|
|
|
from twisted.conch.ssh import factory, keys
|
2010-04-12 19:08:03 +02:00
|
|
|
|
|
|
|
if os.name == 'posix' and os.getuid() == 0:
|
|
|
|
print 'ERROR: You must not run kippo as root!'
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if not os.path.exists('kippo.cfg'):
|
|
|
|
print 'ERROR: kippo.cfg is missing!'
|
|
|
|
sys.exit(1)
|
|
|
|
|
2009-11-22 08:07:58 +01:00
|
|
|
from kippo.core import honeypot
|
|
|
|
from kippo.core.config import config
|
2009-11-19 16:24:57 +01:00
|
|
|
|
|
|
|
factory = honeypot.HoneyPotSSHFactory()
|
|
|
|
factory.portal = portal.Portal(honeypot.HoneyPotRealm())
|
|
|
|
|
|
|
|
pubKeyString, privKeyString = honeypot.getRSAKeys()
|
2010-04-14 11:38:29 +02:00
|
|
|
# This is only the initial password, the rest will be in data/pass.db
|
2009-11-21 12:07:26 +01:00
|
|
|
users = (
|
2009-11-21 13:58:52 +01:00
|
|
|
('root', '123456'),
|
2009-11-21 12:07:26 +01:00
|
|
|
)
|
|
|
|
factory.portal.registerChecker(honeypot.HoneypotPasswordChecker(users))
|
2009-11-19 16:24:57 +01:00
|
|
|
factory.publicKeys = {'ssh-rsa': keys.Key.fromString(data=pubKeyString)}
|
|
|
|
factory.privateKeys = {'ssh-rsa': keys.Key.fromString(data=privKeyString)}
|
|
|
|
|
|
|
|
application = service.Application('honeypot')
|
2009-11-22 07:56:30 +01:00
|
|
|
service = internet.TCPServer(
|
|
|
|
int(config().get('honeypot', 'ssh_port')), factory)
|
2009-11-19 16:24:57 +01:00
|
|
|
service.setServiceParent(application)
|
|
|
|
|
|
|
|
# vim: set ft=python sw=4 et:
|