本文整理汇总了Python中cowrie.core.config.CONFIG.getint方法的典型用法代码示例。如果您正苦于以下问题:Python CONFIG.getint方法的具体用法?Python CONFIG.getint怎么用?Python CONFIG.getint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cowrie.core.config.CONFIG
的用法示例。
在下文中一共展示了CONFIG.getint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def __init__(self, *args, **kw):
channel.CowrieSSHChannel.__init__(self, *args, **kw)
keyPath = CONFIG.get('proxy', 'private_key')
self.keys.append(keys.Key.fromFile(keyPath))
try:
keyPath = CONFIG.get('proxy', 'private_key')
self.keys.append(keys.Key.fromFile(keyPath))
except NoOptionError:
self.keys = None
knownHostsPath = CONFIG.get('proxy', 'known_hosts')
self.knownHosts = KnownHostsFile.fromPath(knownHostsPath)
self.host = CONFIG.get('proxy', 'host')
self.port = CONFIG.getint('proxy', 'port')
self.user = CONFIG.get('proxy', 'user')
try:
self.password = CONFIG.get('proxy', 'password')
except NoOptionError:
self.password = None
log.msg("knownHosts = {0}".format(repr(self.knownHosts)))
log.msg("host = {0}".format(self.host))
log.msg("port = {0}".format(self.port))
log.msg("user = {0}".format(self.user))
self.client = ProxyClient(self)
示例2: connectionMade
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def connectionMade(self):
"""
Called when the connection is made from the other side.
We send our version, but wait with sending KEXINIT
"""
self.transportId = uuid.uuid4().hex[:12]
src_ip = self.transport.getPeer().host
ipv4_search = self.ipv4rex.search(src_ip)
if ipv4_search is not None:
src_ip = ipv4_search.group(1)
log.msg(
eventid='cowrie.session.connect',
format="New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]",
src_ip=src_ip,
src_port=self.transport.getPeer().port,
dst_ip=self.transport.getHost().host,
dst_port=self.transport.getHost().port,
session=self.transportId,
sessionno='S{0}'.format(self.transport.sessionno),
protocol='ssh'
)
self.transport.write('{0}\r\n'.format(self.ourVersionString).encode('ascii'))
self.currentEncryptions = transport.SSHCiphers(b'none', b'none', b'none', b'none')
self.currentEncryptions.setKeys(b'', b'', b'', b'', b'', b'')
self.startTime = time.time()
self.setTimeout(CONFIG.getint('honeypot', 'authentication_timeout', fallback=120))
示例3: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def __init__(self):
self.host = CONFIG.get(self.RETHINK_DB_SEGMENT, 'host')
self.port = CONFIG.getint(self.RETHINK_DB_SEGMENT, 'port')
self.db = CONFIG.get(self.RETHINK_DB_SEGMENT, 'db')
self.table = CONFIG.get(self.RETHINK_DB_SEGMENT, 'table')
self.password = CONFIG.get(self.RETHINK_DB_SEGMENT, 'password', raw=True)
cowrie.core.output.Output.__init__(self)
示例4: connectionMade
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def connectionMade(self):
pt = self.getProtoTransport()
self.realClientIP = pt.transport.getPeer().host
self.realClientPort = pt.transport.getPeer().port
self.logintime = time.time()
log.msg(eventid='cowrie.session.params', arch=self.user.server.arch)
try:
timeout = CONFIG.getint('honeypot', 'interactive_timeout')
except Exception:
timeout = 180
self.setTimeout(timeout)
# Source IP of client in user visible reports (can be fake or real)
try:
self.clientIP = CONFIG.get('honeypot', 'fake_addr')
except Exception:
self.clientIP = self.realClientIP
# Source IP of server in user visible reports (can be fake or real)
if CONFIG.has_option('honeypot', 'internet_facing_ip'):
self.kippoIP = CONFIG.get('honeypot', 'internet_facing_ip')
else:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
self.kippoIP = s.getsockname()[0]
except Exception:
self.kippoIP = '192.168.0.1'
finally:
s.close()
示例5: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def __init__(self):
addr = CONFIG.get('output_socketlog', 'address')
self.host = addr.split(':')[0]
self.port = int(addr.split(':')[1])
self.timeout = CONFIG.getint('output_socketlog', 'timeout')
cowrie.core.output.Output.__init__(self)
示例6: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def __init__(self, sftpserver, filename, flags, attrs):
self.sftpserver = sftpserver
self.filename = filename
self.transfer_completed = 0
self.bytesReceived = 0
self.bytesReceivedLimit = CONFIG.getint('honeypot', 'download_limit_size', fallback=0)
openFlags = 0
if flags & FXF_READ == FXF_READ and flags & FXF_WRITE == 0:
openFlags = os.O_RDONLY
if flags & FXF_WRITE == FXF_WRITE and flags & FXF_READ == 0:
openFlags = os.O_WRONLY
if flags & FXF_WRITE == FXF_WRITE and flags & FXF_READ == FXF_READ:
openFlags = os.O_RDWR
if flags & FXF_APPEND == FXF_APPEND:
openFlags |= os.O_APPEND
if flags & FXF_CREAT == FXF_CREAT:
openFlags |= os.O_CREAT
if flags & FXF_TRUNC == FXF_TRUNC:
openFlags |= os.O_TRUNC
if flags & FXF_EXCL == FXF_EXCL:
openFlags |= os.O_EXCL
if "permissions" in attrs:
filemode = attrs["permissions"]
del attrs["permissions"]
else:
filemode = 0o777
fd = sftpserver.fs.open(filename, openFlags, filemode)
if attrs:
self.sftpserver.setAttrs(filename, attrs)
self.fd = fd
# Cache a copy of file in memory to read from in readChunk
if flags & FXF_READ == FXF_READ:
self.contents = self.sftpserver.fs.file_contents(self.filename)
示例7: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [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()
示例8: start
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def start(self):
"""
"""
log.msg("WARNING: Beta version of new hpfeeds enabled. This will become hpfeeds in a future release.")
if CONFIG.has_option('output_hpfeeds', 'channel'):
self.channel = CONFIG.get('output_hpfeeds', 'channel')
if CONFIG.has_option('output_hpfeeds', 'endpoint'):
endpoint = CONFIG.get('output_hpfeeds', 'endpoint')
else:
server = CONFIG.get('output_hpfeeds', 'server')
port = CONFIG.getint('output_hpfeeds', 'port')
if CONFIG.has_option('output_hpfeeds', 'tlscert'):
with open(CONFIG.get('output_hpfeeds', 'tlscert')) as fp:
authority = ssl.Certificate.loadPEM(fp.read())
options = ssl.optionsForClientTLS(server, authority)
endpoint = endpoints.SSL4ClientEndpoint(reactor, server, port, options)
else:
endpoint = endpoints.HostnameEndpoint(reactor, server, port)
ident = CONFIG.get('output_hpfeeds', 'identifier')
secret = CONFIG.get('output_hpfeeds', 'secret')
self.meta = {}
self.client = ClientSessionService(endpoint, ident, secret)
self.client.startService()
示例9: start
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [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 = {}
示例10: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def __init__(self):
"""
Initializing the class
"""
self.index = CONFIG.get('output_splunklegacy', 'index')
self.username = CONFIG.get('output_splunklegacy', 'username')
self.password = CONFIG.get('output_splunklegacy', 'password', raw=True)
self.host = CONFIG.get('output_splunklegacy', 'host')
self.port = CONFIG.getint('output_splunklegacy', 'port')
cowrie.core.output.Output.__init__(self)
示例11: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [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)
示例12: __init__
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [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)
示例13: makeTftpRetrieval
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def makeTftpRetrieval(self):
"""
"""
progresshook = Progress(self).progresshook
if CONFIG.has_option('honeypot', 'download_limit_size'):
self.limit_size = CONFIG.getint('honeypot', 'download_limit_size')
self.artifactFile = Artifact(self.file_to_get)
tclient = None
url = ''
try:
tclient = tftpy.TftpClient(self.hostname, int(self.port))
# tftpy can't handle unicode string as filename
# so we have to convert unicode type to str type
tclient.download(str(self.file_to_get), self.artifactFile, progresshook)
url = 'tftp://%s/%s' % (self.hostname, self.file_to_get.strip('/'))
self.file_to_get = self.fs.resolve_path(self.file_to_get, self.protocol.cwd)
if hasattr(tclient.context, 'metrics'):
self.fs.mkfile(self.file_to_get, 0, 0, tclient.context.metrics.bytes, 33188)
else:
self.fs.mkfile(self.file_to_get, 0, 0, 0, 33188)
except tftpy.TftpException:
if tclient and tclient.context and not tclient.context.fileobj.closed:
tclient.context.fileobj.close()
if url:
# log to cowrie.log
log.msg(format='Downloaded URL (%(url)s) with SHA-256 %(shasum)s to %(outfile)s',
url=url,
outfile=self.artifactFile.shasumFilename,
shasum=self.artifactFile.shasum)
self.protocol.logDispatch(eventid='cowrie.session.file_download',
format='Downloaded URL (%(url)s) with SHA-256 %(shasum)s to %(outfile)s',
url=url,
outfile=self.artifactFile.shasumFilename,
shasum=self.artifactFile.shasum,
destfile=self.file_to_get)
# Update the honeyfs to point to downloaded file
self.fs.update_realfile(self.fs.getfile(self.file_to_get), self.artifactFile.shasumFilename)
self.fs.chown(self.file_to_get, self.protocol.user.uid, self.protocol.user.gid)
示例14: connectionMade
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def connectionMade(self):
self.transportId = uuid.uuid4().hex[:12]
sessionno = self.transport.sessionno
self.startTime = time.time()
self.setTimeout(CONFIG.getint('honeypot', 'authentication_timeout', fallback=120))
log.msg(eventid='cowrie.session.connect',
format='New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]',
src_ip=self.transport.getPeer().host,
src_port=self.transport.getPeer().port,
dst_ip=self.transport.getHost().host,
dst_port=self.transport.getHost().port,
session=self.transportId,
sessionno='T{0}'.format(str(sessionno)),
protocol='telnet')
TelnetTransport.connectionMade(self)
示例15: setService
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import getint [as 别名]
def setService(self, service):
"""
Remove login grace timeout, set zlib compression after auth
"""
# Reset timeout. Not everyone opens shell so need timeout at transport level
if service.name == b'ssh-connection':
self.setTimeout(CONFIG.getint('honeypot', 'interactive_timeout', fallback=300))
# when auth is successful we enable compression
# this is called right after MSG_USERAUTH_SUCCESS
if service.name == 'ssh-connection':
if self.outgoingCompressionType == '[email protected]':
self.outgoingCompression = zlib.compressobj(6)
if self.incomingCompressionType == '[email protected]':
self.incomingCompression = zlib.decompressobj()
transport.SSHServerTransport.setService(self, service)