Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Make A Moderately-secure Password System Using Javascript, using file redirection to hide the password.
gameratheart
post May 14 2008, 10:20 PM
Post #1


Super Member
*********

Group: [HOSTED]
Posts: 492
Joined: 14-November 05
From: Britannia!
Member No.: 14,287



JavaScript is very handy at making forms, allowing for much more customization and easier ways to send data. So making Login forms using JavaScript may seem to many to be a very feasable idea. However, JavaScript is very bad at protecting Passwords, as since the passwords are not encypted and the whole JavaScript code is in the page, a person could just view the Page Source and find out everything. Even if you use an external JavaScript, it would still be poor as the file name for the external JavaScript would still be revealed.

But I have an answer! There is a relatively easy way to make a moderately-secure password system using JavaScript. And here's the trick: you don't use a password at all!

First, make a webpage with the following content:
CODE
<html>
<head>
</head>
<body>
<form name="login">
<INPUT TYPE="password" NAME="password" VALUE="" size="20">
<INPUT TYPE="button" NAME="button" Value="Submit Password" onClick="submitPassword(this.form)">
</form>
</html>

This page will work as the Login Page.

Now, rename the file you wish to protect so that the bit BEFORE the extension is the same as the password you want to use. To prevent people seeing this file, you should disable indexing for the folder it is in.

Now edit the login page again, and in the HEAD tag of the page, add this:

CODE
<script>
<!--- Hide from old browsers
function submitPass() {
  var location;
  var password;
  password=this.document.login.password.value;
  location=password + ".html";
  location.href = location;
}
--->
</script>

If the file you are protecting uses an extension other than .html, change the ".html" bit to match the extension.

This script directs people to the protected file if the password matches, because it uses the entered password as a redirect to the file. So if the password does not match, the users will either be directed to a non-existant file (Error 404), or a completely different file from the one they wanted to get! This method is only "moderately secure", though, because the actual file is not protected and can still be accessed if someone knows the file's name. So you shouldn't use it for high-security files, but if you just want to keep out the general public, this is a good, simple solution.

Oh, and just a disclaimer. Some HTML Help websites appear to be distributing scripts similar to my one. While they follow the same principle as my own, they are in no way a basis for my code. This whole tutorial is completely, 100%, my own writing, and any similarities are purely coincidential.

This post has been edited by gameratheart: May 15 2008, 11:15 PM
Go to the top of the page
 
+Quote Post
Saint_Michael
post May 15 2008, 03:09 AM
Post #2


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,315
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



I would have to disagree that javascript is great at making forms, yeah they can produce some nice little features, but once you get into PHP coding a form in javascript seems 10 years ago. I was thinking though why wouldn't you just code so you can password protect the fold through the hosting admin panel. I know trap17 cpanel has a folder protection process and so if you code the script to follow that password then it saves you the time of trying to hardcode the group of files within that folder. Of course, I think with a bit of tweaking with javascript and php password protection scripting you might be able to add a second layer of protection
Go to the top of the page
 
+Quote Post
osknockout
post May 16 2008, 02:40 AM
Post #3


Super Member
*********

Group: Members
Posts: 397
Joined: 14-November 04
From: Elysium
Member No.: 2,280



Hey! I remember this method! It's pretty ingenious, but rather vulnerable to man-in-the-middle attacks. And packet sniffing will find that plaintext out in a second. I'd rate it pretty good - assuming you have no malignant character with knowledge of network security. What's the chances of tha- oh wait... biggrin.gif

Php does help, but again, man-in-the-middle attacks. I'm pretty sure trap uses ssl. (you know, the https:// stuff). Which itself uses SHA-1 at least if I remember right. Personally, I'd go with SHA-512 cause a break in 2^39 attempts isn't that fun, but we can't be picky with programs developed for us...

(edit: ssl, not ssh. duh...)

This post has been edited by osknockout: May 16 2008, 04:16 PM
Go to the top of the page
 
+Quote Post
gameratheart
post May 23 2008, 07:34 PM
Post #4


Super Member
*********

Group: [HOSTED]
Posts: 492
Joined: 14-November 05
From: Britannia!
Member No.: 14,287



Yes, obviously if you do have any knowledge of PhP or you are using a Hosting Platform with SSL Password Protection (which Trap17 does), you should use these to secure your files instead of the method I mentioned above, as they are much more secure. This tutorial is really meant as a simple alternative for people who are not expirienced with PhP and do not have any other method of Password Protection for their site's content.

And Saint, while you may be right that Javascript's abilities pale in comparision to PhP, that doesn't mean Javascript is an old-skool coding platform. Actually, if you know how to use Javascript cleverly enough, you can use it with PhP to make some awesome scripts. Just look at some of the popular forum software on the web today...
Go to the top of the page
 
+Quote Post
hitmanblood
post May 23 2008, 11:33 PM
Post #5


Privileged Member
*********

Group: [HOSTED]
Posts: 775
Joined: 13-April 07
From: mreža
Member No.: 41,558



OK first of all javascript shouldn't be used for such purposes like forms and security in general because javascript is not secured at all. And this is the main reason why would I discard it as language of choice for such things. So what is the point. It is very simple javascript is being executed on your clients browser and because of that there have beeen developed many different mathods for obtaining or changing javascript on the page.

Javascript should be used only for sending informations back and forth that is I mean on AjAX(asynchronus javascript and XML) and you should use it to make some nice things to your web page like changing on the page in the real time that is without reloading every single part of the page. Like hover overs and mouse clicks when there is no need to send informations to the server and back. You can even use it to send informations back and forth to the server. But don't use it for any security jobs and for gods sake any inputs. But nontheless when you are programming some portal you should be able to check all the data inserted trough the page.

Also consider that php is server executed language and you have more control over it that is the main reason why it should be used against javascript not that one or the other are old fashioned or something like that. But the thing is that you have to have control over what your users are inputting and check all the data this is the main reason. And in the end I would like to mention that both languages have its good and bad things.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Css Trick: Hide Disabled Internet Explorer Vertical Scrollbar(18)
  2. Image Preloader With Progress Bar Status(22)
  3. How To: Change Your Website's Index File(18)
  4. Css And Javascript Combined For Dynamic Layout(9)
  5. Image Rollovers In Javascript(11)
  6. Making Winrar Archives(12)
  7. Transfer File Of Any Size Using Winsock Control(5)
  8. How To: Make A Simple Php Site(21)
  9. Javascript Framework - A Shortcut Javascript(3)
  10. How To Protect A Directory From Being Viewed(4)
  11. The Many Ways To Bypas File Hosting Annoyances(5)
  12. How To Fix Codecs And Movie File Problems(0)
  13. Starting Or Stopping Apache And Mysql Server Via Batch File(0)
  14. How To Set A Password In Bios(2)
  15. *nix File Permissions - An Overview(6)
  1. Flat-file Cms(4)
  2. Simple Scripts In Html And Javascript(7)
  3. How To Make A Simple File Based Shoutbox Using Php And Html(8)
  4. Javascript Scroll Bar(13)
  5. Mootools - My Favourite Javascript Library(3)
  6. Change Your Computer Password(6)
  7. Create A Simple Html Editor With Php And Javascript(3)
  8. Install An Aef Forum Onto The Trap17(11)
  9. How To Hide Your Important Files And Folders(7)
  10. Simple Javascript And Password System(6)
  11. Tutorial : Hide Folder Without Any Softwares(10)
  12. Debug Exe Files(4)
  13. Lesser Known Useful Javascript Features(2)


 



- Lo-Fi Version Time is now: 27th July 2008 - 01:38 AM