Skip to content

Commit 5a351ce

Browse files
committed
Merge branch 'premaster'
2 parents 4b24b1f + 37e1413 commit 5a351ce

File tree

19 files changed

+239
-35
lines changed

19 files changed

+239
-35
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ The installation script and the update-designer.sh script set environment variab
8989
so you may want to logout/login, or start a new bash shell before using Labtainers the
9090
first time.
9191

92+
July 22, 2024
93+
- Add a base container for Ubuntu22 and changes to framework to support that.
94+
9295
July 5, 2024
9396
- Migrate to Ubuntu 24 as the VM appliance
9497
- The docker pyhton package uses a broken python http library, requires package downgrade.

docs/labdesigner/labdesigner.pdf

506 Bytes
Binary file not shown.

docs/labdesigner/labdesigner.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,6 +2944,8 @@ \subsubsection{Move to network2 base}
29442944
Note however that many packages will not install on Ubuntu 20. You must either install the snap package manager,
29452945
which drags a ton of extra stuff, or find an alternate package source (e.g., the .deb packages).
29462946

2947+
\subsubsection{Ubuntu 22 base image}
2948+
The base3 and network3 base images are built using Ubuntu 22. Only minimal testing has been done and no labs as yet use these images.
29472949

29482950
\subsection{User management and sudo}
29492951
The Dockerfile should make the initial user, i.e., the user named in the start.config file, a member of sudoers.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#FROM jrei/systemd-ubuntu:20.04
2+
FROM ubuntu:noble
3+
LABEL description="Labtainer base image for ubuntu 22 noble"
4+
ARG lab
5+
#RUN mv /etc/apt/sources.list /var/tmp/
6+
RUN cp /etc/apt/sources.list /var/tmp/
7+
#ADD system/etc/nps.sources.list /etc/apt/sources.list
8+
ADD system/bin/apt-source.sh /usr/bin/apt-source.sh
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
build-essential \
11+
expect \
12+
file \
13+
gcc-multilib \
14+
gdb \
15+
iputils-ping \
16+
less \
17+
man \
18+
manpages-dev \
19+
net-tools \
20+
openssh-client \
21+
python3 \
22+
sudo \
23+
tcl8.6 \
24+
vim \
25+
zip \
26+
hexedit \
27+
rsyslog \
28+
ghex \
29+
locales \
30+
nano \
31+
python3-pip
32+
33+
# Set the locale
34+
RUN locale-gen en_US.UTF-8
35+
ENV LANG en_US.UTF-8
36+
ENV LANGUAGE en_US:en
37+
ENV LC_ALL en_US.UTF-8
38+
#RUN sudo pip3 install --upgrade pip
39+
#---Use virtual python environment to avoid Ubuntu lockdown
40+
RUN apt -y install python3.12-venv
41+
RUN mkdir -p /opt/labtainer/venv
42+
RUN python3 -m venv /opt/labtainer/venv
43+
RUN /opt/labtainer/venv/bin/python3 -m pip install setuptools parse inotify_simple
44+
#RUN sudo pip3 install setuptools
45+
#RUN sudo pip3 install parse
46+
#RUN pip3 install inotify_simple
47+
#RUN pip3 install enum
48+
ADD system/etc/sudoers /etc/sudoers
49+
ADD system/etc/rc.local /etc/rc.local
50+
ADD system/bin/funbuffer /usr/bin/
51+
# manage default gateways
52+
ADD system/bin/togglegw.sh /usr/bin/
53+
ADD system/bin/set_default_gw.sh /usr/bin/
54+
ADD system/sbin/waitparam.sh /usr/sbin/waitparam.sh
55+
ADD system/lib/systemd/system/waitparam.service /lib/systemd/system/waitparam.service
56+
RUN systemctl enable waitparam.service
57+
ENV DEBIAN_FRONTEND noninteractive
58+
RUN yes | /usr/local/sbin/unminimize -y
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG registry
2+
FROM $registry/labtainer.base3
3+
LABEL description="This is a base Docker image for networking Parameterized labs using base3"
4+
ARG lab
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
openssl \
7+
openssh-server \
8+
openvpn \
9+
wget \
10+
tcpdump \
11+
update-inetd \
12+
xinetd \
13+
iptables \
14+
dnsutils \
15+
dnsmasq \
16+
nmap \
17+
netcat-openbsd
18+
19+
# step around app armor or whatever
20+
#RUN sudo mv /usr/sbin/tcpdump /usr/bin/tcpdump
21+
#
22+
# /run/sshd created when parameterizing
23+
#
24+
RUN systemctl disable dnsmasq
25+
RUN rm /etc/systemd/system/multi-user.target.wants/openvpn.service
26+
#RUN rm /etc/systemd/system/multi-user.target.wants/ssh.service
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Labtainer Dockerfile
3+
#
4+
# This is the default Labtainer Dockerfile template, plesae choose the appropriate
5+
# base image below.
6+
#
7+
# The labtainer.base image includes the following packages:
8+
# build-essential expect file gcc-multilib gdb iputils-ping less man manpages-dev
9+
# net-tools openssh-client python sudo tcl8.6 vim zip hexedit rsyslog
10+
#
11+
# The labtainer.network image adds the following packages:
12+
# openssl openssh-server openvpn wget tcpdump update-inetd xinetd
13+
#
14+
ARG registry
15+
FROM $registry/labtainer.base3
16+
#FROM $registry/labtainer.network
17+
#FROM $registry/labtainer.centos
18+
#FROM $registry/labtainer.lamp
19+
#
20+
# lab is the fully qualified image name, e.g., mylab.some_container.student
21+
# labdir is the name of the lab, e.g., mylab
22+
# imagedir is the name of the container
23+
# user_name is the USER from the start.config, if other than ubuntu,
24+
# then that user must be added in this dockerfile
25+
# before the USER command
26+
#
27+
ARG lab
28+
ARG labdir
29+
ARG imagedir
30+
ARG user_name
31+
ARG password
32+
ARG apt_source
33+
ARG version
34+
LABEL version=$version
35+
ENV APT_SOURCE $apt_source
36+
RUN /usr/bin/apt-source.sh
37+
#
38+
# put package installation here, e.g.,
39+
# RUN apt-get update && apt-get install -y --no-install-recommends somepackage
40+
#
41+
#
42+
#
43+
# Install the system files found in the _system directory
44+
#
45+
ADD $labdir/$imagedir/sys_tar/sys.tar /
46+
ADD $labdir/sys_$lab.tar.gz /
47+
#
48+
RUN deluser --remove-home ubuntu`
49+
RUN useradd -ms /bin/bash $user_name
50+
RUN echo "$user_name:$password" | chpasswd
51+
RUN adduser $user_name sudo
52+
# replace above with below for centos/fedora
53+
#RUN usermod $user_name -a -G wheel
54+
55+
56+
#
57+
# **** Perform all root operations, e.g., ****
58+
# **** "apt-get install" prior to the USER command. ****
59+
#
60+
USER $user_name
61+
ENV HOME /home/$user_name
62+
#
63+
# Install files in the user home directory
64+
#
65+
ADD $labdir/$imagedir/home_tar/home.tar $HOME
66+
# remove after docker fixes problem with empty tars
67+
RUN rm -f $HOME/home.tar
68+
ADD $labdir/$lab.tar.gz $HOME
69+
#
70+
# The first thing that executes on the container.
71+
#
72+
USER root
73+
CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"]
74+

scripts/labtainer-instructor/bin/gradelab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def CopyStudentArtifacts(labtainer_config, container_name, labname, regress_test
9292
zip_filelist.extend(lab_filelist)
9393
#logger.debug("zip_filelist is (%s)" % zip_filelist)
9494
# Copy zip files from 'Shared' folder to 'home/$CONTAINER_USER'
95-
if len(zip_filelist) is 0:
95+
if len(zip_filelist) == 0:
9696
full_xfer = os.path
9797
print('WARNING: there are no lab results files in %s' % xfer_dir)
9898
for fname in zip_filelist:

scripts/labtainer-student/bin/checkwork

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/opt/labtainer/venv/bin/python3
22
'''
33
This software was created by United States Government employees at
44
The Center for Cybersecurity and Cyber Operations (C3O)
@@ -43,21 +43,31 @@ import CurrentLab
4343
import argparse
4444
import subprocess
4545
import shlex
46-
import imp
46+
try:
47+
import imp
48+
except:
49+
from importlib.machinery import SourceFileLoader
50+
51+
52+
labtainer_dir = os.getenv('LABTAINER_DIR')
53+
scripts_dir = os.path.join(labtainer_dir, 'scripts')
54+
student_dir = os.path.join(scripts_dir, 'labtainer-student')
55+
lab_bin_dir = os.path.join(student_dir, 'lab_bin')
4756
here = os.path.dirname(os.path.abspath(__file__))
48-
lab_bin_dir = os.path.join(here, '../lab_bin')
57+
#lab_bin_dir = os.path.join(here, '../lab_bin')
4958
sys.path.append(here)
5059
sys.path.append(lab_bin_dir)
51-
student_dir = os.path.dirname(here)
52-
scripts_dir = os.path.dirname(os.path.dirname(here))
5360
assess_bin_path = os.path.join(scripts_dir, 'labtainer-instructor', 'assess_bin')
5461
instruct_bin_path = os.path.join(scripts_dir, 'labtainer-instructor', 'bin')
5562
sys.path.append(assess_bin_path)
5663
sys.path.append(instruct_bin_path)
5764
grade_lab_path = os.path.join(scripts_dir, 'labtainer-instructor', 'bin', 'gradelab')
5865
orig_dir=os.getcwd()
5966
os.chdir(student_dir)
60-
gradelab = imp.load_source('gradelab', grade_lab_path)
67+
try:
68+
gradelab = imp.load_source('gradelab', grade_lab_path)
69+
except:
70+
gradelab = SourceFileLoader('gradelab', grade_lab_path).load_module()
6171

6272
def checkRunning(logger):
6373
command = "docker ps"
@@ -107,7 +117,9 @@ def main():
107117

108118
labutils.logger.debug("Begin logging checkwork for %s lab" % labname)
109119

110-
lab_path = os.path.join(os.path.abspath('../../labs'), labname)
120+
labtainer_dir = os.getenv('LABTAINER_DIR')
121+
#lab_path = os.path.join(os.path.abspath('../../labs'), labname)
122+
lab_path = os.path.join(labtainer_dir, 'labs', labname)
111123
labtainer_config, start_config = labutils.GetBothConfigs(lab_path, labutils.logger)
112124
if labtainer_config.checkwork != 'yes':
113125
print('Checking own work not supported for this deployment of Labtainers')

scripts/labtainer-student/bin/imodule

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/opt/labtainer/venv/bin/python3
22
import os
33
import argparse
44
import subprocess

scripts/labtainer-student/bin/labpack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/opt/labtainer/venv/bin/python3
22
'''
33
This software was created by United States Government employees at
44
The Center for Cybersecurity and Cyber Operations (C3O)

0 commit comments

Comments
 (0)