<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abdullah Elmasry</title>
    <description>The latest articles on DEV Community by Abdullah Elmasry (@0xmrmasry).</description>
    <link>https://dev.to/0xmrmasry</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1652326%2Fa884c10c-7e63-4cc2-8131-43b4ba2ab3b7.jpg</url>
      <title>DEV Community: Abdullah Elmasry</title>
      <link>https://dev.to/0xmrmasry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0xmrmasry"/>
    <language>en</language>
    <item>
      <title>Upgrading Simple Shells to Fully Interactive TTYs</title>
      <dc:creator>Abdullah Elmasry</dc:creator>
      <pubDate>Thu, 14 Nov 2024 20:09:09 +0000</pubDate>
      <link>https://dev.to/0xmrmasry/upgrading-simple-shells-to-fully-interactive-ttys-49eb</link>
      <guid>https://dev.to/0xmrmasry/upgrading-simple-shells-to-fully-interactive-ttys-49eb</guid>
      <description>&lt;p&gt;Imagine you’re a hacking pro, right? You pull off this cool move, catching a reverse shell with netcat. The netcat messages start showing off, and the “id” command spills secrets like a chatterbox.&lt;/p&gt;

&lt;p&gt;But, oh boy, here comes the buzzkill! You’re typing away, a command misbehaves, you freak out, hit “Ctrl-C,” and suddenly, the whole connection goes poof.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfkhfx01g0klbp8uor4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfkhfx01g0klbp8uor4a.png" alt="0ops !&amp;lt;br&amp;gt;
" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, these not-so-smart shells have more issues than a cat trying to sneak past a bunch of dogs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Commands like “su” and “ssh” act like drama queens, demanding a fancy terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;STDERR stays hidden, like it’s playing hide and seek.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using text editors like Vim becomes a slapstick comedy — imagine trying to teach a robot to tango.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tab completion? It takes a vacation, and it’s not sending a postcard.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Going back in command history with the up arrow? Nope, too old-school.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Job control? It’s like a part-time job — doesn’t work full hours.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And the comedy show goes on…&lt;/p&gt;

&lt;p&gt;To keep it simple, catching those shells is okay, but I really prefer working with a fully interactive TTY. It just makes things smoother.&lt;/p&gt;

&lt;p&gt;First you need to upgrade your shell using one of those commands :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$ &lt;strong&gt;python&lt;/strong&gt; -c "import pty; pty.spawn('/bin/bash')"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$ &lt;strong&gt;ruby&lt;/strong&gt; -e "exec '/bin/bash'"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$ &lt;strong&gt;perl&lt;/strong&gt; -e "exec '/bin/bash';"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;for me i will use python&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fempigaaz8izcp2ecgh34.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fempigaaz8izcp2ecgh34.png" alt="spawn a pty shell" width="800" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt; , Press &lt;code&gt;CTRL + Z&lt;/code&gt; to background process and get back to your host machine&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then&lt;/strong&gt; , Use stty command to set terminal line settings and foreground back the target terminal:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$ &lt;strong&gt;stty&lt;/strong&gt; raw -echo; fg&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Finally&lt;/strong&gt;, Set the terminal environment to something more appealing (e.g. xterm, xterm-256, etc):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$ &lt;strong&gt;export&lt;/strong&gt; TERM=xterm-256-color&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ak4gizag6c5wnr1vxtg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ak4gizag6c5wnr1vxtg.png" alt="You should now have a stabilized bash shell that can tab complete, clear the screen, and use  raw `CTRL + C` endraw !" width="800" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should now have a stabilized bash shell that can tab complete, clear the screen, and use &lt;code&gt;CTRL + C&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s another trick in the bag to secure a stable terminal window, you can turn to the socat command-line tool. The only catch is that the target machine might not have this tool ready to roll out of the box. So, you’ll have to take a few extra steps to get it installed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For more details, check out the reference on&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/" rel="noopener noreferrer"&gt;&lt;strong&gt;Upgrading Simple Shells to Fully Interactive TTYs&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks for reading &amp;lt; 3
&lt;/h3&gt;

</description>
      <category>linux</category>
      <category>shell</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
  </channel>
</rss>
