Skip to content

Commit

Permalink
Merge branch 'premaster'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfthomps committed Dec 19, 2022
2 parents 937f54b + 90aea9e commit 3c487f5
Show file tree
Hide file tree
Showing 36 changed files with 1,408 additions and 17 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ The installation script and the update-designer.sh script set environment variab
so you may want to logout/login, or start a new bash shell before using Labtainers the
first time.

December 19, 2022
- Add strace lab to introduce system call tracing.
- X11 DISPLAY value was incorrect if multiple devices in the /tmp/.X11-unix directory.
- Use of python/bash/sh/etc with no arguments was causing capinout to crash.
December 9, 2022
- Modify Azure vm creation script to use a prebuilt Labtainer VM image from the Azure Community Gallery.
- Terminals on cloud VMs crash for unknown reasons during startup or right click on the terminal. Attempt
Expand Down
19 changes: 11 additions & 8 deletions UI/MainUI/src/main/java/labtainers/mainui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ public void doCommand(String cmd, String path){
}
private void BuildOnlyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuildOnlyMenuItemActionPerformed
try {
if(!saveLab(true, true)){
if(!saveLab(false, true)){
output("Build aborted due to errors in lab.\n");
return;
}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_

private void BuildAndRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuildAndRunActionPerformed
try {
if(!saveLab(true, true)){
if(!saveLab(false, true)){
output("Build aborted due to errors in lab.\n");
return;
}
Expand Down Expand Up @@ -1446,14 +1446,14 @@ private void LabDocumentsMenuItemActionPerformed(java.awt.event.ActionEvent evt)

private void SimlabDirectivesMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SimlabDirectivesMenuItemActionPerformed
String labtainerPath = System.getenv("LABTAINER_DIR");
System.out.println("labtainerdir is "+labtainerPath);
//System.out.println("labtainerdir is "+labtainerPath);
File labtainer_path = new File(labtainerPath);
String parent = labtainer_path.getParentFile().getPath();
System.out.println("parent is "+parent);
//System.out.println("parent is "+parent);
File simlab_dir = new File(parent+File.separator+"simlab"+File.separator+this.labName);
simlab_dir.mkdirs();
String cmd = "gnome-terminal --working-directory="+simlab_dir;
System.out.println("cmd: "+cmd);
//System.out.println("cmd: "+cmd);
doCommand(cmd);

}//GEN-LAST:event_SimlabDirectivesMenuItemActionPerformed
Expand Down Expand Up @@ -1915,6 +1915,7 @@ private void rmTmp(String f1, String f2){

// Writes current state of the UI the file system
public boolean saveLab(boolean usetmp, boolean force) throws FileNotFoundException{
//System.out.println("savelab");
// If usetmp, save to temporary diretory and compare to current. If they differ,
// prompts the user to save or discard changes.
// Return false if user cancels (does not want to exit).
Expand All @@ -1924,7 +1925,7 @@ public boolean saveLab(boolean usetmp, boolean force) throws FileNotFoundExcepti
for(Component network : networks){
NetworkObjPanel panel = (NetworkObjPanel)network;
if(panel.configShowing()){
System.out.println("network visible");
//System.out.println("network visible");
panel.networkConfigUpdateButton();
}
}
Expand All @@ -1934,12 +1935,13 @@ public boolean saveLab(boolean usetmp, boolean force) throws FileNotFoundExcepti
for(Component container : containers){
ContainerObjPanel panel = (ContainerObjPanel)container;
if(panel.configShowing()){
System.out.println("container visible");
//System.out.println("container visible");
panel.updateData();
}
}

if(usetmp){
//System.out.println("is usetmp");
String f1 = null;
String f2 = null;
boolean something_changed = true;
Expand Down Expand Up @@ -2014,6 +2016,7 @@ public boolean saveLab(boolean usetmp, boolean force) throws FileNotFoundExcepti
}
}else{
labDataCurrent.writeStartConfig(usetmp);
//System.out.println("Lab results saved");
String fname = labDataCurrent.getResultsData().writeResultsConfig(usetmp);
if(fname == null){
output("Error in Results, refusing to save.\n");
Expand All @@ -2034,7 +2037,7 @@ public boolean saveLab(boolean usetmp, boolean force) throws FileNotFoundExcepti
}
//System.out.println("Lab Saved (or not)");
try{
System.out.println("Check manuals");
//System.out.println("Check manuals");
checkManual();
}catch(IOException ex){
System.out.println("Error checking manuals: "+ex);
Expand Down
2 changes: 1 addition & 1 deletion labs/ssh-tunnel/docs/read_first.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Buffer Overflow Lab -- Read this first
SSH Tunnel Lab -- Read this first

The lab manual for this lab is at:
file://LAB_DOCS/ssh-tunnel.pdf
Expand Down
1 change: 1 addition & 0 deletions labs/strace/config/about.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Introduction to the use of strace for dynamic analysis
2 changes: 2 additions & 0 deletions labs/strace/config/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
strace
reverse engineering
1 change: 1 addition & 0 deletions labs/strace/config/parameter.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
portnumber : RAND_REPLACE : the-client:ob.c;the-server:ob.c : MY_PORT_NUMBER : 1 : 20000 : 2
13 changes: 13 additions & 0 deletions labs/strace/config/start.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GLOBAL_SETTINGS
LAB_MASTER_SEED strace_mike_master_seed
NETWORK LAN
MASK 10.10.0.0/24
GATEWAY 10.10.0.101
CONTAINER the-server
USER ubuntu
X11 YES
LAN 10.10.0.2
CONTAINER the-client
USER ubuntu
X11 YES
LAN 10.10.0.1
65 changes: 65 additions & 0 deletions labs/strace/dockerfiles/Dockerfile.strace.the-client.student
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# Labtainer Dockerfile
#
# This is the default Labtainer Dockerfile template for CentOS
#
#
ARG registry
FROM $registry/labtainer.ghidra2
#
# lab is the fully qualified image name, e.g., mylab.some_container.student
# labdir is the name of the lab, e.g., mylab
# imagedir is the name of the container
# user_name is the USER from the start.config, if other than ubuntu,
# then that user must be added in this dockerfile
# before the USER command
#
ARG lab
ARG labdir
ARG imagedir
ARG user_name
ARG password
ARG apt_source
ARG version
LABEL version=$version
ENV APT_SOURCE $apt_source
RUN /usr/bin/yum-source.sh
#
# put package installation here
#
#
# Install the system files found in the _system directory
#
ADD $labdir/$imagedir/sys_tar/sys.tar /
ADD $labdir/sys_$lab.tar.gz /
#
RUN useradd -ms /bin/bash $user_name
RUN echo "$user_name:$password" | chpasswd
# replace above with below for centos/fedora
RUN usermod $user_name -a -G wheel

RUN yum clean metadata
RUN yum install -y strace gcc

#
# **** Perform all root operations, e.g., ****
# **** "apt-get install" prior to the USER command. ****
#
USER $user_name
ENV HOME /home/$user_name
#
# Install files in the user home directory
#
ADD $labdir/$imagedir/home_tar/home.tar $HOME
# remove after docker fixes problem with empty tars
RUN rm -f $HOME/home.tar
ADD $labdir/$lab.tar.gz $HOME
#
# The first thing that executes on the container.
#
USER root
RUN systemctl enable rc-local
CMD ["/usr/sbin/init"]
#
# DO NOT add below this line.
#
73 changes: 73 additions & 0 deletions labs/strace/dockerfiles/Dockerfile.strace.the-server.student
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Labtainer Dockerfile
#
# This is the default Labtainer Dockerfile template, plesae choose the appropriate
# base image below.
#
# The labtainer.base image includes the following packages:
# build-essential expect file gcc-multilib gdb iputils-ping less man manpages-dev
# net-tools openssh-client python sudo tcl8.6 vim zip hexedit rsyslog
#
# The labtainer.network image adds the following packages:
# openssl openssh-server openvpn wget tcpdump update-inetd xinetd
#
ARG registry
FROM $registry/labtainer.network2
#FROM $registry/labtainer.network
#FROM $registry/labtainer.centos
#FROM $registry/labtainer.lamp
#
# lab is the fully qualified image name, e.g., mylab.some_container.student
# labdir is the name of the lab, e.g., mylab
# imagedir is the name of the container
# user_name is the USER from the start.config, if other than ubuntu,
# then that user must be added in this dockerfile
# before the USER command
#
ARG lab
ARG labdir
ARG imagedir
ARG user_name
ARG password
ARG apt_source
ARG version
LABEL version=$version
ENV APT_SOURCE $apt_source
RUN /usr/bin/apt-source.sh
#
# put package installation here, e.g.,
# RUN apt-get update && apt-get install -y --no-install-recommends somepackage
#
#
#
# Install the system files found in the _system directory
#
ADD $labdir/$imagedir/sys_tar/sys.tar /
ADD $labdir/sys_$lab.tar.gz /
#
RUN useradd -ms /bin/bash $user_name
RUN echo "$user_name:$password" | chpasswd
RUN adduser $user_name sudo
# replace above with below for centos/fedora
#RUN usermod $user_name -a -G wheel


#
# **** Perform all root operations, e.g., ****
# **** "apt-get install" prior to the USER command. ****
#
USER $user_name
ENV HOME /home/$user_name
#
# Install files in the user home directory
#
ADD $labdir/$imagedir/home_tar/home.tar $HOME
# remove after docker fixes problem with empty tars
RUN rm -f $HOME/home.tar
ADD $labdir/$lab.tar.gz $HOME
#
# The first thing that executes on the container.
#
USER root
CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"]

7 changes: 7 additions & 0 deletions labs/strace/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
strace.pdf: strace.tex header.tex
pdflatex -jobname=strace strace
pdflatex -jobname=strace strace

clean:
rm -fr auto
rm -f *.aux *.log *.pdf *.dvi *.out
120 changes: 120 additions & 0 deletions labs/strace/docs/header.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
\documentclass[11pt]{article}

\usepackage{times}
\usepackage{epsf}
\usepackage{epsfig}
\usepackage{amsmath, alltt, amssymb, xspace}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\usepackage{url}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{float}

\usepackage{subfigure}
\usepackage{cite}
\usepackage{hyperref}
\hypersetup{%
pdfborder = {0 0 0}
}
\topmargin -0.50in % distance to headers
\oddsidemargin 0.0in
\evensidemargin 0.0in
\textwidth 6.5in
\textheight 8.9in


%\centerfigcaptionstrue

%\def\baselinestretch{0.95}


\newcommand\discuss[1]{\{\textbf{Discuss:} \textit{#1}\}}
%\newcommand\todo[1]{\vspace{0.1in}\{\textbf{Todo:} \textit{#1}\}\vspace{0.1in}}
\newtheorem{problem}{Problem}[section]
%\newtheorem{theorem}{Theorem}
%\newtheorem{fact}{Fact}
\newtheorem{define}{Definition}[section]
%\newtheorem{analysis}{Analysis}
\newcommand\vspacenoindent{\vspace{0.1in} \noindent}

%\newenvironment{proof}{\noindent {\bf Proof}.}{\hspace*{\fill}~\mbox{\rule[0pt]{1.3ex}{1.3ex}}}
%\newcommand\todo[1]{\vspace{0.1in}\{\textbf{Todo:} \textit{#1}\}\vspace{0.1in}}

%\newcommand\reducespace{\vspace{-0.1in}}
% reduce the space between lines
%\def\baselinestretch{0.95}

\newcommand{\fixmefn}[1]{ \footnote{\sf\ \ \fbox{FIXME} #1} }
\newcommand{\todo}[1]{
\vspace{0.1in}
\fbox{\parbox{6in}{TODO: #1}}
\vspace{0.1in}
}

\newcommand{\mybox}[1]{
\vspace{0.2in}
\noindent
\fbox{\parbox{6.5in}{#1}}
\vspace{0.1in}
}


\newcounter{question}
\setcounter{question}{1}

\newcommand{\myquestion} {{\vspace{0.1in} \noindent \bf Question \arabic{question}:} \addtocounter{question}{1} \,}

\newcommand{\myproblem} {{\noindent \bf Problem \arabic{question}:} \addtocounter{question}{1} \,}


\newcommand{\copyrightnotice}[1]{
\vspace{0.1in}
\fbox{\parbox{6in}{
This lab was developed for the Labtainer framework by the Naval Postgraduate
School, Center for Cybersecurity and Cyber Operations under sponsorship from
the National Science Foundation Award Number 1932950. This work is in the public domain, and cannot be copyrighted.}}
\vspace{0.1in}
}


\newcommand{\idea}[1]{
\vspace{0.1in}
{\sf IDEA:\ \ \fbox{\parbox{5in}{#1}}}
\vspace{0.1in}
}

\newcommand{\questionblock}[1]{
\vspace{0.1in}
\fbox{\parbox{6in}{#1}}
\vspace{0.1in}
}


\newcommand{\argmax}[1]{
\begin{minipage}[t]{1.25cm}\parskip-1ex\begin{center}
argmax
#1
\end{center}\end{minipage}
\;
}

\newcommand{\bm}{\boldmath}
\newcommand {\bx} {\mbox{\boldmath $x$}}
\newcommand {\by} {\mbox{\boldmath $y$}}
\newcommand {\br} {\mbox{\boldmath $r$}}


\newcommand{\tstamp}{\today}
%\rfoot[\fancyplain{\tstamp} {\tstamp}] {\fancyplain{}{}}

\pagestyle{fancy}
\lhead{\bfseries Labtainers}
\chead{}
\rhead{\small \thepage}
\lfoot{}
\cfoot{}
\rfoot{}



5 changes: 5 additions & 0 deletions labs/strace/docs/read_first.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The lab manual is at
file://LAB_DOCS/strace.pdf

You may open these by right clicking
and select "Open Link".
Binary file added labs/strace/docs/strace.pdf
Binary file not shown.
Loading

0 comments on commit 3c487f5

Please sign in to comment.