new CONFIG method

This commit is contained in:
Michel Oosterhof 2018-04-09 11:06:07 +04:00
parent 570b4606de
commit 1fc9e66a7b
1 changed files with 10 additions and 8 deletions

View File

@ -11,6 +11,8 @@ from twisted.words.protocols.jabber.jid import JID
from wokkel.xmppim import AvailablePresence
from wokkel import muc
from cowrie.core.config import CONFIG
class XMPPLoggerProtocol(muc.MUCClient):
def __init__(self, rooms, server, nick):
@ -57,18 +59,18 @@ from cowrie.core import dblog
from twisted.words.xish import domish
class DBLogger(dblog.DBLogger):
def start(self, cfg):
def start(self):
from random import choice
import string
server = cfg.get('database_xmpp', 'server')
user = cfg.get('database_xmpp', 'user')
password = cfg.get('database_xmpp', 'password')
muc = cfg.get('database_xmpp', 'muc')
server = CONFIG.get('database_xmpp', 'server')
user = CONFIG.get('database_xmpp', 'user')
password = CONFIG.get('database_xmpp', 'password')
muc = CONFIG.get('database_xmpp', 'muc')
channels = {}
for i in ('createsession', 'connectionlost', 'loginfailed',
'loginsucceeded', 'command', 'clientversion'):
x = cfg.get('database_xmpp', 'signal_' + i)
x = CONFIG.get('database_xmpp', 'signal_' + i)
if not x in channels:
channels[x] = []
channels[x].append(i)
@ -82,8 +84,8 @@ class DBLogger(dblog.DBLogger):
def run(self, application, jidstr, password, muc, channels, anon=True):
self.xmppclient = XMPPClient(JID(jidstr), password)
if self.cfg.has_option('database_xmpp', 'debug') and \
self.cfg.getboolean('database_xmpp', 'debug') == True:
if CONFIG.has_option('database_xmpp', 'debug') and \
CONFIG.getboolean('database_xmpp', 'debug') == True:
self.xmppclient.logTraffic = True # DEBUG HERE
(user, host, resource) = jid.parse(jidstr)
self.muc = XMPPLoggerProtocol(