473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HACKING WITH JAVASCRIPT

Use This for Learning Only ....
Do Not Try To Act Smart
HACKING WITH JAVASCRIPT

Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC

This tutorial is an overview of how javascript can be used to bypass
simple/advanced html forms and how it can be used to override cookie/session
authentication.

SIMPLE HTML FORMS

1. Bypassing Required Fields
Surely you have met a webpage that requires you to fill all fields in a form
in order to submit it. It is possible to bypass these types of restrictions
on any webpage. If you take a look at the webpage's source and follow it
down to the form's code, you will notice the onsubmit form attribute.
Hopefully by this time you have experienced the power of javascript and you
know that javascript has control over every single element in a webpage,
including forms.We can use javascript to our advantage in every page we view
for we can modify, delete, or add any element to the webpage. In this case
we wish to clear the form's onsubmit attribute in order for the form to be
submitted successfully.

The onsubmit attribute generally points to a function that checks the form
to have the correct format. A function that does this may look something
like this:

function formSubmit(x)

{

if(x.email.value=="") return false;

return true;

}

....

<form name="spamform" method=post action="process.php" onsubmit="return
formSubmit(this);">

....

</form>

I will not go into great detail about how the formSubmit function works. You
should know that if the (textfield/optionfield/option/..) field is left
blank, the form will not be submitted to process.php. Now comes the moment
of truth, how do we modify the form so that onsubmit returns true everytime?
The way we can access the form with javascript and do this is:
document.forms[x].onsubmit="return true;";

or
document.spamform.onsubmit="return true;";

Both of these 'queries' will allow you to submit the form free of
restrictions. The secret is how to execute this. I do this using my
browser's Location bar. All you have to do is enter this text into the
location bar and press enter:

javascript:document.spamform.onsubmit="return true;";

The above statement will not work because the 'query' will return a value
javascript doesn't know what to do with it so it dumps the returned value on
the screen. We need a way to use this value and escape it from passing on to
javascript. I know the exact way to do this, with alert()!

javascript:alert(document.spamform.onsubmit="retur n true;");
You will see an alertbox with "return true;" instead of dumping this value
out to the webbrowser. Once you have executed this query you will be able to
enter whatever value into whatever field in spamform.

2. Changing Fields' Values

If you have managed to change a form's onsubmit attribute to let you do
whatever the you want, what are the limits? Of course now you know that you
can modify the onsubmit attribute of a form from the location bar, same goes
for any attributes of any object in the page. This is how you can do it:
javascript:alert(document.spamform.fieldname.value ="Dr_aMado was here!");

or

javascript:alert(document.forms[x].fieldname.value="Dr_aMado was here!");

But of course, you already knew that. Didn't you? You can change the values
of pretty much anything inside a form, including radios, checkboxes,
selects, hidden values, buttons, anything!

SQL INJECTIONS

1. Using Forms to Your Advantage

You probably already know about sql injection, my goal is to explain how
vulnerable forms can be if not handled correctly. When targeting a system,
most times you will start off with 0 code to exploit. The only thing you
have is a constructed webpage to break to pieces and successfully find
vulnerabilities to use to your advantage.

ACQUIRING DATABASE INFORMATION

A very logic way of acquiring system information from a website's database
is by causing errors in the sql queries. These errors can be created through
search forms, dynamic links, or session cookies. Most sql injection papers
explain how dynamic links and text boxes can be used to execute sql queries
but in my opinion, this vulnurability is more common in other input types
(select boxes, hidden fields, checkboxes and radio buttons, and cookies!).

Mixing data types generally crashes a webpage if it's not well coded. Take
for example a link to "memberinfo.php?o_id=1". If your goal is to crash that
page it would be a good idea to stick in a " or a ' in the o_id variable. If
you're lucky you will get a debug message containing the crippled sql query.
After you have all the information you need and you know what you're going
after you're ready to hack the hell out of every page that you have access
to.

CHANGING FIELDS' VALUES

The first form you think of is the profile page. Most profile pages ignore a
user's intellectuals and don't mask out,for example, select boxes. A way of
exploiting this vulnerability is by injecting a sql query in the value
property of the field.

javascript:alert(document.profileform.user_sex.val ue="gay\',user_pasword=\'H
ACKED\' WHERE user_id=1#");

If we assume that the server side sql query looks something like this:

"UPDATE user_data SET
user_password='$user_password',user_email='$user_e mail',user_sex='$user_sex'
WHERE user_id=$user_id";

Then the final query will look somewhat like this:

"UPDATE user_data SET
user_password='mypassword',user_email='myemail',us er_sex='gay',user_password
='HACKED' WHERE

user_id=1 #' WHERE user_id=7382";

# Is a sql comment operator.

2. Bypassing Session Cookies

OVERRIDING BASIC SESSION COOKIE AUTHENTICATION

Most of the time session handling is done with the use of cookies. The
cookies tell the webpage who you are and what you have access to and what
you don't have access to. If the page does not handle session cookies
correctly a hacker might be able to change their identity to that of another
user's. Cookies are stored in "window.document.cookie". With javascript we
are able to erase,edit,create cookies for any website. This task is more
complicated than regular types of attacks. I will not go into great detail
about how it's done.
To View the Cookie:

javascript:alert(unescape(document.cookie));

To Change Cookie Data:

javascript:alert(window.c=function
a(n,v,nv){c=document.cookie;c=c.substring(c.indexO f(n)+n.length,c.length);c=
c.substring(1,((c.indexOf(";")>-1) ? c.indexOf(";") :
c.length));nc=unescape(c).replace(v,nv);document.c ookie=n+"="+escape(nc);ret
urn unescape(document.cookie);});alert(c(prompt("cooki e
name:",""),prompt("replace this value:",""),prompt("with::","")));

So If You are logged in as "John Doe" in www.ima13370h4x0r.net and your
session cookie reads:

SessionData=a:3:{s:11:"SessionUser";s:5:"75959";s: 9:"SessionID";i:70202768;s
:9:"LastVisit";i:1078367189;}
The cookie is actually serialized but you should be able to recognize
"75959" as your user_id. Some of the time you will find a website that
stores data (like user_id) in cookies but does not typecast the data. This
is a serious hole in the site's code because any user is able to change
their user_id to any other user or administrator user_id.

Changing the cookie value is easy once you have declared the window.c
function. First change s:5:"75959" to s:x:"ADMINID" where x is the length of
the new value. So if you want to change 75959 to 1. You must change
s:5:"75959" to s:1:"1" :-) Sometimes you will need to change 75959 to "13 or
1=1" in order to bypass any WHERE statements any sql session queries used to
keep you logged in the website.

----------------------------------------------------------------------------
------------

Notes:

In-line javascript statements can be added to your browser's favorites for
easier access to your own functions.

It is possible to declare your own functions for use in extended hacks.
Declare the function as a method of window. "alert(window.newfunction =
function (){...})"

----------------------------------------------------------------------------
------------

triviasecurity.net

Dr_aMado
Jul 17 '05 #1
0 7048

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jim | last post by:
Hi, I keep getting form results emailed to me that would indicate a form from my web site is getting submitted with all fields blank or empty, but my code should preventing users from proceeding...
0
by: ChangAya | last post by:
I use binary log on mysql system. Yesterday i found some hacking attempt on my machine. ( I found some unknown queries on binary log) But i don't get any information about hacking query...
0
by: masterjuan | last post by:
Networks Hacking (hack C:/ drives, severs...)and security holes all on my website & hacking commands and I explain ways of erasing your tracks so you dont get caught doing "bad" things... What do...
6
by: enes naci | last post by:
i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it.
8
by: diana.ruwanika | last post by:
hey how do you hack in to computers ?
10
by: shingabiss | last post by:
I have a web site that has an HTML form with some Javascript for checking form fields and a PHP script that handles the information on the server side and returns a page to the submitter. In my...
8
by: needhelp | last post by:
Hi there, I really need some help, everything I've tried, all I've found, doesn't seem to work. I have lost an email address which is very important to me. I really need to contact that person...
0
by: e.expelliarmus | last post by:
check this out buddies... a kool site for anti hacking and hacking tips and tricks , computer tweaks to enhance ur pc,small virus creation ,etc.... it's the best site ... ...
0
by: e.expelliarmus | last post by:
check this out buddies. kool website for: * hacking and anti hacking tricks * anti hackng tricks. * registry tweaks * orkut tricks * small virus * computer tricks and loads of different...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.