

The socket is binded and waits for the connection incoming connection. You can refer the official documentation of Python sockets for this or even a simple Google search will do. Sockets are created using socket module which is relatively simple. After the creation of private key, public key is extracted from it and stored in a variable for future use. The function RSA.generate takes two arguments, first is the size of the key in bits and second is the random number usually generated using python random function. key = RSA.generate(2048, random_generator) In the program above, a key is generated first which is also a private key. If you are interested in mathematical working of RSA, then I recommend reading (Beware, for geeks only) Below is a block diagram which describes the process In simple words, public key is used to encrypt the message and private key is used to decrypt. RSA is an asymmetric encryption standard. $ sudo pip install pycryptoīefore we jump into the code let me explain you a bit about RSA encryption and it’s keys. I use P圜rypto module for cryptography in Python. Start_new_thread(clienthandle, (client,)) Start_new_thread(clientthread_sendpublickey, (client,)) Print " Listening to the incoming connection on port 4444." Error code : " + str(v) + " Message " + v

S = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Create socket and bind to accept connections Key = RSA.generate(2048, random_generator) Here is the code of listener_rsa.py #!/usr/bin/python

Listenerįirst we need a listener to handle all incoming connections. I like to mention that this post is more about understanding the cryptography involved in the shell rather than the shell itself. This is a python tutorial on programming a reverse shell with RSA encryption.
