a387cdc1b6
Streams every APDU the server sends or receives as GSMTAP-SIM UDP packets, so a live capture can be followed in Wireshark or the SIMtrace Analyser without a hardware sniffer. CLI-only: --gsmtap [HOST[:PORT]], default target 127.0.0.1:4729; no UI or API. - pysim_simple_server/gsmtap.py: 16-byte big-endian GSMTAP-SIM header (type 0x04, sub_type 0x00 = APDU / 0x01 = ATR) + raw APDU bytes, a fire-and-forget non-blocking sender that never raises into card I/O, an ApduTracer (a response is sent as data + SW1SW2, the wire form) and a fan-out tracer. The packet layout is byte-identical to sigrok-iso7816-stream / simtrace2-sniff (verified against the sigrok module) and is what the analyser's GSMTAP receiver expects. - __main__.py: --gsmtap option, tracer installed on the shared transport before the first APDU, combined with --apdu-trace via the fan-out and re-attached across equips (pySim nulls the tracer on every equip); one ATR packet per equip from _apply_equipped_card/_send_gsmtap_atr. - start.sh/start.bat: forward their extra arguments to the server, so ./start.sh --gsmtap works. - tests: packet layout, loopback UDP delivery, tracer mapping, target parsing, fan-out; docs (READMEs, help EN/RU, AGENTS); version 3.1.0, sw.js simple-v235.
43 lines
1.4 KiB
Bash
Executable File
43 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# pysim-simple-server start script
|
|
# Starts the server, preferring the venv if it exists.
|
|
# Auto-detects PC/SC reader if available.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
VENV_DIR="$SCRIPT_DIR/.venv"
|
|
|
|
# Auto-detect reader
|
|
READER_ARGS=""
|
|
if command -v pcscd > /dev/null 2>&1; then
|
|
# Give pcscd a moment if it's not running yet (USB enumeration delay)
|
|
if ! pgrep -x pcscd > /dev/null 2>&1 && ! pgrep -x pcscd.bin > /dev/null 2>&1; then
|
|
sleep 1
|
|
fi
|
|
if pgrep -x pcscd > /dev/null 2>&1 || pgrep -x pcscd.bin > /dev/null 2>&1; then
|
|
READER_ARGS="-p 0"
|
|
fi
|
|
fi
|
|
|
|
SERVER=""
|
|
if [ -f "$VENV_DIR/bin/pysim-simple-server" ]; then
|
|
SERVER="$VENV_DIR/bin/pysim-simple-server"
|
|
elif command -v pysim-simple-server &> /dev/null; then
|
|
SERVER="pysim-simple-server"
|
|
elif [ -f "$SCRIPT_DIR/pysim_simple_server/__main__.py" ]; then
|
|
echo "Starting pysim-simple-server from source on http://127.0.0.1:8080"
|
|
cd "$SCRIPT_DIR" && python3 -m pysim_simple_server --http-port 8080 $READER_ARGS "$@"
|
|
exit $?
|
|
else
|
|
echo "Error: pysim-simple-server not installed."
|
|
echo "Run setup.sh first or install manually:"
|
|
echo " pip install pysim-simple-server"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Starting pysim-simple-server on http://127.0.0.1:8080"
|
|
echo "Press Ctrl+C to stop."
|
|
echo "Extra arguments are passed to the server (e.g. ./start.sh --gsmtap)."
|
|
$SERVER --http-port 8080 $READER_ARGS "$@"
|