一个简单的投票机
刚才无意间看到一个投票,在页面右键,源码,看了下,就几个字段,很简单。
打开eclipse,操上httpclient模拟下,就可以投票了。
然后循环,,,,发现“对不起,您已经提交了”。加了验证,没有登录可以提交,过了会刷页面还是可以提交。
说明不是通过ip控制了,那就是用ip+时间控制的了。
试了下,10s的延时可以,9s都貌似不行。
投票地址:
http://page.vote.qq.com/?id=141068&result=yes
投票代码:
Java代码
importjava.io.IOException;
importjava.io.UnsupportedEncodingException;
importorg.apache.commons.httpclient.HttpClient;
importorg.apache.commons.httpclient.HttpException;
importorg.apache.commons.httpclient.NameValuePair;
importorg.apache.commons.httpclient.cookie.CookiePolicy;
importorg.apache.commons.httpclient.methods.PostMethod;
publicclassQQVoteGuomei{
privatestaticStringVOTE_SHOW="http://page.vote.qq.com/?id=141068&result=yes";
privatestaticStringVOTE="http://input.vote.qq.com/survey.php";
/**
*@paramargs
*@throwsIOException
*@throwsHttpException
*@throwsInterruptedException
*/
publicstaticvoidmain(String[]args)throwsHttpException,IOException,InterruptedException{
//TODOAuto-generatedmethodstub
//intcount=10000000;
//for(inti=0;i<count;i++){
inti=1;
while(true){
System.out.println("==>第"+i+++"次投票.");
vote();
//if(i<count-1)
Thread.sleep(10000);
}
//}
}
privatestaticvoidvote()throwsIOException,HttpException,UnsupportedEncodingException{
HttpClientclient=newHttpClient();
client.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
PostMethodpost=newPostMethod(VOTE);
post
.addRequestHeader(
"User-Agent",
"Mozilla/4.0(compatible;MSIE8.0;WindowsNT5.1;Trident/4.0;.NETCLR2.0.50727;.NETCLR3.0.04506.30;CIBA;.NETCLR3.0.04506.648;.NETCLR3.5.21022;msnOptimizedIE8;ZHCN)");
post.addRequestHeader("Host","page.vote.qq.com:80");
post.setRequestHeader("Referer",VOTE_SHOW);
NameValuePair[]nvp=newNameValuePair[5];
//<inputtype="hidden"name="PjtID"value="141068">
//<inputtype="hidden"name="result"value="0">
nvp[0]=newNameValuePair("PjtID","141068");
nvp[1]=newNameValuePair("result","0");
nvp[2]=newNameValuePair("sbj_361707[]","25593");
nvp[3]=newNameValuePair("sbj_361708[]","25596");
nvp[4]=newNameValuePair("sbj_361709[]","25598");
post.setRequestBody(nvp);
//使用POST方式提交数据
intstatusCode=client.executeMethod(post);
System.out.println("statusCode:"+statusCode);
if(statusCode==200){
if(post.getResponseBody()!=null){
Stringresponse1String=newString(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、分析返回结果
这个周末在研究爬虫,自动登录,验证码破解之类的东西。
有志同道合的可以给我交流。做了一些复杂的,有针对性的东西。
这里就不方便具体说了。私下交流。