Skip to content

Instantly share code, notes, and snippets.

@Xib3rR4dAr
Last active July 3, 2023 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xib3rR4dAr/833190b31fba8eb74ac39c6171c76933 to your computer and use it in GitHub Desktop.
Save Xib3rR4dAr/833190b31fba8eb74ac39c6171c76933 to your computer and use it in GitHub Desktop.
Solution of challenge "phash" from AUPCTF

phash

Challenge Name: phash
Challenge Text: login source
Initial Hint: No Hint First Hint (when no one solved): Marvel characters (lowercased) Second Hint: Who was the character that fans speculated would appear in a "Marvel Show" but ultimately did not make an appearance? (Third Hint was provided after first 🩸 was obtained by me)

Provided:
image

Solution

Login page is shown on visting https://challs.aupctf.live/phash/

image

Provided logic.py:

from django.shortcuts import render
from django.contrib import messages
import hashlib
import random

with open('marvel.txt', 'r', encoding='utf-8', errors='ignore') as file:
    wordlist = file.read().splitlines()

random_word = random.choice(wordlist)
random_md5 = hashlib.md5(random_word.encode('utf-8')).hexdigest()

def login(request):
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')

        if username == 'admin' and password == random_md5:
            messages.success(request, 'Congratulations! Here is your flag [REDACTED]')
        else:
            messages.error(request, 'Invalid username or password.')

    return render(request, 'phash.html')

image

Looking at logic.py, we can see that to get flag username should be admin and password should be md5 hash of some Marvel character's name.

For this, we can get Marvel charcaters list from https://github.com/JacksonBates/wordlists/blob/master/marvel.txt

  1. Load login request to Burp Intruder. Set username to admin and set password as variable in intruder.
  2. Add two payload processing rules as i) Rule type: modify case, lowercase ii) Rule type: Hash, MD5
  3. Start intruder attack and sort responses by response length, odd length response will contain flag.
    image image image image image image image

To be learned from this writeup: Payload processing rules in burp

End: Got First 🩸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment