\documentclass[11pt]{exam}
\newcommand{\myname}{Vecna}
\newcommand{\myemail}{vvecna@uwaterloo.ca}
\newcommand{\myhwtype}{netsim}
\newcommand{\myhwnum}{Cheat Sheet}
\newcommand{\myclass}{SPARCS}
\newcommand{\mylecture}{}
\newcommand{\mysection}{2024}

\date{2024 May 13}

% Prefix for numedquestion's
\newcommand{\questiontype}{Level}

% Use this if your "written" questions are all under one section
% For example, if the homework handout has Section 5: Written Questions
% and all questions are 5.1, 5.2, 5.3, etc. set this to 5
% Use for 0 no prefix. Redefine as needed per-question.
\newcommand{\writtensection}{0}

\usepackage{amsmath, amsfonts, amsthm, amssymb}  % Some math symbols
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[all]{xy}
\usepackage{wrapfig}
\usepackage{fancyvrb}
\usepackage[T1]{fontenc}
\usepackage{listings}

\usepackage{centernot}
\usepackage{mathtools}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\card}{\vert}{\vert}

% Uncomment the following line to get Solarized-themed source listings
% You will have had to already installed the solarized-light package
% https://github.com/jez/latex-solarized
%
%\usepackage{solarized-light}

\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\pagestyle{empty}

\def\indented#1{\list{}{}\item[]}
\let\indented=\endlist

\newcounter{questionCounter}
\newcounter{partCounter}[questionCounter]

\newenvironment{namedquestion}[1][\arabic{questionCounter}]{%
    \addtocounter{questionCounter}{1}%
    \setcounter{partCounter}{0}%
    \vspace{.2in}%
    	\noindent{\bf \questiontype \; \arabic{questionCounter}. #1}%
    \vspace{0.3em} \hrule \vspace{.1in}%
}{}

\newenvironment{numedquestion}[0]{%
	\stepcounter{questionCounter}%
    \vspace{.2in}%
        \ifx\writtensection\undefined
        \noindent{\bf \questiontype \; \arabic{questionCounter}. }%
        \else
          \if\writtensection0
          \noindent{\bf \questiontype \; \arabic{questionCounter}. }%
          \else
          \noindent{\bf \questiontype \; \writtensection.\arabic{questionCounter} }%
        \fi
    \vspace{0.3em} \hrule \vspace{.1in}%
}{}

\newenvironment{alphaparts}[0]{%
  \begin{enumerate}[label=\textbf{(\alph*)}]
}{\end{enumerate}}

\newenvironment{arabicparts}[0]{%
  \begin{enumerate}[label=\textbf{\arabic{questionCounter}.\arabic*})]
}{\end{enumerate}}

\newenvironment{questionpart}[0]{%
  \item
}{}

\newcommand{\answerbox}[1]{
\begin{framed}
\vspace{#1}
\end{framed}}

\pagestyle{head}

\headrule
\header{\textbf{\myclass\ \mylecture\mysection}}%
{\textbf{\myname\ (\myemail)}}%
{\textbf{\myhwtype\ \myhwnum}}

\begin{document}
\thispagestyle{plain}
\begin{center}
  {\Large \myclass{} \myhwtype{} \myhwnum} \\
  \myname{} (\myemail{}) \\
  2024 May 13
\end{center}

\begin{namedquestion}[Getting started]
	Purpose: Introduce netsim game
	
	\begin{enumerate}
		\item Click red restart button
		\item Click green pause button while packet is visible
		\item Click on any of the 4 computers
		\item Click on a packet (the purple circle)
		\item Press ``+'' button on the side to add packets
		\item Add a packet (no need to fill in the fields at this time)
		\item Press the new arrow button to send the packet
	\end{enumerate}
\end{namedquestion}

\begin{namedquestion}[Packet fields]
	Purpose: Introduce packet fields
	
	Send 1 packet with ``srcip: Alice'' and ``dstip: Bob''
\end{namedquestion}

\begin{namedquestion}[Ping]
	Purpose: Introduce ICMP (ping)
	
	Send 4 packets with ``srcip: Alice'', ``dstip: Google'', ``proto: ICMP'' (can use ``Repeat: 4'' instead of pressing send 4 times)
\end{namedquestion}

\begin{namedquestion}[Routing]
	Purpose: Same as ``Packet fields'' but with an internal view of how routers are the ones that contain addressing information to forward packets
	
	Send 1 packet with ``srcip: Bob'', ``dstip: Carol'' (``Sent from'' field can be Bob or anyone else)
\end{namedquestion}

\begin{namedquestion}[Modems]
	Purpose: Modems forward packets from computers within an internal network (home, with Alice and Bob) to computers outside the network (Google). Specifically, this activity is about how ping requests work with modems.
	
	Send 1 packet with ``srcip: Bob'', ``dstip: Carol'' (``Sent from'' field can be Bob or anyone else)
\end{namedquestion}

\newpage % Make each question stay on 1 page

\begin{namedquestion}[Encryption]
	Purpose: Demonstrate a key exchange allowing Alice and Bob to send encrypted messages.
	
	\begin{enumerate}
		\item Alice sends 1 packet with ``srcip: Alice'', ``dstip: Bob'', ``proto: encryption'', ``type: keyrequest'', ``key: 12345''
		\item Alice receives a response packet with ``type: keyresponse'', ``key: 67890''
		\item Alice sends 1 packet with ``srcip: Alice'', ``dstip: Bob'', ``proto: encryption'', ``type: message'', ``key: 67890'' (where this key is the one Bob sent her)
	\end{enumerate}
\end{namedquestion}

\begin{namedquestion}[IP Spoofing]
	Purpose: The source IP in the header of a packet can be changed without being detected by the recipient of a packet. This is known as `spoofing' a packet.
	
	Alice sends 1 packet with ``srcip: Carol'', ``dstip: Bob''
\end{namedquestion}

\begin{namedquestion}[Stealing packets]
	Purpose: Spoofing can be used to get a link layer device (a switch) associate your hardware address (known as MAC address) with any network layer (IP) address that you send in the source address field. You can impersonate another user this way.
	
	Alice sends 1 packet with ``srcip: Carol'', ``dstip: Google'', but \textbf{timing is important!}
	\begin{enumerate}
		\item Carol sends a ping to Google
		\item Carol sends a second ping as Google sends a pong response to the first ping
		\item Alice must send the above packet \textbf{after Carol sends the second ping, before the Central Hub receives the second pong response from Google}
	\end{enumerate}
\end{namedquestion}

\begin{namedquestion}[Basic DoS]
	Purpose: To overwhelm a given server with packets such that it cannot respond to any more packets. This is known as a ``denial of service'' attack.
	
	Alice sends at least 30 packets with ``dstip: Google'' all at once (use Repeat)
\end{namedquestion}

\begin{namedquestion}[Distributed DoS]
	Purpose: The previous attack can be mitigated by blocking the IP of the computer that sends the large number of requests. This is known as IP-based blocking. In order to circumvent this attack, an attacker can control several ``Zombie'' computers, for instance, in a botnet and force them to send packets. The server cannot block a large number of IPs that belong to legitimate (but botnet-infected) users.
	
	Each zombie computer sends at least 55 packets with ``dstip: Google'' all at once (use Repeat)
\end{namedquestion}

\newpage

\begin{namedquestion}[Smurf attack]
	Purpose: This is another attack to circumvent the DoS mitigation technique of IP-based blocking and is thus similar to the attack in activity 10. It differs from the attack in activity 10 in that it doesn't require control of the zombie machines in order to send packets from them. In other words, Bob, Carol, and Dave's machines behave in an expected manner to ICMP packets with the ``Broadcast'' IP and effectively, this leads them to behaving like zombies. 
	
	Alice sends enough ($\approx 30$) packets with ``srcip: Google'', ``dstip: Broadcast'', ``proto: ICMP'' all at once (use Repeat)
\end{namedquestion}

\begin{namedquestion}[Mallory-in-the-middle]
	Purpose: To combine the IP spoofing skills to perform an attack that convinces both parties (Alice, Bob) who wish to communicate using public-key cryptography into thinking that they are talking to each other securely, whereas as an attacker (Mallory), you obtain the plaintext message. 
	
	\begin{enumerate}
		\item Alice sends a packet with ``srcip: Alice'', ``dstip: Bob'', ``proto: encryption'', ``type: keyrequest'', ``key: 12345'' which Mallory intercepts
		\item Mallory (you) sends a packet with ``srcip: Alice'', ``dstip: Bob'', ``proto: encryption'', ``type: keyrequest'', \textbf{``key: 31337''} so Bob believes Alice's key is 31337
		\item Bob sends a packet with ``srcip: Bob'', ``dstip: Alice'', ``proto: encryption'', ``type: keyresponse'', ``key: 67890'' which Mallory intercepts
		\item Mallory (you) sends a packet with ``srcip: Bob'', ``dstip: Alice'', ``proto: encryption'', ``type: keyresponse'', \textbf{``key: 31337''} so Alice believes Bob's key is 31337
		\item Alice sends a packet with ``srcip: Alice'', ``dstip: Bob'', ``proto: encryption'', ``type: message'', ``key: 31337'' which Mallory intercepts and decrypts
		\item Mallory (you) sends a packet with ``srcip: Alice'', ``dstip: Bob'', ``proto: encryption'', ``type: message'', \textbf{``key: 67890''}, re-encrypted with Bob's key so Bob does not know the message was intercepted
	\end{enumerate}
\end{namedquestion}

\end{document}
