Create new challenge Docker image

This commit is contained in:
Pierre HUBERT 2025-02-03 16:28:30 +01:00
parent c128870b93
commit 46a95ff5a4
4 changed files with 30 additions and 1 deletions

View File

@ -1,4 +1,11 @@
FROM php:8.3-apache FROM php:8.3-apache
COPY src/ /var/www/html/ COPY src/ /var/www/html/
ENV FLAG=CHANGEME ENV FLAG=CHANGEME
COPY docker/start.sh /start.sh
COPY docker/add_flag.php /add_flag.php
EXPOSE 80
ENTRYPOINT ["/start.sh"]

View File

@ -0,0 +1,12 @@
<?php
// First, connect to database
try {
$db = new PDO('sqlite:/var/www/html/database.db');
} catch (PDOException $e) {
echo 'Connection to database failed: ' . $e->getMessage();
}
$stmt = $db->prepare("INSERT INTO secret (flag) VALUES (?)");
$stmt->execute(array(getenv("FLAG")));

View File

@ -0,0 +1,7 @@
#!/bin/sh
echo Add flag to database
php /add_flag.php
echo Run main server
docker-php-entrypoint apache2-foreground

View File

@ -0,0 +1,3 @@
<Files ~ "(.db)">
Require all denied
</Files>