Exemplo n.º 1
0
    def connectionMade(self, end_ip, end_port, honey_ip, honey_port, sensor_name):
        plugin_list = plugins.get_plugin_list(type='output')
        self.loaded_plugins = plugins.import_plugins(plugin_list, self.cfg)
        
        dt = self.getDateTime()
        self.sensor_name = sensor_name
        self.honey_ip = honey_ip
        self.honey_port = str(honey_port)
        self.end_ip = end_ip
        self.end_port = str(end_port)
        self.session_id = uuid.uuid4().hex        
        self.logLocation = self.cfg.get('folders', 'session_path') + "/" + self.sensor_name + "/"+ end_ip + "/"
        
        self.downloadFolder = self.logLocation + 'downloads/'

        for plugin in self.loaded_plugins:
            plugin_name = plugins.get_plugin_name(plugin)
            for plugin_server in self.plugin_servers:
                if plugin_server['name'] == plugin_name:
                    plugins.run_plugins_function([plugin], 'set_server', False, plugin_server['server'])
                    break
        
        country = self.cname(self.end_ip)
        if not country:
            country = ''

        session = self.connections.add_session(self.sensor_name, self.end_ip, self.end_port, dt, self.honey_ip, self.honey_port, self.session_id, self.logLocation, country)
        plugins.run_plugins_function(self.loaded_plugins, 'connection_made', True, session)
Exemplo n.º 2
0
    def commandEntered(self, channel_id, the_command, blocked=False):
        dt = self.getDateTime()
        command = self.connections.add_command(channel_id, dt, the_command, blocked)
        plugins.run_plugins_function(self.loaded_plugins, 'command_entered', True, command)
            
        the_commands_split = re.findall(r'(?:[^;&|<>()"\']|["\'](?:\\.|[^"\'])*[\'"])+', the_command)
        the_commands = []
        
        for command in the_commands_split:
            the_commands.extend(command.split('\n'))

        for command in the_commands:
            command = command.strip().rstrip()

            if self.cfg.get('download','active') == 'true':
                if command.startswith('wget '):
                    command = command[4:]
                    commandArgs = re.findall(r'(?:[^\s"]|"(?:\\.|[^"])*")+', command)
                    args, links = getopt.getopt(commandArgs, 'VhbdqvFcNS46xErkKmpHLnp:e:o:a:i:B:t:O:T:w:Q:P:U:l:A:R:D:I:X:', ['version','help','background','execute=','output-file=','append-output=','debug','quiet','verbose','report-speed=','input-file=','force-html','base=','config=','bind-address=','tries=','output-document=', 'backups=','continue','progress=','timestamping','no-use-server-timestamps','server-response','spider','timeout=','dns-timeout=','connect-timeout=','read-timeout=','limit-rate=','wait=','waitretry=', 'random-wait','no-proxy','quota=','no-dns-cache','restrict-file-names=','inet4-only','inet6-only','prefer-family=','retry-connrefused','user='******'password='******'ask-password','no-iri','local-encoding=','remote-encoding=','unlink','force-directories','protocol-directories','cut-dirs=','directory-prefix=','default-page=','adjust-extension','http-user='******'http-password='******'no-http-keep-alive','no-cache','no-cookies','load-cookies=','save-cookies=','keep-session-cookies','ignore-length','header=','max-redirect=','proxy-user='******'proxy-password='******'referer=','save-headers','user-agent=','post-data=','post-file=','method=','body-data=','body-file=','content-disposition','content-on-error','trust-server-names','auth-no-challenge','secure-protocol=','https-only','no-check-certificate','certificate=','certificate-type=','private-key=','private-key-type=','ca-certificate=','ca-directory=','random-file=','egd-file=','warc-file=','warc-header=','warc-max-size=','warc-cdx','warc-dedup=','no-warc-compression','no-warc-digests','no-warc-keep-log','warc-tempdir=','ftp-user='******'ftp-password='******'no-remove-listing','no-glob','no-passive-ftp','preserve-permissions','retr-symlinks','recursive','level=','delete-after','convert-links','backup-converted','mirror','page-requisites','strict-comments','accept=','reject=','accept-regex=','reject-regex=','regex-type=','domains=','exclude-domains=','follow-ftp','follow-tags=','ignore-tags=','ignore-case','span-hosts','relative','include-directories=','exclude-directories=','no-verbose','no-clobber','no-directories','no-host-directories','no-parent'])
                    username = ''
                    password = ''
                    for a in args:
                        if a[0] in ['--user', '--http-user', '--ftp-user']:
                            username = a[1]
                        if a[0] in ['--password', '--http-password', '--ftp-password']:
                            password = a[1]
                            
                    for l in links:
                        self.activeDownload(channel_id, l, username, password)
Exemplo n.º 3
0
 def connectionLost(self):
     log.msg(log.LRED, '[OUTPUT]', 'Lost Connection with the attacker: %s' % self.end_ip)
     
     dt = self.getDateTime()
     session = self.connections.set_session_close(self.session_id, dt)
     plugins.run_plugins_function(self.loaded_plugins, 'connection_lost', True, session)
     self.connections.del_session(self.session_id)
Exemplo n.º 4
0
    def file_downloaded(self, download):
        finished = False
        file_meta = ''

        if len(download) == 3:
            finished = download[1]
            file_meta = download[2]
            download = download[0]
        else:
            error = download[4]

        if finished:
            if file_meta != '':
                dt = self.get_date_time()
                channel_id, success, link, file, error = download

                download = self.connections.set_download_close(channel_id, dt, link, file, success, file_meta[0],
                                                               file_meta[1])
                plugins.run_plugins_function(self.loaded_plugins, 'download_finished', True, download)
        else:
            if error:
                log.msg(log.LRED, '[OUTPUT]', download)
            else:
                d = threads.deferToThread(self.get_file_meta, download)
                d.addCallback(self.file_downloaded)
Exemplo n.º 5
0
    def connection_made(self, end_ip, end_port, honey_ip, honey_port, sensor_name):
        plugin_list = plugins.get_plugin_list(plugin_type='output')
        self.loaded_plugins = plugins.import_plugins(plugin_list)

        dt = self.get_date_time()
        self.sensor_name = sensor_name
        self.honey_ip = honey_ip
        self.honey_port = str(honey_port)
        self.end_ip = end_ip
        self.end_port = str(end_port)
        self.session_id = uuid.uuid4().hex
        self.logLocation = self.cfg.get(['folders', 'session_path']) + "/" + self.sensor_name + "/" + end_ip + "/"

        self.downloadFolder = self.logLocation + 'downloads/'

        for plugin in self.loaded_plugins:
            plugin_name = plugins.get_plugin_name(plugin)
            for plugin_server in self.plugin_servers:
                if plugin_server['name'] == plugin_name:
                    plugins.run_plugins_function([plugin], 'set_server', False, plugin_server['server'])
                    break

        country = self.cname(self.end_ip)
        if not country:
            country = ''

        session = self.connections.add_session(self.sensor_name, self.end_ip, self.end_port, dt, self.honey_ip,
                                               self.honey_port, self.session_id, self.logLocation, country)
        plugins.run_plugins_function(self.loaded_plugins, 'connection_made', True, session)
Exemplo n.º 6
0
    def login_failed(self, username, password):
        dt = self.get_date_time()

        auth = self.connections.add_auth(self.session_id, dt, username,
                                         password, False, False)
        plugins.run_plugins_function(self.loaded_plugins, 'login_failed', True,
                                     auth)
Exemplo n.º 7
0
 def connection_lost(self):
     self.server.disconnected = True
     if self.networkingSetup:
         self.server.net.removeNetworking(self.server.factory.connections.connections)
     
     if self.auth_plugin:
         if self.server.clientConnected:
             plugins.run_plugins_function(self.auth_plugin, 'connection_lost', True, self.conn_details)
Exemplo n.º 8
0
    def connection_lost(self):
        self.server.disconnected = True
        if self.networkingSetup:
            self.server.net.remove_networking(self.server.factory.connections.connections)

        if self.auth_plugin is not None:
            if self.server.clientConnected:
                plugins.run_plugins_function([self.auth_plugin], 'connection_lost', True, self.conn_details)
Exemplo n.º 9
0
 def packet_logged(self, direction, packet, payload):
     if self.cfg.get('packet_logging', 'enabled') == 'true':
         dt = self.getDateTime()
         self.makeSessionFolder()
         sensor, session = self.connections.get_session(self.session_id)
         session_copy = self.connections.return_session(sensor, session)
         session_copy['session']['packet'] = {'date_time':dt, 'direction':direction, 'packet':packet, 'payload':payload}
         plugins.run_plugins_function(self.loaded_plugins, 'packet_logged', True, session_copy)
Exemplo n.º 10
0
    def login_successful(self, username, password, spoofed):
        dt = self.get_date_time()
        self.make_session_folder()

        auth = self.connections.add_auth(self.session_id, dt, username,
                                         password, True, spoofed)
        plugins.run_plugins_function(self.loaded_plugins, 'login_successful',
                                     True, auth)
Exemplo n.º 11
0
 def packet_logged(self, direction, packet, payload):
     if self.cfg.getboolean(['packet_logging', 'enabled']):
         dt = self.get_date_time()
         self.make_session_folder()
         sensor, session = self.connections.get_session(self.session_id)
         session_copy = self.connections.return_session(sensor, session)
         session_copy['session']['packet'] = {'date_time': dt, 'direction': direction, 'packet': packet,
                                              'payload': payload}
         plugins.run_plugins_function(self.loaded_plugins, 'packet_logged', True, session_copy)
Exemplo n.º 12
0
    def connectionLost(self):
        log.msg(log.LRED, '[OUTPUT]',
                'Lost Connection with the attacker: %s' % self.end_ip)

        dt = self.getDateTime()
        session = self.connections.set_session_close(self.session_id, dt)
        plugins.run_plugins_function(self.loaded_plugins, 'connection_lost',
                                     True, session)
        self.connections.del_session(self.session_id)
Exemplo n.º 13
0
    def connection_lost(self):
        log.msg(log.LRED, '[OUTPUT]', 'Lost Connection with the attacker: %s' % self.end_ip)

        dt = self.get_date_time()

        channels = self.connections.get_channels(self.session_id)
        if channels is not None:
            for channel in channels:
                if 'end_time' not in channel:
                    self._channel_closed(channel['uuid'])

        session = self.connections.set_session_close(self.session_id, dt)
        plugins.run_plugins_function(self.loaded_plugins, 'connection_lost', True, session)
        self.connections.del_session(self.session_id)
Exemplo n.º 14
0
    def __init__(self):
        self.ourVersionString = self.cfg.get('honeypot', 'ssh_banner')
        if self.ourVersionString == '':
            log.msg(log.LPURPLE, '[SERVER]',
                    'Acquiring SSH Version String from honey_ip:honey_port')
            clientFactory = client.HonsshSlimClientFactory()
            clientFactory.server = self

            reactor.connectTCP(
                self.cfg.get('honeypot-static', 'honey_ip'),
                int(self.cfg.get('honeypot-static', 'honey_port')),
                clientFactory)
        else:
            log.msg(
                log.LPURPLE, '[SERVER]',
                'Using ssh_banner for SSH Version String: ' +
                self.ourVersionString)

        plugin_list = plugins.get_plugin_list(type='output')
        loaded_plugins = plugins.import_plugins(plugin_list, self.cfg)
        for plugin in loaded_plugins:
            plugin_server = plugins.run_plugins_function([plugin],
                                                         'start_server', False)
            plugin_name = plugins.get_plugin_name(plugin)
            self.plugin_servers.append({
                'name': plugin_name,
                'server': plugin_server
            })

        if self.ourVersionString != '':
            log.msg(log.LGREEN, '[HONSSH]',
                    'HonSSH Boot Sequence Complete - Ready for attacks!')
Exemplo n.º 15
0
    def __init__(self):
        self.cfg = Config.getInstance()
        self.otherVersionString = ''
        self.connections = connections.Connections()
        self.plugin_servers = []
        self.ourVersionString = self.cfg.get(['honeypot', 'ssh_banner'])

        if len(self.ourVersionString) > 0:
            log.msg(log.LPURPLE, '[SERVER]', 'Using ssh_banner for SSH Version String: ' + self.ourVersionString)
        else:
            if self.cfg.getboolean(['honeypot-static', 'enabled']):
                log.msg(log.LPURPLE, '[SERVER]', 'Acquiring SSH Version String from honey_ip:honey_port')
                client_factory = client.HonsshSlimClientFactory()
                client_factory.server = self

                reactor.connectTCP(self.cfg.get(['honeypot-static', 'honey_ip']),
                                   int(self.cfg.get(['honeypot-static', 'honey_port'])), client_factory)
            elif self.cfg.getboolean(['honeypot-docker', 'enabled']):
                log.msg(log.LRED, '[SERVER][ERR]', 'You need to configure the ssh_banner for docker manually!')

        plugin_list = plugins.get_plugin_list()
        loaded_plugins = plugins.import_plugins(plugin_list)
        for plugin in loaded_plugins:
            plugin_server = plugins.run_plugins_function([plugin], 'start_server', False)
            plugin_name = plugins.get_plugin_name(plugin)
            self.plugin_servers.append({'name': plugin_name, 'server': plugin_server})

        if self.ourVersionString != '':
            log.msg(log.LGREEN, '[HONSSH]', 'HonSSH Boot Sequence Complete - Ready for attacks!')
Exemplo n.º 16
0
 def get_conn_details(self):
     plugin_list = plugins.get_plugin_list(type='honeypot')
     self.auth_plugin = plugins.import_auth_plugins(self.name, plugin_list, self.cfg)
     if self.auth_plugin == None:
         log.msg(log.LRED, '[' + self.name + ']', 'NO PLUGIN ENABLED FOR ' + self.name)
         return {'success':False}
     else:
         return plugins.run_plugins_function(self.auth_plugin, 'get_' + self.name.lower() + '_details', False, self.conn_details)
Exemplo n.º 17
0
    def connection_lost(self):
        if not self.server.post_auth_started:
            self.server.disconnected = True
            if self.networkingSetup:
                self.server.net.removeNetworking(
                    self.server.factory.connections.connections)

            if self.auth_plugin:
                if self.server.clientConnected:
                    plugins.run_plugins_function(self.auth_plugin,
                                                 'connection_lost', True,
                                                 self.conn_details)
        else:
            if self.auth_plugin:
                plugins.run_plugins_function(self.auth_plugin,
                                             'connection_lost', True,
                                             self.conn_details)
Exemplo n.º 18
0
    def validate_config(self):
        plugin_list = plugins.get_plugin_list()
        loaded_plugins = plugins.import_plugins(plugin_list)
        # TODO: Is this right?
        valid = plugins.run_plugins_function(loaded_plugins, 'validate_config',
                                             False)

        # Check prop exists and is an IP address
        props = [['honeypot', 'ssh_addr'], ['honeypot', 'client_addr']]
        for prop in props:
            if not self.check_exist(prop, validation.check_valid_ip):
                valid = False

        # Check prop exists and is a port number
        props = [['honeypot', 'ssh_port']]
        for prop in props:
            if not self.check_exist(prop, validation.check_valid_port):
                valid = False

        # Check prop exists
        props = [['honeypot', 'public_key'], ['honeypot', 'private_key'],
                 ['honeypot', 'public_key_dsa'],
                 ['honeypot', 'private_key_dsa'], ['folders', 'log_path'],
                 ['folders', 'session_path']]
        for prop in props:
            if not self.check_exist(prop):
                valid = False

        # Check prop exists and is true/false
        props = [['advNet', 'enabled'], ['interact', 'enabled'],
                 ['spoof', 'enabled'], ['download', 'passive'],
                 ['download', 'active'], ['hp-restrict', 'disable_publicKey'],
                 ['hp-restrict', 'disable_x11'],
                 ['hp-restrict', 'disable_sftp'],
                 ['hp-restrict', 'disable_exec'],
                 ['hp-restrict', 'disable_port_forwarding'],
                 ['packet_logging', 'enabled']]
        for prop in props:
            if not self.check_exist(prop, validation.check_valid_boolean):
                valid = False

        # If interact is enabled check it's config
        if self.getboolean(['interact', 'enabled']):
            prop = ['interact', 'interface']
            if not self.check_exist(prop, validation.check_valid_ip):
                valid = False

            prop = ['interact', 'port']
            if not self.check_exist(prop, validation.check_valid_port):
                valid = False

        # If spoof is enabled check it's config
        if self.getboolean(['spoof', 'enabled']):
            prop = ['spoof', 'users_conf']
            if not self.check_exist(prop):
                valid = False

        return valid
Exemplo n.º 19
0
def validateConfig(cfg):
    validConfig = True

    plugin_list = plugins.get_plugin_list()
    loaded_plugins = plugins.import_plugins(plugin_list, cfg)
    #TODO: Is this right?
    validConfig = plugins.run_plugins_function(loaded_plugins,
                                               'validate_config', False)

    #Check prop exists and is an IP address
    props = [['honeypot', 'ssh_addr'], ['honeypot', 'client_addr']]
    for prop in props:
        if not checkExist(cfg, prop) or not checkValidIP(cfg, prop):
            validConfig = False

    #Check prop exists and is a port number
    props = [['honeypot', 'ssh_port']]
    for prop in props:
        if not checkExist(cfg, prop) or not checkValidPort(cfg, prop):
            validConfig = False

    #Check prop exists
    props = [['honeypot', 'public_key'], ['honeypot', 'private_key'],
             ['honeypot', 'public_key_dsa'], ['honeypot', 'private_key_dsa'],
             ['folders', 'log_path'], ['folders', 'session_path']]
    for prop in props:
        if not checkExist(cfg, prop):
            validConfig = False

    #Check prop exists and is true/false
    props = [['advNet', 'enabled'], ['interact', 'enabled'],
             ['spoof', 'enabled'], ['download', 'passive'],
             ['download', 'active'], ['hp-restrict', 'disable_publicKey'],
             ['hp-restrict', 'disable_x11'], ['hp-restrict', 'disable_sftp'],
             ['hp-restrict', 'disable_exec'],
             ['hp-restrict', 'disable_port_forwarding'],
             ['packet_logging', 'enabled']]
    for prop in props:
        if not checkExist(cfg, prop) or not checkValidBool(cfg, prop):
            validConfig = False

    #If interact is enabled check it's config
    if cfg.get('interact', 'enabled') == 'true':
        prop = ['interact', 'interface']
        if not checkExist(cfg, prop) or not checkValidIP(cfg, prop):
            validConfig = False
        prop = ['interact', 'port']
        if not checkExist(cfg, prop) or not checkValidPort(cfg, prop):
            validConfig = False

    #If spoof is enabled check it's config
    if cfg.get('spoof', 'enabled') == 'true':
        prop = ['spoof', 'users_conf']
        if not checkExist(cfg, prop):
            validConfig = False

    return validConfig
Exemplo n.º 20
0
 def get_conn_details(self):
     if self.auth_plugin is None:
         log.msg(log.LRED, '[' + self.name + ']',
                 'NO AUTH PLUGIN SET FOR ' + self.name)
         return {'success': False}
     else:
         return plugins.run_plugins_function([self.auth_plugin], 'get_' +
                                             self.name.lower() + '_details',
                                             False, self.conn_details)
Exemplo n.º 21
0
 def get_conn_details(self):
     if self.auth_plugin is None:
         log.msg(log.LRED, '[' + self.name + ']',
                 'NO AUTH PLUGIN SET FOR ' + self.name)
         return {'success': False}
     else:
         return plugins.run_plugins_function(
             [self.auth_plugin], 'get_' + self.name.lower() + '_details',
             False, self.conn_details, self.server
         )  # NOTE PAUL: Added server to detect if we're disconnected
Exemplo n.º 22
0
 def get_conn_details(self):
     plugin_list = plugins.get_plugin_list(type='honeypot')
     self.auth_plugin = plugins.import_auth_plugins(self.name, plugin_list,
                                                    self.cfg)
     if self.auth_plugin == None:
         log.msg(log.LRED, '[' + self.name + ']',
                 'NO PLUGIN ENABLED FOR ' + self.name)
         return {'success': False}
     else:
         return plugins.run_plugins_function(
             self.auth_plugin, 'get_' + self.name.lower() + '_details',
             False, self.conn_details)
Exemplo n.º 23
0
 def fileDownloaded(self, input):
     finished = False
     file_meta = ''
     if len(input) == 3:
         finished = input[1]
         file_meta = input[2]
         input = input[0]
     else:
         error = input[4]
     if finished:
         if file_meta != '':
             dt = self.getDateTime()
             channel_id, success, link, file, error = input
             
             download = self.connections.set_download_close(channel_id, dt, link, file, success, file_meta[0], file_meta[1])
             plugins.run_plugins_function(self.loaded_plugins, 'download_finished', True, download)
     else:
         if error:
             log.msg(log.LRED, '[OUTPUT]', input)
         else:
             d = threads.deferToThread(self.get_file_meta, input)
             d.addCallback(self.fileDownloaded)
Exemplo n.º 24
0
def validateConfig(cfg):
    validConfig = True
    
    plugin_list = plugins.get_plugin_list()
    loaded_plugins = plugins.import_plugins(plugin_list, cfg)
    #TODO: Is this right?
    validConfig = plugins.run_plugins_function(loaded_plugins, 'validate_config', False)
    
    #Check prop exists and is an IP address
    props = [['honeypot','ssh_addr'], ['honeypot','client_addr']]
    for prop in props:
        if not checkExist(cfg,prop) or not checkValidIP(cfg,prop):
            validConfig = False
        
    #Check prop exists and is a port number
    props = [['honeypot','ssh_port']]
    for prop in props:
        if not checkExist(cfg,prop) or not checkValidPort(cfg,prop):
            validConfig = False
        
    #Check prop exists
    props = [['honeypot','public_key'], ['honeypot','private_key'], ['honeypot','public_key_dsa'], ['honeypot','private_key_dsa'], ['folders','log_path'], ['folders','session_path']]
    for prop in props:
        if not checkExist(cfg,prop):
            validConfig = False
            
    #Check prop exists and is true/false
    props = [['advNet','enabled'], ['interact','enabled'], ['spoof','enabled'], ['download','passive'], ['download','active'], ['hp-restrict', 'disable_publicKey'], ['hp-restrict', 'disable_x11'], ['hp-restrict', 'disable_sftp'], ['hp-restrict', 'disable_exec'], ['hp-restrict', 'disable_port_forwarding'], ['packet_logging', 'enabled']]
    for prop in props:
        if not checkExist(cfg,prop) or not checkValidBool(cfg, prop):
            validConfig = False
    
    #If interact is enabled check it's config
    if cfg.get('interact','enabled') == 'true':
        prop = ['interact','interface']
        if not checkExist(cfg,prop) or not checkValidIP(cfg,prop):
            validConfig = False            
        prop = ['interact','port']
        if not checkExist(cfg,prop) or not checkValidPort(cfg,prop):
            validConfig = False    
    
    #If spoof is enabled check it's config
    if cfg.get('spoof','enabled') == 'true':
        prop = ['spoof','users_conf']
        if not checkExist(cfg,prop):
            validConfig = False

    return validConfig
Exemplo n.º 25
0
 def __init__(self):
     self.ourVersionString = self.cfg.get('honeypot', 'ssh_banner')
     if self.ourVersionString == '':
         log.msg(log.LPURPLE, '[SERVER]', 'Acquiring SSH Version String from honey_ip:honey_port')
         clientFactory = client.HonsshSlimClientFactory()
         clientFactory.server = self
         
         reactor.connectTCP(self.cfg.get('honeypot-static', 'honey_ip'), int(self.cfg.get('honeypot-static', 'honey_port')), clientFactory)
     else:
         log.msg(log.LPURPLE, '[SERVER]', 'Using ssh_banner for SSH Version String: ' + self.ourVersionString)
     
     plugin_list = plugins.get_plugin_list(type='output')
     loaded_plugins = plugins.import_plugins(plugin_list, self.cfg)
     for plugin in loaded_plugins:
         plugin_server = plugins.run_plugins_function([plugin], 'start_server', False)
         plugin_name = plugins.get_plugin_name(plugin)
         self.plugin_servers.append({'name':plugin_name, 'server':plugin_server})
         
     if self.ourVersionString != '':    
         log.msg(log.LGREEN, '[HONSSH]', 'HonSSH Boot Sequence Complete - Ready for attacks!')
Exemplo n.º 26
0
 def loginSuccessful(self, username, password, spoofed):
     dt = self.getDateTime()
     self.makeSessionFolder()
     
     auth = self.connections.add_auth(self.session_id, dt, username, password, True, spoofed)
     plugins.run_plugins_function(self.loaded_plugins, 'login_successful', True, auth)
Exemplo n.º 27
0
 def _channel_closed(self, channel_id):
     dt = self.get_date_time()
     channel = self.connections.set_channel_close(channel_id, dt)
     plugins.run_plugins_function(self.loaded_plugins, 'channel_closed', True, channel)
Exemplo n.º 28
0
 def downloadStarted(self, channel_id, link):
     dt = self.getDateTime()
     download = self.connections.add_download(channel_id, dt, link)
     plugins.run_plugins_function(self.loaded_plugins, 'download_started', True, download)
Exemplo n.º 29
0
 def channel_opened(self, channel_id, channel_name):
     dt = self.get_date_time()
     channel = self.connections.add_channel(self.session_id, channel_name, dt, channel_id)
     plugins.run_plugins_function(self.loaded_plugins, 'channel_opened', True, channel)
Exemplo n.º 30
0
    def command_entered(self, channel_id, the_command, blocked=False):
        dt = self.get_date_time()
        command = self.connections.add_command(channel_id, dt, the_command, blocked)
        plugins.run_plugins_function(self.loaded_plugins, 'command_entered', True, command)

        the_commands_split = re.findall(r'(?:[^;&|<>()"\']|["\'](?:\\.|[^"\'])*[\'"])+', the_command)
        the_commands = []

        for command in the_commands_split:
            the_commands.extend(command.split('\n'))

        for command in the_commands:
            command = command.strip().rstrip()

            if self.cfg.getboolean(['download', 'active']):
                if command.startswith('wget '):
                    command = command[4:]
                    command_args = re.findall(r'(?:[^\s"]|"(?:\\.|[^"])*")+', command)
                    args, links = getopt.getopt(command_args,
                                                'VhbdqvFcNS46xErkKmpHLnp:e:o:a:i:B:t:O:T:w:Q:P:U:l:A:R:D:I:X:',
                                                ['version', 'help', 'background', 'execute=', 'output-file=',
                                                 'append-output=', 'debug', 'quiet', 'verbose', 'report-speed=',
                                                 'input-file=', 'force-html', 'base=', 'config=', 'bind-address=',
                                                 'tries=', 'output-document=', 'backups=', 'continue', 'progress=',
                                                 'timestamping', 'no-use-server-timestamps', 'server-response',
                                                 'spider', 'timeout=', 'dns-timeout=', 'connect-timeout=',
                                                 'read-timeout=', 'limit-rate=', 'wait=', 'waitretry=', 'random-wait',
                                                 'no-proxy', 'quota=', 'no-dns-cache', 'restrict-file-names=',
                                                 'inet4-only', 'inet6-only', 'prefer-family=', 'retry-connrefused',
                                                 'user='******'password='******'ask-password', 'no-iri', 'local-encoding=',
                                                 'remote-encoding=', 'unlink', 'force-directories',
                                                 'protocol-directories', 'cut-dirs=', 'directory-prefix=',
                                                 'default-page=', 'adjust-extension', 'http-user='******'http-password='******'no-http-keep-alive', 'no-cache', 'no-cookies', 'load-cookies=',
                                                 'save-cookies=', 'keep-session-cookies', 'ignore-length', 'header=',
                                                 'max-redirect=', 'proxy-user='******'proxy-password='******'referer=',
                                                 'save-headers', 'user-agent=', 'post-data=', 'post-file=', 'method=',
                                                 'body-data=', 'body-file=', 'content-disposition', 'content-on-error',
                                                 'trust-server-names', 'auth-no-challenge', 'secure-protocol=',
                                                 'https-only', 'no-check-certificate', 'certificate=',
                                                 'certificate-type=', 'private-key=', 'private-key-type=',
                                                 'ca-certificate=', 'ca-directory=', 'random-file=', 'egd-file=',
                                                 'warc-file=', 'warc-header=', 'warc-max-size=', 'warc-cdx',
                                                 'warc-dedup=', 'no-warc-compression', 'no-warc-digests',
                                                 'no-warc-keep-log', 'warc-tempdir=', 'ftp-user='******'ftp-password='******'no-remove-listing', 'no-glob', 'no-passive-ftp',
                                                 'preserve-permissions', 'retr-symlinks', 'recursive', 'level=',
                                                 'delete-after', 'convert-links', 'backup-converted', 'mirror',
                                                 'page-requisites', 'strict-comments', 'accept=', 'reject=',
                                                 'accept-regex=', 'reject-regex=', 'regex-type=', 'domains=',
                                                 'exclude-domains=', 'follow-ftp', 'follow-tags=', 'ignore-tags=',
                                                 'ignore-case', 'span-hosts', 'relative', 'include-directories=',
                                                 'exclude-directories=', 'no-verbose', 'no-clobber', 'no-directories',
                                                 'no-host-directories', 'no-parent'])
                    username = ''
                    password = ''
                    for a in args:
                        if a[0] in ['--user', '--http-user', '--ftp-user']:
                            username = a[1]
                        if a[0] in ['--password', '--http-password', '--ftp-password']:
                            password = a[1]

                    for l in links:
                        self.active_download(channel_id, l, username, password)
Exemplo n.º 31
0
 def download_started(self, channel_id, link):
     dt = self.get_date_time()
     download = self.connections.add_download(channel_id, dt, link)
     plugins.run_plugins_function(self.loaded_plugins, 'download_started', True, download)
Exemplo n.º 32
0
 def channelClosed(self, channel):
     dt = self.getDateTime()
     channel = self.connections.set_channel_close(channel.uuid, dt,
                                                  channel.ttylog_file)
     plugins.run_plugins_function(self.loaded_plugins, 'channel_closed',
                                  True, channel)
Exemplo n.º 33
0
 def channelOpened(self, channel_id, channel_name):
     dt = self.getDateTime()
     channel = self.connections.add_channel(self.session_id, channel_name, dt, channel_id)
     plugins.run_plugins_function(self.loaded_plugins, 'channel_opened', True, channel)
Exemplo n.º 34
0
 def setVersion(self, version):
     session = self.connections.set_client(self.session_id, version)
     plugins.run_plugins_function(self.loaded_plugins, 'set_client', True, session)
Exemplo n.º 35
0
 def channelClosed(self, channel):
     dt = self.getDateTime()
     channel = self.connections.set_channel_close(channel.uuid, dt, channel.ttylog_file)
     plugins.run_plugins_function(self.loaded_plugins, 'channel_closed', True, channel)
Exemplo n.º 36
0
 def port_forwarding_requested(self, conn_details):
     plugins.run_plugins_function(self.loaded_plugins,
                                  'port_forwarding_requested', True,
                                  conn_details)
Exemplo n.º 37
0
 def set_version(self, version):
     session = self.connections.set_client(self.session_id, version)
     plugins.run_plugins_function(self.loaded_plugins, 'set_client', True, session)
Exemplo n.º 38
0
    def loginFailed(self, username, password):
        dt = self.getDateTime()

        auth = self.connections.add_auth(self.session_id, dt, username, password, False, False)        
        plugins.run_plugins_function(self.loaded_plugins, 'login_failed', True, auth)