本文整理汇总了Python中twisted.conch.ssh.session.wrapProtocol函数的典型用法代码示例。如果您正苦于以下问题:Python wrapProtocol函数的具体用法?Python wrapProtocol怎么用?Python wrapProtocol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrapProtocol函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execCommand
def execCommand(self, processprotocol, cmd):
"""
"""
self.protocol = insults.LoggingServerProtocol(
protocol.HoneyPotExecProtocol, self, cmd)
self.protocol.makeConnection(processprotocol)
processprotocol.makeConnection(session.wrapProtocol(self.protocol))
示例2: openShell
def openShell(self, trans):
"""
Called when a shell is opened by a user logging in via SSH or similar.
"""
# Obtain a protocol instance. This is our custom Network.SSHServerProtocol.
# The protocol controls the way that data is sent and received down the connection.
# In our case, it presents a TTY-based user interface to the user, while all we care
# about is sending lines to the user and receiving lines from them.
from Network import SSHServerProtocol
# Get the protocol instance. The protocol is also our transport.
# Note that the Twisted networking model is a stack of protocols,
# where lower level protocols transport higher level ones.
self.transport = proto = SSHServerProtocol(self, *self.savedSize)
# Connect the protocol and the transport together (I don't really understand why
# it needs to be connected both ways like this, or what the wrapper does)
proto.makeConnection(trans)
trans.makeConnection(session.wrapProtocol(proto))
#self.send_message("Hi there!")
# Obtain the Player object from the database
player_id = self.world.db.get_player_id(self.username, self._charname)
log.debug("Username: {0}, character: {2}, id: {1}".format(self.username, player_id, self._charname))
self.player = self.world.get_thing(player_id)
# Finish login (what does this call do?)
self.complete_login()
示例3: request_shell
def request_shell(self, data):
protocol = EchoProtocol()
transport = SSHSessionProcessProtocol(self)
protocol.makeConnection(transport)
transport.makeConnection(wrapProtocol(protocol))
self.client = transport
return True
示例4: openShell
def openShell(self, transport):
"""
Write 60 lines of data to the transport, then exit.
"""
proto = protocol.Protocol()
proto.makeConnection(transport)
transport.makeConnection(wrapProtocol(proto))
# Send enough bytes to the connection so that a rekey is triggered in
# the client.
def write(counter):
i = counter()
if i == 60:
call.stop()
transport.session.conn.sendRequest(
transport.session, 'exit-status', '\x00\x00\x00\x00')
transport.loseConnection()
else:
transport.write("line #%02d\n" % (i,))
# The timing for this loop is an educated guess (and/or the result of
# experimentation) to exercise the case where a packet is generated
# mid-rekey. Since the other side of the connection is (so far) the
# OpenSSH command line client, there's no easy way to determine when the
# rekey has been initiated. If there were, then generating a packet
# immediately at that time would be a better way to test the
# functionality being tested here.
call = LoopingCall(write, count().next)
call.start(0.01)
示例5: openShell
def openShell(self, processprotocol):
"""
"""
self.protocol = insults.LoggingServerProtocol(
protocol.HoneyPotInteractiveProtocol, self)
self.protocol.makeConnection(processprotocol)
processprotocol.makeConnection(session.wrapProtocol(self.protocol))
示例6: openShell
def openShell(self, protocol):
serverProtocol = insults.ServerProtocol(SSHDemoProtocol, self)
serverProtocol.makeConnection(protocol)
protocol.makeConnection(session.wrapProtocol(serverProtocol))
示例7: execCommand
def execCommand(self, proto, cmd):
serverProtocol = protocol.LoggingServerProtocol(
protocol.HoneyPotExecProtocol, self, self.env, cmd)
self.protocol = serverProtocol
serverProtocol.makeConnection(proto)
proto.makeConnection(session.wrapProtocol(serverProtocol))
self.protocol = serverProtocol
示例8: openShell
def openShell(self, proto):
serverProtocol = protocol.LoggingServerProtocol(
protocol.HoneyPotInteractiveProtocol, self, self.env)
self.protocol = serverProtocol
serverProtocol.makeConnection(proto)
proto.makeConnection(session.wrapProtocol(serverProtocol))
#self.protocol = serverProtocol
self.protocol = proto
示例9: execCommand
def execCommand(self, proto, cmd):
p = session_wrapper_protocol(self, False)
p.makeConnection(proto)
proto.makeConnection(session.wrapProtocol(p))
p.dataReceived(cmd)
if (not cmd.endswith("\n")):
p.dataReceived("\n")
p.stransport.terminate()
示例10: openShell
def openShell(self, protocol):
shell_protocol = insults.ServerProtocol(
ShellProtocol,
self,
self.executables,
)
shell_protocol.makeConnection(protocol)
protocol.makeConnection(session.wrapProtocol(shell_protocol))
示例11: request_exec
def request_exec(self, data):
print 'request_exec', data
protocol = SCPProtocol()
transport = SSHSessionProcessProtocol(self)
protocol.makeConnection(transport)
transport.makeConnection(wrapProtocol(protocol))
self.client = transport
return True
示例12: openShell
def openShell(self, protocol):
serverProtocol = insults.ServerProtocol(SSHProtocol,
self,
self.prompt,
self.commands)
serverProtocol.makeConnection(protocol)
protocol.makeConnection(session.wrapProtocol(serverProtocol))
示例13: openShell
def openShell(self, transport):
"""
Use our protocol as shell session.
"""
protocol = EchoProtocol()
# Connect the new protocol to the transport and the transport
# to the new protocol so they can communicate in both directions.
protocol.makeConnection(transport)
transport.makeConnection(session.wrapProtocol(protocol))
示例14: openShell
def openShell(self, trans):
log.msg(
"Your terminal name is %r. "
"Your terminal is %d columns wide and %d rows tall." % (
self.terminalName, self.windowSize[0], self.windowSize[1]))
log.msg("ExampleSession: open shell!")
ep = SSHServerConsoleProtocol(self.terminalName)
ep.makeConnection(trans)
trans.makeConnection(session.wrapProtocol(ep))
示例15: openShell
def openShell(self, protocol):
""" Open a shell and connect it to proto. """
peer_address = protocol.getPeer().address # IAddress
(host, port) = (peer_address.host, peer_address.port)
log.msg("Open shell from %s:%d." % (host, port))
serverProtocol = ServerProtocol(GatewayTerminalProtocol, self.avatar)
serverProtocol.makeConnection(protocol)
protocol.makeConnection(wrapProtocol(serverProtocol))