How bmdyy/tudo works
1. What this repository is
TUDO is a deliberately vulnerable PHP application packaged for local training. The runtime is split into containerized services, with the web app, PostgreSQL database, and an admin/cron-emulation component managed by Docker Compose.
2. Top-level deployment shape
docker-compose.yaml is the orchestrator. The main user-facing service serves the PHP app from app/, while a separate PostgreSQL container holds application state. A third container under docker/admin emulates periodic administrator activity, which matters because some app state changes are driven on a schedule rather than only by interactive user requests.
3. Web application entry points
The public HTTP surface is in app/:
- index.php as the landing page
- login.php for authentication
- profile.php for authenticated user data
- forgotusername.php, forgotpassword.php, resetpassword.php for account recovery
- admin/ for privileged actions
This is a classic server-rendered PHP app, not a SPA.
4. Shared application layer
Common behavior is centralized in app/includes/:
- db_connect.php for PostgreSQL access
- utils.php for helper logic
- header.php and login_footer.php for shared page chrome
- logout.php for session teardown
- createpost.php for creating user content
This folder is the main boundary between page controllers and backend logic.
5. Template/rendering subsystem
app/templates/ and app/templates_c/ indicate Smarty-style templating. motd.tpl is a dedicated template for the message-of-the-day UI, and templates_c/ is the compiled-template cache/output directory. This means some page content is rendered through a template engine rather than raw PHP echo statements.
6. Persistent data model
The README exposes the primary database tables:
- users for accounts and role data
- tokens for authentication or reset-related tokens
- class_posts for user-generated posts/content
- motd_images for images used by the message-of-the-day/admin content
These tables support the main flows: login, recovery, posting, and admin content management.
7. Authentication and account recovery flow
Login and recovery pages likely coordinate through the users and tokens tables, with sessions maintained in PHP. The application supports standard credentials for two normal users and one admin, but the app is designed so that access can also be reached through alternate recovery/auth paths.
8. User content flow
Authenticated users can create posts via includes/createpost.php, and those posts are persisted in class_posts. profile.php likely reads user identity plus recent or related content back from the database to display account state and posts.
9. Admin subsystem
app/admin/ contains privileged endpoints:
- import_user.php
- update_motd.php
- upload_image.php
These represent the administrative control plane for importing users, changing the MOTD, and managing images. The admin area is separate from the normal user-facing pages but still part of the same PHP app.
10. Scheduled/admin automation
The docker/admin/emulate.cron and docker/admin/emulate.py files indicate a cron-like background process that simulates admin actions every minute. This is an important architectural boundary: some privileged state transitions happen asynchronously, outside direct browser interaction.
11. Infrastructure and runtime dependencies
docker/app/Dockerfile, docker/admin/Dockerfile, docker/init.sql, and app/vendor/ show that the app is containerized and bootstrapped with an initial schema/data load. app/.htaccess and app/templates/.htaccess are used to control Apache-accessible paths and likely protect sensitive directories from direct web access.
12. Operational/debug tooling
The repo is set up for local reverse debugging with Xdebug and VS Code (.vscode/, docker/app/xdebug.ini). The README also notes PostgreSQL query logging via the database container logs, which is useful for tracing request-to-SQL data flow during analysis.
13. Non-runtime content
solutions/ contains exploit PoCs and writeups, and screenshots/ contains documentation assets. These are not part of the live application architecture, but they explain intended challenge paths and should be excluded from the runtime diagram.
14. High-level data flow
Browser requests enter the PHP app container, which renders pages and delegates state changes to shared include code. That code reads/writes PostgreSQL. Admin-specific state can also be modified by the scheduled emulation service. Static assets and templates stay within the app container, while compiled templates and uploaded images act as filesystem-backed working data alongside the database.
Main entry points: db_connect.php Shared Logic · Dockerfile App Image · docker-compose.yaml Compose · init.sql Database
Components 17
Deployment
Containerized runtime and bootstrapping
- Compose · Starts and wires the application, database, and admin services
docker-compose.yaml - App Image · Container image for the main PHP web application
docker/app/Dockerfile - Postgres · PostgreSQL service and initial schema/data load
docker/init.sql - Admin Image · Container image for scheduled admin emulation
docker/admin/Dockerfile
Web App
Server-rendered PHP application
- Home · Landing page
app/index.php - Login · Authentication entry point
app/login.php - Profile · Authenticated user view
app/profile.php - Recovery · Username and password recovery pages
app/forgotpassword.php - Reset · Password reset entry point
app/resetpassword.php - Admin UI · Privileged HTTP endpoints for user import, MOTD, and image upload
app/admin/import_user.php - Shared Logic · Common DB, session, utility, and post creation code
app/includes/db_connect.php - Templates · Smarty-style templates and compiled cache
app/templates/motd.tpl
Admin Automation
Privileged background activity
Connections 20
- Compose → App Image: builds · Defines the main web service image
- Compose → Postgres: starts · Runs PostgreSQL as a separate service
- Compose → Admin Image: starts · Runs the admin emulation service
- App Image → Home: serves · Hosts the public PHP entry points
- App Image → Shared Logic: includes · Page controllers rely on shared backend logic
- App Image → Templates: renders · Uses template views for selected output
- App Image → Images: stores · Uses filesystem-backed image content
- Shared Logic → Database: queries · Reads and writes application state in PostgreSQL
- Login → Shared Logic: auth via · Delegates authentication and session handling
- Profile → Shared Logic: loads · Fetches account state and related content
- Recovery → Shared Logic: uses · Coordinates account recovery flows
- Reset → Shared Logic: uses · Applies password reset logic
- Admin UI → Shared Logic: admin via · Privileged actions reuse shared backend code
- Shared Logic → Vendor: depends on · Relies on bundled PHP libraries
- Postgres → Database: initializes · Bootstraps schema and seed data
- Admin Image → Cron Emu: runs · Container executes the scheduled emulator
- Cron Emu → Emulator: invokes · Cron entry launches the Python worker
- Emulator → Database: modifies · Performs automated privileged state changes
- Admin UI → Images: uploads · Admin endpoints manage image assets
- Templates → Home: feeds · Template content contributes to rendered pages