From 4f62c56341761c8c18c4efdf9c9e3fb9aaf4debc Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Wed, 27 Jun 2018 12:35:37 +0400 Subject: [PATCH] py3 fixes for proxy --- cowrie/proxy/session.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cowrie/proxy/session.py b/cowrie/proxy/session.py index 0894468c..06021afc 100644 --- a/cowrie/proxy/session.py +++ b/cowrie/proxy/session.py @@ -59,7 +59,7 @@ class InBetween(protocol.Protocol): transport = None # Transport is the back-end the ssh-server client = None # Client is the front-end, the ssh-client - buf = "" # buffer to send to back-end + buf = b"" # buffer to send to back-end def makeConnection(self, transport): protocol.Protocol.makeConnection(self, transport) @@ -133,8 +133,7 @@ class ProxySSHSession(channel.CowrieSSHChannel): for forwarding incoming requests to the backend. """ name = b'proxy-frontend-session' - buf = b'' - + buf = b"" keys = [] host = "" port = 22 @@ -146,6 +145,9 @@ class ProxySSHSession(channel.CowrieSSHChannel): channel.CowrieSSHChannel.__init__(self, *args, **kw) #self.__dict__['request_auth_agent_req@openssh.com'] = self.request_agent + 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)) @@ -154,7 +156,6 @@ class ProxySSHSession(channel.CowrieSSHChannel): knownHostsPath = CONFIG.get('proxy', 'known_hosts') self.knownHosts = KnownHostsFile.fromPath(knownHostsPath) - log.msg("knownHosts = "+repr(self.knownHosts)) self.host = CONFIG.get('proxy', 'host') self.port = CONFIG.getint('proxy', 'port') @@ -164,6 +165,7 @@ class ProxySSHSession(channel.CowrieSSHChannel): except: self.password = None + log.msg("knownHosts = "+repr(self.knownHosts)) log.msg("host = "+self.host) log.msg("port = "+str(self.port)) log.msg("user = "+self.user) @@ -212,8 +214,8 @@ class ProxySSHSession(channel.CowrieSSHChannel): log.msg(eventid='cowrie.client.var', format='request_env: %(name)s=%(value)s', name=name, value=value) # FIXME: This only works for shell, not for exec command - if self.session: - self.session.environ[name] = value + # if self.session: + # self.session.environ[name] = value return 0