Create new challenge Docker image
This commit is contained in:
parent
c128870b93
commit
46a95ff5a4
@ -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"]
|
12
countries_list/docker/add_flag.php
Normal file
12
countries_list/docker/add_flag.php
Normal 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")));
|
7
countries_list/docker/start.sh
Normal file
7
countries_list/docker/start.sh
Normal 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
|
3
countries_list/src/.htaccess
Normal file
3
countries_list/src/.htaccess
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<Files ~ "(.db)">
|
||||||
|
Require all denied
|
||||||
|
</Files>
|
Loading…
x
Reference in New Issue
Block a user