Brainfoldb4u's Blog

Just another WordPress.com weblog

Archive for the ‘Penetration testing’ Category

sqlmap: Open source pentest tool

Posted by brainfoldb4u on March 15, 2010

sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of back-end database servers. It comes with a broad range of features lasting from database fingerprinting, over data fetching from the database, to accessing the underlying file system and executing commands on the operating system via out-of-band connections.

sqlmap features

Features implemented in sqlmap include:

Generic features

  • Full support for MySQL, Oracle, PostgreSQL and Microsoft SQL Server back-end database management systems. Besides these four database management systems software, sqlmap can also identify Microsoft Access, DB2, Informix, Sybase and Interbase.
  • Full support for three SQL injection techniques: inferential blind SQL injection, UNION query (inband) SQL injection and batched queries support. sqlmap can also test for time based blind SQL injection.
  • It is possible to provide a single target URL, get the list of targets from Burp proxy requests log file or WebScarab proxy conversations/ folder, get the whole HTTP request from a text file or get the list of targets by providing sqlmap with a Google dork which queries Google search engine and parses its results page. You can also define a regular-expression based scope that is used to identify which of the parsed addresses to test.
  • Automatically tests all provided GET parameters, POST parameters, HTTP Cookie header values and HTTP User-Agent header value to find the dynamic ones, which means those that vary the HTTP response page content. On the dynamic ones sqlmap automatically tests and detects the ones affected by SQL injection. Each dynamic parameter is tested for numeric, single quoted string, double quoted string and all of these three data-types with zero to two parenthesis to correctly detect which is the SELECT statement syntax to perform further injections with. It is also possible to specify the only parameter(s) that you want to perform tests and use for injection on.
  • Option to specify the maximum number of concurrent HTTP requests to speed up the inferential blind SQL injection algorithms (multi-threading). It is also possible to specify the number of seconds to wait between each HTTP request.
  • HTTP Cookie header string support, useful when the web application requires authentication based upon cookies and you have such data or in case you just want to test for and exploit SQL injection on such header. You can also specify to always URL-encode the Cookie header.
  • Automatically handle HTTP Set-Cookie header from the application, re-establishing of the session if it expires. Test and exploit on these values is supported too. You can also force to ignore any Set-Cookie header.
  • HTTP Basic, Digest, NTLM and Certificate authentications support.
  • Anonymous HTTP proxy support to pass by the requests to the target application that works also with HTTPS requests.
  • Options to fake the HTTP Referer header value and the HTTP User-Agent header value specified by user or randomly selected from a text file.
  • Support to increase the verbosity level of output messages: there exist six levels. The default level is 1 in which information, warnings, errors and tracebacks (if any occur) will be shown.
  • Granularity in the user’s options.
  • Estimated time of arrival support for each query, updated in real time while fetching the information to give to the user an overview on how long it will take to retrieve the output.
  • Automatic support to save the session (queries and their output, even if partially retrieved) in real time while fetching the data on a text file and resume the injection from this file in a second time.
  • Support to read options from a configuration INI file rather than specify each time all of the options on the command line. Support also to save command line options on a configuration INI file.
  • Option to update sqlmap as a whole to the latest development version from the Subversion repository.
  • Integration with other IT security open source projects, Metasploit and w3af.

Fingerprint and enumeration features

  • Extensive back-end database software version and underlying operating system fingerprint based upon inband error messages, banner parsing, functions output comparison and specific features such as MySQL comment injection. It is also possible to force the back-end database management system name if you already know it.
  • Basic web server software and web application technology fingerprint.
  • Support to retrieve the DBMS banner, session user and current database information. The tool can also check if the session user is a database administrator (DBA).
  • Support to enumerate database users, users’ password hashes, users’ privileges, databases, tables and columns.
  • Support to dump database tables as a whole or a range of entries as per user’s choice. The user can also choose to dump only specific column(s).
  • Support to automatically dump all databases’ schemas and entries. It is possibly to exclude from the dump the system databases.
  • Support to enumerate and dump all databases’ tables containing user provided column(s). Useful to identify for instance tables containing custom application credentials.
  • Support to run custom SQL statement(s) as in an interactive SQL client connecting to the back-end database. sqlmap automatically dissects the provided statement, determines which technique to use to inject it and how to pack the SQL payload accordingly.

Download:

Click here to download

Posted in Auditing, Open Source, Penetration testing, Security tools | Tagged: | Leave a Comment »

Researcher Uncovers Twitter, Google Calendar Security Vulnerabilities

Posted by brainfoldb4u on January 3, 2010

A security researcher uncovered some holes in Google Calendar and Twitter that may allow an attacker to steal cookies and user session IDs…

A security researcher has uncovered vulnerabilities in Twitter and Google Calendar that could put users at risk.

In a proof-of-concept, researcher Nir Goldshlager demonstrated cross-site scripting (XSS) vulnerabilities in Google Calendar and Twitter that he said could be used to steal cookies and session IDs. He also uncovered an HTML injection issue affecting Google Calendar as well that he said could be used to redirect a victim to an attack site anytime the user viewed his or her Google Calendar agenda events….

For complete article from eweek, click

Posted in Google, Penetration testing, XSS | Tagged: , , | Leave a Comment »

Cross site scripting scenarios

Posted by brainfoldb4u on January 3, 2010

Web pages contain both text and HTML markup that is generated by the server and interpreted by the client browser. Web servers that generates static web pages have full control over client browser. But servers with dynamic pages do not have complete control over how their output is interpreted by the client. Question is, does the client side browser has enough information to recognize if the script is malicious or legitimate and take proper actions accordingly.

Many web servers generate web pages dynamically. For example, a search engine may do a database search and then build a web page that has the result of the search. Any server that creates web pages by inserting dynamic data into a template should check to make sure that the facts to be inserted does not contain any special characters (e.g., “<“). If the inserted data has special characters, the user’s web browser will mistake them for HTML markup. Because HTML markup can introduce programs, the browser could interpret some data values as HTML tags or script and not displaying them as text.

If a web browser is not performing checks for special characters in dynamically generated web pages, then in some cases an attacker can choose the data that the web server inserts into the generated page. The attacker can trick the user’s browser into running a program of the attacker’s choice. This program will execute in the browser’s security context for communicating with the legitimate web server, not the browser’s security context for communicating with the attacker. Thus, the program will execute in an inappropriate security context with inappropriate privileges.

Todays browsers are capable of interpreting and executing scripts — created in such scripting languages as JavaScript, JScript, VBScript — embedded in the Web-page downloads from the Web server. When an attacker introduces a malicious script to a dynamic form submitted by the user, a cross-site scripting (XSS) attack then occurs. An XSS attack leads to undesirable effects. For example, the attacker gains the ability to capture the session information, peer into private user details such as ID, passwords, credit card information, home address and telephone number, social security/tax IDs, and so on. If the targeted Web site doesn’t check for this type of malicious code, misuse of the user is probable.

Hackers take several steps to cut the risk of having the script identified as malicious, the attacker might encode it with a different encoding method, such as HEX. With this alteration, the Web site displays the malicious content on the page as if the displayed information is the valid content from the site. If the Web application doesn’t confirm the comments, all the attacker has to do is to coax the user to select the malicious hyperlink, after which the Web application collects confidential data from the user. This enables the attacker to capture the user’s session and steal the user’s credentials, redirect to a page on another Web site, and then insert code that can poison cookies, expose SSL connections, access restricted or private sites, or even trigger a number of such attacks.

To stop the XSS, we need to understand the venues that are more prone to XSS attacks. Most obvious venues are

  • Banking web page
  • Online forum and search boxes
  • Email messages with malicious links
  • Search engines
  • Setting up an account

Banking Web page

For example, let us consider an hacker who wants to gather information on a user of a example banking website, http://www.example.com. Attacker needs Login ID and password to enter into the web site, as all banking web sites contain secure login.  Hacker may try using both username and password as “test”. When the resulting error page comes back with a message that says that the user ID and password combination is wrong, the hacker finds himself in an ideal situation for inserting malicious code into the Web page. How?

He first enters the following into the ID text box: <script>alert('Test')</script>. Submits the form and then sees this JavaScript alert message: “TO BE DONE.” Now he knows that the site is prone to an XSS-style attack. attacker then might introduce malicious scripts  into the URL that redirects the submitted user information to hackedsite.com.This code basically passes the user ID and password information of any user logging into the Web site along to the Web site of the attacker. Now that the script to hack the user ID and password is ready, the attacker sends e-mails and posts with attractive offers to banking Web site users employing this link. Prompted by the attractive offers, users might click on the link and log on to the banking Web site. The malicious script introduced by the attacker is executed by the browser and the data is passed to the hacker’s Web site. The rest is a cakewalk for the hacker to log on to the banking Web site with the victim’s credentials.

This situation is most probable in couple of scenarios like when a web server does not take adequate steps to ensure that the properly encoded pages are generated. And when inputs are suitably validated.

Search Boxes and Online Forums

Search boxes and online forums are  most commonly attacked avenue. An attacker inserts malicious code between scripting tags that the Web page accepts and interprets, using FORM or APPLET tags, depending on the page used. Inserted malicious code can do all sorts of harm by stealing session information or cookies. Vulnerability of this sort is prevalent given that a Web designer needs to have knowledge of many languages and technologies like — CGI, JavaScript, ASP, Perl, even HTML tags  can be used as a delivery vehicle for such attacks.

Email messages with malicious links

An attacker can send an e-mail about a banking Web site to a user. Suppose the e-mail contains a link with a malicious script embedded into the URL. The user may be prompted to click on the link and log on to the Web site, whereby the attacker can seize the user’s log on information. The same is true on a dynamically generated page if a link has malicious code in it. Consider the example of a malicious URL that might be a part of the page. If the attacker has the application display a set of HTML, trouble may creep in. Both the IMG and IFRAME tags allow for a new URL to load when HTML is displayed.

Search engines

Search engines that echo the search keyword that was entered are also vulnerable to such attacks. This is because malicious code can be entered as a part of the keyword search input that is executed when the user submits the search. Dangers can include accessing undesirable or private regions of the Web site.

Setting up an account:

When a user submits a form during e-mail account setup or during submission of a form with data in it, the Web application might show the same information after accepting the information as entered. The input content entered can contain such malicious information that may be executed by the browser. This can lead to leaking of critical information from the session and might expose private avenues of the Web server.

XSS attack consequences: Stolen cookies

Cookie theft occurs when the cookie issued by the application is hijacked for malicious purposes by an attacker. By suitably inserting script code into the URL that invokes the portion of the site that uses cookies and is vulnerable, the attacker captures the cookies and can cause damage to content as well as mimic business functions and perform fake transactions.

What an end user can do to protect from XSS?

Below are the ways that a user can choose to cut the impact of XSS attack.

  • Disable scripting when it is not required.
  • Do not trust links to other sites on e-mail or message boards. They may contain malicious code with damaging potential.
  • Do not follow links from sites that lead to security-sensitive pages involving personal or business information unless you specifically trust them.
  • Access any site involving sensitive information directly through its address and not through any third-party sites.
  • Get a list of attacks and the sites and boards they happened on and be careful if you need to visit one of them.

    Posted in Hacking, Information Security, Penetration testing | Tagged: | Leave a Comment »