Example #1
0
 def extract_auth_entity(self, auth_data):
     username = auth_data.get('username', '')
     password = auth_data.get('password', '')
     authentication = Authentication(id=auth_data['id'], username=username, password=password,
                                     successful=auth_data['successful'],
                                     timestamp=isoformatToDatetime(auth_data['timestamp']))
     return authentication
Example #2
0
    def populate_honeybees(self):
        """ Populates the database with 3 Honeybees """

        db_session = database.get_session()
        for i in xrange(3):
            h = BaitSession(id=str(uuid.uuid4()),
                            timestamp=datetime.utcnow(),
                            received=datetime.utcnow(),
                            protocol='ssh',
                            destination_ip='1.2.3.4',
                            destination_port=1234,
                            source_ip='4.3.2.1',
                            source_port=4321,
                            did_connect=True,
                            did_login=False,
                            did_complete=True)
            a = Authentication(id=str(uuid.uuid4()),
                               username='******',
                               password='******',
                               successful=False,
                               timestamp=datetime.utcnow())
            h.authentication.append(a)
            db_session.add(h)

        db_session.commit()
 def extract_auth_entity(self, auth_data):
     username = auth_data.get('username', '')
     password = auth_data.get('password', '')
     authentication = Authentication(id=auth_data['id'],
                                     username=username,
                                     password=password,
                                     successful=auth_data['successful'],
                                     timestamp=datetime.strptime(
                                         auth_data['timestamp'],
                                         '%Y-%m-%dT%H:%M:%S.%f'))
     return authentication
Example #4
0
    def populate_sessions(self):
        """ Populates the database with 3 Sessions """
        db_session = database.get_session()
        for i in xrange(4):
            s = Session(id=str(uuid.uuid4()),
                        timestamp=datetime.utcnow(),
                        received=datetime.utcnow(),
                        protocol='telnet',
                        destination_ip='123.123.123.123',
                        destination_port=1234,
                        source_ip='12.12.12.12',
                        source_port=12345,
                        classification_id='asd')
            a = Authentication(id=str(uuid.uuid4()),
                               username='******',
                               password='******',
                               successful=False,
                               timestamp=datetime.utcnow())
            s.authentication.append(a)
            db_session.add(s)

        db_session.commit()
Example #5
0
def fill_dummy_data():
    """
    Populates the server data with dummy data to ease development.
    """

    db_session = database_setup.get_session()

    protocols = [('pop3', 110), ('ssh', 22), ('telnet', 23), ('ftp', 21),
                 ('http', 80)]
    source_ips = ('192.168.1.2', '192.168.2.3', '192.168.3.4', '192.168.4.5')

    honeypots = [Honeypot(id=str(uuid.uuid4()))]
    client = [Client(id=str(uuid.uuid4()))]
    sessions = []
    authentications = []

    while len(sessions) < 100:
        session = BaitSession(id=str(uuid.uuid4()),
                              timestamp=datetime.now(),
                              source_ip=random.choice(source_ips),
                              source_port=random.randint(1024, 65535),
                              destination_ip='4.3.2.1',
                              destination_port='1111')

        session.protocol, session.destination_port = random.choice(protocols)
        session.honeypot = random.choice(honeypots)
        session.client = random.choice(client)
        session.classification = db_session.query(Classification).filter(
            Classification.type == 'bait_session').one()

        username = ''.join(random.choice(string.lowercase) for x in range(8))
        password = ''.join(random.choice(string.lowercase) for x in range(8))
        authentication = Authentication(id=str(uuid.uuid4()),
                                        username=username,
                                        password=password)
        session.authentication.append(authentication)

        for x in range(10):
            data = ''.join(random.choice(string.lowercase) for x in range(15))
            direction = ('in', 'out')[x % 2]
            transcript = Transcript(timestamp=datetime.now(),
                                    direction=direction,
                                    data=data)
            session.transcript.append(transcript)

        authentications.append(authentication)
        sessions.append(session)

    while len(sessions) < 200:
        session = Session(id=str(uuid.uuid4()),
                          timestamp=datetime.now(),
                          source_ip=random.choice(source_ips),
                          source_port=random.randint(1024, 65535),
                          destination_ip='4.3.2.1',
                          destination_port='1111')

        session.protocol, session.destination_port = random.choice(protocols)
        session.honeypot = random.choice(honeypots)

        session.classification = db_session.query(Classification).filter(
            Classification.type == 'credentials_reuse').one()

        username = ''.join(random.choice(string.lowercase) for x in range(8))
        password = ''.join(random.choice(string.lowercase) for x in range(8))
        authentication = Authentication(id=str(uuid.uuid4()),
                                        username=username,
                                        password=password)
        session.authentication.append(authentication)

        authentications.append(authentication)
        sessions.append(session)

    db_session.add_all(authentications)
    db_session.add_all(sessions)
    db_session.add_all(honeypots)
    db_session.add_all(client)
    db_session.commit()