Post Jobs

Ssti ctf writeup

Please consider reading both parts in their entirety. Part 2 can be found here. As security professionals, we are in the business of helping organizations make risk-based decisions. Seeing as risk is a product of impact and likelihood, without knowing the true impact of a vulnerability, we are unable to properly calculate the risk. This article is the result of that research. The scenario behind this code is that the developer thought it would be silly to have a separate template file for a small page, so he created a template string within the view function.

Pretty reasonable, right? Most people who see this behavior immediately think XSS, and they would be right. This is a good example of that. Now that we have a working exploit, the next step is to dig into the template context and find out what is available to an attacker of the application through the SSTI vulnerability.

Modify the vulnerable view function of the proof-of-concept application to look as follows. There are several sources from which objects end up in the template context. Item 3 is application dependent and can be accomplished in a number of ways.

This stackoverflow discussion contains a few examples. We make our first interesting discovery by introspecting the request object. Within the request object is an object named environ. The request. You guessed it. An extremely low effort denial-of-service. This method does not exist when running the applicatiom using gunicorn, so the vulnerability may be limited to the development server. Our second interesting discovery comes from introspecting the config object.

The config object contains all of the configuration values AFTER they have been resolved by the framework. Our most interesting discovery also comes from introspecting the config object. Finally, an opportunity to dig into source code. The interesting thing about this is that attributes added to the config object maintain their type, which means functions added to the config object can be called from the template context via the config object.

This will add to the config object all attributes of the os library whose variable names are all uppercase. Also notice the types of these configuration items. Any callable items added to the config object can now be called through the SSTI vulnerability.

The next step is finding functionality within the available importable modules that can be manipulated to break out of the template sandbox.

MuzzyBox: 1 Walkthrough Vulnhub CTF

Below is some abbreviated output from the script when run against Python 2. From here, we apply our methodology to the interesting items in hopes of finding something we can use to escape the template sandbox. TL;DR, I was unable to find a sandbox escape through any of these items.Intro Setup: Your virtual environment must be active to use thunder.

I tried to mess around with GO templates since we can define the template in the t parameter. La maquina Writeup fue retirada y aqui esta la solucion que le di a esta maquina. Description Walk softly over to the edge and peak over to the flag. Lets start. The contest was hard but pretty good!

ssti ctf writeup

I feel it was pity that I couldn't solve any tasks about crypto I'd like to post the write-up for some tasks I solved. If you're lucky, your business will grow without much effort. The remote attack vector on the machine is a direct way to get root in case you just read and understand the description of the exploit, so anyone reading this may benefit a bit more from the second attack vector I described.

I have a passion to get to know and learn about anything related to the internet, such as information, technology that exist above the internet, and utilize the internet to do something that I like to do.

If you have any proposal or correction do not hesitate to leave a comment. The best way to get started with this is to jump into a local python terminal. The alternative template is the error string and the error string contains our supplied malicious file name. This year we have prepared challenges from a diverse range of categories such as cryptography, web exploitation, forensics, reverse engineering, binary exploitation, OSINT, quantum computing and more!

A crypto warmup question, how lovely. The try-except part got my attention at first sight. A collection of write-ups for various systems. What does this mean? The NX bit is a feature used to mark certain areas of memory e. Talk is cheap, show you my paper. GitHub Gist: instantly share code, notes, and snippets. Table of Contents: Easyauth Theyear Zumbo 1 Zumbo 2 Zumbo 3 Easyauth This challenge was Grepping the template source files available on GitHub quickly gave me a confirmation that this was indeed the key used to sign the cookies : The first line retrieves the environment variable value and stores it for use in app.

Here is a write-up with the process we took from start to finish. Posted on 29 May Updated on 30 May It is Template Injection In any page. I spent about two days on this, even though it could be done within three hours. So, I wrote a script to try to verify the signature of my session cookie to see if secret-key really is the valid key.Could you take a look?

Now, can you find a way to log in as admin? Can you?

[Writeup - ctf pycon 2019] On flag les 3 Reverse Engineering

Can you leverage the injection technique to get remote code execution? Can you use this table to solve it?. Maybe they can be used to get a password to the process. Connect with nc shell2. Files can be found here: passwd shadow. And again. If you're not careful these kind of problems can really "rockyou".

Can you decrypt it? Two special fields " r" and " s" represent return address and saved registers. You also might be able to find some good shellcode online. You are not logged in to any team.

List of all users List of all organizatioins Advent Calendar. Signup Login. Improve article. Help us understand the problem. What is going on with this article? It's illegal copyright infringement, privacy infringement, libel, etc.

ssti ctf writeup

It's socially inappropriate offensive to public order and morals. It's advertising. It's spam. Other than the above, but not suitable for the Qiita community violation of guidelines. More than 1 year has passed since last update.Well it all begins with a new CTF. Kudos to this guy for creating this challenge! First thing I did was to run an nmap scan! I decided to run an nmap aggressive scan in order to get all possible details regarding the ports which are up and running!

Exploring SSTI in Flask/Jinja2

Nmap 7. OS and Service detection performed. Nmap done at Mon Aug 19 -- 1 IP address 1 host up scanned in We can see that port 21 is open and allows anonymous FTP login. On trying to access the FTP it does not shows anything!

The Gobuster revealed some directories. On checking the default robots. While there is one more directory! The usage of the script is as above! I enumerated the machine further to find places where I could potentially escalate my privileges!

After some investigation, it looks like this user can run Vim as root! Nmap Aggressive Scan! Well this turned to be a rabbit-hole! On opening the default IP in the browser we are provided with the default Apache page! On trying opening this directory it seems to be a rabbit-hole!

Doing a quick google search, I came across multiple CVEs. One being a SQL Injection! Once ran i was prompted with the username and password! On checking the directory I came across the user flag! So we can run the VIM and can escalate out privileges by spawning the shell! I hope that you will be able to find the root flag! Happy Hunting! TryHackMe Blog. Share this.This cheatsheet will introduce the basics of SSTI, along with some evasion techniques we gathered along the way from talks, blog posts, hackerone reports and direct experience.

It would result in 49 in Twig, in Jinja2, and neither if no template language is in use. This step is sometimes as trivial as submitting invalid syntax, as template engines may identify themselves in the resulting error messages.

Note that there are other methods to identify more template engines. Tplmap or its Burp Suite Plugin will do the trick. This guide will specifically focus on Jinja2. Read the docs for more. Basically, you can crawl up the inheritance tree of the known objects using mrothus accessing every class loaded in the current python environment! The usual exploitation starts with the following: from a simple empty string "" you will create a new-type object, type str. If you happen to have the source code of the application, look for the flask.

There are several sources from which objects end up in the template context. Remember that there may be sensitive vars explicitly added by the developer, making the SSTI easier. You can use this list by albinowax to fuzz common variable names with Burp or Zap. The following global variables are available within Jinja2 templates by default:. If you want to explore in major details their globals, here are the links to the API docs: Flask and Jinja. You may conduct introspection with the locals object using dir and help to see everything that is available to the template context.

You can also use introspection to reach every other application variable. This script written by the DoubleSigma team will traverse over child attributes of request recursively. For example, if you need to reach the blacklisted config var you may access it anyway via:. The request.

Exploring SSTI in Flask/Jinja2, Part II

Injecting '' should be enough to shut down the server. So we need an object which has a class inherited from object. While open is the built-in function for creating file objects, the file class is also capable of instantiating file objects, and if we can instantiate a file object then we can use methods like read to extract the contents.

This injection will do the trick:. By using the subprocess class you may issue arbitrary commands. This may be version-dependent:. We now write arbitrary payloads by passing request.After logging in, we are greeted with this page:. On submission, the 3 form fields are sent to the server. The homepage then displays the event, according to the property we chose. After inserting some basic SSTI payloads to the name and address field with no success. It turned out, not only did this verify that it is actually a template injection but also how it is being done.

Judging from the fmt property which uses argument numbers and single curly braces, the server most likely uses Python's built-in format method to create the template.

We have references to SQL Alchemy objects and classes, so maybe it's somehow possible access the database that way. Unfortunately, Python's format method can only do property accesses and not method calls so it's probably going to be really hard if not impossible to query the database.

ssti ctf writeup

I tried lol. Another way worth trying is to access the global objects and modules in the application and hope that there's something interesting inside them. And voila! One of particular interest is the Flask app instance. At this point I didn't realize that by default Flask uses signed cookieswhich means the server signs the session data and sends it back to the client.

Signed cookies sessions are meant to reduce server load by off-loading session data to the client while keeping it secure by signing it with a secret. Unfortunately this makes it very easy for an attacker with a secret key to forge session data by creating the session data and then signing it using the secret key.

This why you should as keep your secret key, secret. I ran a Flask app to forge signed cookies. It successfully authenticated me as another user but didn't grant me admin authorization. So I looked to the other cookie, user. Decoding it reveals that it is actually storing the user's username.Posted on 29 May Updated on 30 May When we look at the source code it is seen that the js code is checked in the client side.

InCTF-2018 Web challenges writeup

If you are an administrator, click here to go to the admin interface. It seems that the signup button is disabled, can you manage to click it any way? Dump all of the classes used in the application. Now we can invoke the new configuration item to run commands on the remote operating system. Our server is vulnerable to a well known attack. What was it called? The system can be accessed at We identified a strange service. Can you identify the flag in the service response?

The system can be reached on When i saw this after a hour. Beating Rock Paper Scisscors is easy when you run it locally. Can you also beat it on the remote service listed below? Hint: No memory corruption is required, think of a way to predict what the computer is going to pick.

You may reach the system at This entry was posted in Writeup and tagged ctfdeloittehackazonpython Beating Rock Paper Scisscorstemplate injectionWriteup. Hey, did you start solving the actual challenge?

I am new with this stuff and im searching for Tipps. You are commenting using your WordPress. You are commenting using your Google account. You are commenting using your Twitter account. You are commenting using your Facebook account. Notify me of new comments via email. Notify me of new posts via email. This article contains the solution of the questions in this competition. Solution: When we look at the source code it is seen that the js code is checked in the client side. When you click the up link; If you are an administrator, click here to go to the admin interface.

Solution: When we entered the link; We have a interesting cookie, when we modify the cookie; We got the flag.

Solution: Nmap output; Nmap scan report for