SlideShare a Scribd company logo
1 of 52
©2009 Justin C. Klein Keane
PHP Code Auditing
Session 3 – Tools of the Trade & Crafting
Malicious Input
Justin C. Klein Keane
jukeane@sas.upenn.edu
©2009 Justin C. Klein Keane
Setting Up Environment

Install VMWare workstation, or player
− Fusion on the Mac

Download the target host

Unzip the host files then start the host in
VMWare
©2009 Justin C. Klein Keane
Get VMWare Image Running

If prompted, say you moved the image
©2009 Justin C. Klein Keane
CentOS Image Booting

Once image boots log in with root/password
©2009 Justin C. Klein Keane
Find the IP Address

Get the IP address of the virtual machine using
# /sbin/ifconfig eth0
©2009 Justin C. Klein Keane
Ensure Apache is Running
©2009 Justin C. Klein Keane
Upload the Exercise
©2009 Justin C. Klein Keane
Extract the Exercise
©2009 Justin C. Klein Keane
Install the Database
©2009 Justin C. Klein Keane
Check the Application
©2009 Justin C. Klein Keane
Troubleshooting

If you get a blank screen, check the web server
and MySQL server:
− # service httpd status
− # service mysqld status

If you need to start services use:
− # /etc/rc.d/init.d/httpd restart
− # /etc/rc.d/init.d/mysqld restart
©2009 Justin C. Klein Keane
Troubleshooting Cont.

Check the log files:
− # tail /var/log/httpd/error_log
©2009 Justin C. Klein Keane
Install Eclipse PDT

Download PDT all in one from
http://www.eclipse.org/pdt/

Alternatively install Eclipse from
http://www.eclipse.org/downloads/
− Be sure to download “Eclipse IDE for Java
Developers”
©2009 Justin C. Klein Keane
Install PDT if Necessary

Use instructions at
− http://wiki.eclipse.org/PDT/Installation

Some platforms, such as Fedora, may have
packages for PHP development, these may be
more stable than a manual install of PDT
©2009 Justin C. Klein Keane
Install RSE

Install the Remote System Explorer tools

Help -> Software Updates

Click the “Add Site” button

Enter the URL
− http://download.eclipse.org/dsdp/tm/download
s/

Select Remote System Explorer Core, Remote
System Explorer End-User Runtime, Remote
System Explorer Extender SDK, and RSE SSH
Service
©2009 Justin C. Klein Keane
Install the RSE Components

Click “Install”
©2009 Justin C. Klein Keane
Open Eclipse

Open Eclipse

Default “perspective” is dull and doesn't suit our
purposes

Click Window -> Show View -> Remote System

In the new window right click and select “new
connection”
©2009 Justin C. Klein Keane
Add New Connection

Select “SSH Only”, click Next
©2009 Justin C. Klein Keane
Connection Details

Fill in VMWare host information, click Finish
©2009 Justin C. Klein Keane
Connect to Remote Host

Click the down arrow for the host, then “Sftp
Files” then “Root” and enter credentials
©2009 Justin C. Klein Keane
View Source
©2009 Justin C. Klein Keane
Look for Potential SQL Injection
©2009 Justin C. Klein Keane
Testing the Injection

First we'll try the injection using manual
methods

Next we'll use some tools to help us out

Sometimes manual testing may be impossible
©2009 Justin C. Klein Keane
Manual Testing
©2009 Justin C. Klein Keane
Using Tamper Data

To start Firefox Tamper Data plugin select
− Tools -> Tamper Data

Click “Start Tamper” in the upper left

Fill in your test values again and submit

When prompted click “Tamper”
©2009 Justin C. Klein Keane
That's Interesting
©2009 Justin C. Klein Keane
Tamper

Fill in new values for Post Parameters

Note that you can also tamper with Cookies
and Referer Data

Click “OK” when you're happy with your values
©2009 Justin C. Klein Keane
That's More Like It
©2009 Justin C. Klein Keane
Checking Cookies

You can also view cookies using the Web
Developer Plugin
− select Cookies -> View Cookie Information
©2009 Justin C. Klein Keane
Using Web Developer
©2009 Justin C. Klein Keane
View Source

View -> Source in Firefox

Look for comments, JavaScript and the like

Sometimes source will reveal information you
may have missed
©2009 Justin C. Klein Keane
JavaScript in Source
©2009 Justin C. Klein Keane
Paros

Download Paros from
http://www.parosproxy.org

Paros is Java based, so if Eclipse can run on
your machine, so can Paros

Paros is a proxy, so it captures requests from
your web browser to a server and responses
from the server back to your browser

You can use it to alter your requests quite
easily
©2009 Justin C. Klein Keane
Start Up Paros
©2009 Justin C. Klein Keane
Configure Firefox

You need to configure Firefox to use Paros as a
proxy
− Choose Edit -> Preferences, then Advanced
-> Network -> Settings
©2009 Justin C. Klein Keane
Configure Settings
©2009 Justin C. Klein Keane
Create Request

Once Firefox is configured to utilize Paros
browse through the site normally

Note how Paros records all your interactions

Try submitting the login form

Note that Paros records GET and POST
requests
©2009 Justin C. Klein Keane
Paros in Action
©2009 Justin C. Klein Keane
Paros Records Details
©2009 Justin C. Klein Keane
Alter Requests

To alter a request click on it in the bottom
window

Next right click and select “Resend”

This opens a new window where you can alter
any of the send requests

Change any data and click the “Send” button
©2009 Justin C. Klein Keane
Paros Resend
©2009 Justin C. Klein Keane
Response is Raw
©2009 Justin C. Klein Keane
Bypassing the Login

In our manual code analysis we found a SQL
injection vulnerability in the login form

A JavaScript check prevents easy manual
testing

We could disable JavaScript or use Paros or
Tamper Data to alter the data we're submitting
for the login form

First let's examine the query
©2009 Justin C. Klein Keane
Our Target
$sql = "select user_id from user
where user_username = '" .
$_POST['username'] . "'
AND user_password = md5('" .
$_POST['password'] . "')";
©2009 Justin C. Klein Keane
Target SQL
select user_id from user
where
user_username = 'somename'
and
user_password = md5('somepass');
©2009 Justin C. Klein Keane
Possible Permutation
select user_id from user
where
user_username = 'somename'
or 1='1'
and
user_password = md5('somepass');

What is the proper input to create this
statement?
©2009 Justin C. Klein Keane
Testing Your SQL
©2009 Justin C. Klein Keane
Bypassing Login
with SQL Injection
©2009 Justin C. Klein Keane
We're In!
©2009 Justin C. Klein Keane
Chained Exploits

Note that the exploitation of the authentication
leads to access to new, potentially exploitable
functionality

Authentication leads to cookie granting

Admin functions are often “trusted”
©2009 Justin C. Klein Keane
Steps to Remember

Look for vulnerabilities
− In the source code
− In the functional front end

Test your exploits in the “friendliest”
environment possible

Use tools to recreate attacks in the live
environment.
©2009 Justin C. Klein Keane
For Next Time
-Install Paros Proxy
-Install Firefox and the Tamper Data and Web
Developer plug ins
-Download and install the sample SQL injection
application on your VM
-Identify at least 4 SQL injection vulnerabilities
-Develop exploits for each vulnerability
-Develop fixes for each vulnerability

More Related Content

What's hot

Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7
Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7
Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7Arun Sharma
 
Bluetooth Over-The-Air Firmware Update
Bluetooth Over-The-Air Firmware UpdateBluetooth Over-The-Air Firmware Update
Bluetooth Over-The-Air Firmware UpdateRamin Firoozye
 
Converting you website to https
Converting you website to httpsConverting you website to https
Converting you website to httpsPeter Salerno
 
Build, Deploy and Run Node Js Application on Azure using Docker
Build, Deploy and Run Node Js Application on Azure using DockerBuild, Deploy and Run Node Js Application on Azure using Docker
Build, Deploy and Run Node Js Application on Azure using DockerOsama Mustafa
 
SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth
SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core BluetoothSV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth
SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core BluetoothCharles Y. Choi
 
Create Applicationwith IIS 7
Create Applicationwith IIS 7Create Applicationwith IIS 7
Create Applicationwith IIS 7Sandeep Verma
 
How to Install Magento on Google Cloud Engine (GCE)
How to Install Magento on Google Cloud Engine (GCE)How to Install Magento on Google Cloud Engine (GCE)
How to Install Magento on Google Cloud Engine (GCE)Cloudways
 
Account creation lab guide
Account creation lab guideAccount creation lab guide
Account creation lab guideopenstackcisco
 
Open mic ibm connections and ibm verse on premise integration 1
Open mic  ibm connections and ibm verse on premise integration 1Open mic  ibm connections and ibm verse on premise integration 1
Open mic ibm connections and ibm verse on premise integration 1sreeJk
 
Jenkins hand in hand
Jenkins  hand in handJenkins  hand in hand
Jenkins hand in handnetdbncku
 
Sexy, Powerful, Exciting
Sexy, Powerful, ExcitingSexy, Powerful, Exciting
Sexy, Powerful, ExcitingRobert Senktas
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIWP Engine
 

What's hot (15)

Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7
Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7
Oracle Enterprise Manager Cloud Control 13c13.3 Installation On Oracle Linux-7
 
How to begin with Amazon EC2?
How to begin with Amazon EC2?How to begin with Amazon EC2?
How to begin with Amazon EC2?
 
Bluetooth Over-The-Air Firmware Update
Bluetooth Over-The-Air Firmware UpdateBluetooth Over-The-Air Firmware Update
Bluetooth Over-The-Air Firmware Update
 
Converting you website to https
Converting you website to httpsConverting you website to https
Converting you website to https
 
Build, Deploy and Run Node Js Application on Azure using Docker
Build, Deploy and Run Node Js Application on Azure using DockerBuild, Deploy and Run Node Js Application on Azure using Docker
Build, Deploy and Run Node Js Application on Azure using Docker
 
HTTPS and HTTP/2
HTTPS and HTTP/2HTTPS and HTTP/2
HTTPS and HTTP/2
 
SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth
SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core BluetoothSV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth
SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth
 
Create Applicationwith IIS 7
Create Applicationwith IIS 7Create Applicationwith IIS 7
Create Applicationwith IIS 7
 
How to Install Magento on Google Cloud Engine (GCE)
How to Install Magento on Google Cloud Engine (GCE)How to Install Magento on Google Cloud Engine (GCE)
How to Install Magento on Google Cloud Engine (GCE)
 
Account creation lab guide
Account creation lab guideAccount creation lab guide
Account creation lab guide
 
Open mic ibm connections and ibm verse on premise integration 1
Open mic  ibm connections and ibm verse on premise integration 1Open mic  ibm connections and ibm verse on premise integration 1
Open mic ibm connections and ibm verse on premise integration 1
 
Jenkins hand in hand
Jenkins  hand in handJenkins  hand in hand
Jenkins hand in hand
 
Sexy, Powerful, Exciting
Sexy, Powerful, ExcitingSexy, Powerful, Exciting
Sexy, Powerful, Exciting
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
ReactJS Workflows
ReactJS WorkflowsReactJS Workflows
ReactJS Workflows
 

Viewers also liked

Php code-auditing3
Php code-auditing3Php code-auditing3
Php code-auditing3ankitankesh
 
Evolution of the web
Evolution of the webEvolution of the web
Evolution of the weblogan54100
 
Php code-auditing
Php code-auditingPhp code-auditing
Php code-auditingankitankesh
 
De thi cuoi hoc ki 2 lop 2
De thi cuoi hoc ki  2  lop 2De thi cuoi hoc ki  2  lop 2
De thi cuoi hoc ki 2 lop 2truongcahp
 
Presentation 3 1 1 1
Presentation 3 1 1 1Presentation 3 1 1 1
Presentation 3 1 1 1Ashwin Kumar
 
Role of Television as a Mass Medium
Role of Television as a Mass MediumRole of Television as a Mass Medium
Role of Television as a Mass MediumCivi Varghese
 

Viewers also liked (11)

Php code-auditing3
Php code-auditing3Php code-auditing3
Php code-auditing3
 
Evolution of the web
Evolution of the webEvolution of the web
Evolution of the web
 
Shape paginado
Shape paginadoShape paginado
Shape paginado
 
Unsmp2013 mat999
Unsmp2013 mat999Unsmp2013 mat999
Unsmp2013 mat999
 
Php code-auditing
Php code-auditingPhp code-auditing
Php code-auditing
 
De thi cuoi hoc ki 2 lop 2
De thi cuoi hoc ki  2  lop 2De thi cuoi hoc ki  2  lop 2
De thi cuoi hoc ki 2 lop 2
 
Presentation 3 1 1 1
Presentation 3 1 1 1Presentation 3 1 1 1
Presentation 3 1 1 1
 
Anti vegf' s in Ophthalmology
Anti vegf' s in OphthalmologyAnti vegf' s in Ophthalmology
Anti vegf' s in Ophthalmology
 
Makalah koperasi
Makalah koperasiMakalah koperasi
Makalah koperasi
 
Keratometry & autorefraction
Keratometry & autorefractionKeratometry & autorefraction
Keratometry & autorefraction
 
Role of Television as a Mass Medium
Role of Television as a Mass MediumRole of Television as a Mass Medium
Role of Television as a Mass Medium
 

Similar to Php code-auditing3

The Right Way To Install Upgrade Dnn
The Right Way To Install Upgrade DnnThe Right Way To Install Upgrade Dnn
The Right Way To Install Upgrade DnnEngage Software
 
Installing Websphere Portal in the IBM Smartcloud
Installing Websphere Portal in the IBM SmartcloudInstalling Websphere Portal in the IBM Smartcloud
Installing Websphere Portal in the IBM SmartcloudDjalma Britto
 
Automating Windows Azure
Automating Windows AzureAutomating Windows Azure
Automating Windows AzureIdo Flatow
 
Securing and Managing the Oracle HTTP Server
Securing and Managing the Oracle HTTP ServerSecuring and Managing the Oracle HTTP Server
Securing and Managing the Oracle HTTP ServerSecureDBA
 
Skype Development Techniques and Tools
Skype Development Techniques and ToolsSkype Development Techniques and Tools
Skype Development Techniques and ToolsPhil Wolff
 
DockerCon EU 2017 - Docker on Windows workshop
DockerCon EU 2017 - Docker on Windows workshopDockerCon EU 2017 - Docker on Windows workshop
DockerCon EU 2017 - Docker on Windows workshopElton Stoneman
 
How to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's EncryptHow to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's EncryptMayeenul Islam
 
Connect to blumix vm with putty
Connect to blumix vm with puttyConnect to blumix vm with putty
Connect to blumix vm with puttyJoseph Chang
 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms AuthenticationLiquidHub
 
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...Amazon Web Services
 
15-ways-to-optimize-spring-boot-for-the-cloud
15-ways-to-optimize-spring-boot-for-the-cloud15-ways-to-optimize-spring-boot-for-the-cloud
15-ways-to-optimize-spring-boot-for-the-cloudBilly Korando
 
15 ways-to-optimize-spring-boot-for-the-cloud
15 ways-to-optimize-spring-boot-for-the-cloud15 ways-to-optimize-spring-boot-for-the-cloud
15 ways-to-optimize-spring-boot-for-the-cloudPolyglotMeetups
 
Amazon AWS Workspace Howto
Amazon AWS Workspace HowtoAmazon AWS Workspace Howto
Amazon AWS Workspace Howtomailbhargav
 
World-Class Test Automation: You Can Build It Too
World-Class Test Automation: You Can Build It TooWorld-Class Test Automation: You Can Build It Too
World-Class Test Automation: You Can Build It TooTechWell
 
ATG - Installing WebLogic Server
ATG - Installing WebLogic ServerATG - Installing WebLogic Server
ATG - Installing WebLogic ServerKeyur Shah
 
SafePeak - How to manually configure SafePeak Cluster
SafePeak - How to manually configure SafePeak ClusterSafePeak - How to manually configure SafePeak Cluster
SafePeak - How to manually configure SafePeak ClusterVladi Vexler
 
3. Basic Pentesting 1 Walkthrough.pdf
3. Basic Pentesting 1 Walkthrough.pdf3. Basic Pentesting 1 Walkthrough.pdf
3. Basic Pentesting 1 Walkthrough.pdfSetiya Nugroho
 
Cloud 101: Hands-on Heroku & AWS
Cloud 101: Hands-on Heroku & AWSCloud 101: Hands-on Heroku & AWS
Cloud 101: Hands-on Heroku & AWSAmine Sadry
 
SixFaceCloud Java framework manual
SixFaceCloud Java framework manualSixFaceCloud Java framework manual
SixFaceCloud Java framework manualSixFaceCloud
 

Similar to Php code-auditing3 (20)

The Right Way To Install Upgrade Dnn
The Right Way To Install Upgrade DnnThe Right Way To Install Upgrade Dnn
The Right Way To Install Upgrade Dnn
 
Oracle vm-installation
Oracle vm-installationOracle vm-installation
Oracle vm-installation
 
Installing Websphere Portal in the IBM Smartcloud
Installing Websphere Portal in the IBM SmartcloudInstalling Websphere Portal in the IBM Smartcloud
Installing Websphere Portal in the IBM Smartcloud
 
Automating Windows Azure
Automating Windows AzureAutomating Windows Azure
Automating Windows Azure
 
Securing and Managing the Oracle HTTP Server
Securing and Managing the Oracle HTTP ServerSecuring and Managing the Oracle HTTP Server
Securing and Managing the Oracle HTTP Server
 
Skype Development Techniques and Tools
Skype Development Techniques and ToolsSkype Development Techniques and Tools
Skype Development Techniques and Tools
 
DockerCon EU 2017 - Docker on Windows workshop
DockerCon EU 2017 - Docker on Windows workshopDockerCon EU 2017 - Docker on Windows workshop
DockerCon EU 2017 - Docker on Windows workshop
 
How to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's EncryptHow to Issue and Activate Free SSL using Let's Encrypt
How to Issue and Activate Free SSL using Let's Encrypt
 
Connect to blumix vm with putty
Connect to blumix vm with puttyConnect to blumix vm with putty
Connect to blumix vm with putty
 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
 
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
 
15-ways-to-optimize-spring-boot-for-the-cloud
15-ways-to-optimize-spring-boot-for-the-cloud15-ways-to-optimize-spring-boot-for-the-cloud
15-ways-to-optimize-spring-boot-for-the-cloud
 
15 ways-to-optimize-spring-boot-for-the-cloud
15 ways-to-optimize-spring-boot-for-the-cloud15 ways-to-optimize-spring-boot-for-the-cloud
15 ways-to-optimize-spring-boot-for-the-cloud
 
Amazon AWS Workspace Howto
Amazon AWS Workspace HowtoAmazon AWS Workspace Howto
Amazon AWS Workspace Howto
 
World-Class Test Automation: You Can Build It Too
World-Class Test Automation: You Can Build It TooWorld-Class Test Automation: You Can Build It Too
World-Class Test Automation: You Can Build It Too
 
ATG - Installing WebLogic Server
ATG - Installing WebLogic ServerATG - Installing WebLogic Server
ATG - Installing WebLogic Server
 
SafePeak - How to manually configure SafePeak Cluster
SafePeak - How to manually configure SafePeak ClusterSafePeak - How to manually configure SafePeak Cluster
SafePeak - How to manually configure SafePeak Cluster
 
3. Basic Pentesting 1 Walkthrough.pdf
3. Basic Pentesting 1 Walkthrough.pdf3. Basic Pentesting 1 Walkthrough.pdf
3. Basic Pentesting 1 Walkthrough.pdf
 
Cloud 101: Hands-on Heroku & AWS
Cloud 101: Hands-on Heroku & AWSCloud 101: Hands-on Heroku & AWS
Cloud 101: Hands-on Heroku & AWS
 
SixFaceCloud Java framework manual
SixFaceCloud Java framework manualSixFaceCloud Java framework manual
SixFaceCloud Java framework manual
 

Php code-auditing3

  • 1. ©2009 Justin C. Klein Keane PHP Code Auditing Session 3 – Tools of the Trade & Crafting Malicious Input Justin C. Klein Keane jukeane@sas.upenn.edu
  • 2. ©2009 Justin C. Klein Keane Setting Up Environment  Install VMWare workstation, or player − Fusion on the Mac  Download the target host  Unzip the host files then start the host in VMWare
  • 3. ©2009 Justin C. Klein Keane Get VMWare Image Running  If prompted, say you moved the image
  • 4. ©2009 Justin C. Klein Keane CentOS Image Booting  Once image boots log in with root/password
  • 5. ©2009 Justin C. Klein Keane Find the IP Address  Get the IP address of the virtual machine using # /sbin/ifconfig eth0
  • 6. ©2009 Justin C. Klein Keane Ensure Apache is Running
  • 7. ©2009 Justin C. Klein Keane Upload the Exercise
  • 8. ©2009 Justin C. Klein Keane Extract the Exercise
  • 9. ©2009 Justin C. Klein Keane Install the Database
  • 10. ©2009 Justin C. Klein Keane Check the Application
  • 11. ©2009 Justin C. Klein Keane Troubleshooting  If you get a blank screen, check the web server and MySQL server: − # service httpd status − # service mysqld status  If you need to start services use: − # /etc/rc.d/init.d/httpd restart − # /etc/rc.d/init.d/mysqld restart
  • 12. ©2009 Justin C. Klein Keane Troubleshooting Cont.  Check the log files: − # tail /var/log/httpd/error_log
  • 13. ©2009 Justin C. Klein Keane Install Eclipse PDT  Download PDT all in one from http://www.eclipse.org/pdt/  Alternatively install Eclipse from http://www.eclipse.org/downloads/ − Be sure to download “Eclipse IDE for Java Developers”
  • 14. ©2009 Justin C. Klein Keane Install PDT if Necessary  Use instructions at − http://wiki.eclipse.org/PDT/Installation  Some platforms, such as Fedora, may have packages for PHP development, these may be more stable than a manual install of PDT
  • 15. ©2009 Justin C. Klein Keane Install RSE  Install the Remote System Explorer tools  Help -> Software Updates  Click the “Add Site” button  Enter the URL − http://download.eclipse.org/dsdp/tm/download s/  Select Remote System Explorer Core, Remote System Explorer End-User Runtime, Remote System Explorer Extender SDK, and RSE SSH Service
  • 16. ©2009 Justin C. Klein Keane Install the RSE Components  Click “Install”
  • 17. ©2009 Justin C. Klein Keane Open Eclipse  Open Eclipse  Default “perspective” is dull and doesn't suit our purposes  Click Window -> Show View -> Remote System  In the new window right click and select “new connection”
  • 18. ©2009 Justin C. Klein Keane Add New Connection  Select “SSH Only”, click Next
  • 19. ©2009 Justin C. Klein Keane Connection Details  Fill in VMWare host information, click Finish
  • 20. ©2009 Justin C. Klein Keane Connect to Remote Host  Click the down arrow for the host, then “Sftp Files” then “Root” and enter credentials
  • 21. ©2009 Justin C. Klein Keane View Source
  • 22. ©2009 Justin C. Klein Keane Look for Potential SQL Injection
  • 23. ©2009 Justin C. Klein Keane Testing the Injection  First we'll try the injection using manual methods  Next we'll use some tools to help us out  Sometimes manual testing may be impossible
  • 24. ©2009 Justin C. Klein Keane Manual Testing
  • 25. ©2009 Justin C. Klein Keane Using Tamper Data  To start Firefox Tamper Data plugin select − Tools -> Tamper Data  Click “Start Tamper” in the upper left  Fill in your test values again and submit  When prompted click “Tamper”
  • 26. ©2009 Justin C. Klein Keane That's Interesting
  • 27. ©2009 Justin C. Klein Keane Tamper  Fill in new values for Post Parameters  Note that you can also tamper with Cookies and Referer Data  Click “OK” when you're happy with your values
  • 28. ©2009 Justin C. Klein Keane That's More Like It
  • 29. ©2009 Justin C. Klein Keane Checking Cookies  You can also view cookies using the Web Developer Plugin − select Cookies -> View Cookie Information
  • 30. ©2009 Justin C. Klein Keane Using Web Developer
  • 31. ©2009 Justin C. Klein Keane View Source  View -> Source in Firefox  Look for comments, JavaScript and the like  Sometimes source will reveal information you may have missed
  • 32. ©2009 Justin C. Klein Keane JavaScript in Source
  • 33. ©2009 Justin C. Klein Keane Paros  Download Paros from http://www.parosproxy.org  Paros is Java based, so if Eclipse can run on your machine, so can Paros  Paros is a proxy, so it captures requests from your web browser to a server and responses from the server back to your browser  You can use it to alter your requests quite easily
  • 34. ©2009 Justin C. Klein Keane Start Up Paros
  • 35. ©2009 Justin C. Klein Keane Configure Firefox  You need to configure Firefox to use Paros as a proxy − Choose Edit -> Preferences, then Advanced -> Network -> Settings
  • 36. ©2009 Justin C. Klein Keane Configure Settings
  • 37. ©2009 Justin C. Klein Keane Create Request  Once Firefox is configured to utilize Paros browse through the site normally  Note how Paros records all your interactions  Try submitting the login form  Note that Paros records GET and POST requests
  • 38. ©2009 Justin C. Klein Keane Paros in Action
  • 39. ©2009 Justin C. Klein Keane Paros Records Details
  • 40. ©2009 Justin C. Klein Keane Alter Requests  To alter a request click on it in the bottom window  Next right click and select “Resend”  This opens a new window where you can alter any of the send requests  Change any data and click the “Send” button
  • 41. ©2009 Justin C. Klein Keane Paros Resend
  • 42. ©2009 Justin C. Klein Keane Response is Raw
  • 43. ©2009 Justin C. Klein Keane Bypassing the Login  In our manual code analysis we found a SQL injection vulnerability in the login form  A JavaScript check prevents easy manual testing  We could disable JavaScript or use Paros or Tamper Data to alter the data we're submitting for the login form  First let's examine the query
  • 44. ©2009 Justin C. Klein Keane Our Target $sql = "select user_id from user where user_username = '" . $_POST['username'] . "' AND user_password = md5('" . $_POST['password'] . "')";
  • 45. ©2009 Justin C. Klein Keane Target SQL select user_id from user where user_username = 'somename' and user_password = md5('somepass');
  • 46. ©2009 Justin C. Klein Keane Possible Permutation select user_id from user where user_username = 'somename' or 1='1' and user_password = md5('somepass');  What is the proper input to create this statement?
  • 47. ©2009 Justin C. Klein Keane Testing Your SQL
  • 48. ©2009 Justin C. Klein Keane Bypassing Login with SQL Injection
  • 49. ©2009 Justin C. Klein Keane We're In!
  • 50. ©2009 Justin C. Klein Keane Chained Exploits  Note that the exploitation of the authentication leads to access to new, potentially exploitable functionality  Authentication leads to cookie granting  Admin functions are often “trusted”
  • 51. ©2009 Justin C. Klein Keane Steps to Remember  Look for vulnerabilities − In the source code − In the functional front end  Test your exploits in the “friendliest” environment possible  Use tools to recreate attacks in the live environment.
  • 52. ©2009 Justin C. Klein Keane For Next Time -Install Paros Proxy -Install Firefox and the Tamper Data and Web Developer plug ins -Download and install the sample SQL injection application on your VM -Identify at least 4 SQL injection vulnerabilities -Develop exploits for each vulnerability -Develop fixes for each vulnerability