Information#
Version#
By | Version | Comment |
---|---|---|
noraj | 1.0 | Creation |
CTF#
- Name : ASIS CTF Finals 2017
- Website : asisctf.com
- Type : Online
- Format : Jeopardy
- CTF Time : link
Dig Dug - Web#
The pot calling the kettle black.
We can begin to look at the website:
Challenge name is Dig Dug, they even tell us the acronym of dig.
Note admin are using dig (dnsutils) so they are not archlinux user because instead they will have use drill (ldns). If you want to know why drill is better than dig: link1 and link2.
They are clearly asking us to take a look at DNS.
Easy we get the IP. Now let's make a reverse DNS lookup.
Note: $ drill -x 192.81.223.250
does the same as drill 250.223.81.192.in-addr.arpa PTR
.
So now we get another domain airplane.asisctf.com
. Maybe a website? ($ curl https://airplane.asisctf.com
):
You can take a look at js.js
but it is a very long script that is minified, this will be pain to decode it.
Maybe we can use a GUI browser this time. Fire Firefox:
They tell us to enable offline mode? Why not:
Flag: ASIS{_just_Go_Offline_When_you_want_to_be_creative_!}
.
Golem is stupid! - Web#
Golem is an animated anthropomorphic being that is magically created entirely from inanimate matter, but Golem is stupid!
It (https://golem.asisctf.com/
) looks like a search engine, it make a POST request with the searched word to https://golem.asisctf.com/golem. Then the content is Hello : <searched word here>, why you don't look at our article?
so we may look for injection in the future (I tried, it is vulnerable to XSS). But first we will follow the link to the article: https://golem.asisctf.com/article?name=article
Nice a GET param, let's try some basic LFI: https://golem.asisctf.com/article?name=../../../../etc/passwd
: bingo we got the file.
I found nothing with FLI let's try something else.
My cookie is eyJnb2xlbSI6bnVsbH0.DJSUhw.vmX8qssjPNZtKGf8xri-PhT8UZM
. It looks like JWT but it is not, it's Flask cookie.
Flask cookies look like JWT (JSON Web Tokens) but that's not the same structure. JWT are header.data.signature, flask cookies are data.nonce.signature.
So the I used flask-session-cookie-manager to decode the cookie:
But we will need the SECRET_KEY from config.py
of the Flask app to sign the modified cookie.
PS: I discovered flask cookie in CTFZone 2017 - Leaked messages challenge.
Let's start by seeing how application was launched: https://golem.asisctf.com/article?name=../../../../../../../proc/self/cmdline
: /usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini --ini /etc/uwsgi/apps-enabled/golem_proj.ini --daemonize /var/log/uwsgi/app/golem_proj.log
.
/etc/uwsgi/apps-enabled/golem_proj.ini
:
Let's see the golem server source /opt/serverPython/golem/server.py
(https://ghostbin.com/paste/32qdz):
We can't see flag.py
(because when flag is find in name notallowed.txt
is displayed instead) but we can see key.py
: key = '7h15_5h0uld_b3_r34lly_53cur3d'
.
Now let's craft a cookie with an SSTI in order to inject the template %s
feed with session['golem']
:
Node: Why we need SSTI trough cookie? We can't do SSTI trough POST because of the replace method removing {
and }
, preventing us to do some template injection.
So finally I used BurpSuite as a proxy to change my cookie.
My SSTI is using {{ config.items() }}
as payload in order to list all what is in Flask config:
So here was the flag: ('FLAG', 'ASIS{I_l0v3_SerV3r_S1d3_T3mplate_1nj3ct1on!!}')
.
PS: To know more about SSTI into Flask.
Mathilda - Web#
Mathilda learned many skills from Leon, now she want to use them!
Always see the source:
Ok rooney let's if you have a directory:
Obviously there is something to do with http://178.62.48.181/~rooney/?path=rooney
.
Basic LFI won't work here but we can try some LFI filter bypass, here is used a pattern I used in a previous article: http://178.62.48.181/~rooney/?path=....//....//....//....//....//etc/passwd
So now that we have a valid payload, let's try to find more interestign stuff: http://178.62.48.181/~rooney/?path=....//....//....//....//....//proc/self/cmdline: /usr/sbin/apache2-kstart
.
If it run apache we can go to /etc/apache2/apache2.conf
: http://178.62.48.181/~rooney/?path=....//....//....//....//....//etc/apache2/apache2.conf
We can see at the end of the config file:
So let's go: http://178.62.48.181/~rooney/?path=....//....//....//....//....//etc/apache2/vhost/host.conf
It looks great for us:
As in the previous challenge, putting flag in the url result in Security failed!
so we must find something else.
We saw previously that we have an user with a valid shell (from /etc/passwd
: th1sizveryl0ngus3rn4me:x:1001:1001:,,,:/home/th1sizveryl0ngus3rn4me:/bin/bash
) and we saw in /etc/ssh/sshd_config
that ssh connection use password. After trying to do some basic bruteforce on ssh and user th1sizveryl0ngus3rn4me I thought it has to be on his user web directory /home/th1sizveryl0ngus3rn4me/public_html
but going to http://178.62.48.181/~th1sizveryl0ngus3rn4me/ give us an Invalid Device error.
Ok so let's guess it's PHP an go to http://178.62.48.181/~rooney/?path=....//....//....//....//....//home/th1sizveryl0ngus3rn4me/public_html/index.php but we get Security failed!. There is a filter on ../
so why not on php
too? Ok web server you want to remove ../
? So do it: index.p../hp
will begin index.php
.
Finally:
We can do the same with flag.php
(as the next curl shows) or send the wanted user agent.