Haber... despues de leer varios tutoriales y fracasar en los ejemplos que A TODO mundo le salen, he decidido postear (derrotado y cansado) el problema que siempre he tenido al intentar un SQL Injection.
Siempre, siempre tengo problemas con la put@ intruccion UNION. En todo lado lo ponen tan fácil pero nunca me sale, incluso, hice una pequeña base de datos para probar y nada.
Ahi va mi fallido intento, tengo esta base de datos en mysql:
mysql> describe tabla1;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| cod | int(3) | YES | | NULL | |
| nombre | varchar(30) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
y
mysql> describe tabla2;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| cod | int(3) | YES | | NULL | |
| nombre | varchar(30) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
Si consulto por separado:
mysql> select cod, nombre from tabla1;
+------+-----------+
| cod | nombre |
+------+-----------+
| 1 | Juanito |
| 2 | Pepito |
| 3 | Juanchito |
+------+-----------+
mysql> select cod, nombre from tabla2;
+------+----------+
| cod | nombre |
+------+----------+
| 1 | Pedrito |
| 2 | Pirobito |
| 3 | Ferchito |
+------+----------+
Ahora intento la UNION de una y otra forma, pero...
mysql> select cod, nombre from tabla1 UNION select cod, nombre from tabla2;
ERROR 1064: You have an error in your SQL syntax near 'UNION select cod, nombre
from tabla2' at line 1
El mismo error así:
mysql> select cod, nombre from tabla1 where cod= 1 UNION select cod, nombre from tabla2;
Y así:
mysql> select cod, nombre from tabla1 where cod= 1 UNION select cod, nombre from tabla2 where cod=1;
Y así:
select * from tabla1 UNION * from tabla2;
Y así:
(select cod, nombre from tabla1) UNION (select cod, nombre from tabla2);
Y nada, maldita sea... alguien que me aclare porque solo no pude ;(
Saludos!!!