开发者

Custom bye-bye message

I am currently working on a honeypot which closely mimics the behavior of vsftpd. Im supposed to close off a connection from the server side when I receive the QUIT command. The protocol instance has subclassed basic.LineReceiver. I am closing off the connection using self.transport.loseConnection() and the message "Connection closed by foreign host" gets sent over to the client side.

I'd like the message "221 Goodbye." to be displayed instead. A skeleton of whats been done right now(the other parts have been omitted as they are not relevant to the problem at hand).

class HoneyProtocol(开发者_JS百科basic.LineReceiver):
    def lineReceived(self, line):
        line = line.upper()
        if line.startswith("QUIT"):
            self.transport.write("221 Goodbye\n")
            self.transport.loseConnection()

I get the message "221 Goodbye" followed by a "Connection closed by foreign host" at the client side when I do this.


There is nothing in twisted.protocols.basic.LineReceiver that will send "Connection closed by foreign host" over the connection. Note that this is a very common string for client programs to generate locally and emit to their stdout. For example:

exarkun@boson:~$ telnet localhost 22
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2
asdlkjds
Protocol mismatch.
Connection closed by foreign host.
exarkun@boson:~$ 

OpenSSH doesn't send "Connection closed by foreign host." Telnet writes that out after the foreign host closes the connection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜