TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-26-2008, 10:39 PM   #1 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default Hide files being accessed directly?

I want to hide js from being viewed directly..
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 02-26-2008, 10:50 PM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Putting this in your .htaccess file should do it

Quote:
IndexIgnore */*
TlcAndres is offline  
Reply With Quote
Old 02-26-2008, 10:59 PM   #3 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

I do a similar things to protect my PHP library / includes folder. I have a .htaccess file in each folder I want protected with:

Code:
deny from all
In it. If a user tries directly access any file in that folder, they get a 403 Forbidden error.

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 02-26-2008, 11:00 PM   #4 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Sometimes I think 403 errors are just nasty to look at.
TlcAndres is offline  
Reply With Quote
Old 02-26-2008, 11:06 PM   #5 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

That's why you use custom error handlers to display a nice friendly error to your visitors

I'm a firm believer that a visitor should never be shown a PHP or HTTP error message directly. The message should be logged and a nice friendly error page should be shown to the user.

display_errors = Off !

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 02-26-2008, 11:53 PM   #6 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

Quote:
Originally Posted by Nor View Post
I want to hide js from being viewed directly..
That's impossible since the JS is loaded in the page. Best way is to obfuscate the code. For example this javascript file from Google Maps. It would take a very long time to figure it out that code.

Sending the people to a 403 page when accessing the javascript will break your page IIRC. The browser sends the request for the javascript page not the server so when someone tries to load the page the request for the javascript will return a 403.
__________________
Eric
wGEric is offline  
Reply With Quote
Old 02-26-2008, 11:59 PM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Yeah, the browser makes a call to the javascript, not the server. Therefore a deny all statement would block all access whatsoever to the file.
__________________

Village Idiot is offline  
Reply With Quote
Old 02-27-2008, 12:07 AM   #8 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

As Javascript doesn't require any line termination character -- not even a semi-colon or a line break, making it utterly confusing is fairly straightforward. Simply place the entire Javascript code on 1 line.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 02-27-2008, 04:08 PM   #9 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

I'm using dean edwards packer but theres a unpacker -.-.. is there any other JS encrypters?
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 02-27-2008, 04:12 PM   #10 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

No, JS is client side so you would have to make them install something on their browser. Its as simple as this, if the client's browser can run it, the client can view the source.
__________________

Village Idiot is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design