当前位置: 首页>>代码示例>>Python>>正文


Python CONFIG.getboolean方法代码示例

本文整理汇总了Python中cowrie.core.config.CONFIG.getboolean方法的典型用法代码示例。如果您正苦于以下问题:Python CONFIG.getboolean方法的具体用法?Python CONFIG.getboolean怎么用?Python CONFIG.getboolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cowrie.core.config.CONFIG的用法示例。


在下文中一共展示了CONFIG.getboolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self, username, server):
        avatar.ConchUser.__init__(self)
        self.username = username.decode('utf-8')
        self.server = server

        self.channelLookup[b'session'] = sshsession.HoneyPotSSHSession

        try:
            pwentry = pwd.Passwd().getpwnam(self.username)
            self.uid = pwentry['pw_uid']
            self.gid = pwentry['pw_gid']
            self.home = pwentry['pw_dir']
        except:
            self.uid = 1001
            self.gid = 1001
            self.home = '/home'

        # SFTP support enabled only when option is explicitly set
        try:
            if CONFIG.getboolean('ssh', 'sftp_enabled') == True:
                self.subsystemLookup[b'sftp'] = conchfiletransfer.FileTransferServer
        except ValueError as e:
            pass

        # SSH forwarding disabled only when option is explicitly set
        self.channelLookup[b'direct-tcpip'] = forwarding.cowrieOpenConnectForwardingClient
        try:
            if CONFIG.getboolean('ssh', 'forwarding') == False:
                del self.channelLookup[b'direct-tcpip']
        except:
            pass
开发者ID:davegermiquet,项目名称:cowrie,代码行数:33,代码来源:avatar.py

示例2: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self, username, server):
        avatar.ConchUser.__init__(self)
        self.username = username.decode('utf-8')
        self.server = server

        self.channelLookup[b'session'] = sshsession.HoneyPotSSHSession

        try:
            pwentry = pwd.Passwd().getpwnam(self.username)
            self.temporary = False
        except KeyError:
            pwentry = pwd.Passwd().setpwentry(self.username)
            self.temporary = True

        self.uid = pwentry['pw_uid']
        self.gid = pwentry['pw_gid']
        self.home = pwentry['pw_dir']

        # SFTP support enabled only when option is explicitly set
        if CONFIG.getboolean('ssh', 'sftp_enabled', fallback=False):
            self.subsystemLookup[b'sftp'] = conchfiletransfer.FileTransferServer

        # SSH forwarding disabled only when option is explicitly set
        if CONFIG.getboolean('ssh', 'forwarding', fallback=True):
            self.channelLookup[b'direct-tcpip'] = forwarding.cowrieOpenConnectForwardingClient
开发者ID:micheloosterhof,项目名称:cowrie,代码行数:27,代码来源:avatar.py

示例3: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
 def __init__(self):
     self.apiKey = CONFIG.get('output_virustotal', 'api_key')
     self.debug = CONFIG.getboolean('output_virustotal', 'debug', fallback=False)
     self.upload = CONFIG.getboolean('output_virustotal', 'upload', fallback=True)
     self.comment = CONFIG.getboolean('output_virustotal', 'comment', fallback=True)
     self.scan_file = CONFIG.getboolean('output_virustotal', 'scan_file', fallback=True)
     self.scan_url = CONFIG.getboolean('output_virustotal', 'scan_url', fallback=False)
     self.commenttext = CONFIG.get('output_virustotal', 'commenttext', fallback=COMMENT)
     cowrie.core.output.Output.__init__(self)
开发者ID:Mato-Z,项目名称:cowrie,代码行数:11,代码来源:virustotal.py

示例4: cowrieOpenConnectForwardingClient

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
def cowrieOpenConnectForwardingClient(remoteWindow, remoteMaxPacket, data, avatar):
    """
    This function will redirect an SSH forward request to another address
    or will log the request and do nothing
    """
    remoteHP, origHP = forwarding.unpackOpen_direct_tcpip(data)

    log.msg(eventid='cowrie.direct-tcpip.request',
            format='direct-tcp connection request to %(dst_ip)s:%(dst_port)s from %(src_ip)s:%(src_port)s',
            dst_ip=remoteHP[0], dst_port=remoteHP[1],
            src_ip=origHP[0], src_port=origHP[1])

    # Forward redirect
    redirectEnabled = CONFIG.getboolean('ssh', 'forward_redirect', fallback=False)
    if redirectEnabled:
        redirects = {}
        items = CONFIG.items('ssh')
        for i in items:
            if i[0].startswith('forward_redirect_'):
                destPort = i[0].split('_')[-1]
                redirectHP = i[1].split(':')
                redirects[int(destPort)] = (redirectHP[0], int(redirectHP[1]))
        if remoteHP[1] in redirects:
            remoteHPNew = redirects[remoteHP[1]]
            log.msg(eventid='cowrie.direct-tcpip.redirect',
                    format='redirected direct-tcp connection request from %(src_ip)s:%(src_port)' +
                           'd to %(dst_ip)s:%(dst_port)d to %(new_ip)s:%(new_port)d',
                    new_ip=remoteHPNew[0], new_port=remoteHPNew[1],
                    dst_ip=remoteHP[0], dst_port=remoteHP[1],
                    src_ip=origHP[0], src_port=origHP[1])
            return SSHConnectForwardingChannel(remoteHPNew, remoteWindow=remoteWindow, remoteMaxPacket=remoteMaxPacket)

    # TCP tunnel
    tunnelEnabled = CONFIG.getboolean('ssh', 'forward_tunnel', fallback=False)
    if tunnelEnabled:
        tunnels = {}
        items = CONFIG.items('ssh')
        for i in items:
            if i[0].startswith('forward_tunnel_'):
                destPort = i[0].split('_')[-1]
                tunnelHP = i[1].split(':')
                tunnels[int(destPort)] = (tunnelHP[0], int(tunnelHP[1]))
        if remoteHP[1] in tunnels:
            remoteHPNew = tunnels[remoteHP[1]]
            log.msg(eventid='cowrie.direct-tcpip.tunnel',
                    format='tunneled direct-tcp connection request %(src_ip)s:%(src_port)' +
                           'd->%(dst_ip)s:%(dst_port)d to %(new_ip)s:%(new_port)d',
                    new_ip=remoteHPNew[0], new_port=remoteHPNew[1],
                    dst_ip=remoteHP[0], dst_port=remoteHP[1],
                    src_ip=origHP[0], src_port=origHP[1])
            return TCPTunnelForwardingChannel(remoteHPNew,
                                              remoteHP,
                                              remoteWindow=remoteWindow,
                                              remoteMaxPacket=remoteMaxPacket)

    return FakeForwardingChannel(remoteHP, remoteWindow=remoteWindow, remoteMaxPacket=remoteMaxPacket)
开发者ID:micheloosterhof,项目名称:cowrie,代码行数:58,代码来源:forwarding.py

示例5: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self):
        self.sessions = {}
        self.ttylogs = {}
        # FIXME figure out what needs to be done here regarding
        self.re_sessionlog = re.compile(
            r'.*HoneyPotSSHTransport,([0-9]+),[:a-f0-9.]+$')

        # cowrie.session.connect is special since it kicks off new logging session,
        # and is not handled here
        self.events = {
            'cowrie.login.success': self.handleLoginSucceeded,
            'cowrie.login.failed': self.handleLoginFailed,
            'cowrie.log.open': self.handleTTYLogOpened,
            'cowrie.command.success': self.handleCommand,
            'cowrie.command.failed': self.handleUnknownCommand,
            'cowrie.session.file_download': self.handleFileDownload,
            'cowrie.command.input': self.handleInput,
            'cowrie.client.version': self.handleClientVersion,
            'cowrie.client.size': self.handleTerminalSize,
            'cowrie.session.closed': self._connectionLost,
            'cowrie.log.closed': self.handleTTYLogClosed,
        }

        self.reported_ssh_port = None
        if CONFIG.has_option('honeypot', 'reported_ssh_port'):
            self.reported_ssh_port = CONFIG.getint('honeypot', 'reported_ssh_port')

        self.report_public_ip = False
        if CONFIG.has_option('honeypot', 'report_public_ip'):
            if CONFIG.getboolean('honeypot', 'report_public_ip') == True:
                self.report_public_ip = True
                import urllib
                self.public_ip = urllib.urlopen('http://myip.threatstream.com').readline()

        self.start()
开发者ID:davegermiquet,项目名称:cowrie,代码行数:37,代码来源:dblog.py

示例6: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
 def __init__(self):
     cowrie.core.output.Output.__init__(self)
     fn = CONFIG.get('output_jsonlog', 'logfile')
     self.epoch_timestamp = CONFIG.getboolean('output_jsonlog', 'epoch_timestamp', fallback=False)
     dirs = os.path.dirname(fn)
     base = os.path.basename(fn)
     self.outfile = cowrie.python.logfile.CowrieDailyLogFile(base, dirs, defaultMode=0o664)
开发者ID:micheloosterhof,项目名称:cowrie,代码行数:9,代码来源:jsonlog.py

示例7: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self):
        try:
            self.debug = CONFIG.getboolean('output_mysql', 'debug')
        except Exception:
            self.debug = False

        cowrie.core.output.Output.__init__(self)
开发者ID:micheloosterhof,项目名称:cowrie,代码行数:9,代码来源:mysql.py

示例8: start

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def start(self):

        server = CONFIG.get('output_hpfeeds', 'server')
        port = CONFIG.getint('output_hpfeeds', 'port')
        ident = CONFIG.get('output_hpfeeds', 'identifier')
        secret = CONFIG.get('output_hpfeeds', 'secret')
        debug = CONFIG.getboolean('output_hpfeeds', 'debug')
        self.client = hpclient(server, port, ident, secret, debug)
        self.meta = {}
开发者ID:Mato-Z,项目名称:cowrie,代码行数:11,代码来源:hpfeeds.py

示例9: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self):
        self.auth_key = CONFIG.get('output_dshield', 'auth_key')
        self.userid = CONFIG.get('output_dshield', 'userid')
        self.batch_size = CONFIG.getint('output_dshield', 'batch_size')
        try:
            self.debug = CONFIG.getboolean('output_dshield', 'debug')
        except:
            self.debug = False

        cowrie.core.output.Output.__init__(self)
开发者ID:davegermiquet,项目名称:cowrie,代码行数:12,代码来源:dshield.py

示例10: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self, *args, **kw):
        """
        Initialize logging
        """
        self.ttylogPath = CONFIG.get('honeypot', 'log_path')
        self.downloadPath = CONFIG.get('honeypot', 'download_path')
        self.ttylogEnabled = CONFIG.getboolean('honeypot', 'ttylog', fallback=True)
        self.bytesReceivedLimit = CONFIG.getint('honeypot', 'download_limit_size', fallback=0)

        channel.SSHChannel.__init__(self, *args, **kw)
开发者ID:Mato-Z,项目名称:cowrie,代码行数:12,代码来源:channel.py

示例11: run

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
 def run(self, application, jidstr, password, muc, server):
     self.xmppclient = XMPPClient(JID(jidstr), password)
     if CONFIG.has_option('output_xmpp', 'debug') and \
             CONFIG.getboolean('output_xmpp', 'debug') is True:
         self.xmppclient.logTraffic = True  # DEBUG HERE
     (user, host, resource) = jid.parse(jidstr)
     self.muc = XMPPLoggerProtocol(
         muc, server, user + '-' + resource)
     self.muc.setHandlerParent(self.xmppclient)
     self.xmppclient.setServiceParent(application)
     self.anonymous = True
     self.xmppclient.startService()
开发者ID:Mato-Z,项目名称:cowrie,代码行数:14,代码来源:xmpp.py

示例12: serviceStarted

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def serviceStarted(self):
        self.interfaceToMethod[credentials.IUsername] = b'none'
        self.interfaceToMethod[credentials.IUsernamePasswordIP] = b'password'
        keyboard = CONFIG.getboolean('ssh', 'auth_keyboard_interactive_enabled', fallback=False)

        if keyboard is True:
            self.interfaceToMethod[credentials.
                                   IPluggableAuthenticationModulesIP] = (
                b'keyboard-interactive')
        self.bannerSent = False
        self._pamDeferred = None
        userauth.SSHUserAuthServer.serviceStarted(self)
开发者ID:micheloosterhof,项目名称:cowrie,代码行数:14,代码来源:userauth.py

示例13: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def __init__(self, *args, **kw):
        """
        Initialize logging
        """
        self.ttylogPath = CONFIG.get('honeypot', 'log_path')
        self.downloadPath = CONFIG.get('honeypot', 'download_path')
        try:
            self.ttylogEnabled = CONFIG.getboolean('honeypot', 'ttylog')
        except NoOptionError:
            self.ttylogEnabled = True

        try:
            self.bytesReceivedLimit = CONFIG.getint('honeypot', 'download_limit_size')
        except NoOptionError:
            self.bytesReceivedLimit = 0

        channel.SSHChannel.__init__(self, *args, **kw)
开发者ID:davegermiquet,项目名称:cowrie,代码行数:19,代码来源:channel.py

示例14: start

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
    def start(self):
        try:
            host = CONFIG.get('output_influx', 'host')
        except Exception:
            host = ''

        try:
            port = CONFIG.getint('output_influx', 'port')
        except Exception:
            port = 8086

        try:
            ssl = CONFIG.getboolean('output_influx', 'ssl')
        except Exception:
            ssl = False

        self.client = None
        try:
            self.client = InfluxDBClient(host=host, port=port, ssl=ssl, verify_ssl=ssl)
        except InfluxDBClientError as e:
            log.err("output_influx: I/O error({0}): '{1}'".format(
                e.errno, e.strerror))
            return

        if self.client is None:
            log.err("output_influx: cannot instantiate client!")
            return

        if (CONFIG.has_option('output_influx', 'username') and
                CONFIG.has_option('output_influx', 'password')):
            username = CONFIG.get('output_influx', 'username')
            password = CONFIG.get('output_influx', 'password', raw=True)
            self.client.switch_user(username, password)

        try:
            dbname = CONFIG.get('output_influx', 'database_name')
        except Exception:
            dbname = 'cowrie'

        retention_policy_duration_default = '12w'
        retention_policy_name = dbname + "_retention_policy"

        if CONFIG.has_option('output_influx', 'retention_policy_duration'):
            retention_policy_duration = CONFIG.get(
                'output_influx', 'retention_policy_duration')

            match = re.search(r'^\d+[dhmw]{1}$', retention_policy_duration)
            if not match:
                log.err(("output_influx: invalid retention policy."
                         "Using default '{}'..").format(
                    retention_policy_duration))
                retention_policy_duration = retention_policy_duration_default
        else:
            retention_policy_duration = retention_policy_duration_default

        database_list = self.client.get_list_database()
        dblist = [str(elem['name']) for elem in database_list]

        if dbname not in dblist:
            self.client.create_database(dbname)
            self.client.create_retention_policy(
                retention_policy_name, retention_policy_duration, 1,
                database=dbname, default=True)
        else:
            retention_policies_list = self.client.get_list_retention_policies(
                database=dbname)
            rplist = [str(elem['name']) for elem in retention_policies_list]
            if retention_policy_name not in rplist:
                self.client.create_retention_policy(
                    retention_policy_name, retention_policy_duration, 1,
                    database=dbname, default=True)
            else:
                self.client.alter_retention_policy(
                    retention_policy_name, database=dbname,
                    duration=retention_policy_duration,
                    replication=1, default=True)

        self.client.switch_database(dbname)
开发者ID:Mato-Z,项目名称:cowrie,代码行数:80,代码来源:influx.py

示例15: __init__

# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getboolean [as 别名]
 def __init__(self):
     self.enabled = CONFIG.getboolean('output_malshare', 'enabled')
     cowrie.core.output.Output.__init__(self)
开发者ID:Mato-Z,项目名称:cowrie,代码行数:5,代码来源:malshare.py


注:本文中的cowrie.core.config.CONFIG.getboolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。