TCP Reverse Shell Using Python

January 31, 2017 | Views: 15681

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Estimated reading time: 1 minute

This article is about creating a reverse shell session over TCP using Python Sockets. Let me explain what happens in a general sense.

First, the server binds its IP address and a PORT to a socket [note that I implemented a fixed solution for other people whose routers change IPs whenever they restart them]. Second, the client initiates a TCP connection to the client on that socket. This clearly doesn’t generate any alert, except a simple connection to a remote server using TCP. After the client(s) connects, we select a target and basically, everything that you write (Server Side) is sent over the socket. Then the client executes it in a subprocess like a command, but it still doesn’t trigger any alert for antivirus or firewall. The result of the execution is sent back to the server so you can read the result.

I put two versions, one encrypted and the other one clear text, with various function implementations. If you are interested in my code, please visit: https://github.com/chmodxxx/tcp_reverse_shell

Any remarks on things I can improve are welcome. Thank you.

Share with Friends
FacebookTwitterLinkedInEmail
Use Cybytes and
Tip the Author!
Join
Share with Friends
FacebookTwitterLinkedInEmail
Ready to share your knowledge and expertise?
5 Comments
  1. At first I was like ‘Whoa, that’s got to be the shortest article I have ever seen’ then I clicked on the link and it was like opening up a Kinder Egg with the toy inside. My way of complimenting you, my hats off you to sir/ma’am. Great work! Keep it up! ^_^

  2. Nice Work on generating asymmetric Cryptography and stuff, I’m really looking forward to see your tunnel version (hybrid Crypto.) Way to go, Bro 🙂

Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge

 
Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel