<commit_before>import sys
from sqlalchemy import Column, Integer, String
#from sqlalchemy.ext.declarative import declarative_base
from HoneypotBase import Base

#Base = declarative_base()

class Plugin:

    ORM = {"table": {"table_name": "telnet",
                     "column":[{"name": "username", "type": "TEXT"},
                               {"name": "password", "type": "TEXT"},
                               {"name": "ip", "type": "TEXT"}]
                     }}


    class Telnet(Base):
        _tablename_ = 'telnet'
        id = Column(Integer, primary_key=True)
        username = Column(String)
        password =  Column(String)
        geo_ip =  Column(String)

    def _init_(self):
        # print "Module Loaded and waiting on run() command"
        self.geo_ip = None
        self.passwords = []
        self.count = 0
        self.username = ""
        self.PORT = 8888

    def run(self,passed_socket, address, session):
         # print("Port Number: " + passed_socket.getsockname()[0])
        if passed_socket:
            # need to sleep thread if no answer
            # for loop and try catch the timeout exception
            # while self.count < 3:
            # may have to save the timeout for the next iteration
            for i in range(0,3):
               # try catch
               passed_socket.settimeout(35)
                passed_socket.sendall("username:")
                self.username = passed_socket.recv(64)
                passed_socket.sendall("Password: ")
                password = passed_socket.recv(64)
                self.passwords.append(password)

                # if they take too long to enter password
                # session.add_all([User(username='', password=''),
                #                   User(username='', password='')])
                # session.commit()
                print 'Password : ' + password
                passed_socket.sendall("---Incorrect--\n")
                passed_socket.sendall("Password: ")
                self.count += 1
                record = Telnet(username= '<name>', password = '<password>')
                 session.add(record)
                 session.commit()
                 session.close()
            passed_socket.close()
            sys.exit(0)
        else:
            print "socket error"

    def get_port(self):
        return self.PORT
<commit_msg>Revert "test"<commit_after>import sys
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Plugin:

    ORM = {"table": {"table_name": "telnet",
                     "column":[{"name": "username", "type": "TEXT"},
                               {"name": "password", "type": "TEXT"},
                               {"name": "ip", "type": "TEXT"}]
                     }}


    class User(Base):
        _tablename_ = 'telnet'

        id = Column(Integer, primary_key=True)
        username = Column(String)
        password =  Column(String)
        geo_ip =  Column(String)

    def _init_(self):
        # print "Module Loaded and waiting on run() command"
        self.geo_ip = None
        self.passwords = []
        self.count = 0
        self.username = ""
        self.PORT = 8888

    def run(self,passed_socket, session):
         # print("Port Number: " + passed_socket.getsockname()[0])
        if passed_socket:
            # need to sleep thread if no answer
            # for loop and try catch the timeout exception
            # while self.count < 3:
            for i in range(0,3):
               # try catch
               passed_socket.settimeout(35)
                passed_socket.sendall("username:")
                self.username = passed_socket.recv(64)
                passed_socket.sendall("Password: ")
                password = passed_socket.recv(64)
                self.passwords.append(password)
               
                # if they take too long to enter password
                # session.add_all([User(username='', password=''),
                #                   User(username='', password='')])
                # session.commit()
                print 'Password : ' + password
                passed_socket.sendall("---Incorrect--\n")
                passed_socket.sendall("Password: ")
                self.count += 1
            passed_socket.close()
            sys.exit(0)
        else:
            print "socket error"

    def get_port(self):
        return self.PORT

{'fraction_non_alphanumeric': 0.11282394995531725, 'fraction_numerical': 0.007596067917783735, 'mean_word_length': 1.6059371362048893, 'pattern_counts': {'":': 18, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5415266', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1139, 'n_words': 290}