MP Bank lab: bank, soft token and mail
The MP Bank scenario is three services working together: the bank web app
(lab_mpbank), the Swekey soft-token page
the bank uses for 2FA (served by the same container), and the lab mail server
(services_mailcow) that delivers
the bank’s mails (money-transfer confirmations, registration mails and lost-password links) to
the students’ @mail.xhack mailboxes. This page shows how they are wired, which names
students use, and where to look when one of the links breaks.
Overview
flowchart LR
subgraph students["students vnet"]
student["Student Kali / Windows client"]
end
subgraph lab["lab vnet - dmz subnet"]
subgraph mpvm["vmmpbank01 (docker)"]
web["mpbank-web<br/>Apache + PHP 5.6<br/>:443 mpbank.{domain}<br/>:80 token.{domain}"]
db[("mpbank-db<br/>MySQL 5.7")]
end
dc["vmdc01<br/>AD DNS zone {domain}"]
end
subgraph services["services vnet - email subnet"]
mc["vmmailcow01 (mailcow)<br/>:587 SMTP submission<br/>:443 SOGo webmail"]
end
zone[("Azure private DNS zone<br/>{domain}")]
student -- "HTTPS: bank app" --> web
student -- "HTTP: current token code" --> web
student -- "HTTPS: webmail" --> mc
web -- "2FA check, pinned to itself" --> web
web --> db
web -- "SMTP 587, STARTTLS TLS 1.2<br/>as donotreply@mail.xhack" --> mc
student -. "name lookups" .-> zone
student -. "domain-joined clients" .-> dc
web -. "mail.{domain}" .-> zone
{domain} is the deployment’s internal_domain (for example ignace.lab). Every name lives
in two places: the Azure private DNS zone, which every vnet resolves through Azure DNS, and the
AD zone on the lab DC. The DC is authoritative for the same domain, so domain-joined clients
only see what is registered there.
A money transfer, end to end
sequenceDiagram
autonumber
actor S as Student
participant T as Token page (token.{domain})
participant B as MP Bank (mpbank.{domain})
participant M as mailcow (mail.{domain})
S->>T: open the token page, pick their Swekey-Nr
T-->>S: current code (changes every minute)
S->>B: log in with user, password and code
B->>T: validate the code (stays inside the container)
T-->>B: OK or NOK
S->>B: start a transfer, confirm it with a fresh code
B->>T: validate the code again
B->>M: send the confirmation (SMTP 587, auth as donotreply@mail.xhack)
M-->>M: deliver to the student's @mail.xhack mailbox
S->>M: read it in SOGo (https://mail.{domain}/SOGo/)
The app ships with its 2FA switch ($swekey_authent in protected/config.do) off;
lab_mpbank turns it on, so both login and the transfer’s Swekey field require a valid code.
The token codes are derived from the Swekey-Nr and the current minute, so they are the same on
every MP Bank instance. The bank validates them against its own container (an extra_hosts
entry maps the token name to 127.0.0.1), so a DNS problem cannot break logins or transfers.
Names
Service |
Shared lab |
Dedicated lab (per student) |
|---|---|---|
Bank app |
|
|
Soft-token page |
|
|
Webmail (SOGo) |
|
same (one mail server for all labs) |
Mailboxes |
|
same |
The mailbox domain mail.xhack exists only inside mailcow and needs no DNS; it is kept because
the bank’s database seed and the course envelopes use those addresses. In dedicated mode the
bank’s vhosts, :80 redirect, 404 page, links and certificate all use the lab’s own
mpbank<id> name.
What each role sets up
lab_mpbankBuilds the two containers from the shipped app tarball and rewrites the app’s hardcoded names for this deployment: the bank’s vhosts and base URL, the token vhost, the token-check URL, and the SMTP host (
mail.{domain}). It enables the 2FA check, patches the bundled PHPMailer so STARTTLS also offers TLS 1.1/1.2 (PHP 5.6 otherwise only speaks TLS 1.0, which current mailcow refuses), registersmpbankandtokenin the private zone, and fails the deploy if the bank or the token vhost does not answer.services_mailcowDeploys mailcow, registers
mailin the private zone, and creates themail.xhackdomain and the mailboxes listed infiles/users.csvthrough the mailcow API. Besides the student mailboxes these includedonotreply(the account the bank sends as),admin(the application owner in the course schedule) andsupport(the Reply-To on the bank’s mails).lab_dc01Registers
mpbank,token,log4j(suffixed with the lab id in dedicated mode), the course apps andmailin the AD zone, for domain-joined clients.
Student handout values
The 2017 envelopes predate the configurable domain. Use these values instead:
Envelope line |
Old |
Now |
|---|---|---|
E-mail login |
|
|
E-mail address and password |
|
unchanged ( |
Application login |
|
|
IP |
|
not needed, use the name |
Swekey soft-token URL |
|
|
Troubleshooting
- The mailbox import fails with
api access denied for ip ... The API call did not come from an allowed address. The role always allows
127.0.0.1and the gateway of mailcow’s docker network (IPV4_NETWORKintemplates/mailcow.conf.j2+.1); check that template if the network was changed.- The deploy fails on “Check the token vhost answers on its name”
The token vhost did not take the rewritten name; check
ServerNamein/opt/mpbank/apachefiles/apache2/sites-enabled/token.confon the bank VM.- No confirmation mail arrives
From the bank VM, check
docker exec mpbank-web php -r 'echo gethostbyname("mail.{domain}");'resolves to mailcow, and look for the delivery in the mailcow UI (Logs, Postfix). A TLS handshake failure there points at the PHPMailer STARTTLS patch.- A student’s browser cannot open
mpbankortoken Domain-joined clients resolve through the DC: check the record exists in its AD zone. Other clients resolve through the private zone.