#!/usr/bin/env python3
"""
TO TEST LOCALLY: Modified Dockerfile that sets FLAG as environment variable

This simulates how the remote challenge likely works.
"""

dockerfile_content = """FROM python:3.11-slim

RUN apt-get update \\
    && apt-get install -y --no-install-recommends \\
        chromium \\
        chromium-driver \\
    && rm -rf /var/lib/apt/lists/*

# THIS IS THE KEY: Set FLAG as environment variable
ENV FLAG=uoftctf{test_flag_local_simulation}

ENV PYTHONDONTWRITEBYTECODE=1 \\
    PYTHONUNBUFFERED=1 \\
    PIP_NO_CACHE_DIR=1 \\
    CHROME_BIN=/usr/bin/chromium \\
    CHROMEDRIVER_PATH=/usr/bin/chromedriver

WORKDIR /app

RUN pip install --no-cache-dir flask selenium

COPY ./src /app

RUN chown -R www-data:www-data /app

RUN mkdir -p /var/www

RUN chown -R www-data:www-data /var/www

USER www-data

EXPOSE 5000

CMD ["python", "app.py"]
"""

print("=" * 80)
print("MODIFIED DOCKERFILE - Sets FLAG Environment Variable")
print("=" * 80)
print("\nThis simulates how the remote challenge likely works:")
print("1. FLAG is set as ENV in Docker")
print("2. Python bot.py reads it via os.environ")
print("3. JavaScript can access it via CDP process.env")
print("\n" + "=" * 80)
print(dockerfile_content)
print("=" * 80)
print("\nTo test locally:")
print("1. Replace your Dockerfile with the above")
print(
    "2. Modify bot.py to use: FLAG = os.environ.get('FLAG', 'uoftctf{fake_flag}')")
print("3. Rebuild: docker build -t pasteboard .")
print("4. Run: docker run -p 5000:5000 pasteboard")
print("5. Use CDP exploits to read process.env.FLAG")
print("=" * 80)
