> For the complete documentation index, see [llms.txt](https://darshan-2.gitbook.io/penetration-testing-checklist/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darshan-2.gitbook.io/penetration-testing-checklist/reverse-shells/stabilizing-shell.md).

# Stabilizing shell

#### Stabilize your shell: <a href="#heading-stabilize-your-shell" id="heading-stabilize-your-shell"></a>

1. Import pty module and spawn bash shell

   ```
   python3 -c 'import pty;pty.spawn("/bin/bash")'
   ```
2. Press `CTRL + Z` to background process and get back to your host machine
3. Use stty command to set terminal line settings and foreground back the target terminal

   ```
   stty raw -echo; fg
   ```
4. Set the terminal emulator to xterm:

   ```
   export TERM=xterm
   ```
5. Press Enter
