forked from netspooky/BGGP
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
Awaiting author updateThis entry needs update from its authorThis entry needs update from its authorBGGP EntryBGGP6This issue was created during BGGP6This issue was created during BGGP6
Description
Entry Info
- Date: 2025-11-12
- BGGP Challenge: 6
- Name: dtmsecurity
- Contact Info: https://x.com/dtmsecurity
- Online Presence: https://dtm.uk/
- Writeup Link: https://rap.sh/Python_Pip_Golf
File Info
- Target File Type: .tgz (gzipped tar archive - pip package)
- Target File Size: 150 bytes
- SHA256 Hash: 81fca99e90c6f3a3798e938bf8cddce7a88fbe3abcb039269821ed380d91a787
File Contents
H4sIAAAAAAAC/6vSL04tKS3QK6hkoBkwgABctIGBuTGCDRY3MwEKKRgwjAJag7Si/FwFcBIoyc/PKVbIzC3ILyrRsgYLaRRUxufmp5TmpBbbRqsXZ5akJpcWl+TnZlalqsdqjgbeMABV+ijRSpNygGD+NzRAzf+GBkbGhqP5nx6goCgzr0TDbDQzj1AAAJMYh/oACAAA
Environment Info
Target Software and Version
- Python: 3.8 or later
- pip: Any version (tested with pip 21.0+)
- setuptools: Any version (dependency of pip)
Environment Setup
Description of Target Software's Environment (Platform/OS, Setup Instructions, etc.)
Platform: Linux, macOS, or Windows
Setup Instructions:
- Install Python 3.8 or later
- Ensure pip is installed (usually comes with Python)
- Run:
pip install bggp6_persistent_150b.tgz - After installation, run any Python command to see "6" printed
Expected Behavior:
- Successfully installs a package named "sitecustomize"
- After installation, every Python invocation will print "6" before executing
- Effect persists until the package is uninstalled
Warning: This package modifies Python's site-wide startup behavior. Uninstall with:
pip uninstall sitecustomize -yAdditional Info
This is the PERSISTENT entry - prints "6" on EVERY Python startup after installation.
Technical Details:
- Uses old-style pre-POSIX tar format (no ustar magic)
- Contains TWO files:
setup.pyandsitecustomize.py - Directory name 'z' chosen for optimal gzip compression with 2-file archive
- File permissions set to 000
- No tar EOF marker
Files in archive:
z/setup.py(60 bytes):from setuptools import*;setup(py_modules=['sitecustomize'])z/sitecustomize.py(9 bytes):print(6)
How It Works:
Python automatically imports sitecustomize.py on startup if it's installed in the site-packages directory. By installing this module via pip, we ensure that every Python invocation (scripts, interactive sessions, etc.) will execute our code first.
Optimizations:
- Old-style tar format avoids ustar header overhead
- Star import (
import*) saves 1 byte - Single-char directory 'z' provides best compression for this 2-file payload
- Mode 000 on both files
- No EOF marker in tar archive
- Minimal sitecustomize implementation
Test Commands:
# Install the package
pip install bggp6_persistent_150b.tgz
# Test 1: Run any Python command
python3 -c 'pass'
# Output: 6
# Test 2: Run a Python script
python3 -c 'print("hello")'
# Output:
# 6
# hello
# Test 3: Interactive Python
python3
# Output: 6
# Python 3.x.x ...
# >>>
# Cleanup when done
pip uninstall sitecustomize -yExpected Output Example:
$ python3 -c "pass"
6Metadata
Metadata
Assignees
Labels
Awaiting author updateThis entry needs update from its authorThis entry needs update from its authorBGGP EntryBGGP6This issue was created during BGGP6This issue was created during BGGP6