CONDING LEVEL 1 HACKTHIS

Vaya vaya, viendo videos en youtube hay uno que nos da un enlace a un programa que nos facilita pasar el reto(no creo que siga funcionando) sin comernos la cabeza, pero para eso estan... así que vamos a hacerlo desde la consola, pues en otro video nos enseñan a hacerlo en javascript, este último explica los dos niveles, 1,2.

De todas formas, decir que viendo los videos, ahora hackthis no nos muestran los datos igual que en ellos, así que el procedimiento no es el mismo, pero al menos nos da una idea, y si sabemos programar tenemos el codigo fuente del primero para modificarlo.

Pero vayamos a hacerlo en consola
Lo primero es capturar la información de nuestra cookie, pues nos hará falta para usarlo con el comando curl y autentificarnos como usuario y recibir el reto en cuestion, y una vez obtenida hacer esto:
curl -s --cookie "$cookie" "https://www.hackthis.co.uk/levels/coding/1" > pagina.txt
donde poner $cookie lo sustituimos por nuestra cookie, teniendo presente dejar las dobles comillas. De esta forma recibimos la pagina(pagina.txt) sobre la que vamos a hacer todos los experimentos:
A continuación buscamos el campo textarea para ver las palabras con las que tenemos que jugar

┌─([13:04]sierra21@sierra21)-(~)
└──┤▶
grep -i textarea pagina.txt
<textarea>just, its, like, almost, among, does, from, his, while, her, then, twas, could, most, with, because, ever, cannot, been, rather, this, than, whom, would, say, across, too, often, but, that, was, some, own, only, least, must, him, have, these, likely, which, our, else, their, all, either, says, off, neither, are</textarea>
<textarea name="answer"></textarea>

Ahora usamos cut para mostrar solo las palabras

┌─([13:10]sierra21@sierra21)-(~)
└──┤▶
grep -i textarea pagina.txt |cut -d ">" -f2 |cut -d "<" -f1
just, its, like, almost, among, does, from, his, while, her, then, twas, could, most, with, because, ever, cannot, been, rather, this, than, whom, would, say, across, too, often, but, that, was, some, own, only, least, must, him, have, these, likely, which, our, else, their, all, either, says, off, neither, are

Vamos a ordenarlas, quitandoles la coma

┌─([13:11]sierra21@sierra21)-(~)
└──┤▶
grep -i textarea pagina.txt |cut -d ">" -f2 |cut -d "<" -f1|sed 's/,//g' |awk '{ for (i=1; i <= NF; ++i) print $i }'|sort
across
all
almost
among
are
because
been
but
cannot
could
does
either
else
ever
from
have
her
him
his
its
just
least
like
likely
most
must
neither
off
often
only
our
own
rather
say
says
some
than
that
their
then
these
this
too
twas
was
which
while
whom
with
would

Ya estamos llegando al final, pues ahora ya solo vamos a formatear de nuevo la letras con su coma(%2C) y listo

┌─([13:21]sierra21@sierra21)-(~)
└──┤▶
grep -i textarea pagina.txt |cut -d ">" -f2 |cut -d "<" -f1|sed 's/,//g' |awk '{ for (i=1; i <= NF; ++i) print $i }'|sort |awk -v ORS="," -v FS="\n" '{ for (i = 1; i <= NF; ++i) print $i }'|sed 's/.$//'|sed 's/,/%2C+/g'
across%2C+all%2C+almost%2C+among%2C+are%2C+because%2C+been%2C+but%2C+cannot%2C
+could%2C+does%2C+either%2C+else%2C+ever%2C+from%2C+have%2C+her%2C+him%2C
+his%2C+its%2C+just%2C+least%2C+like%2C+likely%2C+most%2C+must%2C+neither%2C+off%2C
+often%2C+only%2C+our%2C+own%2C+rather%2C+say%2C+says%2C+some%2C+than%2C
+that%2C+their%2C+then%2C+these%2C+this%2C+too%2C+twas%2C+was%2C+which%2C
+while%2C+whom%2C+with%2C+would

Ya tenemos los datos que necesitamos enviar ordenados alfabeticmente, así que construimos algún scritp en bash para procesar todo lo hecho y enviar los datos obtenidos con curl
No me he esmerado mucho ni el el código anterior ni en el script que pongo a continuación, dicho esto:


#!/bin/bash

echo "Introduce tu cookie entre comillas dobles:"
read cookie

sleep 2

envio=`curl -s --cookie "$cookie" "https://www.hackthis.co.uk/levels/coding/1" | grep -E 'textarea'|cut -d ">" -f2 |cut -d "<" -f1 |sed 's/,//g' |awk  '{ for (i=1; i <= NF; ++i) print $i }'|sort |awk -v ORS="," -v FS="\n" '{ for (i = 1; i <= NF; ++i) print $i }'|sed 's/.$//'|sed 's/,/%2C+/g'`

curl -s --cookie "$cookie" --data "answer=$envio" "https://www.hackthis.co.uk/levels/coding/1" > respuesta.html

Ejecutado el script y pegando nuestra cookie cuando nos la pida, a los dos segundos tendremos la respuesta de la pagina en respuesta.html, podemos mirarla o bien directamente refrescar la pagina del reto y ver si se ha conseguido.