ProxyAsAService

Description

Source

blueprints/routes.py

from flask import Blueprint, request, Response, jsonify, redirect, url_for
from application.util import is_from_localhost, proxy_req
import random, os

SITE_NAME = 'reddit.com'

proxy_api = Blueprint('proxy_api', __name__)
debug     = Blueprint('debug', __name__)


@proxy_api.route('/', methods=['GET', 'POST'])
def proxy():
    url = request.args.get('url')

    if not url:
        cat_meme_subreddits = [
            '/r/cats/',
            '/r/catpictures',
            '/r/catvideos/'
        ]

        random_subreddit = random.choice(cat_meme_subreddits)

        return redirect(url_for('.proxy', url=random_subreddit))
    
    target_url = f'http://{SITE_NAME}{url}'
    response, headers = proxy_req(target_url)

    return Response(response.content, response.status_code, headers.items())

@debug.route('/environment', methods=['GET'])
@is_from_localhost
def debug_environment():
    environment_info = {
        'Environment variables': dict(os.environ),
        'Request headers': dict(request.headers)
    }

    return jsonify(environment_info)

app.py

util.py

Solution

Whenever we go to challenge url we are redirected to some random subreddit, that happens if url is not provided.

Proxy url is hardcoded with reddit.com prefix and we can't really do anything about it, or can we?

Because we are on HTTP protocol we can use @ and URL becomes http://reddit.com@evil.com

RFC3986 > 3.2.1. User Informationarrow-up-right

Protocol standards follow the format of: scheme://[user:password@]host[:port]/path[?query][#fragment]

Good, we bypassed the reddit prefix. How do we leak internal information?

ProxyAsAService.png

The debug endpoint has good endpoint that just dumps env and env contains the flag 👀

There's restricted chunks of IP, but it doesn't contain 0 my favorite \o/

From run.py we know that app is running on port 1337 internally

Get the env variables

circle-check

Last updated