<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Upgrading to Amazing Shell]]></title><description><![CDATA[Obsidian digital garden]]></description><link>http://github.com/dylang/node-rss</link><image><url>site-lib/media/favicon.png</url><title>Upgrading to Amazing Shell</title><link></link></image><generator>Webpage HTML Export plugin for Obsidian</generator><lastBuildDate>Thu, 30 Apr 2026 16:30:54 GMT</lastBuildDate><atom:link href="site-lib/rss.xml" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Apr 2026 16:30:53 GMT</pubDate><ttl>60</ttl><dc:creator></dc:creator><item><title><![CDATA[Upgrading your bad Shell to amazing Shell]]></title><description><![CDATA[In most reverse shell call backs that you get from your victim computers, they are not a very convenient and stable connections, and do not have the advantages and functionalities that you would get from a ssh shell connection, like the auto-fill, tab, etc.This Blog post is going to be showing you the steps to upgrade your "Bad Shell" into a "Good Shell", which you can mostly use in any Linux shell which has python3 installed in it.<img alt="Upgrading Shell.png > Center" src="site-lib/media/favicon.png" target="_self">The examples shows in this blog is part of one of the CTF challenge
Once you have got a shell on your victim computer, check to see if you have python install (mostly all Linux machines will have Python installed in them). If python is installed, then run the following command:
python3 -c 'import pty; pty.spawn("/bin/bash")' Once you have executed this command you will get a bash shell to interact with. Then press Ctrl + Z (To suspend the current netcat/ reverse shell session). On the same terminal (you would have your normal terminal now), enter the following command: stty raw -echo &amp;&amp; fg
There you go, a better shell to interact!!! <br><img alt="Pasted image 20260430151627.png#center" src="attachments/pasted-image-20260430151627.png" target="_self" style="width: 10000px; max-width: 100%;"><br>The following explanations from here are written by an AI (<a data-tooltip-position="top" aria-label="https://chatgpt.com/" rel="noopener nofollow" class="external-link is-unresolved" href="https://chatgpt.com/" target="_self">ChatGPT</a>), hence let me know if there are any issues with it.When you first catch a reverse shell (for example, through nc), what you typically get is a very minimal, non-interactive shell. It’s not a “real” terminal — it’s just a raw stream of input and output over a socket.That’s why things feel broken:
No tab completion
No command history
Arrow keys don’t work
Programs like vim, top, or nano behave strangely or fail
Signals like Ctrl + C may kill the whole connection
To understand the upgrade process, you need to know about pseudo-terminals (PTYs).python3 -c 'import pty; pty.spawn("/bin/bash")'
This works because Python’s built-in pty module creates a pseudo-terminal device, which mimics a real terminal.
Allocates a PTY on the target machine
Launches /bin/bash attached to that PTY
Bridges your raw socket to this new terminal
Programs like bash behave differently depending on whether they are connected to:
a real terminal (TTY/PTY) → full interactive features
a pipe/socket → limited, “dumb” mode
Before this step, your shell is just a pipe. After this step, it becomes something much closer to a real terminal session.When you press:Ctrl + Z
you are sending a SIGTSTP (terminal stop signal) to the current foreground process.
Your reverse shell process is suspended locally
You return to your own terminal prompt
This is important because now you can reconfigure your local terminal to properly handle the upgraded shell.stty raw -echo &amp;&amp; fg
This is the step that makes everything feel normal again.stty raw
Switches your local terminal into raw mode
Input is sent character-by-character, not line-by-line
Disables special processing (like Ctrl+C being handled locally)
-echo
Prevents your terminal from echoing typed characters
Without this, you’d see duplicated input
fg
Brings the suspended reverse shell back to the foreground
At this point, you’ve aligned three critical pieces:
Remote side → Now running inside a PTY (via Python)
Local side → Configured to pass input/output transparently (stty raw -echo)
Connection → Still the same socket, but now behaving like a real terminal
This combination allows:
Proper signal handling (Ctrl+C, Ctrl+Z)
Interactive programs to work correctly
Line editing and job control
A much more stable and usable shell
A basic reverse shell is just:
stdin/stdout over a network socketA fully interactive shell requires:
a terminal interface (TTY/PTY) + proper input/output handlingThis technique works by:
Adding a PTY on the remote system
Configuring your local terminal to match it
Python is commonly used here because:
It’s installed on most Linux systems by default
It provides easy access to PTY functionality (pty.spawn)
The one-liner is short and reliable
Other methods (using script, perl, or socat) achieve the same goal, but Python is often the quickest option.A PTY (pseudo-terminal) is basically a software-emulated terminal that behaves like a real one.Originally, a terminal was a physical device (keyboard + screen) connected to a computer. Programs like bash were designed to talk to that kind of device:
They expect interactive input (keystrokes)
They handle signals like Ctrl+C
They control cursor movement, screen updates, etc.
Modern systems (like Linux) still follow this model — even though the “terminal” is now usually just a window.A PTY (pseudo-terminal) is a pair of virtual devices created by the OS:
Master side → controlled by a program (like your reverse shell or SSH client)
Slave side → looks like a real terminal to programs like bash
Think of it like a translator layer:
One side talks “program”
The other side talks “terminal”
Programs behave differently depending on whether they are connected to a terminal or not.
Bash thinks it's talking to a pipe/socket
No interactive features
No proper signal handling
Tools like vim break Bash thinks it's talking to a real terminal
Enables: Command history
Tab completion
Job control (Ctrl+Z, fg)
Interactive apps (top, nano, etc.) Without PTY → like talking over a walkie-talkie (basic input/output)
With PTY → like a full phone call with proper interaction
When you run:python3 -c 'import pty; pty.spawn("/bin/bash")'
Python:
Creates a PTY
Launches /bin/bash attached to it
Connects that PTY to your network shell
So now:
Bash is happy (it sees a terminal)
You get a much more “real” shell experience
A PTY (pseudo-terminal) is a virtual terminal interface that allows programs to behave as if they are connected to a real interactive terminal, even when communicating over a network or through another program.]]></description><link>upgrading-your-bad-shell-to-amazing-shell.html</link><guid isPermaLink="false">Upgrading your bad Shell to amazing Shell.md</guid><pubDate>Thu, 30 Apr 2026 16:29:19 GMT</pubDate><enclosure url="." length="0" type="false"/><content:encoded>&lt;figure&gt;&lt;img src=&quot;.&quot;&gt;&lt;/figure&gt;</content:encoded></item></channel></rss>