slides/slides03.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 13 Oct 2016 12:08:22 +0100
changeset 479 f76074ed6c9e
parent 471 97ab057cbd2e
child 518 e1fcfba63a31
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t]{beamer}
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
     2
\usepackage{../slides}
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
     3
\usepackage{../graphics}
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
     4
\usepackage{../langs}
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
     5
\usepackage{../data}
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
     6
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
     7
\setmonofont[Scale=.88]{Consolas}
152
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 115
diff changeset
     8
\newfontfamily{\consolas}{Consolas}
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
    10
\hfuzz=220pt 
111
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    11
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
% beamer stuff 
381
036a762b02cf updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    13
\renewcommand{\slidecaption}{SEN 03, King's College London}
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
    19
\begin{frame}[t]
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\frametitle{%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  \begin{tabular}{@ {}c@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  \\
381
036a762b02cf updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    23
  \LARGE Security Engineering (3)\\[-3mm] 
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  \end{tabular}}\bigskip\bigskip\bigskip
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
    26
  \normalsize
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  \begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
  \begin{tabular}{ll}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  Email:  & christian.urban at kcl.ac.uk\\
111
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    30
  Office: & S1.27 (1st floor Strand Building)\\
105
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
    31
  Slides: & KEATS (also home work is there)
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  \end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
    35
\end{frame}
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
    36
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    38
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    39
\begin{frame}[c]
479
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    40
  \frametitle{\Large Homework, Slides etc}
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    41
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    42
  \begin{itemize}
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    43
  \item homework, slides, programs are on KEATS
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    44
  \item include the question text  
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    45
  \item please send the homework as PDF (or txt)\bigskip    
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    46
  \item survey at the end  
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    47
  \end{itemize}
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    48
\end{frame}
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    49
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    50
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    51
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f76074ed6c9e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 471
diff changeset
    52
\begin{frame}[c]
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    53
\frametitle{\Large Buffer Overflow Attacks}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    54
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    55
\begin{center}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    56
\begin{columns}[b]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    57
\begin{column}{.4\textwidth}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    58
\centering
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
    59
\includegraphics[scale=0.3]{../pics/barrier.jpg}\\
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    60
lectures so far
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    61
\end{column}
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
    62
\begin{column}{.4\textwidth}
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    63
\centering
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    64
\includegraphics[scale=0.32]{../pics/trainwreck.jpg}\\
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    65
today
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    66
\end{column}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    67
\end{columns}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    68
\end{center}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    69
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    70
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    71
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    72
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    73
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
    74
\begin{frame}[c]
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    75
\frametitle{\begin{tabular}{@{}c@{}}According to\\ US Vulnerability DB\end{tabular}}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    76
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    77
\begin{center}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    78
\mbox{}\hspace{-8mm}\begin{tikzpicture}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    79
\begin{axis}[
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    80
    xlabel={year},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    81
    xlabel style={yshift=-1em},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    82
    ylabel={\% of total attacks},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    83
    ylabel style={yshift=-0em},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    84
    enlargelimits=false,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    85
    xtick={1997,2000,2002,...,2016},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    86
    xmin=1996.5,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    87
    xmax=2017,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    88
    ymax=23,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    89
    ytick={0,5,...,20},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    90
    scaled ticks=false,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    91
    axis lines=left,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    92
    width=11.5cm,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    93
    height=5cm, 
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    94
    ybar,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    95
    x tick label style={text height=1ex,font=\footnotesize,/pgf/number format/1000 sep={}},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    96
    nodes near coords=
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    97
     {\footnotesize
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    98
      $\pgfmathprintnumber[fixed,fixed zerofill,precision=1,use comma]{\pgfkeysvalueof{/data point/y}}$}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
    99
    ]
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   100
\addplot
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   101
  table [x=Year,y=Percentage] {bufferoverflows.data};
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   102
\end{axis}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   103
\end{tikzpicture}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   104
\end{center}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   105
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   106
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   107
from the US National Vulnerability Database\\
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   108
\small\url{http://web.nvd.nist.gov/view/vuln/statistics}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   109
\end{frame}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   110
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   111
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   112
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   113
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   114
\begin{frame}[c]
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   115
\frametitle{Smash the Stack for Fun\ldots}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   116
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   117
\begin{itemize}
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   118
\item \alert{\bf Buffer Overflow Attacks (BOAs)} or\\ 
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   119
{\bf Smashing the Stack Attacks}\medskip
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   120
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   121
\item unfortunately one of the most popular attacks\\ 
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   122
($>$ 50\% of security incidents reported at CERT are related 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   123
to buffer overflows)
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   124
\begin{flushright}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   125
\small\url{http://www.kb.cert.org/vuls}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   126
\end{flushright}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   127
\medskip
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   128
\item made popular in an article from 1996 by Elias Levy
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   129
(also known as Aleph One):\\
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   130
\begin{center}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   131
{\bf ``Smashing The Stack For Fun and Profit''}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   132
\end{center}\medskip
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   133
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   134
\begin{flushright}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   135
\small\url{http://phrack.org/issues/49/14.html}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   136
\end{flushright} 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   137
 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   138
\end{itemize}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   139
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   140
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   141
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   142
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   143
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   144
\begin{frame}[c]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   145
\frametitle{A Long Printed ``Twice''}
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   146
\mbox{}\\[-6mm]
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   147
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   148
\footnotesize 
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   149
\lstinputlisting[language=C,xleftmargin=4mm]{../progs/C0.c}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   150
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   151
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   152
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   153
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   154
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   155
\begin{frame}[c]
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   156
\frametitle{Printing Out ``Zombies''}
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   157
\mbox{}\\[-6mm]
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   158
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   159
\footnotesize
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   160
\lstinputlisting[language=C,xleftmargin=4mm]{../progs/C1.c}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   161
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   162
\end{frame}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   163
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   164
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   165
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   166
\begin{frame}[c]
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   167
\frametitle{A ``Login'' Function (1)}
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   168
\mbox{}\\[-6mm]
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   169
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   170
\footnotesize
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   171
\lstinputlisting[language=C,xleftmargin=4mm]{../progs/C2a.c}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   172
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   173
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   174
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   175
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   176
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   177
\begin{frame}[c]
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   178
\frametitle{A ``Login'' Function (2)}
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   179
\mbox{}\\[-6mm]
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   180
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   181
\footnotesize
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   182
\lstinputlisting[language=C,xleftmargin=-3mm]{../progs/C2b.c}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   183
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   184
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   185
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   186
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   187
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   188
\begin{frame}[c]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   189
\frametitle{What the Hell Is Going On?}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   190
216
38718062709a updated C2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 211
diff changeset
   191
\begin{itemize}
38718062709a updated C2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 211
diff changeset
   192
\item Let's start with a very simple program:
38718062709a updated C2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 211
diff changeset
   193
\end{itemize}
38718062709a updated C2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 211
diff changeset
   194
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   195
\lstinputlisting[language=C,xleftmargin=4mm]{../progs/example1.c}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   196
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   197
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   198
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   199
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   201
\begin{frame}[c]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   202
\frametitle{Memory}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   203
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   204
\begin{itemize}
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   205
\item each process will get a chunk of memory that is
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   206
      organised as follows: 
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   207
\end{itemize}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   208
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   209
\begin{center}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   210
  \begin{tikzpicture}[scale=0.8]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   211
  %\draw[step=1cm] (-3,-3) grid (3,3);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   212
  \draw[line width=1mm] (-2, -3) rectangle (2,3);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   213
  \draw[line width=1mm] (-2,1) -- (2,1);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   214
  \draw[line width=1mm] (-2,-1) -- (2,-1);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   215
  \draw (0,2) node {\large\tt text};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   216
  \draw (0,0) node {\large\tt heap};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   217
  \draw (0,-2) node {\large\tt stack};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   218
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   219
  \draw (-2.7,3) node[anchor=north east] {\tt\begin{tabular}{@{}l@{}}lower\\ address\end{tabular}};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   220
  \draw (-2.7,-3) node[anchor=south east] {\tt\begin{tabular}{@{}l@{}}higher\\ address\end{tabular}};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   221
  \draw[->, line width=1mm] (-2.5,3) -- (-2.5,-3);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   222
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   223
  \draw (2.7,-2) node[anchor=west] {\tt grows};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   224
  \draw (2.7,-3) node[anchor=south west] {\tt\footnotesize older};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   225
  \draw (2.7,-1) node[anchor=north west] {\tt\footnotesize newer};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   226
  \draw[|->, line width=1mm] (2.5,-3) -- (2.5,-1);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   227
  \end{tikzpicture}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   228
\end{center}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   229
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   230
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   231
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   232
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   233
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   234
\begin{frame}[c]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   235
\frametitle{The Stack}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   236
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   237
\begin{textblock}{7}(1,1)
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   238
  \begin{tikzpicture}[scale=0.8]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   239
  %\draw[step=1cm] (-3,-1) grid (3,8);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   240
  \draw[gray!20,fill=gray!20] (-1, 0) rectangle (1,-1);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   241
  \draw[line width=1mm] (-1,-1.2) -- (-1,7.4);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   242
  \draw[line width=1mm] ( 1,-1.2) -- ( 1,7.4);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   243
  \draw (0,-1) node[anchor=south] {\tt main};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   244
  \draw[line width=1mm] (-1,0) -- (1,0);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   245
  \draw (0,0) node[anchor=south] {\tt arg$_3$=3};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   246
  \draw[line width=1mm] (-1,1) -- (1,1);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   247
  \draw (0,1) node[anchor=south] {\tt arg$_2$=2};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   248
  \draw[line width=1mm] (-1,2) -- (1,2);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   249
  \draw (0,2) node[anchor=south] {\tt arg$_1$=1};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   250
  \draw[line width=1mm] (-1,3) -- (1,3);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   251
  \draw (0,3.1) node[anchor=south] {\tt ret};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   252
  \draw[line width=1mm] (-1,4) -- (1,4);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   253
  \draw (0,4) node[anchor=south] {\small\tt last sp};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   254
  \draw[line width=1mm] (-1,5) -- (1,5);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   255
  \draw (0,5) node[anchor=south] {\tt buf$_1$};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   256
  \draw[line width=1mm] (-1,6) -- (1,6);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   257
  \draw (0,6) node[anchor=south] {\tt buf$_2$};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   258
  \draw[line width=1mm] (-1,7) -- (1,7);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   259
  \draw (2,6.1) node[anchor=south] {\code{$esp}};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   260
  \draw[<-,line width=0.5mm] (1.1,7) -- (2.5,7);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   261
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   262
  \draw[->,line width=0.5mm] (1,4.5) -- (1.8,4.5) -- (1.8, 0) -- (1.1,0); 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   263
  \draw[->,line width=0.5mm] (1,3.5) -- (2.5,3.5);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   264
  \draw (2.6,3.1) node[anchor=south west] {\tt back to main()};
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   265
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   266
  \draw[->,red,line width=2mm] (2.5,0.1) -- (4.2,0.1);
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   267
\end{tikzpicture}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   268
\end{textblock}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   269
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   270
\begin{textblock}{7}(6.4,8)
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   271
\begin{bubble}[6.8cm]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   272
\footnotesize
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   273
\lstinputlisting[language=C,xleftmargin=5mm]{../progs/example1.c} 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   274
\end{bubble}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   275
\end{textblock}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   276
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   277
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   278
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   279
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   280
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   281
\begin{frame}[c]
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   282
\frametitle{Behind the Scenes}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   283
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   284
\only<2->{
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   285
\begin{textblock}{7}(1,0.6)
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   286
\begin{bubble}[6.8cm]
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   287
\footnotesize
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   288
\lstinputlisting[language=C,
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   289
                 xleftmargin=5mm,
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   290
                 belowskip=-1mm,
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   291
                 aboveskip=-1mm]{../progs/example1.c} 
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   292
\end{bubble}
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   293
\end{textblock}}
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   294
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   295
\only<2>{
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   296
\begin{textblock}{7}(0.5,6.6)
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   297
\footnotesize
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   298
\lstinputlisting[language={[x86masm]Assembler},morekeywords={movl},xleftmargin=5mm,numbers=none]{../progs/example1a.s} 
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   299
\end{textblock}}
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   300
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   301
\only<3>{
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   302
\begin{textblock}{7}(0.5,6.6)
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   303
\footnotesize
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   304
\lstinputlisting[language={[x86masm]Assembler},morekeywords={movl,movw},xleftmargin=5mm,numbers=none]{../progs/example1b.s} 
223
2bc8309203c8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 222
diff changeset
   305
\end{textblock}}
211
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   306
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   307
\end{frame}
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   308
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e6e160c7ea33 added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 206
diff changeset
   309
196
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
   310
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22f027da67ec updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 152
diff changeset
   311
\begin{frame}[c]
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   312
\frametitle{Overwriting the Stack}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   313
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   314
\begin{textblock}{7}(1,2)
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   315
  \begin{tikzpicture}[scale=0.8]
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   316
  %\draw[step=1cm] (-3,-1) grid (3,8);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   317
  \draw[gray!20,fill=gray!20] (-1, 0) rectangle (1,-1);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   318
  \draw[line width=1mm] (-1,-1.2) -- (-1,6.4);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   319
  \draw[line width=1mm] ( 1,-1.2) -- ( 1,6.4);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   320
  \draw (0,-1) node[anchor=south] {\tt main};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   321
  \draw[line width=1mm] (-1,0) -- (1,0);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   322
  \draw (0,0) node[anchor=south] {\tt arg$_3$=3};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   323
  \draw[line width=1mm] (-1,1) -- (1,1);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   324
  \draw (0,1) node[anchor=south] {\tt arg$_2$=2};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   325
  \draw[line width=1mm] (-1,2) -- (1,2);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   326
  \draw (0,2) node[anchor=south] {\tt arg$_1$=1};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   327
  \draw[line width=1mm] (-1,3) -- (1,3);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   328
  \draw (0,3.1) node[anchor=south] {\tt ret};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   329
  \draw[line width=1mm] (-1,4) -- (1,4);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   330
  \draw (0,4) node[anchor=south] {\small\tt last sp};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   331
  \draw[line width=1mm] (-1,5) -- (1,5);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   332
  \draw (0,5) node[anchor=south] {\tt buf};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   333
  \draw[line width=1mm] (-1,6) -- (1,6);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   334
  \draw (2,5.1) node[anchor=south] {\code{$esp}};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   335
  \draw[<-,line width=0.5mm] (1.1,6) -- (2.5,6);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   336
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   337
  \draw[->,line width=0.5mm] (1,4.5) -- (1.8,4.5);
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   338
  \draw (2.5,4.1) node[anchor=south] {\code{BBBB}};
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   339
  
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   340
  \draw[->,line width=0.5mm] (1,3.5) -- (2.5,3.5);
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   341
  \draw (2.6,3.1) node[anchor=south west] {\tt jump to \code{\\x080483f4}};
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   342
\end{tikzpicture}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   343
\end{textblock}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   344
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   345
\begin{textblock}{7}(1,13.5)
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   346
\code{char buf[8] = "AAAAAAAABBBB\\xf4\\x83\\x04\\x08\\x00"}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   347
\end{textblock}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   348
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   349
\end{frame}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   350
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   351
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   352
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   353
\tikzset{alt/.code args={<#1>#2#3#4}{%
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   354
  \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   355
}}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   356
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   357
\begin{frame}[t]
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   358
\frametitle{Buffer Overflow Attacks}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   359
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   360
\begin{itemize}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   361
\item the problem arises from the way C/C++ organises its function calls\\[-8mm]\mbox{}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   362
\end{itemize}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   363
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   364
\begin{center}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   365
\begin{tikzpicture}[scale=1]
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   366
%\draw[black!10,step=2mm] (0,0) grid (9,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   367
%\draw[black!10,thick,step=10mm] (0,0) grid (9,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   368
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   369
\node at (0.5,4.5) {\small\begin{tabular}{l}main\\[-2mm] prog.\end{tabular}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   370
\draw[line width=0mm, white, alt=<2->{fill=red}{fill=blue}] (0,2.5) rectangle (1,3.8);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   371
\draw[line width=0mm, white, alt=<9->{fill=red}{fill=blue}] (0,0.2) rectangle (1,0.5);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   372
\draw[line width=1mm, alt=<3->{fill=yellow}{fill=blue}] (0,2.0) rectangle (1,2.5);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   373
\draw[line width=1mm, alt=<6->{fill=red}{fill=blue}] (0,1.0) rectangle (1,2.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   374
\draw[line width=1mm, alt=<7->{fill=yellow}{fill=blue}] (0,0.5) rectangle (1,1.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   375
\draw[line width=1mm] (0,0) -- (0,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   376
\draw[line width=1mm] (1,0) -- (1,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   377
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   378
\node at (3.5,3.5) {\small\begin{tabular}{l}fact(n)\end{tabular}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   379
\draw[line width=1mm, alt=<{4-5,8}>{fill=red}{fill=blue}] (3,1.0) rectangle (4,3.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   380
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   381
\onslide<3-4>{\draw[->, line width=1mm,red] (1,2.3) to node [above,sloped,midway] {n=4} (3,3);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   382
\onslide<5>{\draw[<-, line width=1mm,red] (1,2.3) to node [above,sloped,midway] {res=24} (3,1);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   383
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   384
\onslide<7-8>{\draw[->, line width=1mm,red] (1,0.8) to node [above,sloped,midway] {n=3} (3,3);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   385
\onslide<9>{\draw[<-, line width=1mm,red] (1,0.8) to node [above,sloped,midway] {res=6} (3,1);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   386
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   387
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   388
\node at (7.75,3.9) {\small\begin{tabular}{l}stack\end{tabular}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   389
\draw[line width=1mm] (7,3.5) -- (7,0.5) -- (8.5,0.5) -- (8.5,3.5);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   390
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   391
\onslide<3,4,7,8>{
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   392
\node at (7.75, 1.4) {ret};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   393
\draw[line width=1mm] (7,1.1) -- (8.5,1.1);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   394
\node at (7.75, 2.0) {sp};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   395
\draw[line width=1mm] (7,2.3) -- (8.5,2.3);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   396
}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   397
\onslide<3,4>{
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   398
\node at (7.75, 0.8) {4};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   399
\draw[line width=1mm] (7,1.7) -- (8.5,1.7);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   400
}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   401
\onslide<7,8>{
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   402
\node at (7.75, 0.8) {3};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   403
\draw[line width=1mm] (7,1.7) -- (8.5,1.7);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   404
}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   405
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   406
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   407
\end{tikzpicture}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   408
\end{center}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   409
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   410
\end{frame}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   411
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   412
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   413
\begin{frame}[t]
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   414
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   415
\begin{center}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   416
\begin{tikzpicture}[scale=1]
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   417
%\draw[black!10,step=2mm] (0,0) grid (9,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   418
%\draw[black!10,thick,step=10mm] (0,0) grid (9,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   419
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   420
\node at (0.5,4.5) {\small\begin{tabular}{l}main\\[-2mm] prog.\end{tabular}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   421
\draw[line width=0mm, white, alt=<2->{fill=red}{fill=blue}] (0,2.5) rectangle (1,3.8);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   422
\draw[line width=1mm, white, fill=blue] (0,1.0) rectangle (1,2.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   423
\draw[line width=1mm, alt=<3->{fill=yellow}{fill=blue}] (0,2.0) rectangle (1,2.5);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   424
\draw[line width=1mm] (0,0) -- (0,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   425
\draw[line width=1mm] (1,0) -- (1,4);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   426
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   427
\node at (3.5,3.5) {\small\begin{tabular}{l}fact(n)\end{tabular}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   428
\draw[line width=0mm, alt=<{4-}>{red, fill=red}{blue, fill=blue}] (3,2.8) rectangle (4,3.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   429
\draw[line width=0mm, alt=<{5-}>{red, fill=red}{blue, fill=blue}] (3,2.8) rectangle (4,2.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   430
\draw[line width=0mm, alt=<{7-}>{red, fill=red}{blue, fill=blue}] (3,2.0) rectangle (4,1.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   431
\draw[line width=1mm] (3,1.0) rectangle (4,3.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   432
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   433
\onslide<3->{\draw[->, line width=1mm,red] (1,2.3) to node [above,sloped,midway] {n=4} (3,3);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   434
\onslide<5->{\draw[<-, line width=2mm,red] (4,2) to node [above,sloped,midway] 
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   435
{\begin{tabular}{l}user\\[-1mm] input\end{tabular}} (6,2);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   436
\onslide<8->{\draw[<-, line width=1mm,red] (1,-2) to (3,1);}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   437
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   438
\node at (7.75,3.9) {\small\begin{tabular}{l}stack\end{tabular}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   439
\draw[line width=1mm] (7,3.5) -- (7,-0.1) -- (8.5,-0.1) -- (8.5,3.5);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   440
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   441
\onslide<3->{
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   442
\node at (7.75, 0.2) {4};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   443
\draw[line width=1mm,alt=<6->{fill=red}{fill=white}] (7,0.5) rectangle (8.5,1.1);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   444
\node at (7.75, 0.8) {\alt<6->{@a\#}{ret}};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   445
\draw[line width=1mm,alt=<6->{fill=red}{fill=white}] (7,1.1) rectangle (8.5,1.7);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   446
\node at (7.75, 1.4) {\alt<6->{!?w;}sp};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   447
}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   448
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   449
\onslide<4->{
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   450
\draw[line width=1mm,fill=red] (7,1.7) rectangle (8.5,3.0);
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   451
\node[white] at (7.75, 2.4) {buffer};
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   452
}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   453
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   454
\end{tikzpicture}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   455
\end{center}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   456
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   457
\end{frame}
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   458
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   459
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   460
97ab057cbd2e updated
Christian Urban <urbanc@in.tum.de>
parents: 467
diff changeset
   461
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   462
\begin{frame}[c]
398
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   463
\frametitle{C-Library Functions}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   464
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   465
\begin{itemize}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   466
\item copy everything up to the zero byte
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   467
\end{itemize}\medskip
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   468
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   469
{\small
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   470
\lstinputlisting[language=C,numbers=none]{../progs/app5.c}}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   471
  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   472
  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   473
\end{frame}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   474
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   475
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   476
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   477
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   478
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   479
\begin{frame}[c]
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   480
\frametitle{Payloads}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   481
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   482
\begin{itemize}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   483
\item the idea is that you store some code in the buffer (the payload)
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   484
\item you then override the return address to execute this payload\medskip
398
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   485
\item normally you want to start a shell\pause
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   486
\item difficulty is to guess the right place where to ``jump''
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   487
\end{itemize}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   488
  
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   489
\end{frame}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   490
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   491
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   492
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   493
\begin{frame}[t]
239
0db764174afb updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 226
diff changeset
   494
\frametitle{Starting a Shell}
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   495
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   496
\small
400
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   497
\lstinputlisting[language=C,numbers=none,xleftmargin=-6mm]{../progs/o2.c}
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   498
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   499
\begin{textblock}{7}(5,7.5)
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   500
\begin{bubble}[7cm]
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   501
\lstinputlisting[language=C,numbers=none,xleftmargin=-0mm]{../progs/shell.c}
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   502
\end{bubble}
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   503
\end{textblock}
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   504
  
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   505
\end{frame}
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   506
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   507
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   508
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   509
\begin{frame}[c]
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   510
\frametitle{Avoiding \texttt{$\backslash$x00}}
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   511
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   512
\begin{itemize}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   513
\item another difficulty is that the code is not allowed to contain \texttt{$\backslash$x00}:
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   514
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   515
\begin{center}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   516
\texttt{xorl   \%eax, \%eax}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   517
\end{center}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   518
\end{itemize}\bigskip\bigskip
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   519
  
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   520
{\small
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   521
\lstinputlisting[language=C,numbers=none]{../progs/app5.c}}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   522
  
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   523
\end{frame}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   524
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   525
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   526
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   527
\begin{frame}[t]
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   528
\frametitle{String from the Web}
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   529
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   530
{\small
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   531
\lstinputlisting[language=C,numbers=none,xleftmargin=-6mm]{../progs/o1.c}}
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   532
\bigskip\bigskip
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   533
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   534
\noindent 
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   535
More ``interesting'' shell programs can be found at 
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   536
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   537
\begin{center}
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   538
\url{http://shellblade.net/shellcode.html}
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   539
\end{center}
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   540
  
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   541
\end{frame}
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   542
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   543
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   544
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   545
\begin{frame}[c]
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   546
\frametitle{Overflow.c}
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   547
\mbox{}\\[-6mm]
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   548
222
81f9f0eb1180 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 221
diff changeset
   549
\small
81f9f0eb1180 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 221
diff changeset
   550
\lstinputlisting[language=C,xleftmargin=-4mm,numbers=none]{../progs/overflow.c}
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   551
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   552
  
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   553
\end{frame}
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   554
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   555
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   556
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   557
\begin{frame}[c]
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   558
\frametitle{Optimising Success}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   559
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   560
\begin{center}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   561
\begin{tabular}{l@{\hspace{2cm}}l}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   562
  \begin{tikzpicture}[scale=0.6]
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   563
  \draw[line width=1mm] (-2, -1) rectangle (2,3);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   564
  \draw[line width=1mm,fill=blue!30] (-2, 1.9) rectangle (2,3);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   565
  \draw (0,2.5) node {\small\tt shell code};
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   566
  \draw[line width=1mm,fill=black] (0.3, -1) rectangle (2,-0.7);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   567
  \draw[->,line width=0.3mm] (1.05, -1) -- (1.05,-1.7) --
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   568
  (-3,-1.7) -- (-3, 3.7) -- (-1.9, 3.7) -- (-1.9, 3.1);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   569
   \end{tikzpicture}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   570
&
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   571
 \onslide<2>{
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   572
 \begin{tikzpicture}[scale=0.6]
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   573
  \draw[gray!50,fill=red!30] (-2,0.3) rectangle (2,3);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   574
  \draw[line width=1mm] (-2, -1) rectangle (2,3);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   575
  \draw[line width=1mm,fill=blue!30] (-2, 0.3) rectangle (2, -0.7);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   576
  \draw (0,-0.2) node {\small\tt shell code};
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   577
  \draw[line width=1mm,fill=black] (0.3, -1) rectangle (2,-0.7);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   578
  \draw [line width=0.5,decoration={brace,amplitude=2mm},decorate] 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   579
    (2.3,3) -- (2.3,0.3);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   580
  \draw[line width=0.3mm] (1.05, -1) -- (1.05,-1.7) --
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   581
  (3,-1.7) -- (3,1.65) -- (2.6, 1.65);
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   582
  \end{tikzpicture}}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   583
\end{tabular}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   584
\end{center}\bigskip
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   585
  
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   586
\onslide<2>{  
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   587
fill up the red part of the string with \pcode{NOP} operations
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   588
(Intel \texttt{$\backslash$x90})}  
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   589
  
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   590
\end{frame}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   591
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   592
398
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   593
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   594
\begin{frame}[c]
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   595
\frametitle{Why BOAs Work?}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   596
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   597
\begin{itemize}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   598
\item stack grows from higher addresses to lower addresses
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   599
\item library functions copy memory until a zero-byte is 
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   600
encountered
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   601
\end{itemize}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   602
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   603
\begin{center}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   604
\begin{tabular}{@{\hspace{-7mm}}c@{\hspace{2mm}}c@{}}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   605
\small
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   606
\begin{tikzpicture}[scale=0.45]
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   607
  %\draw[step=1cm] (-3,-3) grid (3,3);
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   608
  \draw[line width=1mm] (-2, -3) rectangle (2,3);
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   609
  \draw[line width=1mm] (-2,1) -- (2,1);
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   610
  \draw[line width=1mm] (-2,-1) -- (2,-1);
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   611
  \draw (0,2) node {\tt text};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   612
  \draw (0,0) node {\tt heap};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   613
  \draw (0,-2) node {\tt stack};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   614
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   615
  \draw (-2.7,3) node[anchor=north east] 
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   616
     {\tt\begin{tabular}{@{}l@{}}lower\\ address\end{tabular}};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   617
  \draw (-2.7,-3) node[anchor=south east] 
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   618
     {\tt\begin{tabular}{@{}l@{}}higher\\ address\end{tabular}};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   619
  \draw[->, line width=1mm] (-2.5,3) -- (-2.5,-3);
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   620
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   621
  \draw (2.7,-3) node[anchor=south west] {\tt\footnotesize older};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   622
  \draw (2.7,-1) node[anchor=north west] {\tt\footnotesize newer};
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   623
  \draw[|->, line width=1mm] (2.5,-3.09) -- (2.5,-1);
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   624
  \end{tikzpicture}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   625
&  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   626
\raisebox{1.3cm}{\footnotesize
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   627
\lstinputlisting[language=C,numbers=none]{../progs/app5.c}}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   628
\end{tabular}  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   629
\end{center}  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   630
  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   631
\end{frame}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   632
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
221
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   633
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   634
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ae6074cc446a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 220
diff changeset
   635
\begin{frame}[c]
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   636
\frametitle{Variants}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   637
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   638
There are many variants:
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   639
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   640
\begin{itemize}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   641
\item return-to-lib-C attacks
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   642
\item heap-smashing attacks\\
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   643
\textcolor{gray}{\small(Slammer Worm in 2003 infected 90\% of vulnerable systems within 10 minutes)}\bigskip
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   644
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   645
\item ``zero-days-attacks'' (new unknown vulnerability)
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   646
\end{itemize}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   647
  
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   648
\end{frame}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   649
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   650
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   651
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   652
\begin{frame}[c]
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   653
\frametitle{\begin{tabular}{c}
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   654
            Protections against\\
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   655
            Buffer Overflow Attacks
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   656
            \end{tabular}}
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   657
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   658
\begin{itemize}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   659
\item use safe library functions
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   660
\item stack canaries
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   661
\item ensure stack data is not executable (can be defeated)
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   662
\item address space randomisation (makes one-size-fits-all more difficult)
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   663
\item choice of programming language (one of the selling points of Java)
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   664
\end{itemize}
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   665
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   666
\only<2>{  
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   667
\begin{textblock}{7}(6,1)
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   668
  \begin{bubble}[5.5cm]
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   669
  \begin{tabular}{cp{2.9cm}}
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   670
  \begin{tikzpicture}[baseline=40mm,scale=0.8]
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   671
  %\draw[step=1cm] (-3,-1) grid (3,8);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   672
  \draw[gray!20,fill=gray!20] (-1, 0) rectangle (1,-1);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   673
  \draw[line width=1mm] (-1,-1.2) -- (-1,7.4);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   674
  \draw[line width=1mm] ( 1,-1.2) -- ( 1,7.4);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   675
  \draw (0,-1) node[anchor=south] {\tt main};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   676
  \draw[line width=1mm] (-1,0) -- (1,0);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   677
  \draw (0,0) node[anchor=south] {\tt arg$_3$=3};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   678
  \draw[line width=1mm] (-1,1) -- (1,1);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   679
  \draw (0,1) node[anchor=south] {\tt arg$_2$=2};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   680
  \draw[line width=1mm] (-1,2) -- (1,2);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   681
  \draw (0,2) node[anchor=south] {\tt arg$_1$=1};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   682
  \draw[line width=1mm] (-1,3) -- (1,3);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   683
  \draw (0,3.1) node[anchor=south] {\tt ret};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   684
  \draw[line width=1mm] (-1,4) -- (1,4);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   685
  \draw (0,4) node[anchor=south] {\small\tt last sp};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   686
  \draw[line width=1mm] (-1,5) -- (1,5);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   687
  \draw (0,5) node[anchor=south] {\tt\small\alert{\textbf{random}}};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   688
  \draw[line width=1mm] (-1,6) -- (1,6);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   689
  \draw (0,6) node[anchor=south] {\tt buf};
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   690
  \draw[line width=1mm] (-1,7) -- (1,7);
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   691
  \end{tikzpicture} &
396
2f4296a0ab21 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
   692
  \raggedright stack canary: a random value after the local variables
226
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   693
  \end{tabular}
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   694
\end{bubble}
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   695
\end{textblock}}
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   696
01fe5aba8781 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 223
diff changeset
   697
220
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   698
\end{frame}
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   699
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   700
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   701
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74772c30e0f4 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 216
diff changeset
   702
\begin{frame}[c]
398
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   703
\frametitle{In my Examples I Cheated}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   704
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   705
I compiled the programs with
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   706
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   707
\begin{center}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   708
\begin{tabular}{l@{\hspace{1mm}}l}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   709
\pcode{/usr/bin/gcc} & \pcode{-ggdb -O0}\\
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   710
                     & \pcode{-fno-stack-protector}\\
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   711
                     & \pcode{-mpreferred-stack-boundary=2}\\
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   712
                     & \pcode{-z execstack} 
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   713
\end{tabular}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   714
\end{center}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   715
  
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   716
\end{frame}
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   717
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   718
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   719
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   720
b183036ba675 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 396
diff changeset
   721
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   722
%% \begin{frame}[c]
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   723
%% \frametitle{NIST Statistics about BOA}
204
8fe0dc898c73 added example1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 199
diff changeset
   724
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   725
%% \begin{center}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   726
%% \begin{tikzpicture}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   727
%% \begin{axis}[
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   728
%%     xlabel={year},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   729
%%     ylabel={\% of total attacks},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   730
%%     ylabel style={yshift=0em},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   731
%%     enlargelimits=false,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   732
%%     xtick={1997,1999,2001,...,2015},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   733
%%     xmin=1996.5,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   734
%%     xmax=2016,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   735
%%     ymax=21,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   736
%%     ytick={0,5,...,20},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   737
%%     scaled ticks=false,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   738
%%     axis lines=left,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   739
%%     width=11cm,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   740
%%     height=5cm,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   741
%%     ybar,
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   742
%%     nodes near coords=
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   743
%%      {\footnotesize
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   744
%%       $\pgfmathprintnumber[fixed,fixed zerofill,precision=1,use comma]{\pgfkeysvalueof{/data point/y}}$},
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   745
%%     x tick label style={font=\footnotesize,/pgf/number format/1000 sep={}}]
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   746
%% \addplot
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   747
%%    table [x=Year,y=Percentage] {../handouts/bufferoverflows.data};
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   748
%% \end{axis}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   749
%% \end{tikzpicture}
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   750
%% \end{center}
204
8fe0dc898c73 added example1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 199
diff changeset
   751
  
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   752
%% from the US National Vulnerability Database\\
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   753
%% \small\url{http://web.nvd.nist.gov/view/vuln/statistics}
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   754
  
467
da4896f201b5 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 400
diff changeset
   755
%% \end{frame}
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   756
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
204
8fe0dc898c73 added example1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 199
diff changeset
   757
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   758
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   759
\begin{frame}[fragile]
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   760
\frametitle{D-Link Wifi Router, BOA}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   761
\small
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   762
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   763
As a proof-of-concept, the following URL allows 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   764
attackers to control the return value saved on 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   765
the stack (the vulnerability is triggered when
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   766
executing \pcode{"/usr/sbin/widget"}):
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   767
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   768
\begin{center}\footnotesize 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   769
\pcode{curl http://<target ip>/post_login.xml?hash=AAA...AAABBBB}
204
8fe0dc898c73 added example1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 199
diff changeset
   770
\end{center}
8fe0dc898c73 added example1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 199
diff changeset
   771
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   772
The value of the "hash" HTTP GET parameter consists of
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   773
292 occurrences of the \pcode{'A'} character, followed by four 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   774
occurrences of character \pcode{'B'}. In our lab setup, characters 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   775
\pcode{'B'} overwrite the saved program counter (\pcode{\%ra}).\bigskip
114
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   776
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   777
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   778
\begin{tabular}{@{}ll}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   779
Discovery date: & 06/03/2013\\
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   780
Release date:   & 02/08/2013
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   781
\end{tabular}\bigskip
114
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   782
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   783
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   784
\footnotesize
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   785
\hfill\url{http://roberto.greyhats.it/advisories/20130801-dlink-dir645.txt} 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   786
\end{frame}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   787
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   788
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   789
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   790
\begin{frame}[fragile]
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   791
\frametitle{GHOST in Glibc}
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   792
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   793
\small The GHOST vulnerability is a buffer overflow condition
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   794
that can be easily exploited locally and remotely. This
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   795
vulnerability is named after the GetHOSTbyname function
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   796
involved in the exploit.\medskip 
114
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   797
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   798
The attack allows the attacker to execute arbitrary code and
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   799
take control of the victim’s vulnerable machine.
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   800
Unfortunately, the vulnerability exists in the GNU C Library
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   801
(glibc), a code library originally released in 2000, meaning
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   802
it has been widely distributed. Although an update released by
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   803
Linux in 2013 mitigated this vulnerability, most systems and
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   804
products have not installed the patch.\medskip 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   805
114
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   806
391
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   807
\begin{tabular}{@{}ll} 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   808
Release date: & 01/28/2015
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   809
\end{tabular}\smallskip
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   810
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   811
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   812
\footnotesize
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   813
\hfill\url{https://community.qualys.com/blogs/laws-of-vulnerabilities/2015/01/27/the-ghost-vulnerability} 
a612dd3ddc81 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 381
diff changeset
   814
\end{frame}
114
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   815
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   816
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   817
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   818
\begin{frame}[c]
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   819
\frametitle{Format String Vulnerability}
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   820
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   821
\small
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   822
\texttt{string} is nowhere used:\bigskip
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   823
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   824
{\footnotesize\lstinputlisting[language=C]{../progs/C4.c}}\bigskip
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   825
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   826
this vulnerability can be used to read out the stack
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   827
  
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   828
\end{frame}
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 391
diff changeset
   829
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
114
3822d91a4639 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   830
113
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 112
diff changeset
   831
28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   832
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   833
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   834
%%% Local Variables:  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   835
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   836
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   837
%%% End: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   838