Lab M a n u a l
S Q L In je c t io n M o d u le 1 4
M odule 1 4 - S Q L In jectio n
S Q L
Injection
Lab Scenario
A SQL injection attack is done by including portions ot SQL statements 111 a web form entry field 111 an attempt to get the website to pass a newly formed rogue SQL command to the database (e.g., dump the database contents to the attacker). SQL injection is a code injection technique that exploits security vulnerability 111 a website's software. The vulnerability happens when user input is either incorrectly filtered for string literal escape characters embedded 111 SQL statements or user input is not strongly typed and unexpectedly executed. SQL commands are thus injected from the web form into die database of an application (like queries) to change the database content or dump the database information like credit card or passwords to die attacker. SQL injection is mosdy known as an attack vector for websites but can be used to attack any type of SQL database. As an expert e th ic a l h ack er, you must use diverse solutions, and prepare statements with bind variables and wliitelisting input validation and escaping. Input validation can be used to detect unauthorized input before it is passed to the SQL query.
Workbook re\
Lab Objectives
The objective of tins lab is to provide expert knowledge on SQL Injection attacks and other responsibilities that include: Understanding when and how web application connects to a database server 111 order to access data
& Too ls
Extracting basic
SQ L in je c tio n fla w s
and v u ln e ra b ilitie s
SQ L in je c tio n v u ln e ra b ilitie s
Scanning web servers and analyzing the reports Securing information in web applications and web servers
Lab Environment
To earn* out die lab, vou need: A computer running W in d o w s
W in d o w 7 S e rv e r 2 0 1 2
A web browser with an Internet connection Administrative privileges to configure settings and run tools
Ethical Hacking and Countermeasures Copyright by EC-Council A ll Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
Lab Duration
Time: 50 Minutes
task
O v e rv ie w
Lab Tasks
Recommended labs to assist you in SQL Injection: Performing b lin d
SQ L in je c tio n c re d e n tia ls
user account d a ta b a s e
listing attacks
S e c u rity A p p S c a n
D e n ia l-o f-s e rv ic e
tool
Lab Analysis
Analyze and document the results related to the lab exercise. Give your opinion on your targets secuntv posture and exposure.
P LE A SE
TA LK
TO
Y O U R IN S T R U C T O R IF Y O U R E L A T E D TO T H IS LAB.
H A V E
Q U E ST IO N S
Ethical Hacking and Countenneasures Copyright by EC-Comicil All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
S Q L
Injection A t t a c k s o n
M S
S Q L
D a t a b a s e SOL i n j e c t i o ni sa ba si cattack used e i t h e rt ogain unauthorised a c c e s st o a database or t or e t r i e v einformation d i r e c t l y from the database.
I C ON
/
KEY
Lab Scenario
Today, SQL injection is one ot die most common and perilous attacks that websites software can experience. Tliis attack is performed on SQL databases that have weak codes and tins vulnerability can be used by an attacker to execute database queries to collect sensitive information, modify the database entries, or attach a malicious code resulting 111 total compromise of the most sensitive data. As an Expert p e n e tra tio n te s te r and se c u rity ad m in is tra to r, you need to test web applications running 011 the M S SQL S e rv e r database for vulnerabilities and flaws.
** Web exercise
m
Workbook re\
Lab Objectives
Tlie objective of tins lab is to provide students with expert knowledge 011 SQL injection attacks and to analyze web applications for vulnerabilities.
111 tins lab, you will learn how
to:
c r e d e n tia ls
listing
Lab Environment
To earn out die lab, you need: A computer running W in d o w
S e rv e r 2 0 1 2
(Victim Maclinie)
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
A computer running W in d o w
MS SQL S e rv e r
(Attacker Machine)
Lab Duration
Time: 30 Minutes
Lab Tasks
is used when a web application is v u ln e ra b le to SQL injection but the results of the injection are n o t v is ib le to die attacker.
B lind SQ L in je c tio n Log on w ith o u t V a lid C red en tia ls
Blind SQL injection is identical to normal SQL injection, except diat, when an attacker attempts to exploit an application, rather dian seeing a useful error message, a g e n e ric c u s to m p a g e displays.
TASK1
1. Run diis lab 111 F ire fo x . It will not work 111 Internet Explorer.
Try to log on using code ' or as login
1=1
2. Open a web browser, type h ttp ://lo c a lh o s t/re a lh o m e and press E n ter. 3. The H o m e
page
111 die
address bar,
A dpiamically generated SQ L query is used to retrieve the number o f matching rows. F IG U R E 1.1: Old House Restaurant home page
Assume diat you are new to diis site and have never re g is te re d with diis website previously.
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 14 - S Q L In jectio n
6.
Enter any password 111 the P a s s w o rd held or leave die password held empty.
__ W hen the attacker |/ enters blah or = , then the S Q L query look like this:
1 1
A user enters a user name and password that matches a record in the Users table.
You are logged 111 to die website widi a take login. Your credentials are not valid, but you are logged in. Now you can browse all the web pages ot die website as a registered member. You will get a Logout link at die uppercorner of die screen.
Reai Home!
You have successfully logged on to die vulnerable site and created your own database.
TASK2
TASK
C r e a te a u s e r a c c o u n t
9. Open a web browser, type h ttp ://lo c a lh o s t/re a lh o m e and press E n ter. 10. The home page ot Real Home appears.
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
in die Login name field and enter any password 111 die P a s s w o rd held or leave die P a s s w o rd field empty. 111 tins query, ju g g y b o y is the username, and ju g g y 1 2 3 is the password.
U=!l To detect SQ L Injection, check if the web application connects to a database server in order to access some data.
12. After executing the query you will be redirected to die login page; tins is normal. 13. Try
ju g g y b o y
It y j Erro r messages are essential for extracting information from the database. Depending on die type o f errors found, you can vary the attack techniques. F IG U R E 1.5: Old House Login page
15. If no error message is displayed on die web page, it means diat you liave successfully created your logui using SQL injection query. 16. To v e rify whether your login has been created successfully, go to the login page, enter ju g g y b o y 111 the Log in N a m e field and ju g g y 1 2 3 111 the P a s s w o rd field, and click Login.
Understanding the underlying SQ L query allows the attacker to craft correct S Q L Injection__________________________________________________________________________________________________________________________ M anual Page 787 E th ic a l H ackin g and Counterm easures Copyright by EC-Council A ll Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
17. You will login successfully with the created login. Now you can access all the features of the website. Go to S ta r t menu apps and launch and login with the credentials.
SQ L S e rv e r M a n a g e m e n t S tu d io
Different databases require different SQ L syntax. Identify die database engine used by the server.
M TAS *
D a ta b a s e
3 \3
TASK3 Open a web browser, type h ttp ://lo c a lh o s t/re a lh o m e and press E n ter.
Hom e Page
C re a te Y o u r O w n
111 the
address bar,
19. The
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
Most injections land in the middle o f a S E L E C T statement. a SELEC T clause, we almost always end up in die W H E R E section.
,Z
111
20.
P a s s w o rd
Mosdv die error messages show you what D B engine you are working oil with O D BC errors. It displays database type as part o f the driver information.
22. No error message or any message displays on die web page. It means diat die site is vulnerable to SQL injection and a database with die name juggyboy has been created at die database server.
Try to replicate an error-free navigation, which could be as simple as ' and '1' = '1 O r ' and '1' = '2.
23. When you open M ic ro s o ft SQ L S e rv e r M a n a g e m e n t D a ta b a s e you can see the created database, ju g g y b o y .
S tu d io ,
under
Ethical Hacking and Countenneasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
Time delays are a type o f blind S Q L Injection that causes die SQ L engine to execute a long-running query or a time delay statement, depending on the logic injected.
Vi
24. Open a web browser, type h ttp ://lo c a lh o s t/re a lh o m e and press E n ter.
25.
111 the
address bar,
The
H om e Page
Once you determine the usernames, you can start gathering passwords: Username: ' union select passw ord,l,l,l from users where username = 'admin' F IG U R E 1.11: Old House Home page
26.
held, type
P a s s w o rd
Login.
111 the above query, you are performing a ping for the www.cert1t1edhacker.com website using an SQL injection query: -I is the send buffer size, and -t means to ping the specified host until stopped.
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
c a Use the bulk insert statement to read any file on the server, and use bcp to create arbitrary text files on the server.
28. The SQL injection query starts pinging die host, and die login page shows a W a itin g fo r lo c a lh o s t... message at the bottom left side of die window. 29. To see whether die query has successfully executed or not and ping is running, open your T a s k M a n a g e r window. 30. hi T a s k
M a n a g e r, P IN G .E X E
under the D e ta ils tab, you see a process called running 111 the background.
31. Tins process is die result of die SQL injection query diat you entered 111 die login held of the website.
Using the sp_OACreate, sp_OAMethod and sp_OAGetProperty system stored procedures to create O ld Automation (ActiveX) applications that can do everything an A SP script can do.
Task Manager
fie Option* V1 ev
1-
P'ccesses 1 Performance 1 Users Detail! Services 1 Nam* j p n t.[a > ?fcteaedSearch e $er/ices.exe L i 5ncit32.exc f / f Sna51tEdtor.ee 1 * ' SnccFnv cxc [ snmoe<e <H T3plAO.% 64.EJC 0 9 spcclsv.exe :!LLsqliwvT.ece [2 jqlwkef.exe 31svcagnt.exe 3 svcognt.cxe 1 1 svchostexe 5 svchostxc (L3s\chosLexe Q tv d v x tm ) viJ ka Lcac ''svchost.exe [? i r .c h o jto c 7 svchost exe @ Ftvve! dctiis PID Statue Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Running Liter name SYSTEM Administra ReportSeive SYSTEM SYSTEM Administra. Administra Administra. SYSTEM Administra. SYSTEM SYSTEM SYSTEM 5Y5TEM SYSTEM SYSTEM NETWORK.. LOCAL SE... SYSTEM LOCAL SE... NE1W0RK. LOCAL CL.. SYSTEM CPU KAerrcrv (p._ Detfnptian 972 K TCP/IP Ping Command 00 00 3,536 K PretectedSearch 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52,644K Reporting Ser/ices Service 3,628 K Services and Controller app 296 K Alndows Session Manager
350 1956 ReporingServicesSer. 1800 580 252 3340 402S 3844 2016 3460 1200 1612 2644 1336 1172 e95 736 808 872 908 996 700 1238
32,264 K Snagit 19,724 K Snagit Editor 1,168 K insert RPC Helper 2.764 K SNMP Service 1,112 K Print driver host for applications 2.568K Spooler SubSystem App 34,292 K SQL Server W1 ndo-A s NT - 64 Bit 1,164 K SQL Server VSSWriter 64 Bit 5,436 K Amdows Desfctcp Agent 2,696K Aindov/: Desktop Agent 1.972 K Host Process for Windows Services 3,164 K Host Process for Windows Services 7.372K 13.432K Host Process for Windows Services Mod Protect for Wmdowt Service? 1
6,188 K Hot Protest for Windoiv* Services 6,596 K Host Process for Windows Services *,324K 1lo*t Proecsi for Wir\dov* Scrviccj 2.784 K Host Process for Windows Services | End task |
32. To manually kill dns process, nght-click die PING.EXE process and select End P ro c e s s . This stops pinging of the host.
Lab Analysis
Analyze and document the results related to die lab exercise. Give your opinion on your targets security posture and exposure.
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 14 - S Q L In jectio n
Information Collected/Objectives Achieved Login id: 1003, 1004 Login Username: juggyboy Password: juggvl23
PLE A SE
TA LK
TO
YO U R
IN ST R U C T O R RELA T ED .
IF
YOU
H A V E
Q U E ST IO N S
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
L a b
T e s t i n g for S Q L
Injection U s i n g T ool
I B M
Security A p p S c a n
I CON KEY
/ Valuable information y s
m
I B M Seen1 7 f yAppScan i sa web appl ica tio ns e c u r i t yt e s t i n gt o olthatautomates v u l n e r a b i l i t ya s s e s s me nt s ,prevents S O L i n j e c t i o n attacks on w e b s i t e s , and scans web sit es for embedded malware.
Lab Scenario
By now, you are familiar with the types of SQL injection attacks an attacker can perform and the impact caused due to these attacks. Attackers can use the following types of SQL injection attacks: authentication bypass, information disclosure, compromised data integrity, compromised availability of data, and remote code execution, which allows them to spoof identity, damage existing data, execute system-level commands to cause denial of service of the application, etc. In the previous lab you learned to test SQL injection attacks on MS SQL database for website vulnerabilities. As an expert s e c u rity p ro fe s s io n a l and p e n e tra tio n t e s t e r of an organization, your job responsibility is to test the companys web applications and web seivices for vulnerabilities. You need to find various ways to extend security tests and analyze web applications, and employ multiple testing techniques. Moving further, in this lab you will learn to test for SQL injection attacks using IBM Security AppScan tool.
Too ls
Lab Objectives
The objective of tins lab is to help students learn how to test web applications for SQL injection threats and vulnerabilities.
111 tins lab,
Perform website scans tor vulnerabilities Analyze scanned results Fix vulnerabilities in web applications
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
Lab Environment
You can download IB M AppScan from http://www .ibm.com.
-01
M o du le 1 4 SQL
A computer running Window Server 2012 Double-click on S E C _ A P P S _ S T D _ V 8 .7 _ E V A L _ W IN .e x e to install You can also download the latest version of S e c u rity A p p S c a n from the link http: / / www01 1b 111.com/software/awdtools / appscan/standard A web browser with Internet access Microsoft .NET Framework Version 4.0 or later
C Q Supported operating systems (both 32-bit and 64 bit editions): Windows 2003: Standard and Enterprise, SP1 and SP2 Windows Server 2008: Standard and Enterprise, SP1 and SP2
Lab Duration
Time: 20 Minutes
Lab Tasks
1. Follow the wizard-driven installation steps and install die IBM Security AppScan tool. 2. To launch IB M S e c u rity A p p S can move your mouse cursor to die lowerleft corner ot your desktop and click S tart.
A personal firewall running on die same computer as Rational AppScan can block communication and result in inaccurate findings and reduced performance. For best results, do not run a personal firewall on the computer that runs Rational AppScan.
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
3. Click die IB M
S ta rt
S evw sunagef
You can configure Scan Expert to perform its analysis and apply some of its recommendations automatically, when you start the scan.
us
F= rm rxler
V
IBM becurny AppScon... # Tokwi Analyrm A
A p p S can
appears; click C re a te
New
/ AppS can can scan both web applications and web services.
5. Li die N e w
N o te: 111
S can
Malware test uses data gathered during the explore stage o f a regular scan, so you must have some explore results for it to function.
Ethical Hacking and Countenneasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
Predefined Templates
Regular Scan
Q uick and L ig h t Scan C o m p re h e n sive Scan P aram eter-B ased N a v ig a tio n W ebS phere C om m erce 3 W ebS phere P ortal I x l d e m o .te s tfire .n e T | Hacm e Bank
Help
Cancel
F IG U R E 2.4: IB M Rational AppScanNew window One o f die options in the scan configuration wizard is for Scan Expert to run a short scan to evaluate the efficiency o f the new configuration for your particular site.
6.
select W eb
and click
Th# Configurator \M 12ard will hdp you cortgur a n* *car b!sd or th* scan tampbtt: dorr*.tootfir*.net
Select the type of scan you wish to yxlcxrr | (3) Web Application Scon |
General Tasks
1 55~ ]
F IG U R E 2.5: IB M Rational AppScan Scan Configuration Wizard
7.
For exarple http //de 1D 0 resrfire net/ Scan only lirks in and below ttos direcw/ W! Case-Sensitive Path Treet all paths as case-sensitive (Unix. liru x efc) &) Additional Servers and Domains Indude the foloAirc adcitcra servers and ctorars in is *
d X W I 5c*1 cort'3urator
* ^ r d p
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
111 Login M a n a g e m e n t, select option A u to m a tic and enter the user name details as Username: js m ith and Password: D e m o 1 2 3 4 and click N ext.
Scan C onfigu ra tion W izard
U R L2nd Servers
Login Management
W,' login Method Use :hefollowing method to log 1* O Recorded (Recommended) O Prompt | (j*) Automatic | O None JserName: |?nrh Password Ccrfrm Pawvfcfd.
T lie total number o f tests to be sent, or U R Ls to be visited, may increase during a scan, as new links are discovered.
General Tasks
!!)session detecjon !& et-0UeC. but Icon cieOeniab l<r.e ret yet teen vet Tied
X * S c * 1 C o n ^ w a c o r
I < Back |Next
9.
111 T e s t P o licy
r
U R Land Servers Login M anagement Test Policy
/ Security Issues view shows the actual issues discovered, from overview level down to individual requests/responses. Tins is the default view.
ki) rest Polky
Default
rol<yMcs
Recent Policies g ) De*'ault
3'CWS#.. =
Predefined Pokdn } Default r f l Applicafccn-Oniy Q Infrastructure-Only ] Hik'd Party-Only E General Tasks V] Seed tees on login and ogoj: paces ( Clear session identifiers befoc losing !cgir osgcs v
P I
Results can display in three views: Security Issues, Remediation Tasks, and Application Data. T lie view is selected by clicking a button in the view selector. The data displayed in all three panes varies with tlie view' selected.
Gereral Tk>
XW !5 C o n f t a u r a t c r * j fd p
<Back
||
hn1Bh~
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
11. When die A uto S a v e window prompts you to save a u to m a tic a lly scan, click Y e s to save die file and proceed to scan.
Auto Save
J The scan needs to be saved now because AppScan is set to Automatically save during scan'. Would you like to save the scan now? Click Yes' to save the scan now. Click No' to disable Automatically save during scan' fof this scan only. Click Disable' to disable Automatically save during scan' for this and future scans.
during
Remediation Tasks view provides a To D o list o f specific remediation tasks to fix the issues found by die scan.
Yes
||
No
||
Disable
12. Security AppScan starts scanning die provided URL for vulnerabilities.
l __ The Result List displays the issues for whatever item is selected in the application tree. These can be for:
Root level: A ll site issues display
Page level: A ll issues for die page Parameter level: A ll issues for a particular request to a particular page
* j*
, >
9 t.
it___
N o te: It will take a lot of time to scan die complete site; stopped before scanning is complete.
111
13. After die scan is complete, die application lists all die security issues and vulnerabilities 111 die website. 14. Results can be displayed 111 diree views: Data, Issues, and Tasks. 15. To view die vulnerabilities and security issues in particular website click die Issues tab.
You can export die complete scan results as an X M L file or as a relational database. (The database option exports die results into a Firebird database structure. This is open source and follows O D BC an d JD B C standards.).
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
FIG U RE 2.12: IBM Rational AppScau Scanning Web Application Result window
TASK
16. To analyze die scan results, click any of die results, such as to list all die links diat are vulnerable to SQL injection.
> I * . ~.i
A n a ly ze R esu lt
P
t__ / The severity level assigned to any issue can be changed manually by rightclicking on die node.
s a p
J5L-
I
I
( It c^ O M S a M d t S i a i p b n j 2 1 0C . 1C :r . : ' , . Cl,
1 JcraierttmwliKrtcati
*tm*
F IG U R E 2.13: IB M Rational AppScan Scanning Web Application Result window Result Expert consists o f various modules that are used to process scan results. The processed results are added to the Issue Information tab of the Detail pane, making die information displayed there more comprehensive and detailed, including screen shots where relevant.
111 die
> j .
& ,* * * -* -----
Tothnid Ootoiptor
stivr. nca T h e 1 M > v y a W e 5 S/sea0kssccun Tvjs0 c e o e < n a 1 ; ^ te e O b yttv u ser!t> e lo c > o*o n v T h e f*e f tteise'tas apt( snBias vsentntart O e e 1 2 3 4 asth ep a s s w o rd ,th eSQ .< n e t/w ill
Ic o t tttM ________________________
The Security Report reports security issues found during the scan. Security information may be very extensive and can be filtered depending on your requirements. Six standard templates are included, but each can easily be tailored to include or exclude categories of information.
> J*g
*H T T F
5 r t J7U
18. To fix diese direats and vulnerabilities, click F ix a list of advice for fixing these vulnerabilities.
[H I*
R e co m m en d a tio n
to view
y p. j o
(m o < < w n U 9 'jiUiauitllM I74.'f*ll M p V te n 9 lM < 1 n r .0 (V 1M (U 1d rvV 4 n g f0 0 "N u alytoW iH k M MF ) aJ.tM -W
e 0
3 rp re n d e scoretrjctifrat m a te1
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 14 - S Q L In jectio n
T A S K
G e n e ra te R epo rt
19. After Rational AppScan assesses your site's vulnerability, you can generate customized reports configured for die various personnel 111 your organization. 20. You can open and view die reports from within Security AppScan, and you can s a v e a re p o rt as a file to be opened widi a tlurd-party application. 21. To generate a report, select T o o ls appears.
-> R epo rt...,
The C re a te
R epo rt
window
H ie Industry Standard Report reports the compliance (or noncompliance) o f your application with a selected industry committee or your own custom standards checklist.
c a The Template Based Report is a custom report containing user-defined data and user-defined document formatting in Microsoft W ord .doc format.
22. Select die type of report to generate, check options, and click
R epo rt...,
S ave
1* 1
w S e c u r i t y
i n d u s t r yS t a n d a r d
J2 >
R e g u l a t o r yC o m p l i a nc e
D e l t aA n a J y i s
( e r r p i a t eB a s e d
The Delta Analysis report compares two sets o f scan results and shows the difference in U RLs and/or security issues discovered.
The Regulatory Compliance Report: It reports on the compliance (or non-compliance) o f your application with a large choice o f regulations or legal standards or with your own custom template).
23. Save die report to die desired location. The saved report will be helpful for future guidance.
Lab Analysis
Analyze and document the results related to the lab exercise. Give your opinion on your targets security posture and exposure.
C E H Lab Manual Page 800 Ethical Hacking and Countenneasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 14 - S Q L In jectio n
PLE A SE
TA LK
TO
Y O U R IN S T R U C T O R IF Y O U R E L A T E D TO T H IS LAB.
H A V E
Q U E ST IO N S
Questions
1. Analyze how to speed up die scanning process and reduce the number of pages that IBM Rational AppScan tinds. 2. Evaluate whether it is possible to perform scans against live production environments with IBM Rational AppScan. Will that cause damage or hurt the site? 3. Analvze how variables can be implemented 111 a multi-step sequence with IBM Rational AppScan. Internet Connection Required
0 Yes
No
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
T e s t i n g for S Q L W e b C r u i s e r T o o l
I C ON KEY
Injection U s i n g
WebCmiser - Web Vulnerability Scanner i san e f f e c t i v eand'powerfuln eb penetration t e s t i n gto olthatwillaidyou in auditingjourw e b s i t e . It has a Vulnerability Scanner and a s e r i e sof s e c u r i t yt o o l s .
Lab Scenario
A deeper understanding of detecting SQL injection attacks using the IBM Security AppScan too was examined 111 the previous lab. 111 this lab we will have a look at a real case scenario where SQL injection attacks were implemented to steal confidential information from banks. Albert Gonzalez, an indicted hacker, stole 130 million credit and debit cards, the biggest identity theft case ever prosecuted in the United States. He used SQL injection attacks to install sniffer software on the companies' servers to intercept credit card data as it was being processed. He was charged for many different cases utilized were:
111
d Q G fe Workbook review
Stmctured Query Language (SQL) was a computer programming language designed to retrieve and manage data on computer databases. SQL Injection Attacks were methods of hacking into and gaining unauthorized access to computers connected to the Internet. SQL Injection Strings were a series of instructions to computers used by hackers 111 furtherance of SQL Injection Attacks. Malware was malicious computer software programmed to, among other diings, identity, store, and export information on computers that were hacked, including information such as credit and debit card numbers and corresponding personal identification information of cardholders (Card Data), as well as to evade detection by anti-virus programs running on those computers. As an expert s e c u rity p ro fe s s io n a l and p e n e tra tio n t e s t e r you should have a complete understanding of SQL injection attack scenarios and list high=risk
C E H Lab Manual Page 802 Ethical Hacking and Countermeasures Copyright by EC-Council A ll Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
components and note entry points to start testing and exploring. Hence, as another aspect 111 SQL Injection testing, in tins lab you will be guided to test for SQL injection using the WebCruiser Tool.
Lab Objectives
& Too ls d e m o n s tra te d in th is lab a re a v a ila b le D:\CEHToo ls\C E H v8 M o du le 14 SQL In je c tio n
The objective of tins kb is to help students learn how to test web applications for SQL injection direats and vulnerabilities.
111 tins kb,
Perform website scans for vulnerabilities Analyze scanned results Fix vulnerabilities 111 web applications Generate reports for scanned web applications
Lab Environment
You can download WebCruiser from http://sec4app.com/downl oad
M o du le 1 4 SQL ln jectio n \S Q L
Run tliis tool 111 Window Sender 2012 You can also download the latest version of http:/ / sec4app.com/download.htm
To produce timeconsuming SQ L sentence and get infom iation from die response time
W e b C ru is e r
A web browser with Internet access Microsoft .NET Framework Version 4.0 or later
Lab Duration
Time: 20 Minutes
Lab Tasks
1. To launch WebCnuser 111 your Windows Sener 2012 host machine, navigate to D :\CEH -Tools\C EHv8 M o du le 1 4 SQL ln jec tio n \S Q L In je c tio n
D e te c tio n ToolsVWebCruiser.
Ethical Hacking and Countemieasures Copyright by EC-Council A ll Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
|G E T IW e b B ro w s e r uJ R e e e n d
P O C (F ro o fO fC c n c e p SQ Lhecion ^
W ebC ruise r - W e b V ulnerability Scanner h ttp :'sec4app.com h t t p : w w w .ia nu sec com http ; 'tw itte r .c o m janusec
- c ....
iy=H Scanning is not necessary for S Q L Injection PO C , you can launch PO C by input the URL directly, or launch from the Scanner. WebCruiser support: * G ET/Post/Cookie Injection; * SQ L Server: Plai Text/FieldEcho(Unio n)/Blind Injection; * M ySQL/DB2/Access: FieldEcho(Union) /Blind Injection; * Oracle: FieldEcho(Union) /Blind/C rossSite Injection;
&
Q fo o ji 1
11
Enter die URL diat you want to scan; 111 tins lab we are scanning h ttp ://1 0 .0 .0 .2 /re a lh o m e / (dns IP address is where die realliome website is hosted).
WebCruiser - Web Vulnerability Scanner Enterprise Edition
File J 4 j| Tools View Configuration Scanner E l SQL Help (J>XSS r f Resend [ J Cookie Sic Report Setting | U i Scan Site | La] Scan URL
| ar
|G E T SQO
0 Browser
WebCruiser Web Vulnerability Scanner for iO S, an effective and convenient web penetration testing tool diat w ill aid you in auditing your website! WebCruiser can find the following web vulnerabilities currently: * G E T SQ L Injection(Int, String, Search) * PO ST S Q L Injection(L t, String, Search) * Cross Site Scripti g(XSS)
^ J r c n b k t )
Q C r o s sSteS c n p tir ;
W ebC n use r - W e b V ulnerability Scanner http: sec I a p p .com http : /w w w ianusec com h ttp .' tw itter .co m januscc
AOiw straionEntt S/sJenToo ^ -. r r f RcsotcTooJ CootoeTool CodeTool 1 - 0 | * SlingTx =2 Settings } < <
Ldi |
fiooJL
11
It can support scanning website as well as PO C (Proof o f concept) for web vulnerabilities: S Q L Injection, Cross Site Scripting, X Pad i Injection etc. So, WebCruiser is also an automatic SQ L injection tool, an X Pad i injection tool, and a Cross Site Scripting tool!
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
Confirm
* Software Disclaimer: * Authorization must be obtained from the web application owner; * This program will try to get each link and post any data when scanning; * Backup the database before scanning so as to avoid disaster; * Using this software at your own risk. * Login as a legal user will help you find vulnerabilities to the most extent. * But not login is better if you intend to scan the login/authentication page. * Continue?
OK
Cancel
System Requirement: .N E T FrameWork V2.0 or higher, you can Download .N E T FrameWork V2.0 From Microsoft.
WebCnuser starts with die URL scan as shown in die following screenshot. It shows Site Stmcture, and die following table is vulnerabilities.
WebCruiser - W eb Vulnerability Scanner Enterp-ise Edition
File Tools View Configuration Scanner 3 Help SQL ^X SS Resend Cootie fjfio Report Setting ^ Scan Site j GET Scan Current URL Scan Multi-Site Reset/Clear Scanner Import Export ( 3 Scan URL H (D Q
! 9 Browser 2 URL:
: WebBowser
H U S Q L injection is a code injection technique that exploits a security vulnerability occurring in the database layer o f an application.
I S a g
} R
< &
I . w
Vjlrcrabfit) Scanner P3C(Fro< Of Ccncep SOL lnie< ?ion 9 O Stc Scnptir 1 I AOnrwtrabcn&ts SyslenTooi t f ReacncTod ootaeTool^ CodeTool SUngTod Settwgj flSo Report
12
[*query tpsyj ... DD_belotcdPNG_0 0.801* j B Heal Hom e WebRM31rr# Jwd7dU87Vtyn1 M7 bWv;KDK>ArM3RCS(bewioXwO^FaXP'ivRTkj1PbAWFf7hOM9u WebResauce .d Logn.aspx } Index aspx H Js jquery triggerjs rcd*-ld ]-[ jqueiy.scrolTo-1.3 3 ^
URL / Refer URL Para nete< http J f \ 0.0.0 2/realhome/Lcgm aspx' 31rton2=L>.. Tex!30x29 O http7/10 0 0 2/Real Home/Loflin asox^Bjttor2=l Texltkw29
Stmg Stma
<[
_ _ _
II
<
<r
1QQ The vulnerability is present when user input is either incorrectly filtered esLpe characters embedded in S Q L statements or user input is not strongly typed and thereby unexpectedly executed.
6.
Right-click each of the vulnerabilities displayed 111 the scan result, and dien V U C a ll laUllcll SQL Illje C t lO ll POC (Proof of Concept).
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
W e b C ru ise r W e b V u ln e ra b ility Scanner E n te rp rise E d itio n File J J Tools J View Configuration Help | j *QL
0 Browser Q Scanner
~JXSS
Q Setting
LfU: O
http:// 13.0.012/realhome/ s c a r Current Site Scan Current URL Scan Multi-Site Reset/Clear Scanner Import
S
It is ail instance o f a more general class o f vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQ L Injection is one o f the most common application layer attack techniques used today.
-< 5 >
1 @
ViebBrowse' \A in ef^ity Scanner POCPracr Of Corcep ; 3 SQ_ hjectbn Q Cross 5e 5cnptn 1 - J l AdnirwbationErtr SjstemTool h r f Resend ool ; S CookeToo _ CodeTool &StmgTod & r Setngs A Report
E>port
j-jquery.ilpsy.js DD_belatedPNG_00.3a-mh js ~ 5 ReaiHome 3 ! Web Resource.axd I- Login aspx nefexaepx ; j-jauety.trigger.js | coda-lider I jqueor.scrollTo-1.3.3js
W e bR e s o u r c e .a x d ? d = U 5 Z W y m f1 c b b h c K D 5 p A| M r 3 R D 3 (b o w o X A K )2 R o X p Y v R T fc j1F b A V ^ 7 h O M 9 iu O k g H O v iH V \ V \ O c G
J S
Typ* Snrq
Vuh#rability
v e w im
_A
7. Tins will launch the SQL injection and till die relevant fields. Click G et
E n viro nm en t In fo rm ation .
W e b C ru ise r - W e b V u ln e ra b ility Scanner En te rp rise E d itio n File fools
5 i i
'/1ew
Configuration
Help
0 Browser Q Scanner
ffSQL
j>XSS
i i Resend 2 Cookie
Report
Setting
Q Scan URL
URL:
htt9://10.0.G.2'realhome/Login.aspx
EJ I DQ
| Reset
There are many methods to getting data in S Q L Injection, but not all these methods are supported in an actual penetration test.
a SGL hector Cress Sie Senptn ^ .idTwwfrabonEntr 2 E - SrstsrrTcol I ^esendTool Q CoskeTocI CoieTool StmcTcol H fii ^eoort L @ About !
8.
Lab Analysis
Analyze and document die results related to die lab exercise. Give your opinion on your targets security posture and exposure. Tool/Utility WebCruiser Information Collected/Objectives Achieved SQL Injection Detected
Ethical Hacking and Countenneasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 14 - S Q L In jectio n
Questions
1. Analyze how to speed up die scanning process and reduce die number of pages die IBM Rational AppScan finds. 2. Evaluate whether it is possible to perform scans against live production environments with IBM Rational AppScan. Will that cause damage or hurt the site? 3. Analyze how variables can be implemented 111 a multi-step sequence with IBM Rational AppScan. Internet Connection Required Yes Platform Supported 0 Classroom 0 1Labs No
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
T e s t i n g for S Q L Stalker T o o l
I C ON KEY
Injection U s i n g
N -
/ Valuable information
S Test your
knowledge
A ]-Stalker Web Application Security Scanner 2012 i sa sop hi st ic at ed Web Security Assessment s o l u t i o nforyour web a p p l i c a t i o n s . By incorporating t h e well-known NStealth H T T P Se cu ri ty Scanner and i t s39,000 Web Attack Signature database along with a patent-pending component-oriented Web Application Se cu ri ty Assessment t e c h n o l o g y , N-Stalker i sa must hare s e c u r i t yt o o lt od e v e l o p e r s , system/s e c u r i t yadm ini st ra to rs , IT a u d i t o r s , and s t a f f .
Lab Scenario
111 the previous lab you examined how to use the Webcruiser tool to scan a website as well as POC (Proof O f Concept) for web vulnerabilities: SQL injection.
Few attackers perform SQL injection attacks based on an error message received from the server. If an error is responded from the application, the attacker can determine the entire structure of the database, and read any value that can be read by the account the ASP application is using to connect to the SQL Server. However, 11 an error message is returned from the database server complaining that the SQL Querys syntax is incorrect, an attacker tries all possible True and False questions through SQL statements to steal data. As an expert s e c u rity p ro fe s s io n a l and p e n e tra tio n t e s t e r you should be familiar with the tips and tricks used 111 SQL injection detection. You must also be aware of all the tools that can be used to detect SQL injection flaws. 111 this lab you will learn to use the tool N-Stalker to detect SQL injection attacks 111 websites.
&
Too ls
Lab Objectives
The objective of tins lab is to help sUidents learn how to test web applications for SQL Injection threats and vulnerabilities.
111 diis lab, you will learn
to:
M odule 14 - S Q L In jectio n
Analyze scanned results Fix vulnerabilities 111 web applications Generate reports for scanned web applications
Lab Environment
You can download NStalker from http://www.nstalker.com/ products/editions/free/do wnload
ca
M o du le 14 SQ L lnjectio n \S Q L
Run tliis tool 111 Window Server 2012 You can also download the latest version of N -S ta lk e r from the link http://www.11stalker.com/products/editions/ free/download A web browser with Internet access
Founded upon die U.S. Patent Registered Technology o f Component-oriented Web Application Security Scanning, N-Stalker Enterprise Edition allows for assessment o f Web Applications
Lab Duration
Time: 20 Minutes
TASK
Lab Tasks
1. To launch N-Stalker move your mouse cursor to die lower-left corner of your desktop and click S tart.
N-Stalker W eb Application Security Scanner 2012 Enterprise Edition provides the most complete and effective suite o f W eb Security assessment checks to enhance the overall security o f your W eb Applications against a wide range of vulnerabilities and sophisticated hacker attacks.
W i n d o w s S < f v e r 2 0 1 2 R c t c * 5 e C a n d i d a t e O a U c c n l ; ^
F IG U R E 4.1: Windows Server 2012 Desktop view
2. Click die N -S ta lk e r F re e
2012
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
Start
CcrrpUer Ti Manager * Command Modb Firefox Google Chrome o Notepad+
A d m in is tra to r
N-Stalker also allows you to create your own assessment policies and requirements, enabling an effective way to manage your applications SD LC , including die ability to control information exposure, development flaws, infrastructure issues and real security vulnerabilities that can be explored by external agents.
*J
&
KOn*net.. Hyper V
'<
91
3. Click die U p d a te button to update die N-Stalker database in die main window of N-Stalker as shown 111 die following screenshot.
* -Stalker b l o e u r t y iM lig a t K cS o r n c o
W eb Security Intelligence Service (W SIS) is provided by W S I Labs and w ill ensure you always get the latest updates available for N-Stalker Web Application Security Scanner as well as for its attack signature database. N ew 0-day exploits and common vulnerabilities w ill be added on daily or weekly basis, giving you the ability to scan you W eb Server infrastructure periodically against the latest threats.
-4
& tf
; -Stalker W ill . 1 M H Iy im *5 * 1 v i e
* r
. JF
** * K t t Jllt e rP r E d i t i o n1
System Requirement: .N E T FrameWork V2.0 or higher, you can Download .N E T FrameWork V2.0 From Microsoft.
1 E m m ( d o n a t e m o 1a w G O O j K M U U M IW ^ :6< * M e t h e t
N iu ir n e e t o n o r N S U l k c f U p i a e s a r t l i m a e d m ' r e t L i n o a n d b | _ | < p r o 1d e d A S I S .* i t h c u t f t o y j a w m f c f t t* n e w n t e n v b s n 6 0 u t w C o m m c r c ! I d f t i c c M j c t js P t x n e * 5 V I 1 T O W H 3 W T 0 J0 ) 1 1
5.
N -S ta lk e r
will start updating the database; it will take some time to update.
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 14 - S Q L In jectio n
(MR OHM
To run N-Stalker W eb Application Security Scanner appropriately, there are minimum requirements to be met: 128MB R A M (available to N-Stalker) A t least 500MB Hard Disk free space (caching purposes) Win32 Platform (W in 2000, X P , 2003 or Vista and later) Internet connection to download N-Stalker database/software updates
-Stalker
toSecurity latclqotics same*
* 1 !*T.,
,.,.
j. b S***V,WNOr '! I - ! - *
6.
-Stalker
W e bS e c u t f e rU te lk ie n c oS f v
You may modify NStalker's cache options to avoid web pages from being permanendy stored in } our hard disk. This might be useful to preserve disk space on large assessments
7.
8.
enter die URL as h ttp ://1 0 .0 .0 .2 /re a lh o m e / (tins IP address is where die realliome website is hosted).
111 N -S ta lk e r S ca n W izard,
P o licy
as OW ASP
Policy,
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
You m ust enter an URL and choose policy Scan Settings may be configured
(E .g: http://W w w .exam pte.tl'. https, w w wtest U V rt-alD irectory.. etc) Choose Scan Policy | Choose URU Policy Optmze Settings Review Sum m ary Start Scan Sesson jl Load Scan Session
pop-up to continue.
---------- 3
You have provided the following page/directory pattern: [/realhome/] Do you want to restrict your scan to the above directory only?
Yes
(I
No
10.
111 Optimize
Optimizing Settings
|http://10.0.0.2/reatx)me/
(Y o um ay choose toru na senes of tests toalowfor optm aation or cbckN ext tooontnue) O ptim ize Results Authentication Optimization Progress False Postive Engm e M iscellaneous
N-Stalker Web Proxy is a combination o f web proxy and H T T P inspection tool. It includes a full W eb Proxy support (for external browsers) along with an event-driven interception mechanism, that allows you to inspect H T T P communications (even SSL) based on keyword matching.
Choose U R L&Pobcy Optimize Settings Review Sum m ary Start Scan Session
|Scan Settings j
Optimize
Back
Cancel
N ext
S e ttin g s
pop-up.
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Stricdy Prohibited.
M odule 1 4 - S Q L In jectio n
The term "G H D B " was allegedly coined by Johnny Long, which started to maintain a number of "google-based" queries that would eventually reveal security flaws in websites (without one having to scan the site directly for that vulnerability).
S e t t in g s
N o t O p tim iz e d
You haven't optimized your scan settings yet but we strongly recommend you to do that. Do you want to continue anyway?
!....... Yes........1
No
12. On die R e v ie w
S u m m a ry
tab, click S ta rt
N-Stalker S ca nW izard
S ession
to continue.
X
This is a string encoding tool which is useful to encode/decode data on multiple formats used by W eb Applications.
Review Summary
|http://10.0.0.2/reaJhom e/
Scanning Settings Choose URL & PoScy Optmze Settings Review Summary Start Scan Sesson
* < *
Scan Setting Host Inform ation Restricted Directory Policy N am e False-Positrve Settings New Server Dacovery Spider Engine H T M LParser Server Technologies Alowed Hosts
Value [10.0.0.2] Port: [80] SSL: [no] /reahome/ O W A SP Policy _ Enabled for M uK pie Extensions Enabled for 404 pages N ! Enabled (recommended most cases) M ax U R Ls [500] M ax Per Node [30] M ax D epth [0 ] JS [Execute/Parse] External JS [D eny] JS Events [Execute N /A N o addtonal hosts configured v
P:
Scan Settings
Back
Cancel
Start Session
F re e Edition
OK
to
N-Stalker Free Edition has a restriction to crawl only the first 500 pages within the same scan session. For more information about our Commercial Edition, please, contact us: E-mail: sales@nstalker.com Phone: +55-11-3675-7093 (GMT-0300)
14. Click S ta rt
S can
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
Google Hacking Database (G H D B ) Tool is a unique application that w ill allow you to search for "google-like" queries within a saved spider data. NStalker, G H D B Tool can be invoked by clicking on "G H D B Tool" button under "Miscellaneous Tools":
15. You can view scanning details as shown in the following screenshot.
H T T P Load Tester is a performance tester tool. It w ill run a Web Macro on a concurrent basis (up to you to decide how many instances) and w ill provide a report on number of connection failures and success.
ca
16. N-Stalker will scan die site widi four different mediods.
m d Macro Recorder is a tool to manage "W eb Macros" within N-Stalker W eb Application Security Scanner.
17.
111
the left pane, die W e b s ite tree displays die pages of the website.
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
"W eb M acro" is a user-provided navigation script that is usually recorded using a web browser and a web proxy tooL Macro Recorder allows you to insert manual U R Ls as well and you must choose between an authentication or navigation macro.
18.
A n authentication W eb Macro is used to authenticate N-Stalker's against W eb Forms or any other o f user interaction based authentication.
111
die following
N e xt S te p s
Total Scan Time 0 Hour(s) 4 Hinute(s) Total Vulnerabilities High: 0 Medium: 0 Low : Info: 2 10
As applications provide both a mean to login and logoff, Authentication Macros have a "logout detection" control that can be configured to prevent accidental logoff.
19
Ethical Hacking and Countermeasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 1 4 - S Q L In jectio n
Results Wizard
8 0 0 2 10 1 0 0
3
0 0
9
___________ 3 _________
Your request has been successfully processed. | Done
W hen you are generating reports, NStalker allows you to customize template and data that w ill be used to generate the final report. Both executive and technical reports allow for that customization.
20. You can view die complete scan results of die URL 111 the main dashboard ot die N -S talker.
<v Applicotio *Scojnty Sea\ncr2012 rec Ldition ---1
'
J.
&
These macros can use any U R Ls and w ill not be prevented from calling external services within NStalker's spider engine. F IG U R E 4.19: N-Stalker Dashboard
Lab Analysis
Analyze and document the results related to die lab exercise. Give your opinion on your targets security posUire and exposure. Tool/Utility N-Stalker Information Collected/Objectives Achieved Scan session successfully processed with 12 vulnerabilities detected
Ethical Hacking and Countenneasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.
M odule 14 - S Q L In jectio n
Questions
1. Analyze how to speed up die scanning process and reduce the number of pages the IBM Rational AppScan finds. 2. Evaluate whether it is possible to perform scans against live production environments with IBM Rational AppScan. Will that cause damage or hurt the site? 3. Analyze how variables can be implemented 111 a multi-step sequence with IBM Radonal AppScan. Internet Connection Required Yes Platform Supported 0 Classroom 0 1Labs No
Ethical Hacking and Countemieasures Copyright by EC-Council All Rights Reserved. Reproduction is Strictly Prohibited.