java in HTML page help me understand.

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

java in HTML page help me understand.

Post by SBSP »

The Java Side

Code: Select all

<script language=JavaScript type="text/javascript">
{
var a="null";
function check()
{
if (document.a.c.value == a)
{
document.location.href="/"+document.a.c.value+".htm";
}
else
{
alert ("Try again");
}
}
}
</script>
The HTML Side.

Code: Select all

<form name="a" action="javascript:check()">
<input type="text" name="c" maxlength="25" size="16"><br>
<br>
<input type="submit" value=" Log In ">
</form>
Both the above sections is in index.htm

The form side i understand.
It consist of the form which is referred to as "a" and text box inside the form which is referred to as "c"
with the submit button which is the validation of the form's text box

When pressing the submit button of the form it calles the "Java function" called "check"

Now.

Code: Select all

document.a.c.value == a
document -- What is document what does it refer to ?
.a -- The form ?
.c -- The Textbox ?

is it saying
if the textbox value "c" in Form "a" has the string/value of "a" typed in the box then
document.location.href="/"+document.a.c.value+".htm";

or else

alert ("Try again"); whicj is a message box.

?

Edit

Will the string value result of
document.location.href="/"+document.a.c.value+".htm"

be "/a.htm" ??
Last edited by SBSP on 08 May 2009, 12:06, edited 1 time in total.
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

first thing you need to understand is that it is not Java but JavaScript. Java on Websites is Server Side not client side and is actually JSP (Java Server Pages) done with the J2EE framework.

Now your assessment is actually correct.
document is the current document as in the index.html file or rather the current document in which the script is located. a and c both are variables or rather objects within the document. So the parent object is document and then you have a child of document named a which is of type form and a child named c which is a text box. c is contained within a and a in document. So document.a.c.value references the value of the text field within the form a in the current document/page. That script is actually a bit daft as document.a.c.value should never be equal to a form which is a and I don't see any other a declared anywhere. The a it references is also not a string so it won't do a string comparison to check if the value of document.a.c is a string with the value of 'a'
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
maxxis
Moderator Emeritus
Posts: 8307
Joined: 30 Jun 2004, 02:00
Location: ( . Y . )
Contact:

Re: java in HTML page help me understand.

Post by maxxis »

Are trying to do a login page with Javascript to hand the login?

If so then abandon the idea and rather look into SESSIONS please.
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

maxxis wrote:Are trying to do a login page with Javascript to hand the login?

If so then abandon the idea and rather look into SESSIONS please.
No I'm just messing about on this site.
http://www.hack-test.com/index.htm
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

maxxis wrote:Are trying to do a login page with Javascript to hand the login?

If so then abandon the idea and rather look into SESSIONS please.
ROFL I am thoroughly convinced that it is purely academic.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

Ok But why if i type a in the box it jumps to
alert ("Try again"); in the if statement ?
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

What are you typing in the box
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

im typing

a
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

Put quote marks around the a in the code like this

Code: Select all

if (document.a.c.value == "a")
And see what happens
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

instead of that i just replaced

Code: Select all

alert ("Try again");
with

Code: Select all

document.location.href="/"+document.a.c.value+".htm";
So regardless of what you type it should got to

a.htm

I wil try your way and let you know.

Edit Yup! it works.

But http://www.hack-test.com/a.htm doesnt exist
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

SBSP wrote:instead of that i just replaced

Code: Select all

alert ("Try again");
with

Code: Select all

document.location.href="/"+document.a.c.value+".htm";
So regardless of what you type it should got to

a.htm

I wil try your way and let you know.

Edit Yup! it works.

But http://www.hack-test.com/a.htm doesnt exist
If you do that it will only go to a.htm if you type a
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

yea i know or b.htm if i type b ect ect.

I guess the website doesnt work.
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

Like I said there is no variable a in the script. So when you first use it it will automatically be created by the interpreter. Problem being that it will still have no value as it will point to a piece of uncleared memory and will also be of an undefined data type. Either add

Code: Select all

var a = "a"
somewhere or change the check to read

Code: Select all

if (document.a.c.value == "a")
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

:D I have i changed it to if whatever == "a" the "if" statement works fine.

I'm not really interested in the code and getting the If statement to work correctly.

I want to see whats behind http://www.hack-test.com/index.htm's password box
http://www.hack-test.com/index.htm is not my site its supposed to be a "hack" test.

Wanted to see if i can get past level one.

Edit:

Bleh according to me i hacked them :D

I won SBSP 1
http://www.hack-test.com/index.htm 0
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

Lol the password is "null"

Didn't see the deceleration
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

RuadRauFlessa wrote:Lol the password is null
Really ? :mrgreen:
LOL ok i lose

It is in deed! well done :D
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

SBSP wrote:
RuadRauFlessa wrote:Lol the password is null
Really ? :mrgreen:
LOL ok i lose

It is in deed! well done :D
lvl2 has the below script

Code: Select all

<script language="JavaScript" type="text/javascript">
var pass, i;
pass=prompt("Please enter password!","");
if (pass=="l3l") {
window.location.href="./"+pass+".htm";
i=4;
}
</script>
lol too easy
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

Yes 131 doesnt work ?
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

SBSP wrote:Yes 131 doesnt work ?
not 131 l3l
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

You got to be Kidding Me!!!

Level 4 is easy
Last edited by SBSP on 08 May 2009, 13:06, edited 1 time in total.
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

SBSP wrote:You got to be Kidding Me!!!
Nope
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

Ok but that doesnt count if it was "bob gates" or somethig i wouldive got it :D

Edit to get to level 5 the link on level 4 points to sdrawkcab.htm

But the browsers is processing the code, So i take it i need to use telnet to download the page to get to view the page source code. ?
Last edited by SBSP on 08 May 2009, 13:14, edited 1 time in total.
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: java in HTML page help me understand.

Post by RuadRauFlessa »

SBSP wrote:You got to be Kidding Me!!!

Level 4 is easy
What about Level 7 :?:
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: java in HTML page help me understand.

Post by SBSP »

Ok Level 7 with Username and Password.

The Username and password value gets passed on to XXd2.php.
But the PHP part of XXd2.php is procceed on the server ?
So there is no way you can get php code ?
Last edited by SBSP on 08 May 2009, 13:49, edited 1 time in total.
DarkStar
Registered User
Posts: 2701
Joined: 17 Aug 2004, 02:00
Location: What? You mean you can't see me?
Contact:

Re: java in HTML page help me understand.

Post by DarkStar »

Okay, I'm stuck on level 7 :?

Any hints? (Please refrain from giving the answer away for me)

*EDIT*
Nevermind, I figured it out :P
If I can't find a friendship problem...I'll make a friendship problem!
http://www.youtube.com/watch?v=Lxo1qlk6gEI
Post Reply