PythonIntermediate · Windows, macOS, or Linux; Python 3.12+

Find credentials embedded in URL lists

Inspect URL lines for embedded user information and insecure HTTP without printing credential values.

Before you begin

  • Python 3.12 or later.
  • Read access to the selected inputs.
What this script changesRead-only local report. No permissions, accounts, configuration, or input files are changed. Review filenames and metadata before sharing.

Set up your example

  1. Save as security-url-credential-report.py.
  2. Open a terminal in its folder.
  3. Run python "security-url-credential-report.py" --help and prepare the listed input files.

Sample files in this download:

  • urls.txt

Download the ZIP, extract it, and open a terminal inside the extracted folder. The source file is security-url-credential-report.py.

Run the script

Run command
python "security-url-credential-report.py" "urls.txt"

If your system uses python3 instead of python, use that command for Python examples. Keep paths containing spaces in quotes. Required inputs and optional settings are described in the code and setup steps.

What to expect

A credential-bearing HTTPS URL is flagged without exposing its user or password.

The complete script

security-url-credential-report.py
#!/usr/bin/env python3
"""Inspect URL lines for embedded user information and insecure HTTP without printing credential values."""
import argparse
import sys
import json
from pathlib import Path
from urllib.parse import urlsplit

def main():
    parser = argparse.ArgumentParser(description='Inspect URL lines for embedded user information and insecure HTTP without printing credential values.')
    parser.add_argument('urls',type=Path)
    args = parser.parse_args()
    for number,line in enumerate(args.urls.read_text(encoding='utf-8').splitlines(),1):
        if not line.strip() or line.lstrip().startswith('#'):continue
        try:p=urlsplit(line.strip());host=p.hostname
        except ValueError:print(json.dumps({'line':number,'issue':'invalid URL'}));continue
        print(json.dumps({'line':number,'scheme':p.scheme,'host':host,'embedded_credentials':bool(p.username is not None or p.password is not None),'plaintext_http':p.scheme.lower()=='http'}))

if __name__ == '__main__':
    try:
        main()
    except (OSError, ValueError, RuntimeError) as exc:
        print(f'Error: {exc}', file=sys.stderr)
        sys.exit(1)

Open source as plain text · Download source and sample files

How it works

  1. Inspect URL lines for embedded user information and insecure HTTP without printing credential values.
  2. Arguments are explicit and expected input errors produce a message with a nonzero exit code.
  3. Results reflect your selected local data or the specific endpoint you choose; the example illustrates the result shape.

Make it your own

Adapt the task

Supply one URL per line. Queries and fragments are omitted because they can also hold secrets.

Adjust presentation

Edit final print statements or json.dumps indentation to adjust the report layout. Keep input validation and exclusive-create file modes intact.

Change one setting at a time, run it again on sample data, and compare the output. The customization guide walks through this process.

If something goes wrong

An input or dependency is unavailable.

Check the path, quote paths with spaces, and use --help to inspect required arguments.

Actual results differ from the example.

Inputs and system state determine values. Review each finding in context; a report is not proof of system health or a complete security assessment.

Reference & next steps

These official references explain the underlying tools. The Scriptage example and guide are original instructional content. See verification notes for what has been checked and the limits of those checks.

Copies a template for your own notes. It does not send anything.