hmmmm4
This commit is contained in:
@@ -6,19 +6,15 @@
|
||||
\providecommand\HyField@AuxAddToFields[1]{}
|
||||
\providecommand\HyField@AuxAddToCoFields[2]{}
|
||||
\babel@aux{portuguese}{}
|
||||
\def\@LN@column{1}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {1}Introdução}{2}{section.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2}Criação de certificados}{2}{section.2}\protected@file@percent }
|
||||
\def\@LN@column{1}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2}Preparação Inicial}{2}{section.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Criação de Certificados}{2}{subsection.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {3}Configuração geral}{3}{section.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4}Configuração da \textit {Gateway} VPN}{3}{section.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}Configurar TOTP}{3}{subsection.4.1}\protected@file@percent }
|
||||
\def\@LN@column{1}
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Encaminhamento e Firewall}{4}{subsection.4.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5}Configuração do Cliente (Road Warrior)}{4}{section.5}\protected@file@percent }
|
||||
\def\@LN@column{1}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {6}Servidor Apache e OCSP}{5}{section.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {6.1}Revocation e OCSP}{5}{subsection.6.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {7}Conclusão}{5}{section.7}\protected@file@percent }
|
||||
\xdef \mintedoldcachechecksum{\detokenize{\minted@cachechecksum }}
|
||||
\gdef \@abspage@last{5}
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Configurar TOTP}{3}{subsection.3.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.2}Encaminhamento e Firewall}{4}{subsection.3.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4}Configuração do Cliente (Road Warrior)}{5}{section.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5}Servidor Apache e OCSP}{5}{section.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1}Revocation e OCSP}{5}{subsection.5.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2}Testes}{6}{subsection.5.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {6}Conclusão}{6}{section.6}\protected@file@percent }
|
||||
\gdef \@abspage@last{6}
|
||||
|
||||
1
relatorio/relatorio.listing
Normal file
1
relatorio/relatorio.listing
Normal file
@@ -0,0 +1 @@
|
||||
openssl ca -revoke user.crt -config cheese.cfg -keyfile ca.key -cert ca.crt
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -1,27 +1,8 @@
|
||||
\documentclass[11pt,a4paper]{article}
|
||||
\usepackage[portuguese]{babel}
|
||||
\usepackage[lining]{ebgaramond}
|
||||
\usepackage{listings}
|
||||
\usepackage{booktabs}
|
||||
|
||||
\usepackage{style}
|
||||
|
||||
\lstdefinestyle{mystyle}{
|
||||
basicstyle=\ttfamily\footnotesize,
|
||||
breakatwhitespace=false,
|
||||
breaklines=true,
|
||||
captionpos=b,
|
||||
keepspaces=true,
|
||||
numbers=left,
|
||||
numbersep=5pt,
|
||||
showspaces=false,
|
||||
showstringspaces=false,
|
||||
showtabs=false,
|
||||
tabsize=2
|
||||
}
|
||||
|
||||
\lstset{style=mystyle}
|
||||
|
||||
\setlength{\parindent}{0em}
|
||||
\setlength{\parskip}{2ex}
|
||||
|
||||
@@ -71,9 +52,11 @@ pois esta contém o \textit{certificate authority} CA.
|
||||
OpenSSL / Apache & VM\_OPENSSL\_APACHE.sh & Rede Interna 10.60.0.0/24 \\
|
||||
\end{tabular}
|
||||
|
||||
\section{Criação de certificados}
|
||||
\section{Preparação Inicial}
|
||||
|
||||
Os certificados utilizados foram auto-certificados por uma autoridade central que "pertence"
|
||||
\subsection{Criação de Certificados}
|
||||
|
||||
Os certificados utilizados foram auto-certificados por uma autoridade central que ``pertence''
|
||||
à máquina de OpenSSL. Esta mesma faz a gestão da lista de revogação.
|
||||
|
||||
Todas as chaves foram criadas no mesmo computador, com as variáveis que estão
|
||||
@@ -85,7 +68,7 @@ com as chaves, requests e certificados necessários.
|
||||
|
||||
O código para gerar os certificados X.509:
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}[bash]{create\_all\_keys.sh}
|
||||
cert_ca="/C=PT/ST=Coimbra/L=Coimbra/O=UC/CN=CoimbraVPN"
|
||||
cert_vpn="/C=PT/ST=Coimbra/L=Coimbra/O=UC/CN=gateway"
|
||||
cert_user="/C=PT/ST=Coimbra/L=Coimbra/O=UC/CN=warrior"
|
||||
@@ -104,19 +87,14 @@ openssl ca -batch -in "user.csr" -cert "ca.crt" -keyfile "ca.key" -out "user.crt
|
||||
openssl genrsa -out apache.key
|
||||
openssl req -new -key apache.key -out apache.csr -subj "$cert_apache" -addext "subjectAltName = IP:10.60.0.1,DNS:apache"
|
||||
openssl ca -batch -in "apache.csr" -cert "ca.crt" -keyfile "ca.key" -out "apache.crt" -config cheese.cfg
|
||||
\end{lstlisting}
|
||||
|
||||
% Porque é que precisamos de uma chave secreta?
|
||||
% Criar chave secreta.
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
openssl --genkey secret ta.key
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
\section{Configuração geral}
|
||||
Para configurar as VMs era preciso introduzir os mesmos comandos várias vezes, o que levava muitas vezes a erros de escrita, ou a correr o mesmo comando várias vezes, por isso criamos vários ficheiros .sh para conseguir facilitar o processo. A utilização de ficheiros .sh também vem com outros positivos pois facilita a testagem, e a recriação do cenário rapidamente.
|
||||
|
||||
No entanto para os serviços que configuramos, instalar, desativar e dar flush às iptables não foi suficiente, tivemos que criar pastas e sincronizar os relógios de todas as VMs visto que elas estarem ligeiramente atrasadas nunca conseguíamos acertar na password do google-authenticator que utiliza o tempo local para calcular a sua chave.
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}[bash]{VM\_CONFIG.sh}
|
||||
yum install -y epel-release
|
||||
yum install -y openvpn iptables-services dhcp-client
|
||||
systemctl stop firewalld
|
||||
@@ -139,26 +117,26 @@ mkdir -p /etc/openvpn/client
|
||||
systemctl stop chronyd
|
||||
ntpdate pool.ntp.org
|
||||
systemctl start chronyd
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Configurar TOTP}
|
||||
|
||||
Foi criado o ficheiro \texttt{totp} com a configuração de autenticação a
|
||||
ser utilizada pelo plugin de PAM para o openvpn.
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}{/etc/pam.d/totp}
|
||||
plugin /usr/lib64/openvpn/plugins/openvpn-plugin-auth-pam.so totp
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
Adicionalmente, devido às restrições de segurança do \textit{systemd},
|
||||
foi necessário desativar o \texttt{ProtectHome} no serviço do OpenVPN
|
||||
para que o plugin PAM consiga ler os ficheiros de segredo do Google Authenticator
|
||||
localizados nas diretorias \textit{home} dos utilizadores.
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}{override.conf}
|
||||
[Service]
|
||||
ProtectHome=false
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
Primeiro, na gateway, entramos como o utilizador desejado e obtemos a chave
|
||||
do gerador de palavras passes temporárias. Ao inserir a chave no
|
||||
@@ -170,10 +148,10 @@ chave de 6 dígitos.
|
||||
\includegraphics[width=8em]{google-authenticator}
|
||||
\end{figure}
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}[bash]{}
|
||||
su john
|
||||
google-authenticator
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Encaminhamento e Firewall}
|
||||
|
||||
@@ -188,7 +166,7 @@ de IP (NAT).
|
||||
%e utilizar as regras apenas para encaminhar corretamente.
|
||||
% Colocar isso na conclusão tho
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}[bash]{firewall.sh}
|
||||
# Ativar encaminhamento
|
||||
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
|
||||
sysctl -p /etc/sysctl.conf
|
||||
@@ -198,7 +176,7 @@ iptables -I INPUT 1 -p udp --dport 1194 -j ACCEPT
|
||||
iptables -I FORWARD 1 -i tun0 -o enp0s9 -j ACCEPT
|
||||
iptables -I FORWARD 1 -i enp0s9 -o tun0 -j ACCEPT
|
||||
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o enp0s8 -j MASQUERADE
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
\section{Configuração do Cliente (Road Warrior)}
|
||||
|
||||
@@ -207,7 +185,7 @@ gateway na porta 1194. Para garantir a segurança, utilizamos autenticação mú
|
||||
e um \textit{two factor authentication} (2FA) como palavras-passe temporárias, geradas através do
|
||||
\textit{Google Authenticator}.
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}{client.conf}
|
||||
client
|
||||
dev tun
|
||||
proto udp
|
||||
@@ -218,7 +196,7 @@ key user.key
|
||||
auth-user-pass
|
||||
cipher AES-256-GCM
|
||||
auth SHA256
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
|
||||
\section{Servidor Apache e OCSP}
|
||||
|
||||
@@ -230,13 +208,17 @@ da autoridade de certificação.
|
||||
\begin{enumerate}
|
||||
\item Estabelecer a ligação VPN e verificar a conectividade à rede interna.
|
||||
\item No diretório da autoridade de certificação (máquina \textit{host}), revogar o certificado do utilizador:
|
||||
\begin{lstlisting}[language=bash]
|
||||
\begin{codeblock}[bash]{revoke.sh}
|
||||
openssl ca -revoke user.crt -config cheese.cfg -keyfile ca.key -cert ca.crt
|
||||
\end{lstlisting}
|
||||
\end{codeblock}
|
||||
\item Atualizar o ficheiro \texttt{index.txt} no servidor OCSP e reiniciar o serviço para carregar o novo estado de revogação.
|
||||
\item Tentar estabelecer uma nova ligação VPN e verificar que a autenticação falha devido à resposta \texttt{revoked} do responder OCSP.
|
||||
\end{enumerate}
|
||||
|
||||
\subsection{Testes}
|
||||
|
||||
Podemos validar que o OCSP
|
||||
|
||||
|
||||
\section{Conclusão}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
\babel@toc {portuguese}{}\relax
|
||||
\contentsline {section}{\numberline {1}Introdução}{2}{section.1}%
|
||||
\contentsline {section}{\numberline {2}Criação de certificados}{2}{section.2}%
|
||||
\contentsline {section}{\numberline {2}Preparação Inicial}{2}{section.2}%
|
||||
\contentsline {subsection}{\numberline {2.1}Criação de Certificados}{2}{subsection.2.1}%
|
||||
\contentsline {section}{\numberline {3}Configuração geral}{3}{section.3}%
|
||||
\contentsline {section}{\numberline {4}Configuração da \textit {Gateway} VPN}{3}{section.4}%
|
||||
\contentsline {subsection}{\numberline {4.1}Configurar TOTP}{3}{subsection.4.1}%
|
||||
\contentsline {subsection}{\numberline {4.2}Encaminhamento e Firewall}{4}{subsection.4.2}%
|
||||
\contentsline {section}{\numberline {5}Configuração do Cliente (Road Warrior)}{4}{section.5}%
|
||||
\contentsline {section}{\numberline {6}Servidor Apache e OCSP}{5}{section.6}%
|
||||
\contentsline {subsection}{\numberline {6.1}Revocation e OCSP}{5}{subsection.6.1}%
|
||||
\contentsline {section}{\numberline {7}Conclusão}{5}{section.7}%
|
||||
\contentsline {subsection}{\numberline {3.1}Configurar TOTP}{3}{subsection.3.1}%
|
||||
\contentsline {subsection}{\numberline {3.2}Encaminhamento e Firewall}{4}{subsection.3.2}%
|
||||
\contentsline {section}{\numberline {4}Configuração do Cliente (Road Warrior)}{5}{section.4}%
|
||||
\contentsline {section}{\numberline {5}Servidor Apache e OCSP}{5}{section.5}%
|
||||
\contentsline {subsection}{\numberline {5.1}Revocation e OCSP}{5}{subsection.5.1}%
|
||||
\contentsline {subsection}{\numberline {5.2}Testes}{6}{subsection.5.2}%
|
||||
\contentsline {section}{\numberline {6}Conclusão}{6}{section.6}%
|
||||
|
||||
@@ -17,7 +17,47 @@
|
||||
\usepackage{pifont}
|
||||
\usepackage{amssymb}
|
||||
|
||||
\usepackage{minted}
|
||||
\usepackage[most]{tcolorbox}
|
||||
\tcbuselibrary{listings, skins, breakable}
|
||||
|
||||
\lstdefinestyle{mystyle}{
|
||||
basicstyle=\ttfamily\footnotesize,
|
||||
breakatwhitespace=false,
|
||||
breaklines=true,
|
||||
captionpos=b,
|
||||
keepspaces=true,
|
||||
numbers=left,
|
||||
numbersep=5pt,
|
||||
showspaces=false,
|
||||
showstringspaces=false,
|
||||
showtabs=false,
|
||||
tabsize=2,
|
||||
commentstyle=\color{gray},
|
||||
keywordstyle=\color{MidnightBlue}\bfseries,
|
||||
stringstyle=\color{ForestGreen}
|
||||
}
|
||||
|
||||
\newtcblisting{codeblock}[2][]{
|
||||
enhanced,
|
||||
breakable,
|
||||
colback=gray!2!white,
|
||||
colframe=gray!20!black,
|
||||
attach boxed title to top left={yshift*=-\tcboxedtitleheight/2, xshift=4mm},
|
||||
boxed title style={
|
||||
colback=gray!20!black,
|
||||
outer arc=0pt,
|
||||
arc=0pt,
|
||||
top=1pt,
|
||||
bottom=1pt,
|
||||
},
|
||||
fonttitle=\bfseries\ttfamily\footnotesize,
|
||||
title={#2},
|
||||
listing only,
|
||||
listing options={
|
||||
style=mystyle,
|
||||
language=#1,
|
||||
}
|
||||
}
|
||||
|
||||
\setlength{\parskip}{1em}%
|
||||
\setlength{\parindent}{0em}%
|
||||
|
||||
Reference in New Issue
Block a user