Jul-06-2017, 09:50 PM
Hey guys!
I'm trying to get this script to work, but I can't seem to make that happen. I've tinkered with it quite a bit, but I keep getting kick backs. When I look it up online and ask buddies, I'm told it should function the way it is. Below is what I'm told is wrong. I understand it can't connect to the host (I had my information and such in there to make connecting possible). I just don't understand why it's saying specific lines are wrong.
Could not establish connection to host
[-] Error Connecting
Traceback (most recent call last):
File "/root/Documents/Python/Serpent.py", line 41, in <module>
botnetCommand('ls -la')
File "/root/Documents/Python/Serpent.py", line 30, in botnetCommand
output = client.send_command(command) #To get output
File "/root/Documents/Python/Serpent.py", line 24, in send_command
self.session.sendline(cmd)
AttributeError: 'NoneType' object has no attribute 'sendline'
I'm trying to get this script to work, but I can't seem to make that happen. I've tinkered with it quite a bit, but I keep getting kick backs. When I look it up online and ask buddies, I'm told it should function the way it is. Below is what I'm told is wrong. I understand it can't connect to the host (I had my information and such in there to make connecting possible). I just don't understand why it's saying specific lines are wrong.
Could not establish connection to host
[-] Error Connecting
Traceback (most recent call last):
File "/root/Documents/Python/Serpent.py", line 41, in <module>
botnetCommand('ls -la')
File "/root/Documents/Python/Serpent.py", line 30, in botnetCommand
output = client.send_command(command) #To get output
File "/root/Documents/Python/Serpent.py", line 24, in send_command
self.session.sendline(cmd)
AttributeError: 'NoneType' object has no attribute 'sendline'
#!/usr/bin/python3.5 from pexpect import pxssh class Client: #Defining the class def __init__(self, host, user, password): #Create the initializer self.host = host self.user = user self.password = password self.session = self.connect() def connect(self):#connect method try: #incase connect fails x = pxssh.pxssh() #Set x as a variable for pxssh x.login(self.host, self.user, self.password) return x #If login is complete except Exception as e: #if fails print (e) print ('[-] Error Connecting') def send_command(self, cmd): self.session.sendline(cmd) self.session.prompt() return self.session.before def botnetCommand(command): #Function to send command(s) for client in botNet: output = client.send_command(command) #To get output print (' [*] Output from ' + client.host) #To get output print ('[+]' + output) def addClient (host, user, password): #Adding client to botnet client = Client(host, user, password) botNet.append(client) #Adding client session to botnet botNet = [] addClient()