How to write a 12306 leaked data query like Btgoogle

Source: Internet
Author: User

Demo Address: http://www.btgoogle.com/12306/

Christmas, 12306 gave us a big gift. About 14w of data leaks, see the internet are uproar. began to look for a database to see, then, I got a copy of the data about 14M is

143,863 Total Data

The. File is leaking files in txt format. When someone in the group got the data. Be prepared to make a Web site with a 12306 compromised database. Provide a list of other people who have queried whether they are leaking information.

Information is this form of

At that time, some people began to be more than speed, programmers are good face ~ ~ ~

Some say 5 minutes to fix it. It's been almost 5-10 minutes. It's really done.

His method is to use the regular matching local file, and then get the email within the site via get and then regular match to the output has been compromised.

  1 <?php  2  3 $email = $_get["email"];  4  5 $L = preg_split ("/\n/", file_get_contents ("12.txt");  6  7 foreach ($L as $c) {  8     if (Preg_match ("/{$emaul}/", $c)) {  9             echo "leaked";     } 12}

Oh, oh, this really is to dispose of this. This is faster than the speed.

However, we still process the data step-by-step and then storage, and then query it. Altogether it is 14w multi-data, and it is obviously not necessary to start considering the use of Sphinx.

The speed is good. Start preparing to use it under this

Order by rand () limit 50

Gets the information for a random 50 users. Using this statement takes more than 6 seconds per execution, and it does take time, and then the site crashes for a while.

The following are the same problems encountered in the treatment.

*****************************************************************

Sql OrderBy Rand stochastic data optimization and performance comparison

From: http://www.111cn.net/database/mysql/53036.htm

Originally using Order by rand (), it was tragic to find tens of thousands of data for 10 seconds.

The code is as follows Copy Code

SELECT * from ' table name ' ORDER by rand ()

Display Line 0-29 (154,825 total, query takes 10.1125 seconds)


Later on the online search for the following methods, the same data feel greatly improved (here is the test of 15W data)

The code is as follows Copy Code

SELECT * FROM table name WHERE ID >= ((select MAX (ID) from table name)-(select MIN (ID) from table name)) *

RAND () + (SELECT MIN (ID) from table name) LIMIT 10

Display Line 0-29 (154,825 total, query takes 0.0221 seconds)

Feel good, a friend said with a join may be better, when looking for a code to test the query spent 0.0025 seconds, but also provide several times ah.

The code is as follows Copy Code

SELECT *
From table name as T1
JOIN (
SELECT ROUND (RAND () * (
SELECT MAX (ID)
From table name) as ID
) as T2
WHERE t1.id >= t2.id
ORDER by T1.id ASC
LIMIT 10

Display Line 0-9 (10 total, query takes 0.0025 seconds)

Finally, we can optimize

The code is as follows Copy Code

SELECT S_url,title
From table name as T1
JOIN (
SELECT ROUND (RAND () * (
SELECT MAX (ID)
From table name) as ID
) as T2
WHERE t1.id >= t2.id and t1.z_type = $z _type ORDER by t1.id ASC LIMIT 10

Display Line 0-9 (10 total, query takes 0.0008 seconds)

To summarize, if we use the same method in the field selection, the less the better, this does not fall from 0.0025 directly to 0.0008 seconds oh.

*****************************************************************************************************

This part is used in the back of the HTML static.

Then you need to process this file and process it into the database, where I use MySQL. For the processing of strings, directly with the editor's own regular match out of the line.

———— It is easy to see that many of these forms are replaced directly by ', ' in this form, and the corresponding characters need to be added after each front. ^ matches the beginning $ match end.

After the data is stored, the direct query output is directly using the PHP front end.

Here is the key code.

$email =$_get[' s ']; $q = "select * from ' user ' WHERE email= ' $email '"; $r = @mysqli_query ($dbc, $q); Echo ' 

Demo Address: http://www.btgoogle.com/12306/

How to write a 12306 leaked data query like Btgoogle

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.