Based on PHP to explain some of the skills of the brush ticket _php example

Source: Internet
Author: User
Tags ack ticket iptables

The ticket-brushing behavior has always been a difficult problem and cannot be prevented fundamentally.

But we can minimize the damage to the ticket, for example, by artificially increasing the logic limit.

Based on PHP, here are some tips for swiping tickets:

1. Use Curl for information forgery

$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://localhost/2.php");
curl_setopt ($ch, Curlopt_httpheader, Array (' x-forwarded-for:8.8.8.8 ', ' client-ip:8.8.8.8 '));
curl_setopt ($ch, Curlopt_referer, "http://localhost/");
curl_setopt ($ch, Curlopt_header, 1);
curl_setopt ($ch, Curlopt_useragent, "mozilla/5.0" (compatible; MSIE 6.0; Windows NT 5.0) ");
$out = curl_exec ($ch);
Curl_close ($ch);

2, Verification code: the use of very complex verification code

The exact verification code appears not for people, but for machines. Through the complexity and identification of the difficulty of control to block off a part of the ticket machine, so as to reduce the occurrence of the brush ticket. However, with the development of software technology and recognition technology, more and more verification code has lost its preventive function in the face of the advanced brush-ticket software, but the professional brush-ticket machine can be breached. If you do not need to verify the code, the basic vote on the rest of the dish, the verification Code acquisition mode, the use of asynchronous loading, that is, click the input box, to request, after the successful vote, delete the verification code session

3. Limited polling

For example: from 8 o'clock to 23 o'clock in the evening

4. Set Polling interval

After the user votes, how long will it take to continue to vote.

Many polling sites have this limitation, but there's no way to change IP attacks.

5, the results of the vote show: delayed display, friendly display

On the page to vote, JS immediately add 1, but refresh the page, not necessarily immediately show the latest voting results, return status to the page (thank you for your vote!) Or a successful vote! As for no success, said another! )

6, Deduction logic: Common in some software selection, such as voting

This is a killer, backstage run script real-time monitor abnormal growth (brush ticket) items, and then implement the deduction logic
For this item, 10 votes is counted as a vote.

7, cookies: commonly used means. Relatively low-level

After the vote, write a cookie on the client and determine whether the cookie exists at the next vote
However, this approach is very easy to break because cookies can delete

8, encryption Option ID: Some voting options for the ID, for random encryption

Encryption algorithm, add salt, and set effective time, such as 5 minutes
The server side decrypts and validates

9, Nginx limit the number of links

Ngx_http_limit_conn_module
Ngx_http_limit_req_module
Nginx_limit_speed_module

You can use these three modules to limit, but this is not a good workaround

10, Iptables limit

/sbin/iptables-a input-p TCP--dport--syn-m recent--name webpool--rcheck--seconds---hitcount 10-j DROP
/sbin/iptables-a input-p TCP--dport--syn-m recent--name webpool--set-j ACCEPT
/sbin/iptables-t filter-a input-p tcp--dport--tcp-flags fin,syn,rst,ack syn-m connlimit--connlimit-above Nnlimit-mask
32-j REJECT

Specific scripts

 #!/bin/bash # date:2015-09-29 # author:cpz@erongtu.com shopt-s-o nounset export PA Th=/usr/bin/:/bin iptables_log= "/tmp/iptables_conf.log"/sbin/iptables-a input-p TCP--dport--syn-m recent--name W Ebpool--rcheck--seconds--hitcount 10-j drop/sbin/iptables-a input-p TCP--dport m--syn-m recent--name Webpoo L--SET-J accept/sbin/iptables-t filter-a input-p TCP--dport---tcp-flags fin,syn,rst,ack syn-m Connlimit Imit-above--connlimit-mask 32-j REJECT while [true]; Do #sleep 1 for IP in ' Netstat-an | Grep-i ': |grep ' estab ' | awk ' {print $} ' | Cut-d:-F 1 | Sort | uniq-c | awk ' {if ($ > && $2!= ' 127.0.0.1 ') {print $}} ' Do/sbin/iptables-l-n | grep $IP >/dev/null | |  /sbin/iptables-a input-p TCP--dport 80-s $IP-j drop echo "/sbin/iptables-a input-p tcp-s $IP-j Drop" >> ${iptables_log} done 

The above content is small series to introduce you based on PHP to explain some of the skills of the ticket, I hope you like.

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.