|
|
Make A Moderately-secure Password System Using Javascript - using file redirection to hide the password. | ||
Discussion by gameratheart with 11 Replies.
Last Update: November 13, 2008, 2:53 pm | |||
![]() |
|
|
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.
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...)
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...
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.
I'm not going to defend the merit of JavaScript any longer. The only two reasons I posted this tutorial were: 1. To share my knowledge, 2. To give people who know nothing about security a simple option to keep them going until they learn how to use the proper stuff. As such, I don't want any more arguments about how insecure JavaScript is for this purpose.
And Osknockout is right - SSL is some of the best protection you can get.
I did this before, Then it came to the stage of an Epic fail because it would accept any password,
But this works brill.
Thanks.
-Sky
JavaScript will never be good at password protection, but this is one of the most secure methods I have seen.
I tried making a system like this, but added a few extra security features like:
I Added some extra numbers and letters and ran some mathematics function on the password input, before the redirect was performed so a password like
"password" would be checked as "2386hjghfqbttxpsesgf76" (this way, when the URL is displayed in the browser window, the password cannot be seen. I used a frame set on that part of the site, so you would have to look at the source code to see the URL of the logged in part.
I also checked the referrer, of the page with javascript, so that if the page had been linked to, or typed into to URL field in a browser, the user would be redirected to the login page, and asked to log in.
hey, yeah I'm one of those newbs you designed this thing for. I need to implement this in my site for a homework assignment and I copied it just the way that you have it up there. Aaaaaaaand . . . It doesn't work.:..(
The only two things that I added was a background image and a link back to the previous page (in case the person typing the password gave up).
Those two things couldn't possibly have any effect on the form, could they?If you could help, that would be great.-
Osman Sufi
Similar Topics:
Simple Javascript And Password Syst...
Php From File To Javascript
Google 39 s Password System Hit By...
How To Make Your Own Counter Strike Source Dedicated Server! (91)
|
(0) Best Way To Add Paypal To Mediawiki Sites
|
Loading...
HOME 





Google I/O 2010 - SEO site advice from the experts
Google I/O 2011: Life of a Google API Developer

