#! /usr/bin/env python import logging import os import sys from twisted.internet import protocol from twisted.internet import reactor from twisted.protocols import basic class NetbusMock(basic.LineReceiver): """Implements a mock netbus backdoor service. The service listens for attempts to guess the password, which must be formatted as 'Password;0;%s\r' % (password). If it finds a match, (the password is simply 'password'), it replies with the expected message for granting access: 'Access;1'. """ def connectionMade(self): self.delimiter = '\r' # Send the initial banner self.sendLine("Hi there! This is a mock netbus backdoor service!") def lineReceived(self, line): logging.info('Received %s from %s', line, self.transport.getPeer().host) reply = 'Ooops, bad password!' if line == 'Password;0;password': reply = 'Access;1' logging.info('-> %s', reply) self.sendLine(reply) def main(): logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.INFO) factory = protocol.ServerFactory() factory.protocol = NetbusMock reactor.listenTCP(12345, factory) reactor.run() if __name__ == '__main__': main()