SlideShare a Scribd company logo
1 of 45
NEBULA LEVEL 14
Prof.ssa Barbara Masucci - Studenti: Emanuele Gargiulo | Giovanni Danese
U n i v e r s i t à d e g l i S t u d i d i S a l e r n o | P r o g r a m m a z i o n e s i c u r a | A . A . 2 0 1 9 / 2 0
NEBULA
LEVEL
14
«This program resides in /home/flag14/flag14. It encrypts input and
writes it to standard output. An encrypted token file is also in that
home directory, decrypt it.» [exploit.education]
• level14 level14
•
INTRODUZIONE ALLA SFIDA
2
NEBULA
LEVEL
14
3
NEBULA
LEVEL
14 OBIETTIVI DELLA SFIDA
flag14
4
NEBULA
LEVEL
14 COMINCIAMO LA SFIDA
5
level14
•
•
NEBULA
LEVEL
14 COSTRUZIONE DELL’ALBERO DI ATTACCO
6
NEBULA
LEVEL
14 RICHIESTA PASSWORD
flag14
7
NEBULA
LEVEL
14 ROTTURA PASSWORD
8
NEBULA
LEVEL
14 AGGIORNAMENTO ALBERO DI ATTACCO 1
I I
9
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
flag14
•
•
flag14
•
•
10
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
11
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
•
•
ls -la /home/flag/flag14
 flag14 flag14
level14
 SETUID
12
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
ls -la /home/flag/token
 level14
13
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
token
14
• cat token
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
flag14
•
15
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
./flag14
16
-e
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
flag14 token
17
• ./flag14
• token
flag14
NEBULA
LEVEL
14 AGGIORNAMENTO ALBERO DI ATTACCO 2
18
I I
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA
19
NEBULA
LEVEL
14 AGGIORNAMENTO ALBERO DI ATTACCO 3
20
I
I I
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA 2
21
flag14
•
ciaociao
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA 2
22
ciaoatutti
precedente nuovo
•
•
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA 2
1234567
23
posizione 0 1 2 3 4 5 6
NEBULA
LEVEL
14 STRATEGIA ALTERNATIVA 2
24
UNICODE CHAR
54 6
55 7
56 8
57 9
58 :
59 ;
60 <
61 =
62 >
posizione 0 1 2 3 4 5
UNICODE TABLE
5 6
6
NEBULA
LEVEL
14 APPROCCIO ALLA SFIDA
25
•
• token
flag14
token
NEBULA
LEVEL
14 AGGIORNAMENTO ALBERO DI ATTACCO 4
26
I I
I
P
P
P
P
P
P
NEBULA
LEVEL
14 APPROCCIO ALLA SFIDA
27
•
•
NEBULA
LEVEL
14 SCRIPT PER L’INVERSIONE DEL CIFRARIO
python --version
28
NEBULA
LEVEL
14
29
SCRIPT PER L’INVERSIONE DEL CIFRARIO
NEBULA
LEVEL
14
30
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
Sfruttando le conoscenze acquisite sul cifrario, si sottrae dal
codice UNICODE di ciascun carattere del token la sua posizione
all’interno della stringa.
Il risultante codice UNICODE viene poi riconvertito nel carattere
in chiaro.
NEBULA
LEVEL
14
31
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
NEBULA
LEVEL
14
32
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
len(token)
La funzione len prende in input una stringa e ne restituisce la
lunghezza.
Otteniamo così la lunghezza del token.
NEBULA
LEVEL
14
33
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
token.find(letter,counter,len(token))
La funzione find, eseguita su una stringa, cerca il primo
argomento tra le posizioni della stringa indicate dagli indici
nel secondo e terzo argomento, e ce ne restituisce la posizione.
Siccome la posizione restituita è quella della prima occorrenza
di letter, è necessario che ad ogni iterazione il contatore sia
incrementato per escludere dal campo di ricerca la parte di
stringa già considerata
NEBULA
LEVEL
14
34
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
token.find(‘a’,counter,len(token))
a b a c b …
token.find(‘a’,counter,len(token)) = 0
counter = 0
0 1 2 3 4 n
NEBULA
LEVEL
14
35
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
a b a c b …
token.find(‘a’,counter,len(token)) = 2
counter = 1
0 1 2 3 4 n
NEBULA
LEVEL
14
36
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
ord(letter)-token.find(letter,counter,len(token))
La funzione ord restituisce il numero intero che corrisponde al
codice UNICODE del carattere ad essa passato.
Da questo intero viene sottratta la posizione del carattere
all’interno della stringa
NEBULA
LEVEL
14
37
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
unichr(ord(letter)-token.find(letter,counter,len(token)))
La funzione unichr restituisce il carattere UNICODE relativo
all’intero ad essa passato.
NEBULA
LEVEL
14
38
SCRITTURA DI UNO SCRIPT PER L’INVERSIONE DEL CIFRARIO
returnpassword+=unichr(ord(letter)-token.find(letter,counter,len(token)))
Il carattere calcolato dall’insieme delle funzioni precedenti,
che altro non è che la ‘decodifica’ di un carattere del token,
viene concatenato alla stringa che al termine dello script
conterrà la password
NEBULA
LEVEL
14
39
INVERSIONE DEL TOKEN
8457c118-887c-4e40-a5a6-33a25353165
Il token invertito è la nostra potenziale password per
l’accesso all’account flag14
NEBULA
LEVEL
14
40
SFRUTTAMENTO DELLA PASSWORD
OTTENUTA
flag14 getflag
NEBULA
LEVEL
14
41
SFIDA VINTA!
NEBULA
LEVEL
14 ALBERO DI ATTACCO FINALE
42
I I
I
P
P
P
P
P
P
NEBULA
LEVEL
14 LE VULNERABILITÀ IN LEVEL 14
43
token
flag14
flag14
SETUID
NEBULA
LEVEL
14 MITIGAZIONI PER LEVEL 14
44
token
flag14
flag14
SETUID
SETUID
flag14
SETUID
SETUID
SETUID
45

More Related Content

What's hot

agile with scrum methodology
agile with scrum methodology agile with scrum methodology
agile with scrum methodology rahul reddy
 
BPMN and DMN for Processing Business Data with Camunda
BPMN and DMN for Processing Business Data with CamundaBPMN and DMN for Processing Business Data with Camunda
BPMN and DMN for Processing Business Data with CamundaAndré Borgonovo
 
Spring tutorial
Spring tutorialSpring tutorial
Spring tutorialPhuong Le
 
Agile Methodology and Tools
Agile Methodology and ToolsAgile Methodology and Tools
Agile Methodology and ToolsNaresh Gajuveni
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...Edureka!
 

What's hot (11)

Gradle
GradleGradle
Gradle
 
agile with scrum methodology
agile with scrum methodology agile with scrum methodology
agile with scrum methodology
 
Qt Licensing Explained
Qt Licensing ExplainedQt Licensing Explained
Qt Licensing Explained
 
BPMN and DMN for Processing Business Data with Camunda
BPMN and DMN for Processing Business Data with CamundaBPMN and DMN for Processing Business Data with Camunda
BPMN and DMN for Processing Business Data with Camunda
 
Spring tutorial
Spring tutorialSpring tutorial
Spring tutorial
 
Protocol Buffer.ppt
Protocol Buffer.pptProtocol Buffer.ppt
Protocol Buffer.ppt
 
Elaborer un logiciel
Elaborer un logicielElaborer un logiciel
Elaborer un logiciel
 
Anti Debugging
Anti DebuggingAnti Debugging
Anti Debugging
 
Agile Methodology and Tools
Agile Methodology and ToolsAgile Methodology and Tools
Agile Methodology and Tools
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
 
Agile SAP ACTIVATE
Agile SAP ACTIVATEAgile SAP ACTIVATE
Agile SAP ACTIVATE
 

Nebula, Level 14