Any code to hide style.css link

Started on the old forum in December 2009 · view the original in the archive · old links redirect here

74 replies · 3,682 views · started 16 years ago · 1 min read

TL;DR · summary of 74 replies
  • - CSS cannot be fully protected from those who know how to look at it.
  • - The only practical method mentioned was hiding the CSS file by changing its name or moving it out of the public directory, which is not a foolproof solution.
  • - Some suggested using PHP Encoder for obfuscating PHP scripts but noted that this does not protect CSS files.
  • - No clear code approach or example was provided to hide CSS.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

28 participants
amylee Principal · 1,092 posts #61

GiLL wrote: you can try to see my css if you get success paste here
link is here Downloads

easy...

body {
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
background-color: #ffffff
}

table {
  WIDTH: 100%
}
.nounderline {
  TEXT-DECORATION: none;
}
.oddrow {
  BACKGROUND-COLOR: #FFCCFF;
}

.mainrow {
  BACKGROUND-COLOR: #FF0099;
}
 td.left{text-align: center; width:20px;}
 td.right{text-align: left;}
 a{color:#0000ff}
 div {margin: 1px 0px 0px 0px; padding: 2px;}
 div.pagetop {padding: 3px; text-align: center; background: #ffffff; border: 0px}
 div.header { padding: 5px; margin: 0px; font-weight: bold; text-align: center; background-color: #FFCCFF; border-bottom: 1px solid #b1cade}
 div.upban { padding: 3px; background-color: #EFF3F6; border-bottom: 1px dotted #AFCDDC}
div.body {
background-color : #ffffff;
padding: 2px;
border : 1px dotted #AFCDDC;
}
 div.body1 { padding: 3px; background-color: #ffffff; border-bottom: 1px dotted #AFCDDC}
 div.downban { padding: 3px; background-color: #EFF3F6; border-bottom: 1px solid #FFFFFF}
 div.copyright { padding: 3px; background-color: #73A2C6; border: 0px}
div.footer   { padding: 1px; background-color: #87CEFA;  border: 1px dotted #AFCDDC}
div.wform{
        background-color: #6699FF;
        padding: 5px 2px 2px 2px;
        margin: 3px 0 0;
        border-width:1px 0;
        border-style:solid;
        border-color:#000;
}
hr {
        background-color: #000000;
        color: #000000;
        border: none;
        height: 1px;
}
a:active, a:visited, a:link, a.ads:active, a.ads:visited, a.ads:link {
color : #0080c0;
}
a:hover {
color : #004040;
}
a.add {
color : #66cc00;
}
a.add:hover {
color : #ff0000;
}
form > fieldset {
border : 1px solid #cccccc;
}
form {
margin : 2px;
}
input, textarea, select {
margin : 2px;
font-family : Verdana, arial;
font-size : 11px;
border : 1px solid #0080c0;
}
div.xxx {
background-color : #F5F5F5;
}
img.image {
margin: 0px 1px 1px 1px;
padding: 2px 2px 2px 2px;
border-style: solid;
border-width:1px;
border-color:#ff0080;
}
modfiles Developer · 200 posts #62

i got same result with amy. its one of the easiest site that posted in this topic to get the css. direct link from the source.

sklbd Junior · 47 posts #65

GiLL ,,,,,,,,, u r protected but tell ur way

ShaK!L AhammeD

Sklifbd.CoM +88-01730039272

ori Lead · 512 posts #66

lol same goes with my site u cant directly download my css as its php but there are other ways to get the code but cos mine is php and css combined then u only see the generated css code

http://wapdesire.com/style.php anyway see what you's can get from that link

metulj Super moderator Principal · 1,726 posts #67

ori wrote: lol same goes with my site u cant directly download my css as its php but there are other ways to get the code but cos mine is php and css combined then u only see the generated css code

http://wapdesire.com/style.php anyway see what you's can get from that link

something like this

body {background-color:#000000; color:#ffffff; font-family:Georgia; font-size:medium;}
head {font-size:medium;}
img {border:0;}
.img {margin:10px;}
small, big, i {color:#4a4839;}
a, a:active, a:visited, a:hover {color:#3366ff; text-decoration:none;}
p, div {text-align:center; width:100%;}
.center { text-align:center; }
.bold { font-weight:bold; }
.adblock, .adblock2 { background-image:url("/images/style/adblock_bg.png"); background-repeat:repeat-x; color:#000; margin:2px 0px 2px 0px; padding:2px 0px 2px 0px; }
.adblock a, .adblock2 a { font-weight:bold; color:#3366ff; }
.adblock a:hover, .adblock2 a:hover { font-weight:bold; color: #ff0000; }
.adblock img, .adblock2 img { height:20px; }
.title { color:#ffffff; padding:2px 0px 2px 0px; background-image:url("/images/style/3366ff_header_bg.png"); background-repeat:repeat-x; background-color:#000000; }
.navi { color:#ffffff; font-size:small; padding:2px 0px 2px 0px; background-image:url("/images/style/3366ff_footer_bg.png"); background-repeat:repeat-x; background-color:#000000; }
.navi a, .navi a:active, .navi a:visited { color:#000000; }
.navi a:hover { color:#ffffff; }
.warn { background-color:#ffe1bb; color:#000; font-size:small; padding:0px 20px 0px 20px; border-bottom:1px solid #ff9900; border-top:1px solid #ff9900; }
.error { background-color:#fda9a9; color:#000; font-size:small; padding:0px 20px 0px 20px; border-bottom:1px solid #ff0000; border-top:1px solid #ff9900; }
.ok { background-color:#c1ffc1; color:#000; font-size:small; padding:0px 20px 0px 20px; border-bottom:1px solid #00c000; border-top:1px solid #ff9900; }

?

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

GiLL Senior · 356 posts #68

sklbd wrote: GiLL ,,,,,,,,, u r protected but tell ur way

Note : its not fully protected but at last people cant get your css as link to your css file like we do as domain/style.css etc

We're going to use .htaccess and PHP for this.

This is what we are going to do: In the index file, before we include the CSS file, we're setting a key (using sessions) and in the CSS file, we check if the key is set and if it's not, we make it stop executing the code so it wont output any CSS. And if the key is set, we output the CSS code and change the key to something else.

So basicly, the CSS file won't work without the index file, because that's where the key is set.

Still don't get it? Don't worry, you'll understand when we're done coding it.

Let's start by creating a file called index.php with this code inside

<?php
session_start();
$_SESSION['csskey'] = "hello";
?>

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
        Hello World
    </body>
</html>

It's very important that you don't use session_start(); before any output is sendt back to the visitor. So we're putting it at the top. $_SESSION['csskey'] = "hello"; -That's our key. We store the key in a session called csskey.

Now it's time for the CSS file, but since we're going to check if the session is set, we need to use PHP, so we'll have to call the file style.php NOT style.css.

<?php
session_start();
header("Content-type: text/css");

if ($_SESSION["csskey"] != "hello") {
    die("Protected");
}

$_SESSION["csskey"] = "somethingelse";
?>

body {
  background-color: #000;
  color: #fff;
}

We use session_start(); here too, and then we set the content-type to text/css so the browser will interpet it as a CSS file (not really necessary) Then we check if the csskey is NOT set to "Hello" and if it isn't we call die() wich stops the script and outputs "Protected". If the key is set and is correct, we set the csskey to "somethingelse" so that it can't be used again without beeing called from index.php

And for the final step, create a file called .htaccess with this inside:

RewriteEngine on
RewriteRule style.css style.php

This will make style.php "look like" style.css. So when someone tries to open style.css they will get the contents of style.php.

Try uploading these three files and run it. If it works, index.php will output "Hello World" with white text and black background. Also, try looking at style.css from your browser, all it should say is "Protected".

This method is far from bulletproof but it's better then nothing if you want to protect your CSS from rippers.

left wap stuff

youngbobby Developer · 55 posts #69

lol could you post a demo lets see exactly one @ work somewhere?

Naijatop.net = Mobile Traffic Booster 👑

📖 YoungBobby.com = Bobby's BLoG 😁

You're Welcome !!

firemax Developer · 221 posts #71

yes gill. it works,

but not possible for web browsers. only you can block access remotely.

browse the page with Firefox, then view the source of page and click on the css file link.now you get the source of your css.

for better results, you must block all web browsers.

but you can't do it 100%. because if someone need a your css, he can access with them web browser using a 3rd party tool.

in my idea, client side code hiding not possible.

External image (may be gone) Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader PHP Tutorials: [How to Secure Your PHP Script (PHP SECURITY)](http://coding-talk.com/f14/how-to-secure-you…

amylee Principal · 1,092 posts #72

just face the facts there is no way to hide the css ffs...

there is always going to be people with no artistic/graphical talent who want to copy other peoples sites if you want to be unique design your site more uniquely rather than protecting the ****ing css as that's a waste of time

metulj Super moderator Principal · 1,726 posts #73

firemax wrote: yes gill. it works,

but not possible for web browsers. only you can block access remotely.

browse the page with Firefox, then view the source of page and click on the css file link.now you get the source of your css.

for better results, you must block all web browsers.

but you can't do it 100%. because if someone need a your css, he can access with them web browser using a 3rd party tool.

in my idea, client side code hiding not possible.

FYI... you CANT block all web browsers ❗ i browse all mobile sites(where WEB browsers are BLOCKED!) with my PC❗ so... forget about that idea.. as for hidding *.CSS file... forget about that aswell... theres NO way to do it so far❗

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

djlee Developer · 224 posts #74

theres no way to do it SO FAR, and there NEVER will be. You cant hide client side language, the client needs to interpret what you send it to do what its gotta do. To that end if the client can get it then so can the user. even if someone brought out httpV2 that encrypted the source, browsers would need the decryption algorythm in order to use the data and therefore the user can extract that data (and that still wouldnt stop someone viewing the source unless browsers stopped that ability or only showed the encrypted stuff to make it harder for style thieves, which they wont ever do as theres no point).

The best thing you can do is run things through obfuscation, that means use stupid css names (i.e. instead of div.header use .jh6fds6f67dshfjsdhkj) and then make it all one line, at least that way you;d be making the user work to steal the code, and in many cases they will give up.

Another thing is that blocking browsers is also impossible, the only thing you can really use is the user agent string, anyone with an ounce of browser know-how can edit their UA string to reflect a mobiles UA string

There is javascript code to help hide the html source too, but that relies on javascript browsers to even use the site (dont think thats too good of an idea for mobile sites just yet) and even then it only causes them hassle, thats still breakable pretty easily

metulj Super moderator Principal · 1,726 posts #75

djlee wrote: theres no way to do it SO FAR, and there NEVER will be. You cant hide client side language, the client needs to interpret what you send it to do what its gotta do. To that end if the client can get it then so can the user. even if someone brought out httpV2 that encrypted the source, browsers would need the decryption algorythm in order to use the data and therefore the user can extract that data (and that still wouldnt stop someone viewing the source unless browsers stopped that ability or only showed the encrypted stuff to make it harder for style thieves, which they wont ever do as theres no point).

The best thing you can do is run things through obfuscation, that means use stupid css names (i.e. instead of div.header use .jh6fds6f67dshfjsdhkj) and then make it all one line, at least that way you;d be making the user work to steal the code, and in many cases they will give up.

Another thing is that blocking browsers is also impossible, the only thing you can really use is the user agent string, anyone with an ounce of browser know-how can edit their UA string to reflect a mobiles UA string

There is javascript code to help hide the html source too, but that relies on javascript browsers to even use the site (dont think thats too good of an idea for mobile sites just yet) and even then it only causes them hassle, thats still breakable pretty easily

very well said❗ as theres no need to say or add anything more, i believe this topic is ready to be locked8)

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close