Skip to content
/ qprobe Public

A lightweight probe authentication utility designed to distinguish secure vs. insecure networks using cryptographically signed HTTP GET requests

License

Notifications You must be signed in to change notification settings

iamgaru/qprobe

Repository files navigation

qprobe

qprobe is a lightweight probe authentication utility designed to distinguish secure vs. insecure networks using cryptographically signed HTTP GET requests. It features:

  • HMAC-SHA256 authentication
  • Timestamp-based freshness checking
  • Nonce-based replay protection
  • Optional LRU or Bloom filter for replay cache
  • Human-friendly logging
  • Simple binary or container deployment

🔐 How It Works

Every probe request includes:

Param Purpose
username Base64-encoded user identity
timestamp Unix epoch seconds for freshness (±5min)
nonce Random per-request value (10 chars)
hmac HMAC-SHA256 over username, timestamp, nonce

🔁 Replay Protection Modes

You can choose the replay cache strategy:

Mode Description
lru Exact match, fixed-size in-memory cache (default)
bloom Probabilistic set using a Bloom filter (low memory, risk of false positives)

🚀 Example Usage

Start the Server

./qprobe --mode=server --replay-mode=lru

Run the Client

./qprobe --mode=client --username=testuser --host=http://localhost:8080

This command:

  1. Generates a signed probe URL
  2. Sends the request to the server
  3. Prints both the probe URL and the HTTP response

Example output:

Generated Probe URL:
http://localhost:8080/check?q=...

Response from server (Status 200):
{"code":"200","message":"Valid probe from testuser"}

Decoded query might look like:

username=dGVzdHVzZXI=  # testuser  
timestamp=1748012345  
nonce=xyz7a9wq5f  
hmac=5d3ff9a....

🧪 Server Behavior

  • 200 OK: Probe accepted, signature verified
  • 403 Forbidden: Rejected due to timestamp expiry, nonce reuse, or bad HMAC
  • 400 Bad Request: Missing or malformed parameters

Logs:

[ACCEPTED] Valid probe (HTTP 200) — user=testuser nonce=abc123 timestamp=... hmac=...
[DENIED] Replay detected (LRU size: 84) (HTTP 403) — user=testuser nonce=abc123 ...
[DENIED] Invalid HMAC (HTTP 403) — user=foo ...

🛠 Building

With Make

make build       # go build -o qprobe .
make run         # ./qprobe --mode=server
make test        # run unit tests
make test-cover  # print test coverage

Docker

make docker-build
make docker-run

🧪 Test Coverage

The project includes unit tests for:

  • HMAC generation + verification
  • Timestamp validation
  • Base64 decoding
  • Replay detection (LRU and Bloom)

Run with:

make test
make test-cover

🧰 Configuration Options

Flag Description
--mode client or server
--username Username for signing (client mode)
--host Server base URL (client mode)
--replay-mode lru or bloom (server only)

🔒 Security Notes

  • The shared secret must be protected on the server
  • Time window ensures freshness; server clocks should be synced (NTP)
  • Replay cache is in-memory only — restart clears it

📝 License

This project is licensed under the MIT License.


👤 Author & Copyright

Field Info
Author Nick Conolly
Copyright © 2025 Nick Conolly
Maintained gamu.io

About

A lightweight probe authentication utility designed to distinguish secure vs. insecure networks using cryptographically signed HTTP GET requests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published