Sicurezza Informatica e Hacking - Università di Teramo 23/10/2015Pawel Zorzan Urban
Modulo Master in Sicurezza Informatica e Hacking
Standard OWASP TOP 10
SQL Injection
XSS
PDF Reverse Shell
Tools
Ringraziamenti a :
Simone Onofri (Moduli SQLi & XSS)
Avv. Pieluigi Perri (Introduzione)
La sicurezza delle Web Application - SMAU Business Bari 2013Massimo Chirivì
Durante lo sviluppo di siti web o web application l’implementazione della sicurezza dovrebbe essere una della fasi più importanti che uno sviluppatore dovrebbe eseguire, spesso però le soluzioni proposte non sono proprio “sicure”.Il talk mira a illustrare le principali tematiche relative all’argomento con un introduzione al Penetration Testing su web application.
Hackers vs Developers - Cross Site Scripting (XSS) Attacco e difesaSimone Onofri
E’ da poco stata pubblicata la nuova versione della OWASP Testing Guide che – nella versione 4 – aggiorna, amplia e completa la versione precedente. Comprende inoltre tre paragrafi specifici per i test dei Cross Site Scripting e altri che comprendono impatti simili. Non è un caso che nella TOP 10 2013 troviamo il Cross Site Scripting al terzo posto. Durante il talk ci focalizzeremo sul Cross Site Scripting e quali sono i vari metodi di attacco e difesa di questa vulneraiblità che – spesso sottovalutata – può portare anche al defacement di un sito web.
Sicurezza Informatica e Hacking - Università di Teramo 23/10/2015Pawel Zorzan Urban
Modulo Master in Sicurezza Informatica e Hacking
Standard OWASP TOP 10
SQL Injection
XSS
PDF Reverse Shell
Tools
Ringraziamenti a :
Simone Onofri (Moduli SQLi & XSS)
Avv. Pieluigi Perri (Introduzione)
La sicurezza delle Web Application - SMAU Business Bari 2013Massimo Chirivì
Durante lo sviluppo di siti web o web application l’implementazione della sicurezza dovrebbe essere una della fasi più importanti che uno sviluppatore dovrebbe eseguire, spesso però le soluzioni proposte non sono proprio “sicure”.Il talk mira a illustrare le principali tematiche relative all’argomento con un introduzione al Penetration Testing su web application.
Hackers vs Developers - Cross Site Scripting (XSS) Attacco e difesaSimone Onofri
E’ da poco stata pubblicata la nuova versione della OWASP Testing Guide che – nella versione 4 – aggiorna, amplia e completa la versione precedente. Comprende inoltre tre paragrafi specifici per i test dei Cross Site Scripting e altri che comprendono impatti simili. Non è un caso che nella TOP 10 2013 troviamo il Cross Site Scripting al terzo posto. Durante il talk ci focalizzeremo sul Cross Site Scripting e quali sono i vari metodi di attacco e difesa di questa vulneraiblità che – spesso sottovalutata – può portare anche al defacement di un sito web.
In data Mercoledì 13 Giugno 2012 in aula 4, dalle 9:00 alle 10:30,il dott. Alessandro Forte della T.&C. Systems Group s.r.l. ha tenuto un seminario sull'Object-Relational Mapping.
Il dott. Forte è attualmente SW Architect per la T.&C. Systems Group s.r.l. e speaker certificato Microsoft Italia.
Si è trattato di un'importante occasione per affacciarsi a nuovi argomenti di interesse del mondo produttivo e allo stesso tempo entrare in contatto con una società attiva sul territorio. Si ringrazia il prof. Antonio Maratea per l'occasione concessa e la disponibilità dimostrata.
Siamo un gruppo di Teoria e Tecnologia della Comunicazione dell'università Bicocca e presentiamo i seguenti motori di ricerca semantici:
Wolfram Alpha
DuckDuck Go
Free Base
Bing
DeepDyve
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Codemotion
Increased complexity makes it very hard and time-consuming to keep your software bug-free and secure. We introduce fuzz-testing as a method for automatically and continuously discovering vulnerabilities hidden in your code. The talk will explain how fuzzing works and how to integrate fuzz-testing into your Software Development Life Cycle to increase your code’s security.
Pompili - From hero to_zero: The FatalNoise neverending storyCodemotion
It was 1993 when we decided to venture in a beat'em up game for Amiga. The Catalypse's success story pushed me and my comrade to create something astonishing for this incredible game machine... but things went harder, assumptions were slightly different, and italian competitors appeared out of nowhere... the project died in 1996. Story ended? Probably not...
More Related Content
Similar to TechDay: Hackers vs. Developers - Le SQL Injection - Simone Onofri
In data Mercoledì 13 Giugno 2012 in aula 4, dalle 9:00 alle 10:30,il dott. Alessandro Forte della T.&C. Systems Group s.r.l. ha tenuto un seminario sull'Object-Relational Mapping.
Il dott. Forte è attualmente SW Architect per la T.&C. Systems Group s.r.l. e speaker certificato Microsoft Italia.
Si è trattato di un'importante occasione per affacciarsi a nuovi argomenti di interesse del mondo produttivo e allo stesso tempo entrare in contatto con una società attiva sul territorio. Si ringrazia il prof. Antonio Maratea per l'occasione concessa e la disponibilità dimostrata.
Siamo un gruppo di Teoria e Tecnologia della Comunicazione dell'università Bicocca e presentiamo i seguenti motori di ricerca semantici:
Wolfram Alpha
DuckDuck Go
Free Base
Bing
DeepDyve
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Codemotion
Increased complexity makes it very hard and time-consuming to keep your software bug-free and secure. We introduce fuzz-testing as a method for automatically and continuously discovering vulnerabilities hidden in your code. The talk will explain how fuzzing works and how to integrate fuzz-testing into your Software Development Life Cycle to increase your code’s security.
Pompili - From hero to_zero: The FatalNoise neverending storyCodemotion
It was 1993 when we decided to venture in a beat'em up game for Amiga. The Catalypse's success story pushed me and my comrade to create something astonishing for this incredible game machine... but things went harder, assumptions were slightly different, and italian competitors appeared out of nowhere... the project died in 1996. Story ended? Probably not...
Il Commodore 65 è un prototipo di personal computer che Commodore avrebbe dovuto mettere in commercio quale successore del Commodore 64. Purtroppo la sua realizzazione si fermò appunto allo stadio prototipale. Racconterò l'affascinante storia del suo sviluppo ed il perchè della soppressione del progetto ormai ad un passo dalla immissione in commercio.
Rivivere l'ebbrezza di progettare un vecchio computer o una consolle da bar è oggi possibile sfruttando le FPGA, ovvero logiche programmabili che consentono a chiunque di progettare il proprio hardware o di ricrearne uno del passato. In questa sessione si racconta come dal reverse engineering dell'hardware di vecchie glorie come il Commodore 64 e lo ZX Spectrum sia stato possibile farle rivivere attraverso tecnologie oggi alla portata di tutti.
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Codemotion
There's a lot of talk about blockchain, but how does the technology behind it actually work? For developers, getting some hands-on experience is the fastest way to get familiair with new technologies. So let's build a blockchain, then! In this session, we're going to build one in plain old Java, and have it working in 40 minutes. We'll cover key concepts of a blockchain: transactions, blocks, mining, proof-of-work, and reaching consensus in the blockchain network. After this session, you'll have a better understanding of core aspects of blockchain technology.
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Codemotion
When was the last time you were truly lost? Thanks to the maps and location technology in our phones, a whole generation has now grown up in a world where getting lost is truly a thing of the past. Location technology goes far beyond maps in the palm of our hand, however. In this talk, we will explore how a ridesharing app works. How do we discover our destination?How do we find the closest driver? How do we display this information on a map? How do we find the best route?To answer these questions,we will be learning about a variety of location APIs, including Maps, Positioning, Geocoding etc.
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Codemotion
Eward Driehuis, SecureLink's research chief, will guide you through the bumpy ride we call the cyber threat landscape. As the industry has over a decade of experience of dealing with increasingly sophisticated attacks, you might be surprised to hear more attacks slip through the cracks than ever. From analyzing 20.000 of them in 2018, backed by a quarter of a million security events and over ten trillion data points, Eward will outline why this happens, how attacks are changing, and why it doesn't matter how neatly or securely you code.
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 - Codemotion
IoT revolution is ended. Thanks to hardware improvement, building an intelligent ecosystem is easier than never before for both startups and large-scale enterprises. The real challenge is now to connect, process, store and analyze data: in the cloud, but also, at the edge. We’ll give a quick look on frameworks that aggregate dispersed devices data into a single global optimized system allowing to improve operational efficiency, to predict maintenance, to track asset in real-time, to secure cloud-connected devices and much more.
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Codemotion
What if Virtual Reality glasses could transform your environment into a three-dimensional work of art in realtime in the style of a painting from Van Gogh? One of the many interesting developments in the field of Deep Learning is the so called "Style Transfer". It describes a possibility to create a patchwork (or pastiche) from two images. While one of these images defines the the artistic style of the result picture, the other one is used for extracting the image content. A team from TNG Technology Consulting managed to build an AI showcase using OpenCV and Tensorflow to realize such goggles.
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Codemotion
The document summarizes some of the security issues with blockchain technology. It discusses how blockchain is not a "silver bullet" and does not inherently solve problems like privacy and security of smart devices. It outlines various application security issues with complex code, protocols, and difficulty of updates on blockchains. Concerns over data immutability and security of smart contracts are also covered. The document questions whether blockchain truly provides the level of decentralization and anonymity claimed, and outlines some impossibility results and limitations of existing approaches to achieving security and privacy in blockchain systems.
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Codemotion
The document provides an overview of the HTTP network protocol in its early stages of development. It summarizes the initial IMP (Interface Message Processor) software used to establish connections and transmit messages over the ARPANET. It outlines some early requirements for host-to-host software to enable simple and advanced use between computer systems. The document also describes the initial host software specifications, including establishing connections, transmitting data efficiently, and implementing error checking between connected systems. This was one of the first documents to define core aspects of the early HTTP network protocol to enable information exchange over the fledgling internet.
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Codemotion
Performance tests are not only an important instrument for understanding a system and its runtime environment. It is also essential in order to check stability and scalability – non-functional requirements that might be decisive for success. But won't my cloud hosting service scale for me as long as I can afford it? Yes, but… It only operates and scales resources. It won't automatically make your system fast, stable and scalable. This talk shows how such and comparable questions can be clarified with performance tests and how DevOps teams benefit from regular test practise.
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Codemotion
Sascha will demonstrate the opportunities and challenges of Conversational AI learned from the practice. Both Technology and User Experience will be covered introducing a process finding micro-moments, writing happy paths, gathering intents, designing the conversational flow, and finally publishing on almost all channels including Voice Services and Chatbots. Valuable for enterprises, developers, and designers. All live on stage in just minutes and with almost no code.
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Codemotion
A key challenge we face at Pacmed is quickly calibrating and deploying our tools for clinical decision support in different hospitals, where data formats may vary greatly. Using Intensive Care Units as a case study, I’ll delve into our scalable Python pipeline, which leverages Pandas’ split-apply-combine approach to perform complex feature engineering and automatic quality checks on large time-varying data, e.g. vital signs. I’ll show how we use the resulting flexible and interpretable dataframes to quickly (re)train our models to predict mortality, discharge, and medical complications.
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Codemotion
Coolblue is a proud Dutch company, with a large internal development department; one that truly takes CI/CD to heart. Empowerment through automation is at the heart of these development teams, and with more than 1000 deployments a day, we think it's working out quite well. In this session, Pat Hermens (a Development Managers) will step you through what enables us to move so quickly, which tools we use, and most importantly, the mindset that is required to enable development teams to deliver at such a rapid pace.
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...Codemotion
Quantum computers can use all of the possible pathways generated by quantum decisions to solve problems that will forever remain intractable to classical compute power. As the mega players vie for quantum supremacy and Rigetti announces its $1M "quantum advantage" prize, we live in exciting times. IBM-Q and Microsoft Q# are two ways you can learn to program quantum computers so that you're ready when the quantum revolution comes. I'll demonstrate some quantum solutions to problems that will forever be out of reach of classical, including organic chemistry and large number factorisation.
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Codemotion
Chinese food exploded across America in the early 20th century, rapidly adapting to local tastes while also spreading like wildfire. How was it able to spread so fast? The GY6 is a family of scooter engines that has achieved near total ubiquity in Europe. It is reliable and cheap to manufacture, and it's made in factories across China. How are these factories able to remain afloat? Chinese-American food and the GY6 are both riveting studies in product-market fit, and both are the product of a distributed open source-like development model. What lessons can we learn for open source software?
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Codemotion
The design space has exploded in size within the last few years and Sketch is one of the most important milestones to represent the phenomenon. But behind the scenes of this growing reality there is a remote team that revolutionizes the design space all without leaving the home office. This talk will present how Sketch has grown to become a modern, product designer's tool.
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Codemotion
Would you fly in a plane designed by a craftsman or would you prefer your aircraft to be designed by engineers? We are learning that science and empiricism works in software development, maybe now is the time to redefine what “Software Engineering” really means. Software isn't bridge-building, it is not car or aircraft development either, but then neither is Chemical Engineering. Engineering is different in different disciplines. Maybe it is time for us to begin thinking about retrieving the term "Software Engineering" maybe it is time to define what our "Engineering" discipline should be.
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Codemotion
What is the job of a CTO and how does it change as a startup grows in size and scale? As a CTO, where should you spend your focus? As an engineer aspiring to be a CTO, what skills should you pursue? In this inspiring and personal talk, I describe my journey from early Red Hat engineer to CTO at Bloomon. I will share my view on what it means to be a CTO, and ultimately answer the question: Should the CTO be coding?
7. Web
e
SQL
Injec4on
Tecnicamente
le
prime
SQL
InjecBon
hanno
cominciato
ad
essere
presenB
sul
web
da
quando
i
vari
interpreB
hanno
permesso
alle
pagine
web
di
mostrare
daB
collegandosi
ai
database
e
quindi
mostrarne
i
daB.
Pensiamo
a
PHP
(1995)
e
ad
ASP
(1996).
8. La
prima
famosa
SQL
Injec4on
Risale
al
1998
da
un
arBcolo
firmato
da
Rain
Forest
Puppy
su
Phrack
“NT
Web
Technology
VulnerabiliBes”
che
conBene
diverse
vulnerabilità
che
dipendono
dalle
tecnologie
Web.
SELECT * FROM table WHERE x=1
SELECT * FROM table WHERE y=5
9. La
risposta
alla
prima
famosa
SQL
Injec4on
“Secondo
loro
(il
vendor)
quello
di
cui
sBamo
per
parlare
non
è
un
problema”
—
Rain
Forest
Puppy
-‐
Phrack
Issue
#54
10. La
famosa
raccomandazione
“Non
date
per
scontato
che
l’input
dell’utente
sia
ok
quando
(lo
inserite)
in
query
SQL”
—
Rain
Forest
Puppy
-‐
Phrack
Issue
#54
11. 2003/2004
(a;acks)
2007
(vulnerabili4es)
2010
(risks)
2013
(risks)
Unvalidated
Input Cross
Site
Scrip4ng
(XSS) Injec4on Injec4on
Broken
Access
Control Injec4on
Flaws Cross-‐Site
Scrip4ng
(XSS)
Broken
Authen4ca4on
and
Session
Management
Broken
Authen4ca4on
and
Session
Management
Malicious
File
Execu4on
Broken
Authen4ca4on
and
Session
Management
Cross-‐Site
Scrip4ng
(XSS)
Cross
Site
Scrip4ng
(XSS)
Flaws
Insecure
Direct
Object
Reference
Insecure
Direct
Object
References
Insecure
Direct
Object
References
Buffer
Overflows
Cross
Site
Request
Forgery
(CSRF)*
Cross-‐Site
Request
Forgery
(CSRF)
Security
Misconfigura4on
Injec4on
Flaws
Informa4on
Leakage
and
Improper
Error
Handling
Security
Misconfigura4on Sensi4ve
Data
Exposure
Improper
Error
Handling
Broken
Authen4ca4on
and
Session
Management
Insecure
Cryptographic
Storage
Missing
Func4on
Level
Access
Control
Insecure
Storage
Insecure
Cryptographic
Storage
Failure
to
Restrict
URL
Access
Cross-‐Site
Request
Forgery
(CSRF)
Denial
of
Service Insecure
Communica4ons
Insufficient
Transport
Layer
Protec4on
Using
Known
Vulnerable
Components
Insecure
Configura4on
Management
Failure
to
Restrict
URL
Access
Unvalidated
Redirects
and
Forwards
Unvalidated
Redirects
and
Forwards
13. E’
stata
compromessa
(almeno
per
la
terza
volta
negli
ulBmi
anni)
l’azienda
di
Telecomunicazioni
Pakistana,
controllata
dallo
stato,
tramite
una
SQL
Injec4on
14. Cosa
dicono
i
trend
sulla
sicurezza?
“gli
aZaccanB
tendono
a
sfruZare
vulnerabilità
che
sono
presenB
a
causa
di
pra4che
di
sicurezza
basilari
inadeguate”
—
Rapporto
Melani
16. Cosa
sono
i
database
relazionali?
I
database
o
basi
di
daB
sono
degli
archivi
organizzaB
tramite
delle
relazioni.
I
daB
sono
contenuB
all’interno
di
alcune
tabelle
che
hanno
delle
intestazioni
(campi)
in
cui
i
daB
sono
organizzaB
in
delle
righe
(o
record).
17. Cos’è
SQL?
SQL
(Structured
Query
Language)
è
un
linguaggio
struZurato
per
eseguire
interrogazioni
a
un
database
relazionale.
Possiamo
avere
una
serie
di
query
esempio
per
richiedere
dei
daB
(SELECT),
inserirli
(INSERT),
aggiornarli
(UPDATE)
e
cancellarli
(DELETE).
Altri
4pi
di
query
servono
per
creare
o
cancellare
database,
utenB,
tabelle
o
sono
comandi
come
es.
per
spegnere
il
database.
19. Perchè
devo
sapere
queste
cose?
Per
eseguire
delle
SQL
InjecBon
è
necessaria
una
conoscenza
approfondita
di
SQL,
dei
database
e
più
nello
specifico
del
linguaggio
supportato
dal
database
uBlizzato
dall’applicazione
che
sBamo
aZaccando.
22. Authen4ca4on
Bypass
by
SQL
Injec4on
• E’
un
Bpico
aZacco
“vecchio
sBle”.
• Non
è
ovviamente
sempre
possibile,
dipende
da
come
è
scriZa
la
query
che
verifica
l’autenBcazione.
• L’impaZo
è
estremamente
criBco,
è
infa`
possibile
personificare
gli
utenB.
23. Come
funziona?
• AnzituZo
è
fondamentale
capire
la
query
che
è
“dietro”
la
richiesta.
• Tipicamente
la
pagina
di
login
è
qualche
cosa
come:
• SELECT
*
FROM
users
WHERE
use_name
=
‘simone’
AND
use_password
=
“pwd”;
• Che
cerca
una
corrispondenza
tra
il
nome
utente
e
la
password
inserita
tramite
GET/POST.
• Se
inseriamo
quindi
come
username:
• simone’—
• La
query
sarà:
• SELECT
*
FROM
users
WHERE
use_name
=
‘simone’—
‘AND
use_password
=
“pwd”
• Quindi
viene
verificato
solo
se
l’utente
esiste
o
meno.
24. Come
funziona?
• Se
però
non
conosciamo
lo
username,
al
neZo
di
quelli
Bpici
come
“admin”,
“administrator”,
o
se
si
uBlizza
un
CMS
basta
andare
a
cercare
la
documentazione,
come
fare?
• E’
possibile
usare
‘
OR
1=1—
o
comunque
generare
una
condizione
logica
che
sia
sempre
vera.
• Cosa
succede
quindi?
il
database
seleziona
tuZo
il
contenuto
della
tabella
users
trovando
sicuramente
almeno
una
corrispondenza.
25. Avvertenze
• A;enzione:
quando
fate
le
prove
con
OR
1=1,
se
ci
sono
molB
record
nella
tabella
è
possibile
che
il
server
impieghi
molto
tempo
a
rispondere,
oppure
potrebbe
andare
in
Bmeout,
è
consigliabile
uBlizzare
una
strategia
del
Bpo
AND
1=1
e
AND
1=0
quindi
condizioni
logiche
sempre
vere
o
sempre
false
che
però
fanno
tornare
meno
record.
• Nota:
nell’esempio
precedente
abbiamo
visto
come
-‐
probabilmente
-‐
la
password
sia
in
chiaro
(MALE),
quando
si
cerca
il
bypass
infa`
è
più
probabile
trovare
una
SQL
InjecBon
nello
username.
• Perché
tuZo
questo
probabile?
Ogni
applicazione
è
diversa.
27. Quando
si
verificano
le
SQL
Injec4on
Le
vulnerabilità
di
Bpo
InjecBon
si
verificano
quando
da4
non
valida4
vengono
inviaB
come
parte
di
una
richiesta
verso
un
interprete,
permeZendo
di
eseguire
richieste
o
comandi
normalmente
non
previsB
dall’applicazione.
L’impaZo
di
queste
vulnerabilità
è
spesso
alto
e
permeZe
di
compromeZere
il
sistema
o
i
daB.
28. Consigli
sulle
SQL
Injec4on
•Fai
il
reverse
engineering
della
query
•Capisci
il
linguaggio
dell’interprete
•Comprendi
la
logica
•Sii
creaBvo/a
29. Passo
dopo
passo
(come
ispirazione)
1.Verifica
il
Bpo
di
dato
che
l’applicazione
si
aspeZa
(es.
numero,
stringa,
data,
uuid
ecc..).
2.Cerca
di
capire
e
“rompere”
la
query
uBlizzando
caraZeri
Bpici
dei
delimitatori
(es.
‘,
’’,
“),
numeri
posiBvi
e
negaBvi,
aZenzione
ai
LIKE
e
alle
date.
3.IdenBfica
le
differenze
nelle
risposte
(es.
daB
caricaB,
errori,
pagine
bianche).
30. Esempio
•Applicazione
che
visualizza
le
noBzie:
•hZp://www.example.com/news.php?id=123
•Solitamente
le
query
in
questo
caso
sono:
•SELECT
*
FROM
news
WHERE
new_id
=
$param
AND
new_published
=
1
•Un
primo
test
può
essere:
•OR
1=1—,
ma
aZenzione
ai
DoS
•AND
1=1—
e
AND
1=0—
valutando
la
differenza
nelle
risposte
•Dato
che
è
un
numero
supponiamo
non
siano
necessarie
delle
parentesi,
ma
dobbiamo
considerare
che
se
la
query
è
complessa
possiamo
lasciare
aperte
es.
delle
parentesi.
32. Fingerprin4ng
e
Reverse
Engineering
Una
volta
idenBficata
la
presenza
potenziale
di
una
SQL
InjecBon
è
necessario
verificarla
e
quindi
sfruZarla.
E’
di
cruciale
importanza
capire
almeno:
•Il
4po
di
dato
che
sBamo
manipolando
•Il
4po
di
query
dove
siamo
dentro
•Dove
siamo
nella
query
•Il
Bpo
di
database
33. Capire
il
4po
di
dato
•Lo
possiamo
valutare
navigando
nell’applicazione
e
vedendo
quali
sono
i
daB
che
normalmente
l’applicazione
si
aspeZa,
Bpicamente:
•Numeri
•Stringhe
•Date
•IdenBficaBvi
34. Capire
il
4po
di
query
Anche
in
questo
caso
il
contesto
applicaBvo
è
importante.
SBamo:
•Visualizzando
dei
daB?
>
SELECT
•Modificando/Aggiornando
dei
daB?
>
UPDATE
•Cancellando
dei
daB?
>
DELETE
A"enzione
a
query
mul0ple
eseguite
dalla
stessa
pagina
35. Capire
dove
siamo
nella
query
Consideriamo
sempre
che
possiamo
essere
in
più
punB
della
query,
quindi
la
nostra
manipolazione
può
avere
effe`
differenB.
SELECT
*
FROM
tabella
WHERE
campo
=
valore
ORDER
BY
campo
36. Capire
il
4po
di
database
Passo
non
poco
difficile
è
capire
il
Bpo
di
database
(es.
Microsow,
Oracle,
Postgre,
DB2…)
e
la
sua
versione
specifica,
in
quanto
alcune
funzionalità
sono
previste
solo
per
determinate
versioni.
Un
piccolo
cheatsheet:
• Concatenare
le
stringhe:
• Oracle:
‘||’FOO
• MsSQL:
‘+’FOO
• MySQL:
‘
‘FOO
• Calcoli
sui
numeri:
• Oracle:
BITAND(1,1)-‐BITAND(1,1)
• MS-‐SQL:
@@PACK_RECEIVED-‐@@PACK_RECEIVED
• MySQL:
CONNECTION_ID()-‐CONNECTION_ID()
• Commen4
di
MySQL:
• Se
MySQL
trova
questo
commento
/*!32302
and
1=0*/
lo
eseguirà
solo
se
la
sua
versione
è
maggiore
o
uguale
alla
3.23.02
38. Come
sfru;are
le
vulnerabilità
Una
volta
oZenute
le
informazioni
sulla
query
e
sul
database
possiamo
procedere
con
lo
sfruZamento.
E’
possibile
uBlizzare
differenB
tecniche
secondo
il
contesto:
In
alcuni
casi
l’errore
SQL
è
visibile,
il
che
semplifica
molto
il
lavoro.
In
altri
casi
dobbiamo
capire
l’esito
delle
nostre
richieste
capendo
quando
l’applicazione:
•Esegue
il
nostro
codice,
inserendo
delle
condizioni
di
vero
o
falso
(seleziona
solo
alcuni
daB)
•La
query
non
è
correZa
(es.
WSOD)
39. Errori
4pici
•ORA-‐01756:
quoted
string
not
properly
terminated
•You
have
an
error
in
your
SQL
syntax;
check
the
manual
that
corresponds
to
your
MariaDB
server
version
for
the
right
syntax
to
use
near
‘'
•Error:
You
have
an
error
in
your
SQL
syntax;
check
the
manual
that
corresponds
to
your
MySQL
server
version
for
the
right
syntax
to
use
near
'''
at
line
•Unclosed
quotaBon
mark
awer
the
character
string
''.
40. La
tecnica
UNION
•La
UNION
è
una
delle
tecniche
più
comuni
per
l’estrazione
di
daB.
•L’operatore
UNION
è
uBlizzato
per
combinare
i
risultaB
di
più
query:
la
prima
è
quella
inclusa
dall’applicazione,
la
seconda
è
quella
da
cui
vogliamo
estrarre
i
daB.
•Quando
facciamo
una
UNION
dobbiamo
considerare
che:
•Le
due
query
devono
avere
lo
stesso
numero
di
colonne
(es.
ORA-‐01789:
query
block
has
incorrect
number
of
result
columns)
•Le
colonne
nella
stessa
posizione
devono
essere
dello
stesso
Bpo
o
uno
compaBbile.
(es.
ORA-‐01790:
expression
must
have
same
datatype
as
corresponding
expression).
NULL
è
spesso
nostro
amico
•Dobbiamo
conoscere
almeno
il
nome
di
una
tabella
(ecco
anche
perchè
facciamo
il
fingerprinBng).
41. Come
fare?
•Trova
il
nome
di
una
tabella
che
esiste
e
cui
hai
accesso
(es.
DUAL
in
Oracle
o
anche
nulla
in
MS-‐SQL)
•Capisci
il
numero
di
colonne:
•‘
UNION
SELECT
NULL—
•‘
UNION
SELECT
NULL,
NULL—
•‘
UNION
SELECT
NULL,
NULL,
NULL—
•Trova
almeno
un
Bpo
di
dato
come
stringa
•‘
UNION
SELECT
‘a’,
NULL,
NULL—
•Estrai
le
informazioni
•UNION
SELECT
banner,
NULL,
NULL
from
v$version
43. Strumen4
automa4ci
•Esistono
numerosi
strumenB
automaBci
tramite
i
quali
è
possibile
idenBficare
e
sfruZare
le
SQL
InjecBon.
•E’
bene
comunque
imparare
a
sfruZarle
a
mano!
•Non
sempre
gli
strumenB
automaBci
sono
di
aiuto:
•In
quel
caso
è
possibile
modificare
lo
strumento
se
è
open
source.
•Oppure
farsi
una
propria
serie
di
script
nel
proprio
linguaggio
preferito
per
sfruZare
la
vulnerabilità.
44. Sqlmap
•Sqlmap
è
uno
dei
più
potenB
strumenB
per
le
SQL
InjecBon,
consideriamo
il
nostro
target
testasp.
•Scaricare:
hZp://sqlmap.org/
•Lanciare:
•python
sqlmap.py
-‐u
“hBp://testasp.vulnweb.com/
showthread.asp?id=1"
•python
sqlmap.py
-‐u
"hBp://testasp.vulnweb.com/
showthread.asp?id=1"
-‐-‐users
•python
sqlmap.py
-‐u
"hBp://testasp.vulnweb.com/
showthread.asp?id=1"
-‐-‐passwords
•python
sqlmap.py
-‐u
"hBp://testasp.vulnweb.com/
showthread.asp?id=1"
-‐-‐dbs
49. Suggerimen4
E’
possibile
miBgare
questa
vulnerabilità
uBlizzando
API
parametriche
per
interfacciarsi
agli
interpreB
oppure
regole
di
validazione
a
whitelist
per
verificare
il
dato.
Inoltre,
prima
della
validazione,
bisogna
eseguire
una
normalizzazione
(canonicalizaBon)
e
codificare
correZamente
il
dato
(encoding),
quindi
applicare
le
regole
specifiche
dell’interprete
per
gesBre
i
cara;eri
speciali
(escaping),
come
ad
esempio:
•CaraZeri
per
la
delimitazione
delle
stringhe
(es.
‘
“
)
•CaraZeri
o
sequenze
intepretate
(es.
%
-‐-‐
#
/*)
•Operatori
o
funzioni
(es.
AND
OR
NOT
SLEEP
||
CHR
+)
52. Frequently
Asked
Ques4ons
• I
database
NoSQL
sono
vulnerabili?
Si
• Esistono
altri
Bpi
di
InjecBon?
Si
es.
LDAP,
ORM,
XML
InjecRon,
XXE,
SSI,
XPath,
XQuery,
SPARQL,
IMAP/SMTP,
Code,
Command
• Se
uso
il
framework
X
sono
invulnerabile?
No,
dipende
da
come
si
usa
• Come
posso
prevenire?
Query
parametriche*,
validazione
whitelist/blacklist*
• Un
Web
ApplicaBon
Firewall
mi
protegge?
Ni*
• Su
una
Web
App
HTML5
posso
avere
SQL
InjecBon?
Si,
se
si
usano
i
Web
Database
• Come
si
fa
la
SQL
InjecBon
sul
database
X?
(dove
X
è
il
tuo
database)
Leggi
il
manuale
e
trova
le
funzioni
del
database
(e
versione)
specifica