I wanted to write an article about the web page for a long time.Source codeBlockedArticle. This is because, after many JS scripts are compiled, we are also worried about the sourceCodeIt will be seen and stolen by others. Therefore, I have been trying my best to maintain the security of the source code of my webpage. Although no completely secure blocking method has been found yet (that is to say, these methods have known their weaknesses and cracking methods while I have come up with them), however, I have a lot of blocking ideas here. Let's summarize them.
As we all know, to protect a page, the most basic thing is to shield right-click. The most commonly used function click () on a webpage is the following code:
<SCRIPT> 〉
Function click (){
If (event. Button = 2 ){
Alert ('Welcome to this website !! ');
}
}
Document. onmousedown = click
</SCRIPT> 〉
However, this blocking method is also well known. That is, you can click the left mouse button and right-click to view the right-click menu. However, I have seen a good method of blocking right-click. Its principles are different from those mentioned above. It is not a script written in JS, but a restriction to define webpage attributes. In addition, JavaScript scripts should be avoided as much as possible during blocking. As long as the browser disables the Javascript script in IE. All blocking is in vain.
In this case, we will continue to use the method of modifying the webpage attribute to shield right-click the webpage. This method uses the "body" in HTML for modification. It has only one line of code:
<Body oncontextmenu = self. event. returnvalue = false> 〉
Oncontextmenu is defined here. If the right-click value is false, the right-click is blocked. Now, try again to hack the attack method just now. You can no longer right-click the shortcut menu when you press the Left or Right button. No, but try other methods. No matter how messy you are, right-clicking is useless. Because the right-click does not exist on this webpage. What can you do for a nonexistent function key?
However, blocking the right-click operation does not solve the problem. If I want to copy a text clip or an image. Then, press Ctrl + C and press Ctrl + V to copy and paste it. By the way, what we will talk about next is to shield the left button (what? Shield left button? So this web page is almost useless? Don't worry. If you don't finish it, it's annoying to leave only one function.
As mentioned above, it is useless to use js to block the website and to eliminate the symptoms. Then, we can use HTML, the most basic language of the web page. Define the <body> 〉. The parameter used this time is onselectstart. Is the left-click selected parameter. The Code is as follows:
<Body onselectstart = "Return false"> "〉
In this way, the left-click selection function is easily blocked. The principle is the same as above. Now, it is useless to select any content with your left-click. Naturally, you cannot press Ctrl + C or Ctrl + v. Now let's merge the two parts. Completely control the left and right keys! :
<Body oncontextmenu = self. event. returnvalue = false onselectstart = "Return false"> "〉
Now, the left and right keys are solved.
Okay. Now let's look at another question. As you all know, in the "View" item in the menu bar of IE browser. There is a "view source code" option. In this way, although we shield the right-click View Source code. However, you can still see the source code by checking the source code in the menu bar. What should I do?
My initial idea was to use a framework to avoid viewing the source code. That is to say, as long as a Web page is embedded in the framework, only the source code of the Framework web page can be viewed in the menu bar. The general format is as follows:
<HTML> 〉
<Head> 〉
<Meta HTTP-EQUIV = "Content-Type" content = "text/html; charset = gb2312"> "〉
<Title> title of this website </title> 〉
</Head> 〉
<Frameset rows = "47, *" framespacing = "0" border = "0" frameborder = "0"> "〉
<Frame name = "Header" scrolling = "no" noresize target = "Main" src = "top.htm"> "〉
<Frame name = "Main" src = "main.htm" scrolling = "Auto" target = "_ Self"> "〉
<Noframes> 〉
<Body> 〉
<P> This webpage uses a framework, but your browser does not support the framework. </P> 〉
</Body> 〉
</Noframes> 〉
</Frameset> 〉
</Html> 〉
It seems that the other party does not directly see your source code. However, if a person wants to look at your source code, he can probably understand it. If you understand HTML, you can see what these two sentences mean:
<Frame name = "Header" scrolling = "no" noresize target = "Main" src = "top.htm"> "〉
<Frame name = "Main" src = "main.htm" scrolling = "Auto" target = "_ Self"> "〉
These two sentences mean that the top.htm webpage file in the relative region is used at the top of the header( 网page. The main.htm webpage file is used in the main(also occupies the location of the webpage. These two points are critical, and we will not explain anything else. The above method of hiding source code by using the framework is to display the page in the main section. Set the header size to 0. However, in this way, you can still view the source code of the Framework webpage by checking the source code in the menu bar. As long as you see these two sentences, you will know the method we used earlier. That is to say, you only need to change the name of the Framework webpage to the target webpage, and then you can directly view the source code of the target webpage in the same way. For example, frame webpage: Ghost. In this way, you can directly browse the protected web page, and the source code blocking effect is still not achieved.
Some may think that if the other party does not see the source code of the Framework webpage. What do you mean to open the protected webpage directly? Yes. This is what I will talk about next. If you want to view the source code in the menu bar of a page, it will be ineffective. The simplest way is to remove the menu bar. This can be achieved through a pop-up window. The reason why you do not use a hyperlink to open a menu bar window is that the target address is exposed. The viewer can directly enter the address in the browser and bypass the blocked menu bar. To use a hyperlink to open a page without a menu bar, you must use the link in a webpage that has been blocked by source code.
Then, let's take a look at how to remove the menu bar using the pop-up window. What we need to do is to open the target webpage in an advertisement bar. This code is available on almost every large website. The Code is as follows:
<SCRIPT> 〉
<〈! --
Window. Open ("red.htm", "Red", "resizable = Yes, width = 500, Height = 300 ");
--> --〉
</SCRIPT> 〉
Hosts web files. At this time, we will talk about a window without a menu bar displaying red.htm. Well, we have achieved our goal. However, this window has a defect that there is no scroll bar. Because there is no parameter about the scroll bar in the window. Open statement, (or do I know? You are welcome to send a letter), so we recommend that you only make the webpage navigation page.
However, to cancel the menu bar using the preceding method, you must have a second-party webpage for pop-up. The page used to pop up the window becomes a problem. For example, assume that an index.htm is used for the pop-up window. When index.htmis opened, the red.htm menu bar window is displayed. As we mentioned above, if you know the address of a webpage, you can see its source code whether or not the webpage is hidden in a menu bar. In that case, exposing the red.htm address becomes the key to solving this problem. However, you only need to open the index.htm to see the source code. But if we shut down index.htm? You only need to disable index.htm before the visitor has the permission to keep its source code. So, you have to write some articles in this index.htm.
That is, add the code to close the webpage.
Then, we can use window. Close to close the window. The Code is as follows:
<SCRIPT> 〉
<〈! --
Window. open ();
--> --〉
</SCRIPT> 〉
Now let's merge the two parts of the Code. Now, the result is that a window without a menu bar is opened. Because the processing speed of the computer is very fast, if we write these two pieces of code together, we can only see the newly created window. The Code is as follows:
<SCRIPT> 〉
<〈! --
Window. Open ("red.htm", "Red", "resizable = Yes, width = 500, Height = 300 ");
Window. Close ();
--> --〉
</SCRIPT> 〉
The original window was closed without notice. In this way, let alone view the source code of the webpage. Here, the webpage with the source code above serves as a stepping stone. But here, we should pay attention to the following points. First, the name of the webpage used for board jumping is index.htm. Change the default homepage name to a new one. In this way, the browser can automatically access the page after entering the network. But does not let the other party know the name of the page. Otherwise, the other party may guess the location of the page. For example, 172.0.0.0/index.htm. In this way, you can view the source code of the page by submitting view-source: http: // 172.0.0.0/index.htm in the browser.
After shielding the menu bar and toolbar, we thought, how nice would it be if there were no top windows? The premise for us to do the following is to open a window without a menu bar on the stepping stone page as mentioned above. What should we do? Let's show only the content in the website content window. (Yes, isn't the website browsed by others? What are the functions of browsers and windows ......) All content is removed. We can use JavaScript. The following code defines features without any window:
<SCRIPT> 〉
Function open1 (URL ){
Newwin = Window. Open (URL, 'newwindow', 'fullscreen = 1 ')
Newwin. resizeTo (800,600)
Newwin. moveTo (screen. width/0-800, screen. Height/0-600)
}
</SCRIPT> 〉
Function open1 (URL) defines the hyperlink writing method. Therefore, when writing the link address, we should write javascript: open1 (URL) as follows ). For example, to open a Sina Homepage without window features, you should write javascript: open1 ('HTTP: www.sina.com.cn ') in a text or image hyperlink '). Of course, the brackets also support relative paths. The final format should be:
<SCRIPT> 〉
Function open1 (URL ){
Newwin = Window. Open (URL, 'newwindow', 'fullscreen = 1 ')
Newwin. resizeTo (800,600)
Newwin. moveTo (screen. width/0-800, screen. Height/0-600)
}
</SCRIPT> 〉
<Body oncontextmenu = self. event. returnvalue = false onselectstart = "Return false"> "〉
<TD width = "100%"> <a href = "javascript: open1('main.htm'), window. close () "> </a> </TD> 〉
</Body> 〉
In this way, we can open a webpage without a window. In addition, the scroll bar is automatically added to the webpage, so that the following content will not be visible as before.
The last thing we need to do is encrypt every page or key page that you think is important. I don't need to talk about how to encrypt the source code of a webpage? There are everywhere on the Internet. You can use tools or write an HTM file for conversion. For the encryption software, I recommend "batch HTML encryptor". Go to Google to find it. The code for converting encrypted Web pages is as follows:
webpage encryption and decryption
<〉〈! -- Software studio --> href = "style.css" rel = stylesheet>
<〈 /head>
< br>
style = "Left: 139px; width: pixel PX; position: absolute; top: 52px; height: 36px ">
<〉〈! -- Dwlayouttable -->
|
function initstyleelements ()/* styles for buttons init */
{
var c = document. PAD;
If (IE)
{< br> // C. text. style. backgroundcolor = "# dddddd";
C. compileit. style. backgroundcolor = "# c0c0a8";
C. compileit. style. cursor = "hand";
C. select. style. backgroundcolor = "# c0c0a8";
C. select. style. cursor = "hand";
C. view. style. backgroundcolor = "# c0c0a8";
C. view. style. cursor = "hand";
C. retur. style. backgroundcolor = "# c0c0a8";
C. retur. style. cursor = "hand";
C. clear. style. backgroundcolor = "# c0c0a8";
C. clear. style. cursor = "hand";
}< br> else return;
}
/* Buttons Enlightment of "Compilation" Panel */
Function lighton (what)
{
If (IE) What. style. backgroundcolor = '# e0e0d0 ';
Else return;
}
Function focuson (what)
{
If (IE) What. style. backgroundcolor = '# ebebeb ';
Else return;
}
Function lightout (what)
{
If (IE) What. style. backgroundcolor = '# c0c0a8 ';
Else return;
}
Function focusoff (what)
{
If (IE) What. style. backgroundcolor = '# dddddd ';
Else return;
}
/* Buttons Enlightment of "Compilation" Panel */
Function generate ()/* generation of "Compilation "*/
{
Code = Document. Pad. Text. value;
If (CODE)
{
Document. Pad. Text. value = 'compiling... please wait! ';
SetTimeout ("compile ()", 1000 );
}
Else alert ('first enter something to compile and then press compileit ')
}
Function compile ()/* The "Compilation "*/
{
Document. Pad. Text. value = '';
Compilation = escape (CODE );
Document. Pad. Text. value = "<SCRIPT> \ n <〈! -- \ Ndocument. Write (Unescape (\ "" + compilation + "\"); \ N // -- >\ n <\/ SCRIPT> 〉";
I ++;
If (I = 1) Alert ("Page compiled 1 time! ");
Else alert ("Page compiled" + I + "times! ");
}
Function selectcode ()/* selecting "Compilation" for copying */
{
If (document. Pad. Text. value. length> 0)
{
Document. Pad. Text. Focus ();
Document. Pad. Text. Select ();
}
Else alert ('Nothing for be selected! ')
}
Function Preview ()/* preview for the "Compilation "*/
{
If (document. Pad. Text. value. length> 0)
{
PR = Window. open ("", "preview", "scrollbars = 1, menubar = 1, status = 1, width = 700, Height = 320, Left = 50, Top = 110 ");
Pr.doc ument. Write (document. Pad. Text. value );
}
Else alert ('Nothing for be previewed! ')
}
Function uncompile ()/* decompiling a "Compilation "*/
{
If (document. Pad. Text. value. length> 0)
{
Source = Unescape (document. Pad. Text. value );
Document. Pad. Text. value = "" + Source + "";
}
Else alert (you need compiled code to uncompile it! ')
}
// --> //--〉
</SCRIPT> 〉
<Br> <B> <font color = #333333> webpage HTML source code encryption encryptor </font> </B> </H2> </div> 〉
<Table cellspacing = 0 bordercolordark = #000000 cellpadding = 10 width = 750
Align = center bordercolorlight = # ffffff border = 2> 〉
<Tbody> 〉
<Tr> 〉
<TD> 〉
<Div align = center> <br> paste your source code to the editing area. <br> 〉
<Table cellspacing = 0 cellpadding = 0 width = "100%" border = 0> 〉
<Tbody> 〉
<Tr> 〉
<TD width = "100%"> <"〉〈! -- Compilation panel --> --〉
<Form name = pad method = post align = "center"> "〉
<Div align = center> <textarea style = "width: 95%; Background-color: # ebebeb" name = text rows = 11 Cols = 58> </textarea> 〉
<Br> <input onmouseover = lighton (this) onclick = generate () onmouseout = lightout (this) type = button value = encrypted name = compileit> 〉
<Input onmouseover = lighton (this) onclick = selectcode () onmouseout = lightout (this) type = button value = select all> 〉
<Input onmouseover = lighton (this) onclick = Preview () onmouseout = lightout (this) type = button value = preview name = View> 〉
<Input onmouseover = lighton (this) onclick = uncompile () onmouseout = lightout (this) type = button value = decryption name = retur> 〉
<Input onmouseover = lighton (this) onmouseout = lightout (this) type = reset value = clear name = clear> 〉
</Div> </form> <〉〈! -- Compilation panel --> </TD> </tr> </tbody> </table> </div> </TD> </tr> </tbody> </table> 〉
<Div align = center> <br> </div> 〉
<Div align = center> </div> & nbsp; </TD> </tr> </tbody> </table> 〉
</Div> 〉
<Div> </body>
To sum up ...... Based on my ideas, the source code of blocked web pages is divided into the following steps:
1. Create a webpage stepping stone, pop up the advertisement page to be protected, and close itself to avoid leaking the address of the webpage to be protected.
2. Because the above conditions shield the source code of the webpage in the advertisement bar, you can use this webpage as the welcome page.
3. On the welcome page, use JavaScript to display website content in a new window without window edge in the form of hyper-connection.
4. encrypt the source code of each page or an important key page, and add a lock to the source code. (Some people say it is useless to encrypt the source code, but I think it is necessary to use an alternative encryption method. For example, the software encryption method is very common. However, the source code encrypted with an HTM file written by me cannot be decrypted by general software. If you are interested, try it .)
5. The last thing I have to mention is the temporary windows webpage folder, which will record the source code. But you don't have to worry about it. By adding a code, you can enable Windows to directly browse without downloading the source code of the webpage. You can look for it.
Note the following:
1. The statement used to automatically close a web page: window. Close () has a drawback. The system will ask whether to close the window before closing the window. If you choose not to close the window, the purpose will not be reached.
2. All of the above are only valid for IE browsers. If other browsers are used for browsing, blocking may fail.
3. Web page source code shielding has always been beyond reach. I just wrote down my ideas. The specific implementation depends on everyone's own research.