Jump to content

Remote Shell with Python3

hirushaadi

NOTE: This is not being built for malicious purposes

 

because to use 1024 bytes at a time with socket, when a big command is running, it wont work as intended

 

what i tried: 

# server

def send(data):
    # data = data.encode()
    # client.send(data)
    jd = json.dumps(data)
    client.send(data.encode())

def recv():
    jrd = ""
    while True:
        try:
            jrd = jrd.encode() + client.recv(1024)
            return json.loads(jrd.decode())
        except ValueError:
            break
    # output = client.recv(1024)
    # output = output.decode()
    # return output
# client

while True:
    print("[-] Awaiting commands...")
    command = client.recv(1024)
    command = command.decode()
    op = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    output = op.stdout.read()
    output_error = op.stderr.read()
    print("[-] Sending response...")
    client.send(output + output_error)

 

This is what using it looks like!

image.png.b1b57b9aed000db216eef53c5c743cdc.png

hey! i know to use a computer

Link to comment
Share on other sites

Link to post
Share on other sites

    while True:
        try:
            jrd = jrd.encode() + client.recv(1024)

this is just going to fail if you don't send valid json data in the first 1024 bytes... you should first string all the bytes together and then encode them.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×