A javascript injection by itself is fairly harmless. This is because the 'exploit' is client-side. When a javascript injection occurs, nothing changes on the server. The real workings of it are that the user is telling their browser to change how the web page is displayed; For instance, if we used a javascript injection to change the google logo at www.google.com to the goatse.cz image, nothing on the google servers will be altered. No one else accessing google.com will have the goatse man on their browser.
Its fairly simple to do. Open a web browser pointed to www.google.com, clear the address bar, and enter
javascript:void(document.images[0].src="//google.com/intl/en//images/sitesearch/linux.gif");Now to break it down. The prefix "javascript:" tells the browser that the following is a javascript command, much like the prefix "http:" says to display the page html. The "void():" function carries out what is passes as an argument, in this case, to assign a variable to a new value. Now it gets a bit harder... The data we are changing is stored in the variable "document.images[0].src". The main object here is "document", which is the current web page. Images are stored in an array called "images[ ]", which is simply an indexed list of images from top to bottom. The top-most image will be "images[0]", the next will be "images[1]", and so on. The google logo happens to be the first image, so we use "images[0]" to reference it. The variable "src" contains the URL of the image to be displayed. When we change this, the browser will display whatever we change it to. Of course the "=" sign assigns whatever is next to the "document.images[0].src" variable, and then comes the new source value itself.
So in essence, this javascript injection is saying: "Hey, browser, change the source(src) of the first image(images[0]) on this web page(document) to "http://www.google.com/intl/en//images/sitesearch/linux.gif". Pretty neat eh?
This is a pretty fun way to silence those "1337 Hax0rs!!1!1!" by showing them up. :-D And extra points if you convert the command string into hex characters to throw them off.
Here is some additional material, mainly for my personal reference:
Appearance Related:
- document.bgColor - The background color.
- document.fgColor - The foreground text color.
- document.defaultCharset - The default charset.
- document.title - The name of the current document.
- document.write() - Writes the argument passed to write() onto the document.
Non-Visible:
- document.cookie - The cookie associated with the web page.
- document.security
- document.location - What the web browser is pointing to. Change this to change pages.
- document.referrer - The URL of the document that we got the link to the present document from.
- document.URL - The path to the current document.
Document Arrays:
- document.embeds[ ] - An array containing all the plugins in a document.
- document.anchors[ ] - An array of all the anchors in the document.
- document.forms[ ] - An array of all the forms in the document.
- document.frames[ ] - An array that consists of all the frame objects in the document.
- document.layers[ ] - An array containing all the layers in a document.
- document.images[ ] - An array of the images in the document.
- document.links[ ] - An array of links in the document.
Image Objects:
document.image - An image in a document.
- image.border - The width of the border around the image in pixels.
- image.complete - A Boolean value which identifies whether an image is completely loaded yet.
- image.height - The read only height of the image in pixels.
- image.hspace - The read only amount of horizontal space to the left and right sides of the image.
- image.lowsrc - The URL of an alternate image for low-res screens.
- image.name - The image name.
- prototype - Used for adding user-specified properties to the image.
- image.src - The URL of the image to be displayed. It is a read/write string.
- image.vspace - The read only vertical space above and below the image.
- image.width - The width of the image in pixels.
Link Objects:
document.link - A link within the document.
- link.hash - The URL anchor part including the leading hash mark if one exists.
- link.host - The URL host name and port.
- link.hostname - The URL host name section.
- link.href - The URL.
- link.pathname - The URL path name section.
- link.port - The URL port section.
- link.protocol - The URL protocol section including the colon after the protocol name.
- link.search - The URL query string. This is the section after and including the question mark.
- link.target - The URL link’s target name.
Document Object Methods:
- clear() - This is depreciated.
- close() - Closes an output stream that was used to create a document object.
- contextual() - Used to specify specific attributes. To change things in block quotes to the color blue:
document.contextual(document.tags.blockquote).color = "blue";
Nice intro man.
ReplyDeletejavascripting in funny
ReplyDelete