py3 fixes for proxy

This commit is contained in:
Michel Oosterhof
2018-06-27 12:35:37 +04:00
parent 786d09e29d
commit 4f62c56341

View File

@ -59,7 +59,7 @@ class InBetween(protocol.Protocol):
transport = None # Transport is the back-end the ssh-server transport = None # Transport is the back-end the ssh-server
client = None # Client is the front-end, the ssh-client 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): def makeConnection(self, transport):
protocol.Protocol.makeConnection(self, transport) protocol.Protocol.makeConnection(self, transport)
@ -133,8 +133,7 @@ class ProxySSHSession(channel.CowrieSSHChannel):
for forwarding incoming requests to the backend. for forwarding incoming requests to the backend.
""" """
name = b'proxy-frontend-session' name = b'proxy-frontend-session'
buf = b'' buf = b""
keys = [] keys = []
host = "" host = ""
port = 22 port = 22
@ -146,6 +145,9 @@ class ProxySSHSession(channel.CowrieSSHChannel):
channel.CowrieSSHChannel.__init__(self, *args, **kw) channel.CowrieSSHChannel.__init__(self, *args, **kw)
#self.__dict__['request_auth_agent_req@openssh.com'] = self.request_agent #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: try:
keyPath = CONFIG.get('proxy', 'private_key') keyPath = CONFIG.get('proxy', 'private_key')
self.keys.append(keys.Key.fromFile(keyPath)) self.keys.append(keys.Key.fromFile(keyPath))
@ -154,7 +156,6 @@ class ProxySSHSession(channel.CowrieSSHChannel):
knownHostsPath = CONFIG.get('proxy', 'known_hosts') knownHostsPath = CONFIG.get('proxy', 'known_hosts')
self.knownHosts = KnownHostsFile.fromPath(knownHostsPath) self.knownHosts = KnownHostsFile.fromPath(knownHostsPath)
log.msg("knownHosts = "+repr(self.knownHosts))
self.host = CONFIG.get('proxy', 'host') self.host = CONFIG.get('proxy', 'host')
self.port = CONFIG.getint('proxy', 'port') self.port = CONFIG.getint('proxy', 'port')
@ -164,6 +165,7 @@ class ProxySSHSession(channel.CowrieSSHChannel):
except: except:
self.password = None self.password = None
log.msg("knownHosts = "+repr(self.knownHosts))
log.msg("host = "+self.host) log.msg("host = "+self.host)
log.msg("port = "+str(self.port)) log.msg("port = "+str(self.port))
log.msg("user = "+self.user) 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', log.msg(eventid='cowrie.client.var', format='request_env: %(name)s=%(value)s',
name=name, value=value) name=name, value=value)
# FIXME: This only works for shell, not for exec command # FIXME: This only works for shell, not for exec command
if self.session: # if self.session:
self.session.environ[name] = value # self.session.environ[name] = value
return 0 return 0