六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 48|回复: 0

一个简单的投票机

[复制链接]

升级  78%

47

主题

47

主题

47

主题

秀才

Rank: 2

积分
167
 楼主| 发表于 2013-1-29 11:48:47 | 显示全部楼层 |阅读模式
 
刚才无意间看到一个投票,在页面右键,源码,看了下,就几个字段,很简单。
 
打开eclipse,操上httpclient模拟下,就可以投票了。
 
然后循环,,,, 发现“对不起,您已经提交了”。加了验证,没有登录可以提交,过了会刷页面还是可以提交。
说明不是通过ip控制了,那就是用ip+时间控制的了。
 
试了下,10s的延时可以,9s都貌似不行。
 
投票地址:
http://page.vote.qq.com/?id=141068&result=yes
 
 
投票代码:
import java.io.IOException;import java.io.UnsupportedEncodingException;import org.apache.commons.httpclient.HttpClient;import org.apache.commons.httpclient.HttpException;import org.apache.commons.httpclient.NameValuePair;import org.apache.commons.httpclient.cookie.CookiePolicy;import org.apache.commons.httpclient.methods.PostMethod;public class QQVoteGuomei {private static String VOTE_SHOW = "http://page.vote.qq.com/?id=141068&result=yes";private static String VOTE = "http://input.vote.qq.com/survey.php";/** * @param args * @throws IOException * @throws HttpException * @throws InterruptedException  */public static void main(String[] args) throws HttpException, IOException, InterruptedException {// TODO Auto-generated method stub//int count = 10000000;//for (int i = 0; i < count; i++) {int i = 1;while(true){System.out.println("==>  第 " + i++ +" 次投票.");vote();//if(i < count - 1)Thread.sleep(10000);}//}}private static void vote() throws IOException, HttpException, UnsupportedEncodingException {HttpClient client = new HttpClient();client.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);PostMethod post = new PostMethod(VOTE);post.addRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; msn OptimizedIE8;ZHCN)");post.addRequestHeader("Host", "page.vote.qq.com:80");post.setRequestHeader("Referer", VOTE_SHOW);NameValuePair[] nvp = new NameValuePair[5];// <input type="hidden" name="PjtID" value="141068" >// <input type="hidden" name="result" value="0" >nvp[0] = new NameValuePair("PjtID", "141068");nvp[1] = new NameValuePair("result", "0");nvp[2] = new NameValuePair("sbj_361707[]", "25593");nvp[3] = new NameValuePair("sbj_361708[]", "25596");nvp[4] = new NameValuePair("sbj_361709[]", "25598");post.setRequestBody(nvp);// 使用POST方式提交数据int statusCode = client.executeMethod(post);System.out.println("statusCode : " + statusCode);if (statusCode == 200) {if (post.getResponseBody() != null) {String response1String = new String(post.getResponseBody(),"gbk");System.out.println(response1String);}}}} 
 
 
输出:
==>  第 1 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
==>  第 2 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
==>  第 3 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
==>  第 4 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
==>  第 5 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
==>  第 6 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
==>  第 7 次投票.
statusCode : 200
<script>try{document.domain="qq.com";window.parent.AppPlatform.Survey.Input.callback("0","361707-25593:1:0|361708-25596:1:0|361709-25598:1:0");}catch(e){alert("提交成功,谢谢参与!");if(0==141068){window.opener=null;window.close();}else{window.location.replace("http://page.vote.qq.com?id=141068&result=yes");}}</script>
........
 
 --------------------------------------------------------------------------
 
一般的灌水机,投票机,注册机大概就是这个样子的:
1\分页页面表单元素
2\分析页面跳转流程
3\ 获取和分析验证码
4、模拟表单提交
5、保持cookie
6、执行操作
7、分析返回结果
 
这个周末在研究爬虫,自动登录,验证码破解之类的东西。
有志同道合的可以给我交流。做了一些复杂的,有针对性的东西。
这里就不方便具体说了。私下交流。
 
---------------------------------------------------------------------------
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表