I will assume you are using kali linux which comes with metasploit preinstalled or you already know how to install it. To generate shellcode we need to use a tool that comes with metasploit-framework called msfvenom. Generating the shellcode is simple enough. If you have not used msfvenom before you can check out a guide here..For our purposes we are just going to be using a meterpreter reverse tcp payload.