473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.valu e=="") return false;

return true;

}

....

<form name="spamform" method=post action="process .php" onsubmit="retur n
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="retu rn true;";

or
document.spamfo rm.onsubmit="re turn 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:docu ment.spamform.o nsubmit="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:aler t(document.spam form.onsubmit=" return 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:aler t(document.spam form.fieldname. value="Dr_aMado was here!");

or

javascript:aler t(document.form s[x].fieldname.valu e="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:aler t(document.prof ileform.user_se x.value="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='$u ser_email',user _sex='$user_sex '
WHERE user_id=$user_i d";

Then the final query will look somewhat like this:

"UPDATE user_data SET
user_password=' mypassword',use r_email='myemai l',user_sex='ga y',user_passwor d
='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.documen t.cookie". With javascript we
are able to erase,edit,crea te 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:aler t(unescape(docu ment.cookie));

To Change Cookie Data:

javascript:aler t(window.c=func tion
a(n,v,nv){c=doc ument.cookie;c= c.substring(c.i ndexOf(n)+n.len gth,c.length);c =
c.substring(1,( (c.indexOf(";") >-1) ? c.indexOf(";") :
c.length));nc=u nescape(c).repl ace(v,nv);docum ent.cookie=n+"= "+escape(nc);re t
urn unescape(docume nt.cookie);});a lert(c(prompt(" cookie
name:",""),prom pt("replace this value:",""),pro mpt("with::","" )));

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

SessionData=a:3 :{s:11:"Session User";s:5:"7595 9";s:9:"Session ID";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.n ewfunction =
function (){...})"

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

triviasecurity. net

Dr_aMado
Jul 17 '05 #1
0 7071

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

Similar topics

11
8756
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 if they left any field blank. My guess is that someone is trying to hack the site using the form to gain entry or run commands -- I don't really know since I'm not a hacker. I just know that forms are often susceptible to these kinds of...
0
1693
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 connection on binary log file.. ( username, host.. i don't know anything ) only thing that i know is "thread_id".
0
3782
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 you think? check out my website its about hacking networks and step by step guides of how to do it all. Any suggestions on information or anything you think would be interesting to write about please tell me. Also what do you think of the...
6
12890
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
2489
by: diana.ruwanika | last post by:
hey how do you hack in to computers ?
10
1491
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 HTML/Javascript page, I have date entry combo boxes; mm/dd/yyyy. I also use the Javascript to take care of correcting the date aspects when the user changes values; correct num of days in month etc. The year fields (for arriving and departing dates)...
8
2505
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 asap. I'm sure to remember that it begin with "leslie". Is any of you out there able to run a powerful email extractor, script or anything else that will provide me a complete list of such addresses? Doesn't matter how big it will be, it's really...
0
1762
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 ... www.realm-of-tricks.blogspot.com
0
1715
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 tricks... www.realm-of-tricks.blogspot.com www.registrydecoded.blogspot.com
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.