微信小程序> 一个投票刷票小程序

一个投票刷票小程序

浏览量:2097 时间: 来源:TRUE_LOVE1314

在朋友圈看到一个朋友的母亲最近在参选一个活动,需要投票。和这位朋友交情不错,闲来无事帮他写个小程序刷票。

就是这个页面

http://m.fangxinbao.com/wx/voteDetail-161181.html? (已做处理)

小程序

点击那个"给TA投一票"就可以投票。

经过测验,服务器端是通过ip检测来防止刷票的,那么通过挂代理就可以绕过检测了。

查看一下源码

<div id="pollbtn" class="toupiao-btn flex-box flex-center" οnclick="toPolls('38354')"  style="background-image: url('http://m.fangxinbao.com/img/represent/btn-bg.png');">     给TA投一票</div>

onlick="topolls('xxxx')"是重点

function toPolls(obj){$.ajax({           type: "POST",           url: "http://m.fangxinbao.com/wx/repersentVote.html",           dataType: "html",           data:  "userId="+obj,           success: function (jsonStr) {                   if(jsonStr=='1'){//已投票         alert("今天您已经投过票了!");         }else if(jsonStr=='2'){//投票成功         alert("投票成功!");         window.location.reload();         }else {//异常         alert("投票失败,有问题请联系微信公众号!");         }        }    });

加载出来js,如何构造包一目了然

package crawler;import java.io.BufferedInputStream;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.ByteArrayInputStream;import java.io.DataOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.RandomAccessFile;import java.io.UnsupportedEncodingException;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLEncoder;import java.util.ArrayList;import java.util.List;public class shuapiao {public  static void main(String[] args) throws Exception{ URL postUrl = new URL("http://m.fangxinbao.com/wx/repersentVote.html");        HttpURLConnection connection = (HttpURLConnection) postUrl.openConnection();        connection.setDoOutput(true);        connection.setDoInput(true);        connection.setRequestMethod("POST");        connection.setUseCaches(false);        connection.setInstanceFollowRedirects(true);        connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");        try {        connection.connect();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();connection.disconnect();  }                DataOutputStream out = new DataOutputStream(connection.getOutputStream());        String formdata = "userId=xxxx";        out.writeBytes(formdata);        out.flush();        out.close();         String linetoreturn = "";        BufferedReader reader = null;        try {         reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8"));            String line;            while ((line = reader.readLine()) != null){            System.out.println(line + "");            }             reader.close();             connection.disconnect();} catch (Exception e) {// TODO: handle exception e.printStackTrace(); if(reader!=null) reader.close();             connection.disconnect();             System.out.println("Got an http Error!");      }}}


之后只需要不断切换vpn就可以愉快的刷票了
小程序


--第一次更新--

又发现服务器端对ip的检测只是检测http请求头中的ip,这样的话我们只需要伪造http header中的ip就可以了,实现面代理全自动刷票


package test;import java.io.IOException;import java.util.Random;import org.apache.commons.httpclient.Header;import org.apache.commons.httpclient.HttpClient;import org.apache.commons.httpclient.HttpException;import org.apache.commons.httpclient.HttpStatus;import org.apache.commons.httpclient.NameValuePair;import org.apache.commons.httpclient.methods.PostMethod;public class Shuapiaole {public static void main(String[] args) throws InterruptedException {// TODO Auto-generated method stubwhile(true){HttpClient httpClient = new HttpClient();String url = "http://m.fangxinbao.com/wx/repersentVote.html";PostMethod postMethod = new PostMethod(url);//   填入各个表单域的值NameValuePair[] data = {new NameValuePair("userId", "xxxx"),};//   将表单的值放入postMethod中postMethod.setRequestBody(data);//   执行postMethodString s = getRandomIp();postMethod.setRequestHeader("x-forwarded-for",s);System.out.println(s);int statusCode = 0;try {statusCode = httpClient.executeMethod(postMethod);System.out.println(postMethod.getRequestBodyAsString());} catch (HttpException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}//   HttpClient对于要求接受后继服务的请求,象POST和PUT等不能自动处理转发//   301或者302if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY){//   从头中取出转向的地址Header locationHeader = postMethod.getResponseHeader("location");String location = null;if (locationHeader != null) {location = locationHeader.getValue();System.out.println("The page was redirected to:" + location);}else {System.err.println("Location field value is null.");}return;}else{System.out.println(postMethod.getStatusLine());String str = "";str = postMethod.getResponseBodyAsString();        System.out.println(str);}postMethod.releaseConnection();int waitTime = (int)(Math.random()*4);for(int j = 0; j < waitTime; j++){System.out.print(". ");Thread.sleep(1000);}System.out.println("");}}public static String getRandomIp(){                //ip范围        int[][] range = {{607649792,608174079},//36.56.0.0-36.63.255.255                         {1038614528,1039007743},//61.232.0.0-61.237.255.255                         {1783627776,1784676351},//106.80.0.0-106.95.255.255                         {2035023872,2035154943},//121.76.0.0-121.77.255.255                         {2078801920,2079064063},//123.232.0.0-123.235.255.255                         {-1950089216,-1948778497},//139.196.0.0-139.215.255.255                         {-1425539072,-1425014785},//171.8.0.0-171.15.255.255                         {-1236271104,-1235419137},//182.80.0.0-182.92.255.255                         {-770113536,-768606209},//210.25.0.0-210.47.255.255                         {-569376768,-564133889}, //222.16.0.0-222.95.255.255        };                 Random rdint = new Random();        int index = rdint.nextInt(10);        String ip = num2ip(range[index][0]+new Random().nextInt(range[index][1]-range[index][0]));        return ip;    } /*     * 将十进制转换成ip地址     */    public static String num2ip(int ip) {        int [] b=new int[4] ;        String x = "";                 b[0] = (int)((ip >> 24) & 0xff);        b[1] = (int)((ip >> 16) & 0xff);        b[2] = (int)((ip >> 8) & 0xff);        b[3] = (int)(ip & 0xff);        x=Integer.toString(b[0])+"."+Integer.toString(b[1])+"."+Integer.toString(b[2])+"."+Integer.toString(b[3]);                  return x;      }}


版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎