如何修复异常“属性错误:'Nonetype'对象没有属性'sendline'

时间:2019-06-15 21:23:08

标签: python exception attributeerror botnet

我正在使用python上的安全外壳创建一个简单的僵尸网络,但是代码抛出了一个我无法弄清其解决方案的异常

在ubuntu gedit编辑器中的python 3上运行它。

from pexpect import pxssh

class Bot:

    # initialize new client
    def __init__(self, host, user, password):
        self.host = host
        self.user = user
        self.password = password
        self.session = self.ssh()


    # secure shell into client
    def ssh(self):
        try:
            bot = pxssh.pxssh()
            bot.login(self.host, self.user, self.password)
            return bot
        except Exception as e:
            print('Connection failure.')
            print(e)


    # send command to client
    def send_command(self, cmd):
        self.session.sendline(cmd)
        self.session.prompt()
        return self.session.before


# send a command to all bots in the botnet
def command_bots(command):
    for bot in botnet:
        attack = bot.send_command(command)
        print('Output from ' + bot.host)
        print(attack)

# list of bots in botnet
botnet = []

# add a new bot to your botnet
def add_bot(host, user, password):
    new_bot = Bot(host, user, password)
    botnet.append(new_bot)

add_bot('10.0.0.59', '', '')

# list user home directory
command_bots('ls')

输出应该是主机的ls命令的结果,这是我在代码的下一部分中要攻击的主机

0 个答案:

没有答案