Use PHP to change your 404 million shopping spree so that its power cannot be met.

Source: Internet
Author: User

404 million users, many people know that if the url to be asked does not exist, it will show this aspect. in the past, in terms of processing 404, our usual practice was to write a single line of text, and some people may still beautify it, in addition, a small number of hackers who want to take advantage of the opportunity even use the meta tag for delayed loading. In fact, 404 can also help us do a lot of things, this is what we will discuss today.

First, let me explain what I can do for 404:

1. He can tell me when and where I am going to use it and ask me which URL is missing.

2. He can tell me why the other party wants to ask this URL and help me compile the website

3. He can tell me the IP address of the other party

4. He can tell me what this person cares about

5. I can ask him to tell me what he doesn't want to tell me.

6. He can send me the email he wants to tell me

7. He can help me with 301 permanent redirection.

8. He can tell me someone is hacking into my website or host.

It sounds very mysterious and dazzling. Well, next we will discuss how he did it. One by one:

1. We can use PHP to capture the source URL and the previous URL of the queue, so we can do it easily first.

2. because of the source URL, you can directly guess the intention of using the website. I have a few examples, just like my website http://www.7di.net, what if a source URL with a cursor is a http://www.7di.net and the current URL captured is a http://www.7di.net/user.php? Id = 1 this means that when this person uploads my website, when he clicks on a person's profile, he cannot find this person. data comes from, note: The Nonexistent token with ID = 1 may have been deleted, so you need to check whether there is a URL overlay on the website, if you have one, you have to try to cancel it!

3. this function is simpler than simply using PHP to capture the ip address of the other party. then, you can use the IP address of another website to locate the physical address of the website.

4. this function is very good, very large. because my website www.7di.net is a self-configured server, we have to handle security issues on our own, some non-streaming groups tend to be interested in other people's server servers. They will use various program-based methods to access the server, at this time, you will find that you have received a large number of 404 million bytes in a short time, and the source URL is empty, the URLs they want to ask are some very sensitive URLs. What you need to do at this time is to open your fireproof configuration, then empty the IP address. recently I used this method to block dozens of IP addresses! I forgot to mention that the IP address of the Information Industry Department has also been blocked. My server is waiting for you to verify what kind of IP address is ~~!

5. to be honest, this plug-in was very difficult at the beginning, because I receive hundreds of emails every day for him, some of them are caused by normal indexing and some by various search engines collecting content, some of them are because they want to intrude into Alibaba Cloud. In the end, they don't need them. Later, I will make some changes, add the exhibition name or IP address to the certificate. as long as these are met, no Email will be sent. This is much more refreshing.

6. all of these functions cannot be used to send emails in PHP immediately. My approach is to modify PHP. INI to realize the internal mail data sending in PHP, of course, if you can also use other methods, such: you can either install sendmail or send a mail to help third-party smtp sending. as long as you are comfortable with it (it is not a theoretical discussion today ).

7. since we can directly ask this question, it is clear that the URL used to answer the question does not exist, therefore, we need to direct the website to the correct URL, so since it is a signed URL or maybe you will simply use a meta tag or a JS extension, why bother with the weekly chapter? what about 301 redirection? Because I don't want to be recognized by search engines as cheating! The answer is complete.

8. I have already mentioned this in the previous article, basically, the judgment on xiaoyun3 is determined based on your experience and familiarity with your own website. What's more, you need to understand which URLs on your website have been reversed by other websites ).

I should say, I should leave it all over. Next, I want to show it, save the next generation of PHP as 404.php, and then apache or nginx will point your 404 million bytes to the past.

<? PHP # Set the URL. Do not strip/$ MyURL = (isSet ($ _ SERVER ['HTTP _ host'])? Str_iReplace ('HTTP: // ', '', StrToLower (rTrim ($ _ SERVER ['HTTP _ host'],'/'): 'www .7di.net '; # Set the URL. Do not strip/$ MyDomain = (isSet ($ _ SERVER ['HTTP _ host'])? 'Http ://'. str_iReplace ('HTTP: // ', '', StrToLower (rTrim ($ _ SERVER ['HTTP _ host'],'/'): 'http: // www.7di.net '; // set the time zone. it is mainly used to modify the 8-hour time difference Date_Default_Timezone_Set ('etc/GMT-8 '); // output Header ('content-type: text/html; charset = UTF-8 '); /** email sending parameter: recipient, email subject (cannot have a line character), and email content (\ n must be used to separate rows and rows, each line must not exceed 70 characters.) Description: You can use a PHP internal Mail to send a Mail to a mailbox and return the following message: return the publish value. Usage: $ IsSend = Fun :: mail2 ($ email, $ tit, $ msg);/**/Function Mail2 ($ to, $ tit, $ msg) {IF (Filter_var ($ to, FILTER _ VALIDATE_EMAIL) = '') {throw new Exception ('email address verification failed! ') ;}$ Tit =' =? UTF-8? B? '. Base64_Encode ($ tit ).'? = '; $ Msg = str_replace ("\ n. "," \ n .. ", $ msg); // If a period is found at the beginning of a line in Windows, it will be deleted. to avoid this problem, replace a period with two periods: Return Mail ($, $ tit, $ msg, 'From: see7di@gmail.com '. "\ n ". 'content-Type: text/html; charset = UTF-8 ');} $ msg = '<table cellspacing = "0" cellpadding = "0" border = "0"> <tr> <td style = "padding: 5px; background-color: # F57900; font-size: 13px; border: 2px solid #222; color: #222; "> '; $ msg. = (isSet ($ _ SERVER ['remote _ ADDR '])? "<B> the IP address of the attacker is: </B> <br> <a href = 'HTTP: // www.ip138.com/ips138.asp? Ip = {$ _ SERVER ['remote _ ADDR ']} & action = 2 'target =' _ blank '> {$ _ SERVER ['remote _ ADDR']} </ a> <br> ": ''; $ msg. = "<B> coming time: </B> <br> ". date ('Y-m-d H: I: s', time ()). '<br>'; $ msg. = (isSet ($ _ SERVER ['remote _ host'])? "<A href = 'HTTP: // www.ip138.com/ips138.asp? Ip = {$ _ SERVER ['remote _ host']} & action = 2 'target = '_ blank'> {$ _ SERVER ['remote _ host']} </ a> <br> ": '<br>'; $ msg. = (isSet ($ _ SERVER ['HTTP _ USER_AGENT '])? "<B> response information: </B> <br >{$ _ SERVER ['HTTP _ USER_AGENT ']} <br> ": ''; $ msg. = (isSet ($ _ SERVER ['request _ URI '])? "<B> the plane to be asked is: </B> <br >{$ MyDomain }{$ _ SERVER ['request _ URI ']} <br> ":''; $ msg. = (isSet ($ _ SERVER ['HTTP _ referer']) And Trim ($ _ SERVER ['HTTP _ referer'])! = '')? "<B> source address: </B> <br >{$ _ SERVER ['HTTP _ referer']} <br> ":''; $ msg. = '</td> </tr> </table>'; // which types of URLs do not send emails, if you do not block them, you can abort me $ arr = Array ('mp3', 'rm ', 'swf', 'jpg ', 'gif '); // which IP addresses do not send emails. These are basically search engine spider $ arrIP = Array ('66. 249.77.217 ', '66. 249.74.67 '); // display name of the worker to be asked $ needEx = Explode ('. ', StrToLower (Trim ($ _ SERVER ['request _ URI']); $ needEx = end ($ needEx); IF (! In_Array ($ needEx, $ arr) And! In_Array (Trim ($ _ SERVER ['remote _ ADDR ']), $ arrIP) {Mail2 ('see7di @ gmail.com', 'from 【'. $ MyURL. '] 404 precondition failed! ', $ Msg);} unSet ($ MyURL, $ msg, $ needEx, $ arr); Header ('HTTP/1.1 301 Moved Permanently'); Header ("Location: {$ MyDomain} "); Die ();

  Note: If you feel that the functions provided in the previous generation cannot meet your expectations, you need to modify them, improve them, and add others, I agree, but please share your work with me. Thank you ~~~~!

Welcome to my PHP Group for discussion, which is 223494678

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.