SQL Injection
Project for lecture "Computer Systems Security"
You can find a SQL Injection Attack with sqlmap here: http://www.youtube.com/watch?v=wAwUv5dzwLk
It was performed for educational purposes ONLY.
The most massive crime of identity theft in history was perpetrated in 2007 by exploiting an SQL Injection vulnerability. This issue is one of the most common and most serious threats to web application security. In this presentation, you'll see some common myths busted and you'll get a better understanding of defending against SQL injection.
The presentation has a quick preamble on SQL injection definition, sqlmap and its key features.
I will then illustrate into details common and uncommon problems and respective solutions with examples that a penetration tester faces when he wants to take advantage of any kind of web application SQL injection flaw on real world web applications, for instance SQL injection in ORDER BY and LIMIT clauses, single entry UNION query SQL injection, specific web application technologies IDS bypasses and more.
These slides have been presented at the 2nd Digital Security Forum in Lisbon on June 27, 2009.
Updated version of http://www.slideshare.net/inquis/sql-injection-not-only-and-11.
The presentation has a quick preamble on SQL injection definition, sqlmap and its key features.
I then illustrate into details common and uncommon problems and respective solutions with examples that a penetration tester faces when he wants to take advantage of any kind of web application SQL injection flaw on real world web applications, for instance SQL injection in ORDER BY and LIMIT clauses, single entry UNION query SQL injection, specific web application technologies IDS bypasses and more.
These slides have been presented at the Front Range OWASP Conference in Denver on March 5, 2009.
How to Become a Thought Leader in Your NicheLeslie Samuel
Are bloggers thought leaders? Here are some tips on how you can become one. Provide great value, put awesome content out there on a regular basis, and help others.
SQL injection is a code injection technique, used to attack data-driven applications,
in which malicious SQL statements are inserted into an entry field for execution.
This is a method to attack web applications that have a data repository.The
attacker would send a specially crafted SQL statement that is designed to cause
some malicious action.SQL injection is an attack technique that exploits a security
vulnerability occurring in the database layer of an application and a service. This
is most often found within web pages with dynamic content.
The most massive crime of identity theft in history was perpetrated in 2007 by exploiting an SQL Injection vulnerability. This issue is one of the most common and most serious threats to web application security. In this presentation, you'll see some common myths busted and you'll get a better understanding of defending against SQL injection.
The presentation has a quick preamble on SQL injection definition, sqlmap and its key features.
I will then illustrate into details common and uncommon problems and respective solutions with examples that a penetration tester faces when he wants to take advantage of any kind of web application SQL injection flaw on real world web applications, for instance SQL injection in ORDER BY and LIMIT clauses, single entry UNION query SQL injection, specific web application technologies IDS bypasses and more.
These slides have been presented at the 2nd Digital Security Forum in Lisbon on June 27, 2009.
Updated version of http://www.slideshare.net/inquis/sql-injection-not-only-and-11.
The presentation has a quick preamble on SQL injection definition, sqlmap and its key features.
I then illustrate into details common and uncommon problems and respective solutions with examples that a penetration tester faces when he wants to take advantage of any kind of web application SQL injection flaw on real world web applications, for instance SQL injection in ORDER BY and LIMIT clauses, single entry UNION query SQL injection, specific web application technologies IDS bypasses and more.
These slides have been presented at the Front Range OWASP Conference in Denver on March 5, 2009.
How to Become a Thought Leader in Your NicheLeslie Samuel
Are bloggers thought leaders? Here are some tips on how you can become one. Provide great value, put awesome content out there on a regular basis, and help others.
SQL injection is a code injection technique, used to attack data-driven applications,
in which malicious SQL statements are inserted into an entry field for execution.
This is a method to attack web applications that have a data repository.The
attacker would send a specially crafted SQL statement that is designed to cause
some malicious action.SQL injection is an attack technique that exploits a security
vulnerability occurring in the database layer of an application and a service. This
is most often found within web pages with dynamic content.
Σχεδίαση και ανάπτυξη Μηχανισμού Αυτοματοποίησης παραγωγής Λογισμικού Ελέγχου...ISSEL
Σήμερα, η ανάπτυξη της τεχνολογίας και η αξιοποίηση της σε όλους τους τομείς της ζωής του ανθρώπου, δημιουργεί την ανάγκη για λογισμικό που είναι έυκολα προσαρμόσιμο, ευπαρουσίαστο, επιλύει πολλούς τύπους προβλημάτων, είναι οικονομικό και αξιόπιστο. Η Μοντελοστραφής Μηχανική (MDE), δηλαδή η ανάπτυξη λογισμικού που στηρίζεται σε μοντέλα, η αυτόματη παραγωγή κώδικα με βάση αυτά τα μοντέλα, η δυνατότητα γραφικής απεικόνισης του λογισμικού σε συνδυασμό με τις τεχνικές του Αυτοματοποιημένου Ελέγχου Συμπερασμών (Automated Reasoning) καλύπτουν ανά περίπτωση τις παραπάνω ανάγκες. Στην παρούσα διπλωματική εργασία, έγινε αξιοποίηση όλων των παραπάνω τεχνικών για την κατασκευή ενός ολοκληρωμένου εργαλείου, στην πλατφόρμα του Eclipse, με στόχο την κάλυψη των προαναφερθέντων αναγκών. Πιο συγκεκριμένα στα πλαίσια της Μοντελοστραφούς Μηχανικής (MDE) κατασκευάστηκε ένα μέτα-μοντέλο που αποτελεί τον πηρύνα του συστήματος και ενσωματώνει όρους από το πεδίο του Λογισμού. Στη συνέχεια, πάνω σε αυτό δημιουργήθηκε μια γραφική διεπαφή, στο περιβάλλον του Sirius, που δίνει την δυνατότητα στον ενδιαφερόμενο να καταγράψει, με γραφικό τρόπο, το μοντέλο που επιθυμεί. Η καταγραφή του μοντέλου γίνεται με την μορφή εξισώσεων σωστά διατυπωμένων στα πρότυπα της Κατηγορηματικής Λογικής Πρώτης Τάξης (FOL). Από αυτό το μοντέλο ύστερα, παράγεται αυτόματα κώδικας Java, ο οποίος αξιοποιώντας συναρτήσεις και αντικείμενα της βιβλιοθήκης TweetyProject, διαμορφώνεται κατάλληλα ώστε να αποτελεί έγκυρη είσοδο για τον built-in prover της ίδιας βιβλιοθήκης που μπορεί να πραγματοποιεί λογικούς ελέγχους στα πρότυπα του Αυτοματοποιημένου Ελέγχου Συμπερασμών. Μερικές ακόμα βοηθητικές συναρτήσεις σε Java, ολοκληρώνουν το εργαλείο της διπλωματικής. Όλα τα παραπάνω καθιστούν, το σύστημα που αναπτύχθηκε σε αυτή την διπλωματική, ικανό να χρησιμοποιηθεί από διάφορους υπάρχοντες μηχανισμούς αυτόματης παραγωγής συστημάτων, προκειμένου να ελέγξουν την εγκυρότητα των υπό σχεδίαση συστημάτων, δίχως κάποιος να απαιτείται να υλοποιήσει λογισμικό που κάνει λογικούς συμπερασμούς.
Design and Implementation of a Mechanism that automates the generation of Sof...ISSEL
Today, the development of technology and its utilization in all areas of human life, creates the need for software that is easily customizable, presentable, solves many types of problems, is economical and reliable. Model-Driven Engineering (MDE), ie software development based on models, the automatic production of code based on these models, the ability to graphically display the software, in combination with the techniques of Automated Reasoning meet the above needs. In the current diploma thesis, in order to meet the aforementioned needs, all the above techniques were utilized for the construction of a complete software tool, on the Eclipse platform. More specifically, in the framework of Model-Driven Engineering (MDE), a meta model was constructed which constitutes the core of the system and incorporates terms from the field of Logic. Expanding on this, a graphical interface was created, in the Sirius environment, which allows the interested party to construct, in a graphic way, the model he wants. The construction of the model is done in the form of equations, correctly formulated in the standards of First Order Logic (FOL). From this model, Java code is automatically generated, which utilizing functions and objects of the TweetyProject library, is properly configured to be a valid input for the built-in prover of the same library, that can perform logical tests in the standards of Automated Logic. Some more functions written in Java, complete the software tool of this diploma thesis. All of the above, constitute the software tool developed in this diploma, capable of being used by various mechanisms that automatically produce systems, in order to check the validity of the systems under design, without the need to implement additional software that draws logical conclusions.
Αυτοματοποίηση της μετατροπής των HR επιχειρησιακών διαδικασιών εταιριών σε W...ISSEL
Digital transformation is the process of using digital technologies to create new - or modify existing - business processes to respond to changing market needs. So, the need is obvious, especially now, because of the ongoing pandemic, where companies need to adapt quickly to the required changes in the way they operate. This diploma thesis aspires to respond to the above need, automating the digital transformation of HR business processes and producing specialized web applications for each of them. As part of this effort, in this diploma thesis, MDE (Model Driven Engineering) is utilized. More specifically, once an abstract process model is defined, a series of transformationstakes place, resulting in a functional full-stack application for it. In this way, the software development process is accelerated, and software is produced more reliably. In this diploma thesis, the EzProcess system is implemented, where the user through a friendly graphical user interface, sets parameters for the business processes he/she wants to transform. These processes refer specifically to the description of a job, the evaluation of the candidates who applied for the above position and finally their onboarding into the company with their successful evaluation. In addition, the above processes are interdependent in the EzProcess system, resulting in fewer human mistakes and at the same time even easier and faster software development. Based on these parameters the user has set, the executable code that performs the digital transformation of the processes is created and the corresponding web applications, which include both the client and the server part, are generated. The latter provide in the background additional capabilities of user identification, sorting and database search of candidates, by communicating with the generated server API.
Automated digital transformation of HR business processes to web applicationsISSEL
Digital transformation is the process of using digital technologies to create new - or modify existing - business processes to respond to changing market needs. So, the need is obvious, especially now, because of the ongoing pandemic, where companies need to adapt quickly to the required changes in the way they operate. This diploma thesis aspires to respond to the above need, automating the digital transformation of HR business processes and producing specialized web applications for each of them. As part of this effort, in this diploma thesis, MDE (Model Driven Engineering) is utilized. More specifically, once an abstract process model is defined, a series of transformationstakes place, resulting in a functional full-stack application for it. In this way, the software development process is accelerated, and software is produced more reliably. In this diploma thesis, the EzProcess system is implemented, where the user through a friendly graphical user interface, sets parameters for the business processes he/she wants to transform. These processes refer specifically to the description of a job, the evaluation of the candidates who applied for the above position and finally their onboarding into the company with their successful evaluation. In addition, the above processes are interdependent in the EzProcess system, resulting in fewer human mistakes and at the same time even easier and faster software development. Based on these parameters the user has set, the executable code that performs the digital transformation of the processes is created and the corresponding web applications, which include both the client and the server part, are generated. The latter provide in the background additional capabilities of user identification, sorting and database search of candidates, by communicating with the generated server API.
1. University of Central Greece
Computer Science and Biomedical Informatics
SQL INJECTION
System Security project
Sapountzi Eleni
Siganos Marios
2. ΣΙ ΕΙΝΑΙ;
Σεχνικό που χρηςιμοποιεύται ςυχνϊ για επιθϋςεισ ςε ΒΔ μϋςω
δικτυακού τόπου
Σεχνικό ϋγχυςησ (ειςαγωγόσ) κώδικα που εκμεταλλεύεται μύα
ευπϊθεια αςφαλεύασ ςτο λογιςμικό ενόσ ιςτοτόπου
Οι επιθϋςεισ SQL injections εμφανύςτηκαν ταυτόχρονα με τισ πρώτεσ
εφαρμογϋσ web
Μεγϊλοσ ο αριθμόσ των ςυςτημϊτων που εύναι ευϊλωτα ςτισ
επιθϋςεισ SQL Injections
Εύκολα μπορεύ να διερευνηθεύ ςε μια εφαρμογό και με κατϊλληλη
πρόβλεψη να αποφευχθεύ
4. Μ Π Ο Ρ ΟΤ Μ Ε Ν Α Π ΡΑ Γ Μ ΑΣ Ο Π Ο Ι Η ΟΤ Μ Ε
ΜΙΑ ΣΕΣΟΙΑ ΕΠΙΘΕΗ;
5. Ε ΤΑ Λ ΩΣ Ε Β Δ Κ Α Ι ΓΛ Ω Ε
Π Ρ Ο Γ ΡΑ Μ Μ ΑΣ Ι Μ ΟΤ
χεδόν όλεσ οι βϊςεισ δεδομϋνων SQL και γλώςςεσ
προγραμματιςμού εύναι δυνητικϊ ευϊλωτεσ, πχ:
MS SQL Server
Oracle
MySQL
Postgres
DB2
MS Access
Sybase
Informix, κλπ.
6. Ε ΤΑ Λ ΩΣ Ε Β Δ Κ Α Ι ΓΛ Ω Ε
Π Ρ Ο Γ ΡΑ Μ Μ ΑΣ Ι Μ ΟΤ
Πρόςβαςη μϋςω εφαρμογών που ϋχουν αναπτυχθεύ με χρόςη:
Perl και CGI scripts
ASP, JSP, PHP
XML, XSL και XSQL
Javascript
VB, MFC, και ϊλλα ODBC-based εργαλεύα και APIs
DB ςυγκεκριμϋνη web-based εφαρμογϋσ και το API
Reports and DB Applications
3 and 4GL-based languages (C, OCI, Pro * C, COBOL)
7. ΑΝΑΛΤΗ
Σι χρειαζόμαςτε;
• Απλϊ ϋναν web browser
Σι πρϋπει να ψϊξουμε;
• ελύδεσ που επιτρϋπουν την ειςαγωγό δεδομϋνων όπωσ:
• login page
• search page
• feedback κλπ.
• HTML ςελύδεσ που χρηςιμοποιούν POST εντολϋσ για
να ςτεύλουν τισ ςχετικϋσ παραμϋτρουσ ςε κϊποια ςελύδα ASP
8. ΑΝΑΛΤΗ
Τπϊρχει δυνατότητα απομακρυςμϋνησ εκτϋλεςησ με
SQL Injection;
• Η SQL δύνει την δυνατότητα ςτουσ developers να
κϊνουν ΣΑ ΠΑΝΣΑ ςε ϋνα ςύςτημα
• O SQL Server τρϋχει ςαν SYSTEM, δηλαδό τα
δικαιώματα που ϋχει εύναι επιπϋδου administrator ςτο
ςύςτημα
• Οπότε μπορούμε να αποκτόςουμε εύκολα πρόςβαςη,
αφού μπορούμε να τρϋξουμε ότι θϋλουμε
9. ΑΡΦΙΣΕΚΣΟΝΙΚΗ
Web Server Application Server Database Server
Web Input Injected SQL
Page Validation Execution!
Access Flaw
11. ΕΤΠΑΘΕΙΑ
Ελλιπόσ ό λανθαςμϋνη επαλόθευςη (validation)
των δεδομϋνων ειςόδου (input data) μιασ
εφαρμογόσ ςε:
• φόρμεσ (μϋθοδοι HTTP GET και POST)
• links (μϋθοδοσ HTTP GET)
12. Α Ν Α ΛΤ Η Μ Ι Α Ε Τ Π ΑΘ ΟΤ
W E B ΕΥΑ Ρ Μ Ο Γ Η
13. ΠΑΡΑΔΕΙΓΜΑ 1
Έςτω πύνακασ «employees» ςε μια ΒΔ MySQL
Ευπαθϋσ block κώδικα PHP
<?php
$qry = "SELECT employeeid, fullname, salary FROM employees " .
"WHERE employeeid =" . $_GET['employeeid'];
$result = mysql_query($qry);
?>
κοπόσ εύναι η εκτϋλεςη επερώτηςεων τησ μορφόσ:
SELECT employeeid, fullname, salary FROM employees
WHERE employeeid = 3
SELECT employeeid, fullname, salary FROM employees
WHERE employeeid = 352
14. ΠΑΡΑΔΕΙΓΜΑ 1
Σο Employeeid εύναι το πρωτεύον κλειδύ ςτον πύνακα employees δύνεται
μϋςω browser, με χρόςη τησ μεθόδου GET του HTTP με link τησ μορφόσ:
http://www.example.com/employees.php?employeeid=3
Η τιμό τησ παραμϋτρου GET «employeeid» που δύνεται ςτο URL, ΔΕΝ
επαληθεύεται επαρκώσ πριν την εκτϋλεςη τησ επερώτηςησ από τον κώδικα
http://www.example.com/employees.php?employeeid=3 OR 1=1
Ωσ αποτϋλεςμα θα εκτελεςτεύ ςτη βϊςη δεδομϋνων η εξόσ επερώτηςη:
•SELECT employeeid, fullname, salary FROM employees
WHERE employeeid=3 OR 1=1
Έτςι ενδϋχεται ο κακόβουλοσ χρόςτησ να δει πληροφορύεσ που δεν εύναι
ςκόπιμο
15. ΠΑΡΑΔΕΙΓΜΑ 2
Login form
Ευπαθϋσ block κώδικα PHP
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$qry = "SELECT userid FROM users" .
" WHERE username='$username'
AND password='$password'";
$result = mysql_query($qry);
if (mysql_numrows($result) > 0) {
//log in user...
}
?>
16. ΠΑΡΑΔΕΙΓΜΑ 2
Οι τιμϋσ username και password δύνονται με χρόςη μιασ
τυπικόσ web login φόρμασ με τη μϋθοδο HTTP POST
Αν δώςουμε ςτο πεδύο password: bar' OR 1=1 OR username='
ϋχουμε την εκτϋλεςη τησ επερώτηςησ:
•SELECT userid FROM users WHERE username='foo'
AND password='bar' OR 1=1 OR username='';
Έτςι ενδϋχεται η πρόςβαςη ςτην εφαρμογό (login) από ϊτομα
που δεν εύναι εξουςιοδοτημϋνα
18. ΠΑΡΑΔΕΙΓΜΑ 3
Δεδομϋνα ειςόδου από links τησ μορφόσ:
http://www.example.com/employees.php?employeeid=3
Αποτϋλεςμα η εκτϋλεςη τησ επερώτηςησ:
SELECT employeeid, fullname, salary FROM employees
WHERE employeeid = 3
19. ΠΑΡΑΔΕΙΓΜΑ 3
Ο κακόβουλοσ χρόςτησ δύνει τo εξόσ URL
http://www.example.com/employees.php?employeeid=3;
DELETE FROM users;
Έτςι θα εκτελεςτούν οι 2 εντολϋσ:
SELECT employeeid, fullname, salary
FROM employees WHERE employeeid = 3;
DELETE FROM users;
Διαγραφό όλων των δεδομϋνων του πύνακα users από τη βϊςη!
20. Α Ν Α Ζ Η Σ Η Η Ε Τ Π ΑΘ Ω Ν Ι Σ Ε Ε Λ Ι ΔΩ Ν
Φ Ρ Η Ι Μ Ο Π Ο Ι Ω Ν ΣΑ G O O G L E D O R K S
Αναζότηςη με τα παρακϊτω: Προςθϋτουμε ’ ςτο τϋλοσ
inurl:index.php?id= του url και αν εμφανύςει
error τότε η ιςτοςελύδα
inurl:index.php?catid= εύναι ευϊλωτη ςε SQLi
inurl:news.php?id= επιθϋςεισ
inurl:news.php?catid=
inurl:product.php?id=
21. Η ΔΤΝΑΜΗ ΣΟΤ «’»
Κλεύνει την παρϊμετρο ςυμβολοςειρϊσ
Ό,τι ακολουθεύ θεωρεύται μϋροσ τησ εντολόσ SQL
Παραπλανητικϋσ προτϊςεισ Διαδικτύου περιλαμβϊνουν:
• Αποφύγετε το! : Αντικαταςτόςτε το με ’’
Σα αλφαριθμητικϊ πεδύα εύναι πολύ ςυχνϊ, αλλϊ υπϊρχουν και
ϊλλα εύδη πεδύων:
• Αριθμητικϊ
• Ημερομηνύεσ
22. Α Ν Α Ζ Η Σ Η Η Ι ΣΟ Ε Λ Ι ΔΩ Ν
Ε Τ Π ΑΘ Ω Ν Ε S Q L I N J EC T I O N
Automated and heuristic web vulnerability scanner
Ανώφελο να ανιχνεύςουμε μόνο τισ αδυναμύεσ των
γνωςτών εφαρμογών
Πιο ευπαθεύσ εύναι οι εφαρμογϋσ που προςαρμόζονται
από τον χρόςτη
23. SQLMAP
Open Source penetration testing tool
Αυτοματοποιεύ τον εντοπιςμό και την αξιοπούηςη των
ελαττωμϊτων SQLi και την ανϊληψη των εξυπηρετητών ΒΔ
Τποςτόριξη για απαρύθμηςη των χρηςτών τησ ΒΔ, «password
hashes» των χρηςτών, προνόμια, τουσ ρόλουσ των χρηςτών,
ΒΔ, πύνακεσ και ςτόλεσ
24. SQLMAP
Αναγνώριςη τησ μορφόσ των «password hashes»
και υποςτηρύζονται για να ςπϊςουν με επύθεςη
λεξικού
Εντοπιςμόσ των πινϊκων που περιϋχουν
διαπιςτευτόρια όπου τα ονόματα αντύςτοιχων ςτηλών
περιϋχουν ςυμβολοςειρϋσ όπωσ το name και pass
26. ΠΩ ΑΠΟ ΥΕΤΓΟΤΜΕ
SQL INJECTIONS;
Αποφεύγουμε χαρακτόρεσ όπωσ:
• quotes, slash, backslash, semicolon, NULL, new line, κλπ
που εντοπύζονται ςε:
• πεδύα από φόρμεσ ειςαγωγόσ από τουσ χρόςτεσ
• παραμϋτρουσ ςτο URL
• τιμϋσ από cookies
27. ΠΩ ΑΠΟ ΥΕΤΓΟΤΜΕ
SQL INJECTIONS;
Όλα τα νούμερα μετατρϋπονται ςε ακεραύουσ
Διαγραφό των stored procedures που δεν ςασ αρϋςουν
και δεν χρειϊζεςτε όπωσ:
• master..Xp_cmdshell,
• xp_startmail,
• xp_sendmail,
• sp_makewebtask
28. ΤΜΠΕΡΑΜΑΣΑ
Η SQL Injection εύναι ςυναρπαςτικό και επικύνδυνη
ευπϊθεια
Όλεσ οι γλώςςεσ προγραμματιςμού και ΒΔ SQL εύναι
δυνητικϊ ευϊλωτεσ
Προςταςύα από SQLi απαιτεύ:
• ανθεκτικό ςχεδιαςμό
• ςωςτό επικύρωςη των δεδομϋνων ειςόδου