HUB
Sign inSign up
atm-simulation-engine logo

credkellar/atm-simulation-engine

By credkellar

•Updated 14 days ago

Educational ATM simulator + RE lab in pure Python stdlib. Synthetic only, 13 HOLD gates.

Image
Security
Languages & frameworks
Developer tools
1

253

credkellar/atm-simulation-engine repository overview

⁠credkellar/atm-simulation-engine

Inside an ATM, in code. An educational ATM simulator and reverse-engineering lab — built from the transparent-ATM model video ("Inside an ATM: How cash actually gets dispensed!") — that shows, step by step, how an ATM verifies a transaction before any cash is allowed to move, then picks, scans, stacks, recounts, presents, settles — or retracts and reverses.

Project name in code: ATM-SimX · Source: https://github.com/kimanicollier44-cmyk/atm-simulation-engine⁠

Pure Python standard library. Zero dependencies. Synthetic only: fake accounts, fake PINs, fake bills, fake firmware, fake dispenser protocol. No real bank network, no real card data, no real cash hardware.

Honest scope: this is a simulator and a teaching / reverse-engineering lab for its own synthetic artefacts. It does not connect to a bank, a payment network, a card reader, or ATM hardware, and it cannot dispense real cash. bypass_bank_verification is a permanent HOLD gate — see Owner / operator mode below.

⁠Run it

docker pull credkellar/atm-simulation-engine:latest
docker run --rm credkellar/atm-simulation-engine

The image's default command runs the built-in self-check suite. Expected last line:

CHECKS 33/33 ALL PASSED

To run the other demos from the source checkout (Python 3.11+, nothing to install):

python main.py withdraw --amount 500             # Alice (demo PIN 1234) takes $500
python main.py withdraw --amount 200 --no-take   # watch it retract + reverse
python main.py withdraw --amount 200 --user bob  # Bob (demo PIN 4321, $300 balance)
python main.py operator-test                     # owner test-dispense + cash count
python main.py re                                # firmware / protocol / trace / black-box RE
python -m pytest tests/ -q                       # 19 passed

⁠What is this?

An ATM is two machines in one box:

  1. An electronic verifier — card reader, hashed PIN check, and a bank that must say YES (PIN correct, account real, balance enough, daily limit, fraud checks) and place a hold before any cash moves.
  2. A mechanical dispenser — cash cassettes, a friction picker that peels one bill at a time, sensors that catch doubles, torn and wrong-length bills, an escrow stacker that recounts before presenting, and a presenter that retracts un-taken cash.

Both halves are modelled in one 962-line main.py, with the failure paths included:

  • Bad PIN → declined; 3 bad PINs block the card
  • Insufficient funds → declined at bank verification, nothing picks
  • Daily limit → declined at bank verification
  • Unmakeable amount ($7 from $10/$20/$50/$100 cassettes) → declined before picking
  • Double / torn / short bill → diverted to the reject bin, a replacement is picked
  • All-bad cassette → abort + hold reversal, nothing presented
  • Cash not taken in time → retract + hold reversal, no debit
  • Ledger tampering → detected by the hash chain

⁠What this does — step by step ($500)

  1. Insert card — identifies the synthetic account (Alice, demo card).
  2. Enter PIN — verified against a salted SHA-256 hash. Plain PIN is never stored. 3 wrong PINs block the card.
  3. ATM asks the bank — card, amount and PIN result go to the synthetic Bank model.
  4. Bank verifies — PIN result, account exists, balance ≥ $500, daily limit, not blocked.
  5. Hold placed first — on YES, hold HOLD-0001 for $500 is placed. No cash has moved yet, and none can move before this step.
  6. Plan the mix — fewest-bills: $500 = 5 × $100. Unmakeable amounts decline here, before picking.
  7. Council check — Gemini Argon 4 DECIDER seat (offline stub, tighten-only) risk-scores the sim; Muse advisor seat adds exactly 4 notes, authority none. A HOLD gate stops the run.
  8. Picker peels one bill at a time — one bill per cycle, a protocol frame per pick.
  9. Sensor scan on every bill — thickness, length, torn. Bad bills go to the reject bin; a replacement is picked.
  10. Escrow stack + recount — recount must be exactly $500 or the stack retracts inside, the hold reverses, and the run aborts. Nothing is presented on a failed count.
  11. Presenter opens — only a recounted, exact stack is presented.
  12. Take, or retract — taken: the hold settles, the account is debited exactly once ($2,000 → $1,500), receipt issued. Not taken: cash retracts, hold reverses, no debit.
  13. Ledger entry, hash-sealed — every step writes to the hash-chained journal; tampering is detected.

⁠Owner / operator mode

Owning an ATM gives you supervisor testing, not a bank-verification bypass — bank verification belongs to the cardholder's bank and the payment network. Modelled here (demo operator code 2468):

  • Test-dispense — cycles 2 × $100 into the internal test bin only. Presents no cash, debits no account, settles nothing, writes a $0 journal entry.
  • Cash count + journal audit — cassette counts/value, reject / retract / test bins, and a hash-chain check of the ledger.

⁠Reverse-engineering lab (own synthetic artefacts only)

  • Firmware RE — parse the synthetic ATMX firmware header, extract strings, disassemble its toy bytecode (PICK 100, SCAN, STACK, PRESENT, SETTLE, HALT); bad magic is rejected.
  • Protocol RE — decode dispenser wire frames (STX, cmd, len, payload, LRC, ETX) and catch a tampered frame by its LRC checksum.
  • Trace RE — rebuild a whole transaction (picks, rejects, amount stacked, settled?) from its protocol trace alone.
  • Black-box RE — probe the dispenser with amounts, observe the mixes, infer its strategy — it answers fewest_bills, cross-checked against brute force.
  • State-machine RE — extract the controller's 13 states/transitions and prove every state is reachable from IDLE.

⁠HOLD gates (13)

live_bank_network · real_cash_hardware · real_card_reader · store_plain_pin · bypass_pin · bypass_bank_verification · override_balance_check · dispense_without_authorization · disable_sensor_checks · disable_recount · open_safe · skip_retract_reversal · exceed_daily_limit

⁠Brains

  • Gemini Argon 4 Extended Thinking — DECIDER seat (offline stub, names-only): risk-scores each simulated dispense; can only tighten, never lift a HOLD.
  • Muse — advisor seat (offline stub, names-only): exactly 4 advice notes per transaction, authority none, can never override a HOLD.

⁠Verified

  • pytest — 19 passed
  • python main.py checks — CHECKS 33/33 ALL PASSED
  • Verified $500 flow — SETTLED, mix 5 × $100, Alice $2,000 → $1,500
  • Source head at publish: 61883145 on kimanicollier44-cmyk/atm-simulation-engine (main.py, tests, Dockerfile + full-template README pushed at a583aa52, workflows pasted by owner)

⁠Requirements

Python 3.11+ (image uses 3.12-slim) · zero runtime dependencies · no network, API keys or hardware needed (or used) at runtime · Docker only for the container route above.

⁠Project structure

atm-simulation-engine/
├── main.py                  # everything in one file (962 lines): bank, dispenser,
│                            #   protocol, firmware, state machine, HOLD gates,
│                            #   council seats, RE lab, 33 self-checks, CLI
├── tests/
│   └── test_atm_simx.py     # pytest suite (19 tests)
├── Dockerfile               # python:3.12-slim, CMD runs the checks suite
├── README.md                # full-template README: tech stack, mermaid per script,
│                            #   10 cool reasons, 10 problems / solutions, install steps
└── .github/workflows/
    ├── ci.yml               # CI: Python 3.12, pytest, self-checks
    └── docker-publish.yml   # publishes credkellar/atm-simulation-engine:latest

Synthetic only. Educational. No real bank network, no real card data, no real cash hardware — and bypass_bank_verification stays HOLD, permanently.

Tag summary
Recent tags
Content type
Image
Digest
sha256:0b6d2c156…
Size
41.3 MB
Last updated
14 days ago
docker pull credkellar/atm-simulation-engine:latest