parsonsisconsulting

Parsons Software Security Consulting Blog

Archive for the ‘O2’ Category

Apple hacked!! Ethical hackers personal information hacked at Apple

leave a comment »

My fiancé was trying to download a movie today from iTunes when the security certificate was marked as invalid.  My first thought was did Apple get hacked?   She was trying to download the Jackie Robinson movie, 42.   I didn’t think anything of it and went back to my normal Sunday evening routine.   I was outside playing with our dogs in the yard when my iPhone alerted me of a new message.  

The message I received was the following.  
Image

I then did a little research and found out that Apple was indeed hacked and they were doing major over runs for maintenance.   Part of the problem is that first and foremost I am a an application security engineer and apple developer second.  I have been programming for 15 years and doing application security for 11 of those years.  I have been an apple developer for two years learning cocoa daily to one day strike it rich on an apple development idea. 

I was then thinking.   Apple has all of my sensitive information.   They have my social security number, my credit card, my name and address and my bank account number to deposit my application sales at least 60 percent of it to my bank account while apple profits 40 percent.  

I was thinking that man;  I am an ethical hacker and I got hacked.   It was not a good feeling.  It was a similar feeling when I found out my veteran’s information was hacked and they enrolled me in credit monitoring.  

I felt like a victim.   My career goal in life is to make more applications more secure.   I actually interviewed a few times with the apple development team and they told me I was not smart enough.   I do know this; if I was working with Apple, I would have been smart enough to encrypt all sensitive information.   I would have ensured that the confidentiality, integrity and availability of the application was met.  

I am not sure how this attacked happened but I am guessing from a web application vulnerability.   I believe if Apple hired a competent 3rd party unbiased application security engineer this would not have happened.   Attackers use the same tools and techniques that application security professionals do.   A thorough penetration test and a secure application review could have prevented this.  I pray for other consumers sake and companies that more companies take application security more seriously and reach out to non profit organizations like the open web application security project by training developers and hiring ethical third party security engineers to do software reviews to ensure the confidentiality, integrity and availability of data in systems and putting the proper security controls in place to prevent this from happening in the future.  

 

 

I hope that the most successful company getting hacked is a wake up call.   We need to train developers to program applications more securely and value the competent ethical third party application security engineers that review these applications.  

 

Matt Parsons, CISSP, MSM, CWASE

mparsons@parsonsisconsulting.com

 

 

http://allthingsd.com/20130721/apple-developer-center-was-hacked-site-remains-down-while-company-overhauls-security/

http://www.businessinsider.com/apple-developers-site-hacked-2013-7

How many software security bugs can you find in OWASP web goat below?

leave a comment »

Today’s post is going to be interactive.  I am going to show the source code of a file in web goat.    The file name is BlindSQLInjection.java.   I am asking my readers to point out the security vulnerabilities in the code and post below in comments.  I will post my answers in a couple days.

Many thanks to OWASP, Jeff Williams, Aspect Security and Bruce Mayhew and anyone else that have worked on the web goat project.


package org.owasp.webgoat.lessons;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.<a class="zem_slink" title="Dynamic array" rel="wikipedia" href="http://en.wikipedia.org/wiki/Dynamic_array">ArrayList</a>;
import java.util.List;
import org.apache.ecs.Element;
import org.apache.ecs.ElementContainer;
import org.apache.ecs.StringElement;
import org.apache.ecs.html.Input;
import org.apache.ecs.html.P;
import org.owasp.webgoat.session.DatabaseUtilities;
import org.owasp.webgoat.session.ECSFactory;
import org.owasp.webgoat.session.WebSession;

/***************************************************************************************************
 *
 *
 * This file is part of WebGoat, an <a class="zem_slink" title="OWASP" rel="wikipedia" href="http://en.wikipedia.org/wiki/OWASP">Open Web Application Security Project</a> utility. For details,
 * please see http://www.owasp.org/
 *
 * Copyright (c) 2002 - 2007 Bruce Mayhew
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * <a class="zem_slink" title="GNU General Public License" rel="wikipedia" href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GNU General Public License</a> as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the <a class="zem_slink" title="Implied warranty" rel="wikipedia" href="http://en.wikipedia.org/wiki/Implied_warranty">implied warranty of MERCHANTABILITY</a> or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if
 * not, write to the <a class="zem_slink" title="Free Software Foundation" rel="homepage" href="http://www.fsf.org/">Free Software Foundation, Inc.</a>, 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * Getting Source ==============
 *
 * Source for this application is maintained at code.google.com, a repository for free software
 * projects.
 *
 * For details, please see http://code.google.com/p/webgoat/
 *
 * @author Chuck Willis <a href="http://www.securityfoundry.com">Chuck's web site</a> (this lesson
 *         is heavily based on Bruce Mayhews' <a class="zem_slink" title="SQL" rel="wikipedia" href="http://en.wikipedia.org/wiki/SQL">SQL</a> Injection lesson
 * @created January 14, 2005
 */
public class BlindSqlInjection extends LessonAdapter
{

 private final static String ACCT_NUM = "account_number";

 private final static int TARGET_ACCT_NUM = 15613;

 /**
 * Description of the Method
 *
 * @param s
 *            Description of the Parameter
 * @return Description of the <a class="zem_slink" title="Return statement" rel="wikipedia" href="http://en.wikipedia.org/wiki/Return_statement">Return Value</a>
 */
 protected Element createContent(WebSession s)
 {
 ElementContainer ec = new ElementContainer();

 try
 {
 Connection connection = DatabaseUtilities.getConnection(s);

 ec.addElement(new P().addElement("Enter your Account Number: "));

 String accountNumber = s.getParser().getRawParameter(ACCT_NUM, "101");
 Input input = new Input(Input.TEXT, ACCT_NUM, accountNumber.toString());
 ec.addElement(input);

 Element b = ECSFactory.makeButton("Go!");
 ec.addElement(b);

 String query = "<a class="zem_slink" title="Select (SQL)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Select_%28SQL%29">SELECT</a> * FROM user_data WHERE userid = " + accountNumber;
 String answer_query;
 answer_query = "SELECT TOP 1 first_name FROM user_data WHERE userid = " + TARGET_ACCT_NUM;

 try
 {
 Statement answer_statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
 ResultSet.CONCUR_READ_ONLY);
 ResultSet answer_results = answer_statement.executeQuery(answer_query);
 answer_results.first();
 //System.out.println("Account: " + accountNumber);
 //System.out.println("Answer : " + answer_results.getString(1));
 if (accountNumber.toString().equals(answer_results.getString(1)))
 {
 makeSuccess(s);
 }
 else
 {

 Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
 ResultSet.CONCUR_READ_ONLY);
 ResultSet results = statement.executeQuery(query);

 if ((results != null) && (results.first() == true))
 {
 ec.addElement(new P().addElement("<a class="zem_slink" title="National identification number" rel="wikipedia" href="http://en.wikipedia.org/wiki/National_identification_number">Account number</a> is valid"));
 }
 else
 {
 ec.addElement(new P().addElement("Invalid account number"));
 }
 }
 } catch (SQLException sqle)
 {
 ec.addElement(new P().addElement("An error occurred, please try again."));
 }
 } catch (Exception e)
 {
 s.setMessage("Error generating " + this.getClass().getName());
 e.printStackTrace();
 }

 return (ec);
 }

 /**
 * Gets the category attribute of the SqlInjection object
 *
 * @return The category value
 */
 protected Category getDefaultCategory()
 {
 return Category.INJECTION;
 }

 /**
 * Gets the credits attribute of the AbstractLesson object
 *
 * @return The credits value
 */
 public Element getCredits()
 {
 return new StringElement("By Chuck Willis");
 }

 /**
 * Gets the hints attribute of the DatabaseFieldScreen object
 *
 * @return The hints value
 */
 protected List<String> getHints(WebSession s)
 {
 List<String> hints = new ArrayList<String>();
 hints.add("Compound SQL statements can be made by joining multiple tests with keywords like AND and OR. "
 + "Create a SQL statement that you can use as a true/false test and then "
 + "select the first character of the target element and do a start narrowing "
 + "down the character using > and <"
 + "<br><br>The backend database is HSQLDB.  Keep that in mind if you research SQL functions "
 + "on the Internet since different databases use some different functions and syntax.");
 hints.add("This is the code for the query being built and issued by WebGoat:<br><br> "
 + "\"SELECT * FROM user_data WHERE userid = \" + accountNumber ");
 hints.add("The application is taking your input and inserting it at the end of a pre-formed SQL command. "
 + "You will need to make use of the following SQL functions: "
 + "<br><br>SELECT - query for your target data and get a string "
 + "<br><br>substr(string, start, length) - returns a "
 + "substring of string starting at the start character and going for length characters "
 + "<br><br>ascii(string) will return the ascii value of the first character in string "
 + "<br><br>&gt and &lt - once you have a character's value, compare it to a choosen one");
 hints.add("Example: is the first character of the first_name of userid " + TARGET_ACCT_NUM
 + " less than 'M' (ascii 77)? "
 + "<br><br>101 AND (ascii( substr((SELECT first_name FROM user_data WHERE userid=" + TARGET_ACCT_NUM
 + ") , 1 , 1) ) < 77 ); "
 + "<br><br>If you get back that account number is valid, then yes.  If get back that the number is"
 + "invalid then answer is no.");
 hints.add("Another example: is the second character of the first_name of userid "
 + TARGET_ACCT_NUM
 + " greater than 'm' (ascii 109)? "
 + "<br><br>101 AND (ascii( substr((SELECT first_name FROM user_data WHERE userid="
 + TARGET_ACCT_NUM
 + ") , 2 , 1) ) > 109 ); "
 + "<br><br>If you get back that account number is valid, then yes.  If get back that the number is "
 + "invalid then answer is no.");
 return hints;
 }

 /**
 * Gets the instructions attribute of the SqlInjection object
 *
 * @return The instructions value
 */
 public String getInstructions(WebSession s)
 {
 String instructions = "The form below allows a user to enter an account number and determine if "
 + "it is valid or not.  Use this form to develop a true / false test check other entries in the database.  "
 + "<br><br>Reference Ascii Values: 'A' = 65   'Z' = 90   'a' = 97   'z' = 122 "
 + "<br><br>The goal is to find the value of " + "the first_name in table user_data for userid "
 + TARGET_ACCT_NUM
 + ".  Put the discovered name in the form to pass the lesson.  Only the discovered name "
 + "should be put into the form field, paying close attention to the spelling and capitalization.";

 return (instructions);
 }

 private final static Integer DEFAULT_RANKING = new Integer(70);

 protected Integer getDefaultRanking()
 {
 return DEFAULT_RANKING;
 }

 /**
 * Gets the title attribute of the DatabaseFieldScreen object
 *
 * @return The title value
 */
 public String getTitle()
 {
 return ("Blind SQL Injection");
 }

 /**
 * Constructor for the DatabaseFieldScreen object
 *
 * @param s
 *            Description of the Parameter
 */
 public void handleRequest(WebSession s)
 {
 try
 {
 super.handleRequest(s);
 } catch (Exception e)
 {
 //System.out.println("Exception caught: " + e);
 e.printStackTrace(System.out);
 }
 }
}

 

Matt Parsons, CISSP, MSM

mparsons1980@gmail.com

Parsons Software Security Consulting, LLC

Threat Model for OWASP web goat

leave a comment »

I am trying to completely dissect OWASP’s web goat and link source code findings with web penetration findings.   In my quest to do this I have created a very, very rough threat model.   There is a lot more that needs to be added to the threat model.   I have completed probably ten threat models for different clients’ of mine.   I used the Microsoft Threat Model tool. I used an older version.  I think there are newer ones and better ones.   It is a good idea to use a threat model to see all of the components of the application.   It allows a security analyst or a developer to see the users’ of the application, the data and the possible data exposure of the data of the confidentiality, integrity and availibility of your application.    You can then create use and abuse cases for the application.

 

 

 

 

 

 

 

 

Matt Parsons, CISSP, MSM

mparsons1980@gmail.com

Parsons Software Security Consulting, LLC

Reflected Cross Site Scripting in OWASP Web Goat source code

leave a comment »

I am doing another web goat vulnerability.  This time once again I scanned Web Goat with a commercial static code analyzer.   The tool is telling me that the below vulnerability is reflected cross site scripting.    With reflected XSS attacks an attacker tricks a user into sending malicious code to a vulnerable web server.   This could access the user’s cookie.


Description of the Exception

*/

public String getRawParameter(String name) throws ParameterNotFoundException

{

String[] values = request.getParameterValues(name);

if (values == null)

{

throw new ParameterNotFoundException(name + " not found");

}

else if (values[0].length() == 0) { throw new ParameterNotFoundException(name + " was empty"); }

return (values[0]);


public String getRawParameter(String name, String def)

{

try

{

return getRawParameter(name);

} catch (Exception e)

{

return def;

}

}

/**

* Gets the rawParameter attribute of the ParameterParser object

*

String to = s.getParser().getRawParameter(HIDDEN_TO, "");

String gId = s.getParser().getRawParameter(GMAIL_ID, "");

String gPass = s.getParser().getRawParameter(GMAIL_PASS, "");

String message = s.getParser().getRawParameter(MESSAGE, "");

String subject = s.getParser().getRawParameter(SUBJECT, "");

boolean haveCredentials = !(YOUR_REAL_GMAIL_ID.equals(gId) || YOUR_REAL_GMAIL_PASSWORD.equals(gPass));

ec.addElement(new HR());

createGoogleCredentials(s, ec);

ec.addElement(new HR());

ec.addElement(new BR());

createMailMessage(s, subject, message, ec);

{

if (haveCredentials)

{

Message sentMessage = sendGoogleMail(to, subject, message, emailFromAddress, gId, gPass);

formatMail(ec, sentMessage);

}

else

{

sendSimulatedMail(ec, to, subject, message);

}

}

From reading the code it looks like it gets your gmail information and then sends the message without validating any inputs or encoding any outputs.

All of this takes place inside of the Web Goat file uncheckedemail.java.

Once again thanks to OWASP and Aspect Security for creating and supporting web goat.  It’s a great web application security to practice white box ethical hacking, secure code review without going to prison for real hacking.


msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type

msg.setSubject(subject);

msg.setContent(message, "text/plain");

Transport.send(msg);

return msg;
<pre>

I couldn't find the page in Web goat that the above code references, but I was able to find the reflected XSS lesson in web goat.
I went to the recently retired from software security blogging, RSNAKE's hackers.org website.

I used the following script to attack it.   
 
<IMG SRC=`javascript:alert("Parsons Software Security Consulting says, 'XSS'")`>


Matt Parsons, CISSP, MSM
Parsons Software Security Consulting, LLC
mparsons1980@gmail.com

Parsons Software Security Consulting, LLC Video Introduction

leave a comment »

How to find Robots.txt with 02

with 2 comments

We already discussed a script to find the crossdomain.xml file with 02.  Today we are going to talk about how to find the Robots.txt file.  Many websites have Robots.txt file but sometimes they contain sensitive information inside of these files.   Today we are going to write a script that searches Google for these files.

 

 

Below is a sample Robots.txt from a sample web application.

 

 

 

 

 

 


var ie = panel.clear().add_IE().silent(true);
ie.open("http://www.google.com");
ie.field("Search").value("inurl:robots.txt filetype:txt");


ie.button("Google Search").click();
var targetUrls = new List<string>();

foreach(var link in ie.links().urls())
 if (link.ends("robots.txt"))
 targetUrls.Add(link);

return targetUrls;
return targetUrls;
return targetUrls;
return ie.buttons();

//O2File:WatiN_IE_ExtensionMethods.cs
//using  O2.XRules.Database.Utils.O2
//O2Ref:WatiN.Core.1x.dll

 

 

 

 

I don’t plan on showing you how to exploit robots.txt.  But the 02 script is a simple one to find robots.txt  out in the wild.

 

Parsons Software Security Consulting, LLC

Securing the Internet one Application at a time.

 

mparsons [at] gmail.com

 

Written by mparsons1980

December 8, 2010 at 11:07 pm

Etherpad 02 scripting to search and click on a link in Google

leave a comment »

I was on an Etherpad session with Dinis and Sarah from OWASP.   Below is the link to Etherpad.   Etherpad is a great tool for programmers and for us to help write scripts together and trouble shoot.

http://ietherpad.com/

We used the free version.

Below are our Etherpad sessions from December, 3, 2010.

http://ietherpad.com/xkckfhJGAY

http://ietherpad.com/UYmog5ljkj

Dinis blogs about it on his blog.   http://o2platform.wordpress.com/2010/12/04/o2-script-to-perform-a-google-search/

Below is today’s 02 script.  Dinis is the original author but I tweaked it to do some shameless self promoting.


panel.clear();
var ie = panel.add_IE().silent(true);
ie.disableFlashing(); // use this when developing the script to make it faster
Action<string> searchGoogle =
 (searchText)=> {
 ie.open("http://www.google.com");
 searchText = searchText.line();       // here......  <----
 ie.field("Search").value(searchText).flash();
 ie.button("Google Search").Click();
 };
Action<string> clickOnLink =
 (linkToClick)=> {
 if (ie.hasLink(linkToClick))
 ie.link(linkToClick).flash().click();
 else
 "Error: could not find link: {0}".error(linkToClick);
 };

searchGoogle("Parsons Software Security Consulting, LLC");
clickOnLink("Parsons Software Security Consulting, LLC - Home");


return ie.link("Parsons Software Security Consulting, LLC - Home").click();




//O2File:WatiN_IE_ExtensionMethods.cs
//using O2.XRules.Database.Utils.O2
//O2Ref:WatiN.Core.1x.dll


This code opens Google.  Disables flashing to make the search faster.  Then searches for my company, Parsons Software Security Consulting, LLC and clicks on the first link then opening my company’s website.

There is the script. Feel free to email me at mparsons1980@gmail.com for comments.

Matt Parsons, CISSP, MSM,
Parsons Software Security Consulting, LLC
Securing the Internet one Application at a time.

Written by mparsons1980

December 4, 2010 at 4:05 am