overview of code coverage & code...

20
SQL Injection © Meganadha Reddy K., 2015 http://www.netcomlearning.com/ Meganadha Reddy K. Technical Trainer | NetCom Learning www.NetComLearning.com

Upload: lekhue

Post on 15-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Meganadha Reddy K.Technical Trainer | NetCom Learning

www.NetComLearning.com

Page 2: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Agenda

• Overview of Hacking : 5 Mins

• Hackers Approach : 5 Mins

• SQL Injection Background : 10 Mins

• SQL Injection Techniques : 10 Mins

• Preventing SQL Injection : 10 Mins

• Demos : 10 Mins

• Q & A : 10 Mins

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

This is L100 Webinar on “SQL Injection”

Page 3: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Computer Hacking

In the computer security context, hacking is exploiting weaknesses in a computer system or computer network.

For stealing confidential data.

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 4: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Why people do computer hacking?

Well!!! This webinar is not on human psychology

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 5: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Why people do computer hacking?

On a lighter note [These could be some reasons]

MONEY [This is obvious reason]

To know how much boss is getting paid??

His company might have sacked him and he wants to take revenge by deleting some data.

For some people, hacking can be fun as well.

BUT HACKING IS CRIME

We should design our software in such a way

that its hard to hack

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 6: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Ethical Hacking

Well!!! Hacking itself is a CRIME.,

then what is

Ethical hacking?

There are even plenty of courses On “Ethical Hacking”

Even companies do recruit ethical hackers

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 7: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Types of hacking?

Type-1:

Guessing the access code or credentials

[Normally by trial and error mode]

a. Manual way

b. By automation

Type-2:

Through a programming script / some code.

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 8: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

Exam Results

Enter your roll number : 1012950

On click of “Search”, Query will be framed as:

Select * from Students where RollNo = 1012950

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 9: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

Exam Results

Enter your roll number : 1012950

Roll Name Name Score Result

1012950 Curious George 95 Pass

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 10: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

I want to know results of all students.

But I don’t know their roll numbers

How to Hack????

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 11: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

Let me try SQL Injection

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 12: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

Exam Results

Enter your roll number : 1012950 or 1=1

Select * from Students where RollNo = 1012950 or 1=1

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 13: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection

Exam Results

Enter your roll number : 1012950 or 1=1

Roll Name Name Score Result

1012950 Curious George 95 Pass

1012951 Nick 90 Pass

1012922 Doug 30 Fail

1012999 Meg 90 Pass

I got the

highest score

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 14: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection – What can be done?

SQL Injection

Read Crucial

Data

Delete Data

Alter Tables

Drop Tables

Any

Data Operation

All required is :

• To know the table name

• And well formed SQL Query

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 15: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection – Query Appending

Select * from Students where RollNo = 1012950 or 1=1

All the records in the table will be displayed in result grid

Select * from Students where RollNo = 1012950 ; Delete from Students

All the records from the table Students will be deleted

Select * from Students where RollNo = 1012950 ; Drop table Students

Table Students will be deleted for ever

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 16: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Preventing from SQL Injection

• Do not allow = in the input textbox. [Do JavaScript validation]

• Do not allow single quotes or double quotes in the input textbox

• Have a limit to the input length of textbox

• Scan query string for undesirable word combinations that indicate SQL statements [Example : Insert, Drop etc., ]

• Limit database permissions to the credentials used for website. I only read is required provide only read access. [Never provide DBA role]

• Use Stored Procedures instead of Inline Queries

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 17: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

SQL Injection – Some more demos

Demo

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 18: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

That’s all for now

Hope all attendees got a

clear idea on SQL

Injection

Thanks for Joining

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/

Page 19: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Some Relevant Courses

• CEH: Certified Ethical Hacker v8 & CNDA: Certified Network Defense

Architect

• Students will begin by understanding perimeter defenses work and then be lead into

scanning and attacking their own networks, no real network is harmed.

• Students then learn how intruders escalate intruders escalate privileges and what

steps can be taken to secure a system.

• Students will also learn about Intrusion Detection, Policy Creation, Social

Engineering, DDoS Attacks, Buffer Overflows and Virus Creation.

Page 20: Overview of Code Coverage & Code Analysisa.netcominfo.com/pdf/SQL_Injection_NetCom_Webinar.pdf · SQL Injection –Query Appending Select * from Students where RollNo = 1012950 or

Q & A

?

© Meganadha Reddy K., 2015 http://www.netcomlearning.com/