Skip to content

MITMProxy addon to replace false with true in HTTP responses

License

Notifications You must be signed in to change notification settings

SakuraNekooo/false2true-proxy

Repository files navigation

False2True Proxy

A MITMProxy addon that automatically replaces false with true in HTTP responses. Useful for testing, debugging, or having some fun with web applications.

Features

  • πŸ”„ Replaces false with true in HTTP responses
  • 🎯 Smart content-type detection (JSON, HTML, JavaScript, XML, etc.)
  • πŸ›‘οΈ Preserves JSON structure when possible
  • πŸ“Š Logging and statistics
  • 🚫 Skips binary content (images, videos, etc.)
  • πŸ”§ Configurable via command-line options
  • 🐳 Docker container support
  • ☁️ GitHub Container Registry (GHCR) hosted images

Installation

Prerequisites

  • Python 3.7+
  • pip

Install from source

git clone https://github.com/SakuraNekooo/false2true-proxy.git
cd false2true-proxy
pip install -r requirements.txt

Quick install

pip install mitmproxy

Docker Installation

# Pull from GitHub Container Registry
docker pull ghcr.io/sakuranekooo/false2true-proxy:latest

# Or build locally
docker build -t false2true-proxy .

Usage

Basic usage (Python)

mitmdump -s mitm_false2true.py

With mitmproxy (interactive)

mitmproxy -s mitm_false2true.py

Docker Usage

Run with Docker

# Basic usage
docker run -p 8080:8080 ghcr.io/sakuranekooo/false2true-proxy:latest

# Custom port
docker run -p 8888:8080 ghcr.io/sakuranekooo/false2true-proxy:latest --listen-port 8888

# Persist mitmproxy data
docker run -p 8080:8080 -v mitmproxy-data:/home/mitmuser/.mitmproxy ghcr.io/sakuranekooo/false2true-proxy:latest

# Save traffic to file
docker run -p 8080:8080 -v ./traffic:/home/mitmuser/.mitmproxy ghcr.io/sakuranekooo/false2true-proxy:latest -w /home/mitmuser/.mitmproxy/traffic.mitm

Docker Compose

# Start with docker-compose
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Kubernetes (example)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: false2true-proxy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: false2true-proxy
  template:
    metadata:
      labels:
        app: false2true-proxy
    spec:
      containers:
      - name: false2true-proxy
        image: ghcr.io/sakuranekooo/false2true-proxy:latest
        ports:
        - containerPort: 8080
        env:
        - name: MITMPROXY_VERBOSE
          value: "false"

Set proxy in your browser or system

  1. Configure your browser/system to use the proxy at 127.0.0.1:8080
  2. Install the MITMProxy CA certificate (mitmproxy will guide you)
  3. Start browsing - all false values will become true!

Advanced options

# Run on a different port
mitmdump -s mitm_false2true.py --listen-port 8888

# Verbose logging
mitmdump -s mitm_false2true.py -v

# Save modified traffic to file
mitmdump -s mitm_false2true.py -w modified_traffic.mitm

# Docker with custom options
docker run -p 8080:8080 ghcr.io/sakuranekooo/false2true-proxy:latest --set block_global=false -v

Container Registry

The Docker image is available on GitHub Container Registry:

Primary Image: ghcr.io/sakuranekooo/false2true-proxy:latest

Available Tags:

  • latest - Latest stable release
  • v1.x.x - Version tags (e.g., v1.0.0)
  • sha-xxxxxx - Commit SHA tags
  • main - Latest from main branch

Pull Command:

docker pull ghcr.io/sakuranekooo/false2true-proxy:latest

How It Works

The addon intercepts HTTP responses and:

  1. Checks if the content-type is text-based (JSON, HTML, JS, XML, etc.)
  2. Decodes the response content
  3. Replaces all occurrences of false with true (and False with True)
  4. For JSON responses, it also converts boolean false to true
  5. Returns the modified response to the client

Examples

Before (JSON response):

{
  "success": false,
  "enabled": false,
  "count": 0,
  "message": "Operation failed",
  "items": []
}

After modification:

{
  "success": true,
  "enabled": true,
  "count": 0,
  "message": "Operation failed",
  "items": []
}

Before (JavaScript):

var isReady = false;
var hasError = false;

After modification:

var isReady = true;
var hasError = true;

Use Cases

  • πŸ§ͺ Testing how applications behave when APIs always return true
  • πŸ› Debugging optimistic UI states
  • 🎭 Pranks (use responsibly!)
  • πŸ”¬ Research on client-side validation
  • πŸ› οΈ Development and prototyping
  • 🐳 Containerized testing environments
  • ☁️ Cloud-native application testing

Configuration

Environment Variables

  • FALSE2TRUE_PORT - Proxy port (default: 8080)
  • FALSE2TRUE_VERBOSE - Enable verbose logging
  • MITMPROXY_VERBOSE - MITMProxy verbose mode

Docker Environment Variables

docker run -e MITMPROXY_VERBOSE=true -p 8080:8080 ghcr.io/sakuranekooo/false2true-proxy:latest

Content Types Processed

By default, the addon processes these content types:

  • text/* (all text types)
  • application/json
  • application/javascript
  • application/xml
  • application/xhtml+xml

Project Structure

false2true-proxy/
β”œβ”€β”€ mitm_false2true.py    # Main MITMProxy addon
β”œβ”€β”€ requirements.txt      # Python dependencies
β”œβ”€β”€ Dockerfile           # Docker image definition
β”œβ”€β”€ docker-compose.yml   # Docker Compose configuration
β”œβ”€β”€ .dockerignore        # Docker ignore file
β”œβ”€β”€ README.md            # This file
β”œβ”€β”€ .gitignore           # Git ignore file
β”œβ”€β”€ .github/workflows/   # CI/CD workflows
β”‚   └── docker.yml       # Docker build and push workflow
β”œβ”€β”€ examples/            # Example configurations
β”‚   β”œβ”€β”€ custom_rules.py  # Example of custom rules
β”‚   └── test_server.py   # Simple test server
└── tests/               # Test files
    └── test_addon.py    # Unit tests

Development

Running tests

python -m pytest tests/

Building Docker image locally

# Build image
docker build -t false2true-proxy .

# Run tests
docker run --rm false2true-proxy --version

# Run with test server
docker-compose up

GitHub Actions

The project includes GitHub Actions workflow that:

  1. Builds Docker image on push to main
  2. Runs security scans
  3. Pushes to GitHub Container Registry
  4. Creates releases on version tags

Code style

  • Follow PEP 8
  • Use type hints where possible
  • Add docstrings to functions and classes

Security Considerations

⚠️ Important: This tool modifies network traffic. Use responsibly:

  1. Only use on networks and applications you own or have permission to test
  2. The MITMProxy CA certificate must be installed in the client browser/device
  3. This will break SSL/TLS verification unless the certificate is trusted
  4. Some applications may behave unexpectedly when false becomes true
  5. Docker containers run as non-root user for security

Troubleshooting

"Certificate error" in browser

Run MITMProxy and follow the instructions to install its CA certificate.

Addon not modifying responses

  1. Check that the proxy is correctly configured
  2. Verify the content-type is being processed
  3. Enable verbose logging with -v

Docker container issues

# Check container logs
docker logs <container_name>

# Check if container is running
docker ps | grep false2true-proxy

# Run with interactive shell for debugging
docker run -it --entrypoint /bin/bash ghcr.io/sakuranekooo/false2true-proxy:latest

Performance issues

The addon adds minimal overhead. For high-traffic scenarios, consider:

  • Using mitmdump instead of mitmproxy (non-interactive)
  • Adding domain whitelisting in the code
  • Adjusting Docker resource limits

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

Acknowledgments


Note: This tool is for educational and testing purposes only. Use responsibly and with proper authorization.

About

MITMProxy addon to replace false with true in HTTP responses

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages