# Path: beeswarm/drones/honeypot/capabilities/handlerbase.py
# class HandlerBase(object):
#     def __init__(self, options, workdir):
#         """
#         Base class that all capabilities must inherit from.
# 
#         :param sessions: a dictionary of Session objects.
#         :param options: a dictionary of configuration options.
#         :param workdir: the directory which contains files for this
#                         particular instance of Beeswarm
#         """
#         self.options = options
#         self.sessions = {}
#         if 'users' in options:
#             self.users = options['users']
#         else:
#             self.users = {}
#         # virtual file system shared by all capabilities
#         self.vfsystem = OSFS(os.path.join(workdir, 'data/vfs'))
#         # service port
#         self.port = int(options['port'])
# 
#     def create_session(self, address):
#         protocol = self.__class__.__name__.lower()
#         session = Session(address[0], address[1], protocol, self.users)
#         self.sessions[session.id] = session
#         session.destination_port = self.port
#         logger.debug(
#             'Accepted {0} session on port {1} from {2}:{3}. ({4})'.format(protocol, self.port, address[0],
#                                                                           address[1], str(session.id)))
#         logger.debug('Size of session list for {0}: {1}'.format(protocol, len(self.sessions)))
#         return session
# 
#     def close_session(self, session):
#         logger.debug('Closing sessions')
#         session.end_session()
#         if session.id in self.sessions:
#             del self.sessions[session.id]
#         else:
#             assert False
# 
#     def handle_session(self, socket, address):
#         raise Exception('Do no call base class!')


import base64
import logging
import time
import random
import smtpd
import asyncore
import asynchat
import mailbox
from smtpd import NEWLINE, EMPTYSTRING
from beeswarm.drones.honeypot.capabilities.handlerbase import HandlerBase
            transmit_msg = msg + '\r\n'
            self.session.transcript_outgoing(transmit_msg)
            asynchat.async_chat.push(self, transmit_msg)

    def close_quit(self):
        self.close_when_done()
        self.handle_close()

    def smtp_QUIT(self, arg):
        self.push('221 Bye')
        self.close_when_done()
        self.close_quit()

    def collect_incoming_data(self, data):
        self.session.transcript_incoming(data + self.terminator)
        self.__line.append(data)

    def smtp_EHLO(self, arg):
        if not arg:
            self.push('501 Syntax: HELO/EHLO hostname')
            return
        if self.__greeting:
            self.push('503 Duplicate HELO/EHLO')
        else:
            self.push('250-%s Hello %s' % (self.banner, arg))
            self.push('250-AUTH PLAIN LOGIN CRAM-MD5')
            self.push('250 EHLO')

    def smtp_AUTH(self, arg):


# Path: beeswarm/drones/honeypot/capabilities/handlerbase.py
# class HandlerBase(object):
#     def __init__(self, options, workdir):
#         """
#         Base class that all capabilities must inherit from.
# 
#         :param sessions: a dictionary of Session objects.
#         :param options: a dictionary of configuration options.
#         :param workdir: the directory which contains files for this
#                         particular instance of Beeswarm
#         """
#         self.options = options
#         self.sessions = {}
#         if 'users' in options:
#             self.users = options['users']
#         else:
#             self.users = {}
#         # virtual file system shared by all capabilities
#         self.vfsystem = OSFS(os.path.join(workdir, 'data/vfs'))
#         # service port
#         self.port = int(options['port'])
# 
#     def create_session(self, address):
#         protocol = self.__class__.__name__.lower()
#         session = Session(address[0], address[1], protocol, self.users)
#         self.sessions[session.id] = session
#         session.destination_port = self.port
#         logger.debug(
#             'Accepted {0} session on port {1} from {2}:{3}. ({4})'.format(protocol, self.port, address[0],
#                                                                           address[1], str(session.id)))
#         logger.debug('Size of session list for {0}: {1}'.format(protocol, len(self.sessions)))
#         return session
# 
#     def close_session(self, session):
#         logger.debug('Closing sessions')
#         session.end_session()
#         if session.id in self.sessions:
#             del self.sessions[session.id]
#         else:
#             assert False
# 
#     def handle_session(self, socket, address):
#         raise Exception('Do no call base class!')


# Path: beeswarm/drones/honeypot/capabilities/smtp.py
import base64
import logging
import time
import random
import smtpd
import asyncore
import asynchat
import mailbox
from smtpd import NEWLINE, EMPTYSTRING
from beeswarm.drones.honeypot.capabilities.handlerbase import HandlerBase

            transmit_msg = msg + '\r\n'
            self.session.transcript_outgoing(transmit_msg)
            asynchat.async_chat.push(self, transmit_msg)

    def close_quit(self):
        self.close_when_done()
        self.handle_close()

    def smtp_QUIT(self, arg):
        self.push('221 Bye')
        self.close_when_done()
        self.close_quit()

    def collect_incoming_data(self, data):
        self.session.transcript_incoming(data + self.terminator)
        self.__line.append(data)

    def smtp_EHLO(self, arg):
        if not arg:
            self.push('501 Syntax: HELO/EHLO hostname')
            return
        if self.__greeting:
            self.push('503 Duplicate HELO/EHLO')
        else:
            self.push('250-%s Hello %s' % (self.banner, arg))
            self.push('250-AUTH PLAIN LOGIN CRAM-MD5')
            self.push('250 EHLO')

    def smtp_AUTH(self, arg):


        if (self.plain_authenticating and self.login_pass_authenticating and