relatorio: vpn gateway
This commit is contained in:
@@ -6,15 +6,25 @@
|
||||
\providecommand\HyField@AuxAddToFields[1]{}
|
||||
\providecommand\HyField@AuxAddToCoFields[2]{}
|
||||
\babel@aux{portuguese}{}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {1}Introdução}{2}{section.1}\protected@file@percent }
|
||||
\@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 {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}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {1}Introdução}{3}{section.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2}Preparação Inicial}{3}{section.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Criação de Certificados}{3}{subsection.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}Configuração geral}{4}{subsection.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {3}VPN Gateway}{5}{section.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Configuração da Máquina}{5}{subsection.3.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.2}Configuração do Serviço OpenVPN}{6}{subsection.3.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.3}Erros}{7}{subsection.3.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.4}Configurar o utilizador com TOTP}{8}{subsection.3.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4}VPN Client (Road Warrior)}{8}{section.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}Configuração da Máquina}{8}{subsection.4.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Configuração do Cliente OpenVPN}{8}{subsection.4.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Testes}{9}{subsection.4.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5}Servidor Apache e OCSP}{9}{section.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1}Configuração da Máquina}{9}{subsection.5.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2}Configuração do Serviço Apache}{9}{subsection.5.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{\numberline {5.2.1}Testes}{9}{subsubsection.5.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.3}Configuração do Serviço OpenSSL}{9}{subsection.5.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{\numberline {5.3.1}Testes}{9}{subsubsection.5.3.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {6}Teste Integrado}{10}{section.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {7}Conclusão}{10}{section.7}\protected@file@percent }
|
||||
\gdef \@abspage@last{10}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
This is pdfTeX, Version 3.141592653-2.6-1.40.29 (TeX Live 2026/Arch Linux) (preloaded format=pdflatex 2026.4.13) 27 APR 2026 13:20
|
||||
This is pdfTeX, Version 3.141592653-2.6-1.40.29 (TeX Live 2026/Arch Linux) (preloaded format=pdflatex 2026.4.13) 27 APR 2026 20:43
|
||||
entering extended mode
|
||||
\write18 enabled.
|
||||
%&-line parsing enabled.
|
||||
@@ -1137,15 +1137,17 @@ LaTeX Font Info: Trying to load font information for U+msb on input line 17.
|
||||
|
||||
(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd
|
||||
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
|
||||
)
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/m/n' will be
|
||||
(Font) scaled to size 14.4pt on input line 17.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/bold/n' aliased to
|
||||
(Font) `T1/Raleway-OsF/b/n' on input line 17.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/b/n' will be
|
||||
(Font) scaled to size 14.4pt on input line 17.
|
||||
) [1
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.toc
|
||||
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}{/usr/share/texmf-dist/fonts
|
||||
/enc/dvips/raleway/a_itoun2.enc}]
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/m/n' will be
|
||||
(Font) scaled to size 14.4pt on input line 19.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/bold/n' aliased to
|
||||
(Font) `T1/Raleway-OsF/b/n' on input line 19.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/b/n' will be
|
||||
(Font) scaled to size 14.4pt on input line 19.
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.toc
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/bold/n' aliased to
|
||||
(Font) `T1/Raleway-OsF/b/n' on input line 2.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/b/n' will be
|
||||
@@ -1154,24 +1156,22 @@ LaTeX Font Info: Font shape `T1/Raleway-OsF/b/n' will be
|
||||
\tf@toc=\write5
|
||||
\openout5 = `relatorio.toc'.
|
||||
|
||||
[1
|
||||
|
||||
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}{/usr/share/texmf-dist/fonts
|
||||
/enc/dvips/raleway/a_itoun2.enc}]
|
||||
[2]
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/m/it' will be
|
||||
(Font) scaled to size 10.95pt on input line 23.
|
||||
(Font) scaled to size 10.95pt on input line 26.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/bold/n' aliased to
|
||||
(Font) `T1/Raleway-OsF/b/n' on input line 57.
|
||||
(Font) `T1/Raleway-OsF/b/n' on input line 60.
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/b/n' will be
|
||||
(Font) scaled to size 12.0pt on input line 57.
|
||||
(Font) scaled to size 12.0pt on input line 60.
|
||||
\g__tcobox_out_iow=\write6
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
LaTeX Font Info: Font shape `T1/cmtt/bx/n' in size <10.95> not available
|
||||
(Font) Font shape `T1/cmtt/m/n' tried instead on input line 91.
|
||||
(Font) Font shape `T1/cmtt/m/n' tried instead on input line 92.
|
||||
LaTeX Font Info: Font shape `T1/cmtt/bx/n' in size <9> not available
|
||||
(Font) Font shape `T1/cmtt/m/n' tried instead on input line 91.
|
||||
(/usr/share/texmf-dist/tex/latex/listings/lstlang1.sty
|
||||
(Font) Font shape `T1/cmtt/m/n' tried instead on input line 92.
|
||||
|
||||
(/usr/share/texmf-dist/tex/latex/listings/lstlang1.sty
|
||||
File: lstlang1.sty 2025/11/14 1.11b listings language file
|
||||
)
|
||||
(/usr/share/texmf-dist/tex/latex/listings/lstlang1.sty
|
||||
@@ -1180,7 +1180,7 @@ File: lstlang1.sty 2025/11/14 1.11b listings language file
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing
|
||||
LaTeX Font Info: Font shape `T1/Raleway-OsF/m/n' will be
|
||||
(Font) scaled to size 9.0pt on input line 1.
|
||||
) [2{/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1.enc}]
|
||||
) [3{/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1.enc}]
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
@@ -1188,15 +1188,31 @@ LaTeX Font Info: Font shape `T1/Raleway-OsF/m/n' will be
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [3]
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [4]
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [5]
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing)
|
||||
<google-authenticator.jpg, id=127, 225.84375pt x 447.6725pt>
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing)
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [6]
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [7]
|
||||
<google-authenticator.jpg, id=284, 225.84375pt x 447.6725pt>
|
||||
File: google-authenticator.jpg Graphic file (type jpg)
|
||||
<use google-authenticator.jpg>
|
||||
Package pdftex.def Info: google-authenticator.jpg used on input line 148.
|
||||
Package pdftex.def Info: google-authenticator.jpg used on input line 314.
|
||||
(pdftex.def) Requested size: 87.59998pt x 173.64207pt.
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
@@ -1205,16 +1221,12 @@ Package pdftex.def Info: google-authenticator.jpg used on input line 148.
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [4 </home/raw/uni/fsi/
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [8 </home/raw/uni/fsi/
|
||||
trabalho/relatorio/google-authenticator.jpg>]
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing)
|
||||
\openout6 = `relatorio.listing'.
|
||||
|
||||
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [5] [6]
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.listing) [9] [10]
|
||||
(/home/raw/uni/fsi/trabalho/relatorio/relatorio.aux)
|
||||
***********
|
||||
LaTeX2e <2025-11-01>
|
||||
@@ -1228,13 +1240,13 @@ Package rerunfilecheck Warning: File `relatorio.out' has changed.
|
||||
|
||||
Package rerunfilecheck Info: Checksums for `relatorio.out':
|
||||
(rerunfilecheck) Before: <no file>
|
||||
(rerunfilecheck) After: 41C11594F8395BDDF3DB5C5ABB4704A9;1637.
|
||||
(rerunfilecheck) After: FCCD2EDF8B7B6A2528F85719166C3546;3316.
|
||||
)
|
||||
Here is how much of TeX's memory you used:
|
||||
31766 strings out of 469495
|
||||
625795 string characters out of 5470098
|
||||
1425222 words of memory out of 5000000
|
||||
59766 multiletter control sequences out of 15000+600000
|
||||
32007 strings out of 469495
|
||||
629242 string characters out of 5470098
|
||||
1506188 words of memory out of 5000000
|
||||
59884 multiletter control sequences out of 15000+600000
|
||||
790677 words of font info for 87 fonts, out of 8000000 for 9000
|
||||
16 hyphenation exceptions out of 8191
|
||||
113i,8n,122p,500b,1792s stack positions out of 10000i,1000n,20000p,200000b,200000s
|
||||
@@ -1243,11 +1255,11 @@ hare/texmf-dist/fonts/type1/impallari/raleway/Raleway-Italic.pfb></usr/share/te
|
||||
xmf-dist/fonts/type1/impallari/raleway/Raleway-Regular.pfb></usr/share/texmf-di
|
||||
st/fonts/type1/public/cm-super/sftt0900.pfb></usr/share/texmf-dist/fonts/type1/
|
||||
public/cm-super/sftt1095.pfb>
|
||||
Output written on /home/raw/uni/fsi/trabalho/relatorio/relatorio.pdf (6 pages,
|
||||
153091 bytes).
|
||||
Output written on /home/raw/uni/fsi/trabalho/relatorio/relatorio.pdf (10 pages,
|
||||
168978 bytes).
|
||||
PDF statistics:
|
||||
222 PDF objects out of 1000 (max. 8388607)
|
||||
177 compressed objects within 2 object streams
|
||||
97 named destinations out of 1000 (max. 500000)
|
||||
387 PDF objects out of 1000 (max. 8388607)
|
||||
336 compressed objects within 4 object streams
|
||||
214 named destinations out of 1000 (max. 500000)
|
||||
162 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -14,7 +14,10 @@
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
\newpage
|
||||
\tableofcontents
|
||||
|
||||
\newpage
|
||||
|
||||
\section{Introdução}
|
||||
@@ -66,8 +69,6 @@ Numa situação normal teríamos uma autoridade de certificação para enviar e
|
||||
no fundo gerir todos, mas para este cenário podemos inicializar as máquinas
|
||||
com as chaves, requests e certificados necessários.
|
||||
|
||||
O código para gerar os certificados X.509:
|
||||
|
||||
\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"
|
||||
@@ -90,10 +91,34 @@ openssl ca -batch -in "apache.csr" -cert "ca.crt" -keyfile "ca.key" -out "apache
|
||||
openssl --genkey secret ta.key
|
||||
\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.
|
||||
Como o CA foi criado ``\textit{in place}'', e não na sua pasta prédefinida, foi necessário utilizar
|
||||
um configuração própria para definir os ficheiros \textit{index.txt} e \textit{serial}.
|
||||
|
||||
\begin{codeblock}[bash]{cheese.cfg}
|
||||
[ ca ]
|
||||
default_ca = CA_default
|
||||
[ CA_default ]
|
||||
default_days = 365
|
||||
database = index.txt
|
||||
serial = serial
|
||||
copy_extensions = copy
|
||||
new_certs_dir = .
|
||||
default_md = sha256
|
||||
policy = policy_any
|
||||
[ policy_any ]
|
||||
commonName = supplied
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{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 visto que utiliza o tempo local para calcular a sua chave.
|
||||
|
||||
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{codeblock}[bash]{VM\_CONFIG.sh}
|
||||
yum install -y epel-release
|
||||
yum install -y openvpn iptables-services dhcp-client
|
||||
@@ -119,15 +144,154 @@ ntpdate pool.ntp.org
|
||||
systemctl start chronyd
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Configurar TOTP}
|
||||
|
||||
\section{VPN Gateway}
|
||||
|
||||
\subsection{Configuração da Máquina}
|
||||
|
||||
Como já foi dito anteriormente, cada máquina vem com um \textit{script}
|
||||
que instala toda a configuração necessária.
|
||||
|
||||
Para que a gateway funcione como router entre a rede externa e a rede interna,
|
||||
foi necessário ativar o \textit{IP forwarding} no kernel e configurar as regras
|
||||
de \textit{iptables} para permitir o tráfego da VPN e realizar o mascaramento
|
||||
de IP (NAT).
|
||||
|
||||
% NOTA(vasco): Não temos regras de DROP a packets
|
||||
% talvez deviamos mudar isso nao sei <- não diz nada no enunciado ¯\_(ツ)_/¯
|
||||
% também o trabalho não é sobre ip tables por isso it does make sense não fazer drop
|
||||
%e utilizar as regras apenas para encaminhar corretamente.
|
||||
% Colocar isso na conclusão tho
|
||||
|
||||
\begin{codeblock}[bash]{VM\_VPN\_GATEWAY.sh}
|
||||
#!/bin/bash
|
||||
# --- configuracao --- #
|
||||
source VM_CONFIG.sh
|
||||
yum install -y google-authenticator qrencode ntpsec
|
||||
|
||||
# --- forwarding --- #
|
||||
if_fora="enp0s8"
|
||||
ip_fora="193.136.212.1"
|
||||
if_dentro="enp0s9"
|
||||
ip_dentro="10.60.0.3"
|
||||
mega_tunel="tun0"
|
||||
ip_mega_tunel="10.8.0.0/24"
|
||||
|
||||
ifconfig $if_fora $ip_fora netmask 255.255.255.0
|
||||
ifconfig $if_dentro $ip_dentro netmask 255.255.255.0
|
||||
|
||||
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
|
||||
sysctl -p /etc/sysctl.conf
|
||||
|
||||
iptables -I INPUT 1 -p udp --dport 1194 -j ACCEPT
|
||||
iptables -I FORWARD 1 -i $mega_tunel -o $if_dentro -j ACCEPT
|
||||
iptables -I FORWARD 1 -i $if_dentro -o $mega_tunel -j ACCEPT
|
||||
iptables -I FORWARD 1 -i $mega_tunel -o $if_fora -j ACCEPT
|
||||
iptables -I FORWARD 1 -i $if_fora -m state --state ESTABLISHED,RELATED -j ACCEPT
|
||||
iptables -t nat -A POSTROUTING -s $ip_mega_tunel -o $if_fora -j MASQUERADE
|
||||
iptables-save > /etc/sysconfig/iptables
|
||||
|
||||
# --- vpn server --- #
|
||||
vpn_dir="/etc/openvpn/server"
|
||||
cp ca/ta.key $vpn_dir
|
||||
cp ca/ca.crt $vpn_dir
|
||||
cp ca/vpn.key $vpn_dir
|
||||
cp ca/vpn.crt $vpn_dir
|
||||
cp ca/dh2048.pem $vpn_dir
|
||||
cp conf/vpn.conf $vpn_dir
|
||||
cp conf/ocsp-verify.sh $vpn_dir
|
||||
cp conf/totp /etc/pam.d/
|
||||
systemctl enable --now openvpn-server@vpn.service
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Configuração do Serviço OpenVPN}
|
||||
|
||||
|
||||
O servidor OpenVPN utiliza um certificado X.509 assinado pelo nosso \textit{Certificate Authority} (CA).
|
||||
E faz uso de um script \texttt{oscp-verify.sh} para validar ou revogar os certificados através do servidor OCSP.
|
||||
|
||||
\begin{codeblock}{vpn.conf}
|
||||
local 193.136.212.1
|
||||
port 1194
|
||||
proto udp
|
||||
dev tun
|
||||
|
||||
verb 4
|
||||
|
||||
ca /etc/openvpn/server/ca.crt
|
||||
cert /etc/openvpn/server/vpn.crt
|
||||
key /etc/openvpn/server/vpn.key
|
||||
dh /etc/openvpn/server/dh2048.pem
|
||||
|
||||
topology subnet
|
||||
server 10.8.0.0 255.255.255.0
|
||||
push "route 10.60.0.0 255.255.255.0"
|
||||
|
||||
# ocsp and revocation
|
||||
script-security 2
|
||||
tls-verify /etc/openvpn/server/ocsp-verify.sh
|
||||
# auth
|
||||
cipher AES-256-GCM
|
||||
auth SHA256
|
||||
|
||||
plugin /usr/lib64/openvpn/plugins/openvpn-plugin-auth-pam.so totp
|
||||
tls-auth /etc/openvpn/server/ta.key 0
|
||||
\end{codeblock}
|
||||
|
||||
Foi criado o ficheiro \texttt{totp} com a configuração de autenticação a
|
||||
ser utilizada pelo plugin de PAM para o openvpn.
|
||||
|
||||
\begin{codeblock}{/etc/pam.d/totp}
|
||||
plugin /usr/lib64/openvpn/plugins/openvpn-plugin-auth-pam.so totp
|
||||
\begin{codeblock}{totp}
|
||||
auth required pam_google_authenticator.so forward_pass
|
||||
auth required pam_unix.so use_first_pass
|
||||
account required pam_unix.so
|
||||
\end{codeblock}
|
||||
|
||||
Este script simplesmente comunica com o servidor OpenSSl
|
||||
e verifica o resultado.
|
||||
|
||||
\begin{codeblock}{ocsp\_verify.sh}
|
||||
#!/bin/bash
|
||||
depth=$1
|
||||
env >> /etc/openvpn/server/ocsp_env.log
|
||||
if [ "$depth" -eq 0 ]; then
|
||||
echo "Checking OCSP for serial=$tls_serial_0" >> /etc/openvpn/server/ocsp.log
|
||||
if [ -n "$tls_serial_0" ]; then
|
||||
# e preciso converter o serial para hexadecimal porque o openssl espera em hex
|
||||
hex_serial=$(printf '%x' "$tls_serial_0")
|
||||
status=$(openssl ocsp -issuer /etc/openvpn/server/ca.crt -serial "0x$hex_serial" -url http://10.60.0.1:8888 -CAfile /etc/openvpn/server/ca.crt 2>>/etc/openvpn/server/ocsp.log)
|
||||
echo "OCSP Status: $status" >> /etc/openvpn/server/ocsp.log
|
||||
|
||||
if echo "$status" | grep -q "revoked"; then
|
||||
echo "Result: REVOKED" >> /etc/openvpn/server/ocsp.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo "$status" | grep -q "good"; then
|
||||
echo "Result: GOOD" >> /etc/openvpn/server/ocsp.log
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Result: UNKNOWN/ERROR" >> /etc/openvpn/server/ocsp.log
|
||||
exit 1
|
||||
else
|
||||
echo "tls_serial_0 is empty!" >> /etc/openvpn/server/ocsp.log
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "ERROR: depth > 0" >> /etc/openvpn/server/ocsp.log
|
||||
|
||||
exit 0
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Erros}
|
||||
|
||||
Um dos erros que encontramos pelo caminho foi que o OpenSSL OCSP espera que o
|
||||
\textit{serial} esteja num formato diferente do que o esperado. Foi necessário
|
||||
converter para hexadecimal primeiro.
|
||||
|
||||
|
||||
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
|
||||
@@ -138,6 +302,8 @@ localizados nas diretorias \textit{home} dos utilizadores.
|
||||
ProtectHome=false
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Configurar o utilizador com TOTP}
|
||||
|
||||
Primeiro, na gateway, entramos como o utilizador desejado e obtemos a chave
|
||||
do gerador de palavras passes temporárias. Ao inserir a chave no
|
||||
\texttt{google authenticator} podemos obter um código QR, a nossa primeira
|
||||
@@ -153,32 +319,12 @@ su john
|
||||
google-authenticator
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Encaminhamento e Firewall}
|
||||
\section{VPN Client (Road Warrior)}
|
||||
|
||||
Para que a gateway funcione como router entre a rede externa e a rede interna,
|
||||
foi necessário ativar o \textit{IP forwarding} no kernel e configurar as regras
|
||||
de \textit{iptables} para permitir o tráfego da VPN e realizar o mascaramento
|
||||
de IP (NAT).
|
||||
\subsection{Configuração da Máquina}
|
||||
ads
|
||||
|
||||
% NOTA(vasco): Não temos regras de DROP a packets
|
||||
% talvez deviamos mudar isso nao sei <- não diz nada no enunciado ¯\_(ツ)_/¯
|
||||
% também o trabalho não é sobre ip tables por isso it does make sense não fazer drop
|
||||
%e utilizar as regras apenas para encaminhar corretamente.
|
||||
% Colocar isso na conclusão tho
|
||||
|
||||
\begin{codeblock}[bash]{firewall.sh}
|
||||
# Ativar encaminhamento
|
||||
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
|
||||
sysctl -p /etc/sysctl.conf
|
||||
|
||||
# Regras de Firewall
|
||||
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{codeblock}
|
||||
|
||||
\section{Configuração do Cliente (Road Warrior)}
|
||||
\subsection{Configuração do Cliente OpenVPN}
|
||||
|
||||
O cliente encontra-se na rede externa (\texttt{193.136.212.10}) e liga-se à VPN
|
||||
gateway na porta 1194. Para garantir a segurança, utilizamos autenticação mútua (os certificados X.509)
|
||||
@@ -198,12 +344,29 @@ cipher AES-256-GCM
|
||||
auth SHA256
|
||||
\end{codeblock}
|
||||
|
||||
\subsection{Testes}
|
||||
|
||||
\section{Servidor Apache e OCSP}
|
||||
|
||||
\subsection{Configuração da Máquina}
|
||||
|
||||
asd
|
||||
|
||||
\subsection{Configuração do Serviço Apache}
|
||||
|
||||
O servidor interno (\texttt{10.60.0.1}) alberga o serviço Apache e o responder OCSP
|
||||
da autoridade de certificação.
|
||||
|
||||
\subsection{Revocation e OCSP}
|
||||
\subsubsection{Testes}
|
||||
|
||||
1. verificar que é necessário o dominio,
|
||||
|
||||
1. verificar que é necessário o https,
|
||||
|
||||
1. verificar que é necessário o certificado,
|
||||
|
||||
|
||||
\subsection{Configuração do Serviço OpenSSL}
|
||||
|
||||
\begin{enumerate}
|
||||
\item Estabelecer a ligação VPN e verificar a conectividade à rede interna.
|
||||
@@ -215,14 +378,23 @@ openssl ca -revoke user.crt -config cheese.cfg -keyfile ca.key -cert ca.crt
|
||||
\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}
|
||||
\subsubsection{Testes}
|
||||
|
||||
Podemos validar que o OCSP
|
||||
|
||||
1. verificar que recebe os certificados e responde
|
||||
|
||||
1. verificar que revocation funciona
|
||||
|
||||
|
||||
\section{Teste Integrado}
|
||||
|
||||
verificamos coisas
|
||||
|
||||
\section{Conclusão}
|
||||
|
||||
% Conclusão!!!!
|
||||
|
||||
Atingimos o objetivo deste trabalho, conseguimos configurar o VPN tunnel,
|
||||
o two-factor authentication e conseguimos criar e retirar acesso aos
|
||||
certificados que emitimos. Utilizar mais maquinas para simular um cenario
|
||||
@@ -230,6 +402,7 @@ maior seria redundante, teriamos que emitir mais certificados mas não iamos
|
||||
aprender muito mais. Se fossemos aplicar o que fizemos no trabalho anterior
|
||||
podiamos dar DROP aos pacotes que não nos interessa nesta cenario,
|
||||
e implementar suricata para identificar possiveis ataques nos serviços.
|
||||
|
||||
%È estranho que para uma cadeira de cybersegurança nós implementamos
|
||||
%pouca you know segurança.
|
||||
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
\babel@toc {portuguese}{}\relax
|
||||
\contentsline {section}{\numberline {1}Introdução}{2}{section.1}%
|
||||
\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 {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}%
|
||||
\contentsline {section}{\numberline {1}Introdução}{3}{section.1}%
|
||||
\contentsline {section}{\numberline {2}Preparação Inicial}{3}{section.2}%
|
||||
\contentsline {subsection}{\numberline {2.1}Criação de Certificados}{3}{subsection.2.1}%
|
||||
\contentsline {subsection}{\numberline {2.2}Configuração geral}{4}{subsection.2.2}%
|
||||
\contentsline {section}{\numberline {3}VPN Gateway}{5}{section.3}%
|
||||
\contentsline {subsection}{\numberline {3.1}Configuração da Máquina}{5}{subsection.3.1}%
|
||||
\contentsline {subsection}{\numberline {3.2}Configuração do Serviço OpenVPN}{6}{subsection.3.2}%
|
||||
\contentsline {subsection}{\numberline {3.3}Erros}{7}{subsection.3.3}%
|
||||
\contentsline {subsection}{\numberline {3.4}Configurar o utilizador com TOTP}{8}{subsection.3.4}%
|
||||
\contentsline {section}{\numberline {4}VPN Client (Road Warrior)}{8}{section.4}%
|
||||
\contentsline {subsection}{\numberline {4.1}Configuração da Máquina}{8}{subsection.4.1}%
|
||||
\contentsline {subsection}{\numberline {4.2}Configuração do Cliente OpenVPN}{8}{subsection.4.2}%
|
||||
\contentsline {subsection}{\numberline {4.3}Testes}{9}{subsection.4.3}%
|
||||
\contentsline {section}{\numberline {5}Servidor Apache e OCSP}{9}{section.5}%
|
||||
\contentsline {subsection}{\numberline {5.1}Configuração da Máquina}{9}{subsection.5.1}%
|
||||
\contentsline {subsection}{\numberline {5.2}Configuração do Serviço Apache}{9}{subsection.5.2}%
|
||||
\contentsline {subsubsection}{\numberline {5.2.1}Testes}{9}{subsubsection.5.2.1}%
|
||||
\contentsline {subsection}{\numberline {5.3}Configuração do Serviço OpenSSL}{9}{subsection.5.3}%
|
||||
\contentsline {subsubsection}{\numberline {5.3.1}Testes}{9}{subsubsection.5.3.1}%
|
||||
\contentsline {section}{\numberline {6}Teste Integrado}{10}{section.6}%
|
||||
\contentsline {section}{\numberline {7}Conclusão}{10}{section.7}%
|
||||
|
||||
Reference in New Issue
Block a user