byr论坛灌水小工具

原来写过一个模拟登陆byr论坛的脚本:一个CURL模拟登陆论坛的脚本+cookie伪造的方法 

这次改了改,就成了一个小小的灌水机器人。

直接贴代码了:

<?php
/**
 * @author : wusuopubupt
 * @date : 2014-02-19
 * @desc : byr论坛灌水小工具
 * 
 * 利用crontab定时任务跑,每次随机出一个用户,再随机出一句回复,然后就可以模拟登陆灌水了。
 * */
$url = "http://bbs.byr.cn/wForum/logon.php";

//这里可以弄成一个用户数组,每次随机出来一个用户
$field_data = "id=yourusername&passwd=yourpassword&CookieDate=2";


// first time curl request,get cookie
$ch = curl_init ($url);
$cookie_jar = tempnam (".", "cookie");

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); // save cookie
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.81 Safari/537.36" );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $field_data);
curl_exec($ch);
curl_close();

// second time curl request, use formar getted cookie
$url = "http://bbs.byr.cn/wForum/dopostarticle.php";
$reply = array(
		"ding","好诗!","这个节目很好看","还有特别逆天的小朋友","小朋友好可爱","bd"
);
$random = mt_rand(0,5);
$post_data = "board=Poetry&reID=23100&subject=poetry&Content=$reply[$random]&signature=1";
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar); // use cookie
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_exec($ch);
curl_close($ch);

/*---------------------*/
#这是初步想法,如果有更好的办法,请指出~#


你可能感兴趣的:(byr论坛灌水小工具)