title: Using Go to spawn a shell with a TTY from "nc -e /bin/bash"
body: <p>I want to escape a restricted shell spawning a bash shell via Go. In other words, I want to do this but using Go:</p>
  
  <pre><code>python -c 'import pty; pty.spawn("/bin/bash")'
  </code></pre>
  
  <p>I am totally new to Go. I have tried this (following the answer in this question <a href="https://stackoverflow.com/questions/38485656/go-how-to-spawn-a-bash-shell">Go: How to spawn a bash shell</a>) but nothing happens:</p>
  
  <pre><code>package main
  
  import "os"
  import "os/exec"
  
  func main() {
      shell := exec.Command("/bin/bash")
      shell.Stdout = os.Stdout
      shell.Stdin = os.Stdin
      shell.Stderr = os.Stderr
      shell.Run()
  }
  </code></pre>
  
  <p>Also if I add the  <code>fmt.Println("hello")</code> line at the end of the main function nothing is printed</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Maybe I did not expalined well. What I am trying to achieve it's to spawn a shell gotten a restricted shell. This is what I did:
  Listener:</p>
  
  <pre><code>nc.traditional -l -p 8080 -e /bin/bash
  </code></pre>
  
  <p>Connects to listener:  And I exec the code here</p>
  
  <pre><code>nc.traditional localhost 8080 -v
  </code></pre>